-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbypass-techniques.js
More file actions
522 lines (445 loc) · 20.1 KB
/
bypass-techniques.js
File metadata and controls
522 lines (445 loc) · 20.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
/**
* Security Bypass Techniques for Load Testing
*
* IMPORTANT DISCLAIMER:
* This code is provided for EDUCATIONAL and LEGITIMATE SECURITY TESTING purposes only.
* Only use on systems you own or have explicit permission to test.
* Unauthorized testing is illegal and unethical.
*
* Developed By Triotion (https://t.me/Triotion)
*/
// Utility function to generate random values
const crypto = require('crypto');
// Generate a random string of specified length
const randomString = (length = 10) => {
return crypto.randomBytes(Math.ceil(length / 2))
.toString('hex')
.slice(0, length);
};
// Get a random IPv4 address
const randomIP = () => {
return Array.from({length: 4}, () => Math.floor(Math.random() * 256)).join('.');
};
// Get a number within a range
const randomInRange = (min, max) => {
return Math.floor(Math.random() * (max - min + 1)) + min;
};
// Shuffle array in place
const shuffleArray = (array) => {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
return array;
};
const generateJA3Fingerprint = () => {
// Generate realistic JA3 fingerprints
const ja3Samples = [
'771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-21,29-23-24,0',
'771,4865-4867-4866-49195-49199-52393-52392-49196-49200-49162-49161-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513-21,29-23-24-25-256-257,0',
'771,4865-4867-4866-49195-49199-52393-52392-49196-49200-49162-49161-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513-21,29-23-24-25-256-257,0',
'771,4865-4866-4867-49195-49196-49200-49199-52393-52392-49171-49172-49161-49162-156-157-47-53,0-23-65281-10-11-13-35-16-5-51-18-45-43-27-21,29-23-24-25,0'
];
return ja3Samples[Math.floor(Math.random() * ja3Samples.length)];
};
// Collection of bypass techniques
const bypassTechniques = {
/**
* Randomize header order to bypass pattern matching systems
*/
randomizeHeaderOrder: (requestOptions) => {
const headers = requestOptions.headers;
const headerNames = Object.keys(headers);
const shuffledHeaders = {};
shuffleArray(headerNames).forEach(name => {
shuffledHeaders[name] = headers[name];
});
requestOptions.headers = shuffledHeaders;
},
/**
* Add random case variation to header names
* Many servers are case-insensitive for headers
*/
randomizeHeaderCase: (requestOptions) => {
const headers = requestOptions.headers;
const randomCaseHeaders = {};
Object.keys(headers).forEach(name => {
// Convert header to random case
const randomCaseName = name.split('').map(char =>
Math.random() > 0.5 ? char.toUpperCase() : char.toLowerCase()
).join('');
randomCaseHeaders[randomCaseName] = headers[name];
});
requestOptions.headers = randomCaseHeaders;
},
/**
* Add X-Forwarded-For with random IP to simulate traffic coming
* from different sources
*/
randomForwardedIP: (requestOptions) => {
requestOptions.headers['X-Forwarded-For'] = randomIP();
requestOptions.headers['X-Forwarded-Host'] = `${randomString(8)}.com`;
requestOptions.headers['X-Client-IP'] = randomIP();
},
/**
* Add a believable referrer from popular websites
*/
believableReferrer: (requestOptions) => {
const referrers = [
'https://www.google.com/search?q=',
'https://www.bing.com/search?q=',
'https://search.yahoo.com/search?p=',
'https://duckduckgo.com/?q=',
'https://www.facebook.com/',
'https://twitter.com/search?q=',
'https://www.reddit.com/r/',
'https://www.linkedin.com/search/results/all/?keywords=',
'https://www.youtube.com/results?search_query=',
'https://www.instagram.com/explore/tags/'
];
const searchTerms = [
'latest news',
'weather forecast',
'online shopping',
'best products',
'top rated services',
'discount codes',
'local business',
'sports results',
'technology trends',
'health advice'
];
const baseReferrer = referrers[Math.floor(Math.random() * referrers.length)];
const searchTerm = searchTerms[Math.floor(Math.random() * searchTerms.length)];
requestOptions.headers['Referer'] = `${baseReferrer}${encodeURIComponent(searchTerm + ' ' + randomString(5))}`;
},
/**
* Add random query parameters and cache control headers to bypass cache
*/
cacheBypass: (requestOptions) => {
const timestamp = Date.now();
const randomParam = randomString(8);
// Add URL parameters to bypass cache
if (requestOptions.path.includes('?')) {
requestOptions.path += `&_=${timestamp}&${randomParam}=${randomString(5)}`;
} else {
requestOptions.path += `?_=${timestamp}&${randomParam}=${randomString(5)}`;
}
// Add cache-busting headers
requestOptions.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate, max-age=0';
requestOptions.headers['Pragma'] = 'no-cache';
requestOptions.headers['Expires'] = '0';
// Add If-Modified-Since with old date to force revalidation
const oldDate = new Date();
oldDate.setFullYear(oldDate.getFullYear() - 1); // 1 year ago
requestOptions.headers['If-Modified-Since'] = oldDate.toUTCString();
// Add unique ETag to prevent matching
requestOptions.headers['If-None-Match'] = `"${randomString(16)}"`;
}
};
// Add more bypass techniques
Object.assign(bypassTechniques, {
/**
* Add client hints to make the request look like a modern browser
*/
clientHints: (requestOptions) => {
requestOptions.headers['Sec-CH-UA'] = `"Not.A/Brand";v="${randomInRange(8, 99)}", "Chromium";v="${randomInRange(110, 123)}", "Google Chrome";v="${randomInRange(110, 123)}"`;
requestOptions.headers['Sec-CH-UA-Mobile'] = Math.random() > 0.7 ? '?1' : '?0';
requestOptions.headers['Sec-CH-UA-Platform'] = ['Windows', 'macOS', 'Linux', 'Android', 'iOS'][Math.floor(Math.random() * 5)];
requestOptions.headers['Sec-CH-UA-Platform-Version'] = `"${randomInRange(10, 15)}"`;
requestOptions.headers['Sec-CH-UA-Full-Version-List'] = requestOptions.headers['Sec-CH-UA'];
},
/**
* Simulate browser capabilities
*/
browserCapabilities: (requestOptions) => {
requestOptions.headers['Accept-Language'] = [
'en-US,en;q=0.9',
'en-GB,en;q=0.9',
'es-ES,es;q=0.9,en;q=0.8',
'fr-FR,fr;q=0.9,en;q=0.8',
'de-DE,de;q=0.9,en;q=0.8',
'zh-CN,zh;q=0.9,en;q=0.8',
'ja-JP,ja;q=0.9,en;q=0.8',
'ru-RU,ru;q=0.9,en;q=0.8',
'pt-BR,pt;q=0.9,en;q=0.8',
'ar-SA,ar;q=0.9,en;q=0.8'
][Math.floor(Math.random() * 10)];
// Random DNT (Do Not Track) setting
if (Math.random() > 0.7) {
requestOptions.headers['DNT'] = '1';
}
// Random Save-Data setting (bandwidth saving mode)
if (Math.random() > 0.9) {
requestOptions.headers['Save-Data'] = 'on';
}
},
/**
* Generate and add security tokens to simulate a valid session
*/
securityTokenEmulation: (requestOptions) => {
// Add CSRF-like token
const csrfToken = crypto.randomBytes(16).toString('hex');
requestOptions.headers['X-CSRF-Token'] = csrfToken;
// Add realistic cookie pattern with session tokens
const sessionId = crypto.randomBytes(20).toString('hex');
const visitorId = crypto.randomBytes(16).toString('hex');
const cookieExpire = new Date(Date.now() + 86400000).toUTCString();
const cookieParts = [
`session_id=${sessionId}; Path=/; HttpOnly; Secure`,
`visitor_id=${visitorId}; Expires=${cookieExpire}; Path=/`,
`csrf=${csrfToken}; Path=/; Secure; SameSite=Lax`,
`_ga=GA1.2.${Math.floor(Math.random() * 1000000000)}.${Math.floor(Date.now()/1000 - Math.random() * 10000000)}; Expires=${cookieExpire}; Path=/`,
`_gid=GA1.2.${Math.floor(Math.random() * 1000000000)}; Expires=${cookieExpire}; Path=/`
];
// Add 50% chance of including additional typical cookies
if (Math.random() > 0.5) {
cookieParts.push(`theme=light; Path=/`);
}
if (Math.random() > 0.5) {
cookieParts.push(`last_visit=${Math.floor(Date.now()/1000 - Math.random() * 864000)}; Path=/`);
}
requestOptions.headers['Cookie'] = cookieParts.join('; ');
},
/**
* Add timing obfuscation to confuse timing-based detection
*/
timingObfuscation: (requestOptions) => {
// This is handled in the main code by adding a random delay
// But we can add a header that some systems may use for timing metrics
requestOptions.headers['X-Request-Start'] = Date.now().toString();
},
/**
* Add TLS fingerprint scrambling headers
*/
tlsFingerprintScrambling: (requestOptions) => {
// JA3 fingerprint is derived from TLS client hello parameters
// While we can't directly modify this, we can add headers that mislead systems
// that try to correlate HTTP and TLS data
requestOptions.headers['Sec-Fetch-Site'] = ['same-origin', 'same-site', 'cross-site', 'none'][Math.floor(Math.random() * 4)];
requestOptions.headers['Sec-Fetch-Mode'] = ['navigate', 'cors', 'no-cors', 'same-origin'][Math.floor(Math.random() * 4)];
requestOptions.headers['Sec-Fetch-Dest'] = ['document', 'image', 'style', 'script', 'font', 'empty'][Math.floor(Math.random() * 6)];
requestOptions.headers['Sec-Fetch-User'] = Math.random() > 0.5 ? '?1' : '';
},
/**
* Add browser-like navigation behavior
*/
navigationBehavior: (requestOptions) => {
const paths = ['/home', '/about', '/products', '/services', '/contact', '/news', '/blog', '/login', '/register', '/search'];
// Determine the host and base path from the requested URL
const urlParts = requestOptions.path.split('?')[0].split('/');
const baseUrl = urlParts.slice(0, urlParts.length - 1).join('/') || '/';
// Randomly choose a previous path from likely site structure
const previousPath = paths[Math.floor(Math.random() * paths.length)];
const fullPreviousPath = baseUrl + previousPath;
// Set the Referer to simulate normal site navigation
requestOptions.headers['Referer'] = `http${requestOptions.protocol === 'https:' ? 's' : ''}://${requestOptions.hostname}${fullPreviousPath}`;
},
/**
* Add anti-measurement evasion techniques
*/
antiMeasurementEvasion: (requestOptions) => {
// Add random number of DOM elements to confuse bot detection
requestOptions.headers['X-DOM-Elements'] = (500 + Math.floor(Math.random() * 1000)).toString();
// Add random script execution time to confuse performance metrics
requestOptions.headers['X-Script-Exec-Time'] = (10 + Math.floor(Math.random() * 500)).toString();
// Add fake canvas fingerprint to appear like a real browser
requestOptions.headers['X-Canvas-Fingerprint'] = crypto.randomBytes(16).toString('hex');
},
/**
* Add content type specific behavior
*/
contentTypeSpecificBehavior: (requestOptions) => {
// Based on the request, set appropriate Accept headers
if (requestOptions.path.endsWith('.jpg') || requestOptions.path.endsWith('.jpeg') ||
requestOptions.path.endsWith('.png') || requestOptions.path.endsWith('.gif')) {
requestOptions.headers['Accept'] = 'image/avif,image/webp,image/apng,image/*,*/*;q=0.8';
} else if (requestOptions.path.endsWith('.css')) {
requestOptions.headers['Accept'] = 'text/css,*/*;q=0.1';
} else if (requestOptions.path.endsWith('.js')) {
requestOptions.headers['Accept'] = '*/*';
} else if (requestOptions.path.includes('/api/') || requestOptions.path.includes('/json/')) {
requestOptions.headers['Accept'] = 'application/json, text/plain, */*';
} else {
// Default for HTML content
requestOptions.headers['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7';
}
}
});
// Add Cloudflare specific bypass techniques
Object.assign(bypassTechniques, {
/**
* Generic Cloudflare bypass
*/
cloudflareBypass: (requestOptions) => {
// Add Cloudflare-specific headers
requestOptions.headers['CF-IPCountry'] = ['US', 'GB', 'CA', 'AU', 'DE', 'FR'][Math.floor(Math.random() * 6)];
// Add Cloudflare clearance cookies
const clearance = `${randomString(32)}-${Math.floor(Date.now()/1000) - randomInRange(100, 900)}`;
const now = new Date();
const expires = new Date(now.getTime() + 86400000);
const cookieHeader = requestOptions.headers['Cookie'] || '';
const cloudflareTokens = [
`cf_clearance=${clearance}; Expires=${expires.toUTCString()}; Path=/; Domain=.${requestOptions.hostname}; Secure; SameSite=None`,
`__cf_bm=${randomString(40)}; Expires=${new Date(now.getTime() + 1800000).toUTCString()}; Path=/; Domain=.${requestOptions.hostname}; Secure; SameSite=None`,
];
requestOptions.headers['Cookie'] = cookieHeader + (cookieHeader ? '; ' : '') + cloudflareTokens.join('; ');
},
/**
* Cloudflare UAM (Under Attack Mode) bypass
*/
cloudflareUAMBypass: (requestOptions) => {
// Add Cloudflare-specific headers
requestOptions.headers['CF-IPCountry'] = ['US', 'GB', 'CA', 'AU', 'DE', 'FR'][Math.floor(Math.random() * 6)];
requestOptions.headers['CF-Visitor'] = JSON.stringify({ "scheme": "https" });
requestOptions.headers['CF-RAY'] = `${randomString(16).toLowerCase()}-${['EWR', 'DFW', 'LAX', 'LHR', 'FRA'][Math.floor(Math.random() * 5)]}`;
requestOptions.headers['CF-Connecting-IP'] = randomIP();
// Add browser canvas fingerprint emulation via header
requestOptions.headers['X-Canvas-Fingerprint'] = crypto.randomBytes(16).toString('hex');
// Add WebGL fingerprint emulation
requestOptions.headers['X-WebGL-Fingerprint'] = crypto.randomBytes(22).toString('hex');
// Mimic browser JS engine characteristics
requestOptions.headers['X-JS-Engine'] = ['V8', 'SpiderMonkey', 'JavaScriptCore'][Math.floor(Math.random() * 3)];
// Add mouse movement telemetry simulation
const mouseData = {
moves: Math.floor(Math.random() * 100) + 50,
clicks: Math.floor(Math.random() * 8) + 1,
elements: ['nav', 'button', 'div.content', 'a.link', 'input'][Math.floor(Math.random() * 5)]
};
requestOptions.headers['X-User-Interaction'] = JSON.stringify(mouseData);
// Emulate browser navigation timing
const navTiming = {
fetchStart: Date.now() - Math.floor(Math.random() * 1000) - 2000,
domLoading: Date.now() - Math.floor(Math.random() * 800) - 1000,
domInteractive: Date.now() - Math.floor(Math.random() * 500) - 500,
domComplete: Date.now() - Math.floor(Math.random() * 300)
};
requestOptions.headers['X-Nav-Timing'] = JSON.stringify(navTiming);
// TLS fingerprinting resistance
requestOptions.headers['X-TLS-Fingerprint'] = generateJA3Fingerprint();
},
/**
* Cloudflare Turnstile bypass
* Simulates solving the Turnstile CAPTCHA challenge
*/
cloudflareTurnstileBypass: (requestOptions) => {
// Generate a fake Turnstile token (cf_turnstile_response)
const turnstileToken = `${randomString(600)}_${Date.now() / 1000 - randomInRange(10, 60)}`;
// Generate site-specific data
const siteKey = `0x4${randomString(7)}`;
const actionTokens = {
chlPageData: randomString(90),
cDataNonce: randomString(60),
execution: randomString(36),
chlStageT: Date.now() - randomInRange(1000, 5000)
};
// Apply tokens to cookies
let cookieHeader = requestOptions.headers['Cookie'] || '';
const turnstileCookies = [
`cf_turnstile=${randomString(20)}; Path=/; Max-Age=3600`,
`cf_chl_tk=${actionTokens.cDataNonce}; Path=/; Max-Age=3600`,
`cf_chl_seq_${siteKey}=${randomInRange(1, 5)}; Path=/; Max-Age=3600`
];
cookieHeader += (cookieHeader ? '; ' : '') + turnstileCookies.join('; ');
requestOptions.headers['Cookie'] = cookieHeader;
// Add Turnstile-specific headers
requestOptions.headers['CF-Turnstile-Response'] = turnstileToken;
requestOptions.headers['Sec-Turnstile-Token'] = actionTokens.chlPageData;
// Add Turnstile parameters to URL
const turnstileParams = `cf_turnstile_response=${encodeURIComponent(turnstileToken)}&cf_chl_opt_tk=${encodeURIComponent(actionTokens.execution)}`;
if (requestOptions.path.includes('?')) {
requestOptions.path += '&' + turnstileParams;
} else {
requestOptions.path += '?' + turnstileParams;
}
},
/**
* Cloudflare Managed Challenge bypass
* Simulates solving the non-interactive JS challenge
*/
cloudflareManagedChallengeBypass: (requestOptions) => {
// Generate a managed challenge token
const mcToken = randomString(24);
const mcTimestamp = Math.floor(Date.now() / 1000) - randomInRange(30, 120);
const mcSignature = randomString(64);
// Create the managed challenge data structure
const managedChallengeData = {
token: mcToken,
ts: mcTimestamp,
sig: mcSignature,
// Browser fingerprint data
fp: {
canvas: randomString(30),
timezone: randomInRange(-12, 12) * 60,
webgl: randomString(40),
plugins: randomInRange(0, 8),
cores: randomInRange(2, 16)
},
// Challenge completion metrics
metrics: {
timeToSolve: randomInRange(500, 3000),
interactionCount: randomInRange(0, 2),
challengeId: randomString(16)
}
};
// Add to cookies
let cookieHeader = requestOptions.headers['Cookie'] || '';
cookieHeader += (cookieHeader ? '; ' : '') + `cf_mc_token=${mcToken}; Path=/; Max-Age=1800; Secure`;
requestOptions.headers['Cookie'] = cookieHeader;
// Add managed challenge headers
requestOptions.headers['CF-Challenge-Id'] = managedChallengeData.metrics.challengeId;
requestOptions.headers['CF-Challenge-Response'] = Buffer.from(JSON.stringify(managedChallengeData)).toString('base64');
// Add JS challenge parameters to URL
const mcParams = `cf_mc=${encodeURIComponent(mcToken)}&cf_mc_ts=${mcTimestamp}&cf_mc_sig=${encodeURIComponent(mcSignature)}`;
if (requestOptions.path.includes('?')) {
requestOptions.path += '&' + mcParams;
} else {
requestOptions.path += '?' + mcParams;
}
},
/**
* HTTP/2 specific bypass for Cloudflare
* Adds HTTP/2 specific headers and settings
*/
http2Bypass: (requestOptions) => {
// HTTP/2 pseudo-headers must be in correct order
const h2PseudoHeaders = {
':method': requestOptions.method,
':scheme': 'https',
':authority': requestOptions.hostname + (requestOptions.port && requestOptions.port !== 443 ? `:${requestOptions.port}` : ''),
':path': requestOptions.path
};
// HTTP/2 frame settings
const h2Settings = {
SETTINGS_HEADER_TABLE_SIZE: 65536,
SETTINGS_ENABLE_PUSH: 0,
SETTINGS_MAX_CONCURRENT_STREAMS: 1000,
SETTINGS_INITIAL_WINDOW_SIZE: 6291456,
SETTINGS_MAX_FRAME_SIZE: 16384,
SETTINGS_MAX_HEADER_LIST_SIZE: 262144
};
// HTTP/2 connection info
const h2ConnectionInfo = {
enablePush: false,
initialWindowSize: 1048576,
maxFrameSize: 16384,
maxConcurrentStreams: 100
};
// Merge HTTP/2 specific headers with existing headers
requestOptions.h2Settings = h2Settings;
requestOptions.h2ConnectionInfo = h2ConnectionInfo;
// Add HTTP/2 specific fingerprinting evasion
const h2Priorities = [
// Simulate Chrome H2 priorities
{ exclusive: true, parent: 0, weight: 256, dependency: 0 },
// Simulate Firefox H2 priorities
{ exclusive: false, parent: 0, weight: 100, dependency: 3 }
];
requestOptions.h2Priority = h2Priorities[Math.floor(Math.random() * h2Priorities.length)];
// Add HTTP/2 specific headers that help bypass detection
requestOptions.headers['Access-Control-Request-Method'] = requestOptions.method;
requestOptions.headers['Accept-CH'] = 'DPR, Width, Viewport-Width, Sec-CH-UA, Sec-CH-UA-Mobile, Sec-CH-UA-Platform';
requestOptions.headers['HTTP2-Settings'] = Buffer.from(JSON.stringify(h2Settings)).toString('base64');
}
});
module.exports = bypassTechniques;