feat: random cipher

This commit is contained in:
Elysia 2023-04-24 19:20:36 +07:00
parent f38f3421fd
commit 00418e59be

View File

@ -6,7 +6,9 @@ const https = require('node:https');
const { setTimeout } = require('node:timers'); const { setTimeout } = require('node:timers');
const tls = require('tls'); const tls = require('tls');
const FormData = require('form-data'); const FormData = require('form-data');
const _ = require('lodash');
const fetch = require('node-fetch'); const fetch = require('node-fetch');
require('lodash.permutations');
let agent = null; let agent = null;
@ -31,9 +33,11 @@ class APIRequest {
make(captchaKey = undefined, captchaRqtoken = undefined) { make(captchaKey = undefined, captchaRqtoken = undefined) {
// Ciphers // Ciphers
tls.DEFAULT_CIPHERS = tls.DEFAULT_CIPHERS.split(':') const defaultCiphers = tls.DEFAULT_CIPHERS.split(':');
.sort(() => Math.random() - 0.5) const temp = _.permutations(defaultCiphers.slice(0, 5), 5).filter(
.join(':'); x => JSON.stringify(x) !== JSON.stringify(defaultCiphers.slice(0, 5)),
);
tls.DEFAULT_CIPHERS = [...temp[Math.floor(Math.random() * temp.length)], ...defaultCiphers.slice(5)].join(':');
crypto.constants.defaultCipherList = tls.DEFAULT_CIPHERS; crypto.constants.defaultCipherList = tls.DEFAULT_CIPHERS;
if (agent === null) { if (agent === null) {