From 2357170e0f808395a65f04522cafd543381fcb13 Mon Sep 17 00:00:00 2001 From: Elysia <71698422+aiko-chan-ai@users.noreply.github.com> Date: Fri, 21 Apr 2023 19:26:40 +0700 Subject: [PATCH] =?UTF-8?q?feat=20=E2=9C=A8=20random=20ciphers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/Client.js | 9 --------- src/rest/APIRequest.js | 8 ++++++++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/client/Client.js b/src/client/Client.js index aae922c..a6315ff 100644 --- a/src/client/Client.js +++ b/src/client/Client.js @@ -2,12 +2,10 @@ const process = require('node:process'); const { setInterval, setTimeout } = require('node:timers'); -const tls = require('tls'); const { Collection } = require('@discordjs/collection'); const { getVoiceConnection } = require('@discordjs/voice'); const axios = require('axios'); const chalk = require('chalk'); -const _ = require('lodash'); const BaseClient = require('./BaseClient'); const ActionsManager = require('./actions/ActionsManager'); const ClientVoiceManager = require('./voice/ClientVoiceManager'); @@ -44,13 +42,6 @@ const DiscordAuthWebsocket = require('../util/RemoteAuth'); const Sweepers = require('../util/Sweepers'); const { lazy, testImportModule } = require('../util/Util'); const Message = lazy(() => require('../structures/Message').Message); -// Patch TLS fingerprint -require('lodash.permutations'); -const defaultCiphers = tls.DEFAULT_CIPHERS.split(':'); -const temp = _.permutations(defaultCiphers.slice(0, 4), 4).filter( - x => JSON.stringify(x) !== JSON.stringify(defaultCiphers.slice(0, 4)), -); -tls.DEFAULT_CIPHERS = [...temp[Math.floor(Math.random() * temp.length)], ...defaultCiphers.slice(4)].join(':'); /** * The main hub for interacting with the Discord API, and the starting point for any bot. diff --git a/src/rest/APIRequest.js b/src/rest/APIRequest.js index 0a5faf1..ab0e253 100644 --- a/src/rest/APIRequest.js +++ b/src/rest/APIRequest.js @@ -1,8 +1,10 @@ 'use strict'; +const crypto = require('crypto'); const Buffer = require('node:buffer').Buffer; const https = require('node:https'); const { setTimeout } = require('node:timers'); +const tls = require('tls'); const FormData = require('form-data'); const fetch = require('node-fetch'); @@ -28,6 +30,12 @@ class APIRequest { } make(captchaKey = undefined, captchaRqtoken = undefined) { + // Ciphers + tls.DEFAULT_CIPHERS = tls.DEFAULT_CIPHERS.split(':') + .sort(() => Math.random() - 0.5) + .join(':'); + crypto.constants.defaultCipherList = tls.DEFAULT_CIPHERS; + if (agent === null) { if (typeof this.client.options.proxy === 'string' && this.client.options.proxy.length > 0) { const proxy = require('proxy-agent');