-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdiscord.js
1244 lines (1220 loc) · 38.1 KB
/
discord.js
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
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//######## SETUP #########//
const UserAgent = require('user-agents');
const cluster = require('cluster');
const fetch = require('node-fetch');
const cmd = require('child_process');
const fs = require("fs-extra");
const moment = require('moment');
const ua = new UserAgent({deviceCategory:'desktop'});
const home = "/home/discord/files/";
//######## SETUP #########//
const random = (length, code) => {
const rl = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ0123456789';
const rc = rl.charAt(Math.floor(Math.random() * rl.length));
code ? code += rc : code = rc;
return length ? random(length -= 1, code) : code;
}
const random_name = (s) => {
const rn = require('node-random-name');
return s ? rn().split(' ') : rn();
}
const random_int = (l, s) => {
const r = Math.random().toString().slice(2);
const rv = r.slice(0, s ? s : r.length);
return l ? parseInt(rv) : rv;
}
const random_number = (min, max) => {
return Math.floor(Math.random() * (max - min) + 1) + min;
}
const random_country = () => {
const countries = {
uk:"united kingdom",
ru:"russia",
nl:"netherlands",
il:"israel",
ee:"estonia",
ua:"ukraine",
pl:"poland",
ph:"philippines",
br:"brazil",
fr:"france"
};
const ctys = Object.keys(countries);
const rc = random_number(0, ctys.length - 1);
return [countries[ctys[rc]], ctys[rc]];
}
const random_email = () => {
const lst = [
"@yandex.com"
// "@gmail.com",
// "@yahoo.com",
// "@gmx.com",
// "@mail.com",
// "@outlook.com"
];
return lst[0];
};
const islink = (link) => {
const a = link.indexOf('discordapp.com/invite');
const b = link.indexOf('discord.gg');
if (a > -1) return true;
else if (b > -1) return true;
else return false;
}
const resetconst = (oo, ot) => {
for (let bp in ot) {
oo[bp] = ot[bp];
}
return;
}
const sleep = (t) => {
return new Promise((resolve, reject) => {
setTimeout(resolve, t);
});
}
const browser_create = async (rd, data) => {
const puppeteer = require("puppeteer");
const args = [
"--no-sandbox",
"--disable-setuid-sandbox",
"--disable-infobars",
"--disable-gpu",
"--window-position=0,0",
"--ignore-certifcate-errors",
`--user-agent=${ua.random().toString()}`,
`--proxy-server=${data.proxy}`
];
const browserFetcher = puppeteer.createBrowserFetcher();
const revisionInfo = await browserFetcher.download('594312');
const options = {
args,
executablePath: revisionInfo.executablePath,
headless: true,
ignoreHTTPSErrors: true,
userDataDir: rd
};
await fs.ensureDir(rd);
return await puppeteer.launch(options);
}
const browser_window = async (browser) => {
return await browser.createIncognitoBrowserContext();
}
const browser_page = async (window) => {
return await window.newPage();
}
const browser_ip = async (page, data) => {
thread_status('Checking IP.');
await page.authenticate({username:data.proxyauth[0],password:data.proxyauth[1]});
await page.goto('https://api.ipify.org/');
await evidence(page)
const ip = await page.evaluate('document.body.innerText');
thread_status('Session IP: '+ip);
return;
}
const page_config = async (page) => {
await page.setViewport({width: 1366, height: 768});
const trick_one = async () => {
await page.evaluateOnNewDocument(() => {
Object.defineProperty(navigator, 'languages', {
get: () => ['en'],
});
});
await page.evaluateOnNewDocument(() => {
const plugs = () => {
const arr = new Array(random_number(3,20));
for (let i = 0; i < arr.length; i++) {
arr[i] = random_number(0, 1000000);
}
return arr;
};
Object.defineProperty(navigator, 'plugins', {
get: () => plugs(),
});
});
await page.evaluateOnNewDocument(() => {
const originalQuery = window.navigator.permissions.query;
return window.navigator.permissions.query = (parameters) => (
parameters.name === 'notifications' ?
Promise.resolve({ state: Notification.permission }) :
originalQuery(parameters)
);
});
await page.evaluateOnNewDocument(() => {
Object.defineProperty(navigator, 'webdriver', {
get: () => false,
});
});
};
const trick_two = async () => {
await page.evaluateOnNewDocument(() => {
Object.defineProperty(window, 'navigator', {
appCodeName: {[random(56)]:random(56)},
appName: {[random(56)]:random(56)},
appVersion: {[random(56)]:random(56)},
bluetooth: {[random(56)]:random(56)},
clipboard: {[random(56)]:random(56)},
connection: {[random(56)]:random(56)},
cookieEnabled: true,
credentials: {},
deviceMemory: {[random(56)]:random(56)},
doNotTrack: {[random(56)]:random(56)},
geolocation: {[random(56)]:random(56)},
hardwareConcurrency: {[random(56)]:random(56)},
keyboard: {[random(56)]:random(56)},
language: "en-US",
languages: ["en-US", "en", random(56)],
locks: {[random(56)]:random(56)},
maxTouchPoints: {[random(56)]:random(56)},
mediaCapabilities: {[random(56)]:random(56)},
mediaDevices: {[random(56)]:random(56)},
mimeTypes: [],
onLine: true,
userAgent: ua.random().toString(),
permissions: {[random(56)]:random(56)},
platform: {[random(56)]:random(56)},
plugins: {[random(56)]:random(56)},
presentation: {[random(56)]:random(56)},
product: {[random(56)]:random(56)},
productSub: {[random(56)]:random(56)},
usb: {[random(56)]:random(56)},
vendor: {[random(56)]:random(56)},
vendorSub: {[random(56)]:random(56)},
});
});
};
// await trick_one();
await trick_two();
return page;
}
const page_url = (url) => {
// const scrun = ['.png','.jpg','.jpeg','.mp4','.mp3','v6/science']
const scrun = ['v6/science'];
for (let sc of scrun) {
if (url.indexOf(sc) > -1) return true;
}
return false;
}
const evidence = async (page, clear) => {
const dir = home + "evidence/";
if (clear) await fs.emptyDir(dir);
await page.screenshot({
path: dir + (await thread_evidence()) + ".jpeg",
fullPage: true,
type: 'jpeg',
quality: 20
});
return;
}
const evidence_bot = async (page) => {
await page.screenshot({
path: `/home/discord/public/img/evidence${await thread_evidence(true)}.jpeg`,
fullPage: true,
type: 'jpeg',
quality: 20
});
return;
}
const presskey = async (page, times, key) => {
for (let i = 0; i < times; i++) {
await page.keyboard.down(key);
await page.keyboard.up(key);
}
return;
}
const pressreturn = async (page) => {
await page.keyboard.down('Shift');
await page.keyboard.down('Enter');
await page.keyboard.up('Enter');
await page.keyboard.up('Shift');
return;
}
const typeword = async (page, word, tab) => {
for (let letter of word.split('')) {
await presskey(1, 'Shift');
await page.keyboard.sendCharacter(letter);
}
if (tab) {
await presskey(page, 1, "Tab");
await sleep(random_number(900,2156));
}
return;
}
const typemessage = async (page, message) => {
const msg = message.split("");
for (const i of msg) {
if (i == "\n" || i == '\t' || i == '\r') {
await pressreturn(page);
}
else if (i == " ") {
await presskey(page, 1, 'Space');
}
else {
await page.keyboard.sendCharacter(i);
}
}
return;
}
const captcha_solve_google = async (page, key, data) => {
thread_status('Solving captcha.');
const url = `${data.curl}?key=${data.ckey}&method=userrecaptcha&googlekey=${key}&pageurl=${page}`;
const submit = () => {
return new Promise((resolve, reject) => {
fetch(url).then(res => resolve(res.text()));
});
};
const result = (id) => {
return new Promise((resolve, reject) => {
const params = `?key=${data.ckey}&action=get&id=${id}`;
fetch(data.cres + params).then(res => resolve(res.text()));
});
};
const getres = async (id) => {
await sleep(20000);
const code = await result(id);
if (code.indexOf('NOT_READY') > -1) {
console.log(code);
return await getres(id);
}
else if (code.length < 50) {
console.log('google captcha attempt failed');
return false;
} else return code.split('|')[1].trim();
};
const rid = await submit();
let ret;
try {
ret = await getres(rid.split('|')[1]);
console.log(ret);
} catch(e){
console.log(e);
ret = false;
}
return ret;
}
const captcha_solve_sms = async (gdata) => {
const cty = random_country();
const data = {
country: cty[0],
countrycode: cty[1]
};
const get_number = () => {
const params = `?metod=get_number&country=${cty[1]}&service=opt45&apikey=${gdata.skey}`;
return new Promise((resolve, reject) => {
fetch(gdata.surl + params).then(res => resolve(res.json()));
});
};
const result = await get_number();
console.log(result);
if (!result.number) return false;
data.number = result.number;
data.id = result.id;
data.check = async (sms, data) => {
const getsms = () => {
const params = `?metod=get_sms&country=${sms.countrycode}&service=opt45&apikey=${data.skey}&id=${sms.id}`;
return new Promise((resolve, reject) => {
fetch(data.surl + params).then(res => resolve(res.json()));
});
};
const checksms = async () => {
const text = await getsms();
console.log(text);
if (!text.sms) {
await sleep(21000);
return await checksms();
} else return text.sms;
};
return await checksms();
}
return data;
}
const discord_phone = async (page, data) => {
thread_status('Phone verification.');
const sms = await captcha_solve_sms(data);
await page.evaluate("document.querySelectorAll('div[class*=phone]')[0].click();");
await page.evaluate("document.querySelectorAll('div[class*=countryButton]')[0].click();");
await typeword(page, sms.country);
await page.evaluate("document.querySelectorAll('div[class*=countryName]')[0].click();");
await page.evaluate("document.querySelectorAll('input[class*=input]')[0].focus();");
await typeword(page, sms.number);
await page.waitFor(1000);
await page.evaluate("document.querySelectorAll('button[class*=sendButton]')[0].click();");
await page.waitFor(2500);
const check4 = await page.evaluate(`document.querySelectorAll('input[maxlength="1"]').length > 0 ? true : false;`);
await evidence(page);
if (check4) {
const code = await sms.check(sms, data);
for (const number of code.split('')) {
await typeword(page, number);
await page.waitFor(500);
}
await page.waitFor(5000);
await evidence(page);
return true;
}
else {
thread_status('Check evidence to identify error.');
return false;
}
}
const discord_create = async (page, data) => {
if (!data.user) {
console.log('bad user info');
return false;
}
if (!(await thread_check())) throw "Bot stopped";
thread_status('Creating account');
await page.authenticate({username:data.proxyauth[0],password:data.proxyauth[1]});
await page.goto("https://discordapp.com/register?redirect_to=%2Factivity");
// await evidence(page, true);
await page.waitForSelector("form input[type=email]");
await page.evaluate("document.querySelector('form input[type=email]').focus();");
await typeword(page, data.user.email, true);
await typeword(page, data.user.username, true);
await typeword(page, data.user.password, true);
await page.evaluate(`d=document.querySelector('input[type*=checkbox]');if(d){d.click()}`);
await presskey(page, 1, "Enter");
await evidence(page);
if (!(await thread_check())) throw "Bot stopped";
await page.waitFor(15000);
if (!(await thread_check())) throw "Bot stopped";
await evidence(page);
const check1 = await page.evaluate("document.querySelector('div[class*=subTitle]') ? true : false;");
const check2 = await page.evaluate("document.querySelectorAll('iframe').length > 0 ? true : false;");
if (check1 && check2) {
thread_status('Captcha detected');
await discord_captcha(page, data);
}
thread_status('Waiting for submission');
try{await page.waitForSelector("div[class*=phone]",{timeout:60000})}catch(e){}
await evidence(page);
const check3 = await page.evaluate("document.querySelector('div[class*=phone]') ? true : false;");
if (check3) await discord_phone(page, data);
await page.evaluate(`c=document.querySelectorAll('form[class*=modal] button')[0];if(c){c.click()}`);
const check5 = await page.evaluate("document.querySelectorAll('span.username').length > 0 ? true : false");
await evidence(page);
if (check5) {
thread_post(data.user.email, 'accountupdate');
thread_status('Discord account created successfully');
return true;
}
else {
thread_status('There was a problem creating discord account, check evidence for potential error.');
return false;
}
}
const discord_login = async (page, data) => {
thread_status('Logging into: '+data.user.email+' account');
if (!(await thread_check())) throw "Bot stopped";
await page.authenticate({username:data.proxyauth[0],password:data.proxyauth[1]});
await page.goto("https://discordapp.com/login?redirect_to=%2Factivity");
await page.waitForSelector("form input[type=email]");
await evidence(page);
await typeword(page, data.user.email);
await presskey(page, 1, "Tab");
await sleep(random_number(500,1100));
await typeword(page, data.user.password);
await sleep(random_number(500,1100));
await presskey(page, 1, "Tab");
await presskey(page, 1, "Enter");
await page.waitFor(15000);
await evidence(page);
thread_status('Verifiying login.');
let logged = await page.evaluate(() => {
if (document.querySelector('div[class*=accountDetails] .username')) return true;
else return false;
});
thread_status('Login status: '+logged);
if (!logged) {
if (!(await thread_check())) throw "Bot stopped";
await discord_captcha(page, data);
try {
await page.waitForSelector("div[class*=accountDetails] .username", {timeout:60000});
logged = true;
} catch(e){}
await evidence(page);
let check3 = false;
try {
await page.waitForSelector("div[class*=phone]", {timeout:20000});
check3 = true;
} catch(e){}
if (check3) {
await discord_phone(page, data);
await page.waitFor(3000);
}
await evidence(page);
const disabled = await page.evaluate(() => {
const g = document.querySelector('form input[type=email]') ? true : false;
if (g) {
const f = document.querySelectorAll('form[class*=authBox]')[0].innerText;
if (f.indexOf('disabled') > -1) return f;
else return false;
} else return false;
});
console.log('Account disabled: ' +disabled);
if (disabled) {
thread_post(data.user.email, 'accountdisable');
thread_status(data.user.email + ' account has been disabled.');
}
await evidence(page);
console.log('Login status: '+logged);
return logged;
}
else {
await evidence(page);
return logged;
}
}
const discord_join = async (page, data) => {
thread_status('Joining server: '+data.link);
if (!(await thread_check())) throw "Bot stopped";
await page.authenticate({username:data.proxyauth[0],password:data.proxyauth[1]});
await page.goto(data.link);
await evidence(page);
try {
await page.waitForSelector('button');
await page.evaluate("document.querySelectorAll('button')[0].click();");
} catch(e){}
try {
await page.waitFor(2000);
const iviv = await page.evaluate(()=>{
const f = document.querySelectorAll('div[class*=subTitle]');
if (f) {
if (f[0].innerText.toLowerCase().indexOf('might not have permission') > -1) return true;
else return false;
} else return false;
});
console.log(iviv);
if (iviv) {
thread_post(data.link, "completedlink");
return false;
}
} catch(e) {console.log(e)}
try{await page.waitForSelector("div[class*=membersGroup]", {timeout:60000});}catch(e){}
await evidence(page);
const invalid = await page.evaluate("document.querySelectorAll('div[class*=memberGroupsPlaceholder]').length > 0 ? true : false;");
thread_status('Making sure server is accessible');
if (invalid) {
thread_status(data.link + " is missing access or invalid.");
thread_post(data.link, 'invalidlink');
return false;
}
else {
await page.waitForSelector('header[class*=header] span[class*=name]');
return await page.evaluate("window.location.href");
}
}
const discord_message = async (page, gdata, pageurl) => {
if (!(await thread_check())) throw "Bot stopped";
const data = {
ss: 0,
sh: 0,
ht: parseInt(await page.evaluate(`window.innerHeight`)),
pl: await page.evaluate("window.location.href"),
qm: gdata.title,
un: gdata.user.username
};
const find_online = async () => {
if (!(await thread_check())) throw "Bot stopped";
thread_status('Finding unique online user.');
try{await page.waitForSelector("div[class*=membersGroup]");}catch(e){}
const uniqueuser = {found: false, scrolls: 0, online: false};
while (!uniqueuser.online) {
const result = await page.evaluate((data, tscrolls) => {
let ds = document.querySelectorAll('div[class*=membersGroup]');
let od = false;
let bl = ['moderator','admin','bot','community','support','dev','owner',]
for (const d of ds) {
let dt = d.innerText.toLowerCase();
for (let b of bl) {
if (dt.indexOf(b) > -1) od = true;
}
}
document
.querySelectorAll('div[class*=membersWrap] div[class*=scroller-]')[0]
.scrollBy(0, data.sh += data.ht);
tscrolls += 1;
return [od, tscrolls];
}, data, uniqueuser.scrolls);
uniqueuser.scrolls = result[1];
if (!result[0]) {
uniqueuser.online = true;
break;
}
else if (uniqueuser.scrolls > 1000) {
thread_status("Can't find online users. Scrolled 1000 times.");
throw "Can't find online users. Scrolled 1000 times.";
}
}
data.cu = await thread_get('contacted');
while (!uniqueuser.found) {
const onlineuser = await page.evaluate((data, tscrolls) => {
const olm = document.querySelectorAll('div[class*=memberOnline] span[class*=username-]');
for (let cm of olm) {
if (!data.cu[cm.innerText]) {
cm.click();
document.querySelectorAll('input[class*=quickMessage]')[0].value = data.qm;
return [cm.innerText,tscrolls];
}
}
document.querySelectorAll('div[class*=membersWrap] div[class*=scroller-]')[0].scrollBy(0, data.sh += data.ht);
tscrolls += 1
return [false, tscrolls];
}, data, uniqueuser.scrolls);
uniqueuser.scrolls = onlineuser[1];
if (onlineuser[0]) {
uniqueuser.found = onlineuser[0];
thread_post(uniqueuser.found, 'newcontact');
await sleep(random_number(300, 1111));
break;
}
else if (uniqueuser.scrolls > 2000) {
thread_status("Can't find online users. Scrolled 2000 times. All users contacted.");
break;
}
}
if (!uniqueuser.found) {
thread_post(gdata.link, 'completedlink');
return {s: 0, m: ('Contacted all possible users.')};
}
await evidence(page);
thread_status('Found user: ' + uniqueuser.found);
let uc = 1009;
await presskey(page, 1, 'Enter');
while (uc-=1) {
let ul = await page.evaluate("window.location.href");
if (ul !== data.pl) break;
}
try{await page.waitForSelector("textarea[class*=textArea]");}catch(e){}
const tb = await page.evaluate(()=>{
let d = document.querySelectorAll('textarea[class*=textArea]');
if (!d) return false;
else {
let c = 3;
while(c-=1) {
d[0].click();
}
return true;
}
});
if (!tb) thread_status("Error getting to user message page.");
else {
await typemessage(page, gdata.message);
await page.evaluate(()=>{
let d = document.querySelectorAll('textarea[class*=textArea]');
try {
let c = 3;
while(c-=1) {
d[0].focus();
}
return true;
} catch(e){return false;}
});
await evidence(page);
await presskey(page, 2, 'Enter');
try{await page.waitForSelector("textarea[class*=textArea]");}catch(e){}
await evidence(page);
const dv = await page.evaluate(()=>{
const v = document.querySelectorAll('div[class*=messages] h2[class*=headerCozy] span[class*=username]');
const b = v[v.length - 1];
return b.innerText.toLowerCase()
});
if (dv == data.un.toLowerCase()) {
thread_post(uniqueuser.found, 'newcontact');
await evidence_bot(page);
thread_status('Message has been confirmed.');
}
else {
await evidence(page);
const blocked = await page.evaluate(()=>{
const m = document.querySelectorAll('div[class*=contentCozy]');
const n = m[m.length - 1];
if (n.innerText.toLowerCase().indexOf('disabled direct message') > -1) return true;
else return false;
});
if (blocked) {
thread_post(uniqueuser.found, 'newcontact');
thread_status('User has disabled direct messages.');
} else {
thread_status('Problem sending message.');
throw 'Message limit or error';
}
}
}
await evidence(page);
await page.authenticate({username:gdata.proxyauth[0],password:gdata.proxyauth[1]});
await page.goto(data.pl);
return {s: 1, m: "Running again."};
};
if (data.pl !== pageurl) {
await page.authenticate({username:data.proxyauth[0],password:data.proxyauth[1]});
await page.goto(pageurl);
}
await evidence(page, true);
return await find_online();
};
const discord_captcha = async (page, data) => {
const key = await page.evaluate("document.querySelectorAll('iframe')[0].src.split('k=')[1].split('&')[0]");
const url = await page.evaluate("window.location.href");
const code = await captcha_solve_google(url, key, data);
await page.evaluate(`
try {window.___grecaptcha_cfg.clients[0].xd.O.callback("${code}");}catch(e){}
`);
return;
}
const thread_status = (s) => {
process.send({
status: true,
text: `${s} |-------> Thread ID: ${process.pid}`,
id: process.pid
});
};
const thread_error = (e) => {
process.send({
error: true,
text: e,
id: process.pid
});
};
const thread_post = (data, name) => {
process.send({
key: name,
data: data,
id: process.pid,
post: true
});
};
const thread_launch = () => {
return new Promise((resolve, reject) => {
process.send({
launch: true,
id: process.pid
});
process.on('message', m => {
if (m.user) resolve(m);
});
setTimeout(()=>{
resolve(false);
},10000);
});
};
const thread_evidence = (type) => {
return new Promise((resolve, reject) => {
process.send({
evidence: true,
id: process.pid,
key: type
});
process.on('message', m => {
if (m.evidence) resolve(m.total);
});
setTimeout(() => {
resolve(false);
}, 10000);
});
}
const thread_check = () => {
return new Promise((resolve, reject) => {
process.send({
check: true,
id: process.pid,
});
process.on('message', m => {
if (m.active) resolve(true);
});
setTimeout(()=>{
resolve(false);
},3000);
})
};
const thread_get = (name) => {
return new Promise((resolve, reject) => {
process.send({
key: name,
id: process.pid,
get: true
});
process.on('message', m => {
if (m.contacts) resolve(m.data);
});
setTimeout(()=>{
resolve(false);
},3000);
});
}
const main = async() => {
const data = await thread_launch();
const rdir = home + random(10);
const br = await browser_create(rdir,data);
const br_window = await browser_window(br);
const br_page = await page_config((await browser_page(br_window)));
const messenger = async (data, url) => {
const msgs = await discord_message(br_page, data, url);
thread_status(msgs.m);
if (msgs.s === 1) return await messenger(data, url);
else return;
};
const create = async (page, data) => {
const names = random_name(true);
const u = names.join('') + random_int(true, 5);
const user = {
firstname: names[0],
lastname: names[1],
username: u,
password: random(16),
email: u + random_email(),
date: new Date().toString(),
discordactive: 'no',
emailblock: 'fake email',
discordusers: '',
};
thread_post(user, 'account');
const status = await discord_create(page, data);
if (user.email && status) {
const one = await discord_join(br_page, data);
if (!one) return false;
await messenger(data, one);
return true;
}
else {
thread_status('Error creating account.');
return false;
}
};
const login = async (page, data) => {
const one = await discord_login(br_page, data);
if (!one) return false;
const two = await discord_join(br_page, data);
if (!two) return false;
const three = await messenger(data, two);
return true;
};
try {
if (!data) throw 'Data error';
await evidence(br_page, true);
await br_page.setRequestInterception(true);
br_page.on('request', req => {
if (page_url(req.url())) req.abort();
else req.continue();
});
br_page.on('error', async e => {
console.log(e);
await br_window.close();
await br.close();
await fs.remove(rdir);
console.log("restarting app...");
global_data.running = false;
});
await br_page.setDefaultNavigationTimeout(60000);
await browser_ip(br_page, data);
const status = data.user ?
await login(br_page, data) :
await create(br_page, data);
}
catch(e) {
console.log(e);
thread_error(e);
}
finally {
console.log('done')
await br_window.close();
await br.close();
await fs.remove(rdir);
const ra = await thread_check();
if (data.user) thread_post(data.user.email, 'release');
if (ra) return await main();
else {
thread_status('Bot stopped.');
thread_post(process.pid, 'killme');
process.exit();
}
}
}
const thread_master = async () => {
const Database = require('better-sqlite3');
const http = require("http");
const routes = {};
const accountdb = new Database(home + 'accounts.db');
const global_data = fs.readJsonSync(home + 'settings.json');
const contactedusers = fs.readJsonSync(home + 'blacklist.json');
const table = {
t: (name) => {
return `CREATE TABLE ${name} (firstname TEXT, lastname TEXT, email TEXT, password TEXT, username TEXT, date TEXT, emailblock TEXT, discordactive TEXT, discordusers TEXT)`;
},
n: "accounts"
};
const dashcache = [];
const autosave = async () => {
const gd_backup = global_data;
const cu_backup = contactedusers;
try {
await fs.writeJson((home + 'settings.json'), global_data);
await fs.writeJson((home + 'blacklist.json'), contactedusers);
}
catch(e) {
console.log(e);
resetconst(global_data, gd_backup);
resetconst(contactedusers, cu_backup);
}
finally {
setTimeout(autosave, 5000);
}
}
const autobackup = () => {
cmd.exec('cp -r /home/discord/* /home/backup/');
setTimeout(autobackup, 1000 * 60 * 30);
}
const autocache = async () => {
try {
dashcache[0] = await fs.readFile(global_data.page,'utf8');
} catch(e) {
console.log(e)
} finally {
setTimeout(autocache, 1000 * 60 * 20);
}
}
const botstatus_cache = ['Bot not running.'];
const botstatus = (s) => {
console.log(s);
botstatus_cache[0] = s;
};
const db_fresh = (db) => {
const sdel = db.prepare(`DROP TABLE IF EXISTS ${table.n}`);
sdel.run();
const sset = db.prepare(table.t(table.n));
sset.run();
};
const db_get = (db, key, header) => {
try {
const commands = [
`SELECT email FROM ${table.n} ORDER BY random() LIMIT 1`,
`SELECT * FROM ${table.n} WHERE ${header} = ? ORDER BY random()`
];
if (key && header) return db.prepare(commands[1]).get(key);
else return db.prepare(commands[0]).get();
} catch (e) {
console.log(e);
return false;
}
};
const db_post = (db, setvalue, setheader, searchheader, searchvalue) => {
try {
const command = `UPDATE ${table.n} SET ${setheader} = ? WHERE ${searchheader} = ?`;
return db.prepare(command).run(setvalue, searchvalue);
} catch (e) {
console.log(e);
return false;
}
};
const db_account = (db, data) => {
db.prepare(`INSERT INTO ${table.n} (firstname,lastname,email,password,username,date,emailblock,discordactive,discordusers) VALUES ($firstname,$lastname,$email,$password,$username,$date,$emailblock,$discordactive,$discordusers)`).run(data);
return;
};
const db_random = (db, total) => {
const rt = new Set();
while (rt.size < total) {
rt.add(db_get(db, 'yes', 'discordactive'));
}
return Array.from(rt);
};
autosave();
autobackup();
autocache();
global_data.running = false;
global_data.cr = false;
global_data.activeaccounts = new Set();
global_data.activelinks = [];
accountdb.pragma('journal_mode = wal');
const workers = {};
const workers_allocate = async (res) => {
global_data.cr = true;
if (Object.keys(workers).length < global_data.threads) {
let base = 5000;
for (let i = 0; i < global_data.threads; i++) {
setTimeout(() => {
const wrk = cluster.fork();
workers[wrk.process.pid] = wrk;
wrk.on('message', handle_message);
}, random_number(base * i, (base * 2) * i));
}
res.end('Success');
}
else {
res.end('Active threads reached max.');
}
}
const handle_get = async (msg) => {
try {
if (msg.key == 'contacted') {
workers[msg.id].send({contacts:true,data:contactedusers});
}
} catch(e) {
console.log(e);
}
};
const hangle_post = async (msg) => {
try {
switch(msg.key) {
case 'invalidlink':
if (!global_data.invalidlinks) global_data.invalidlinks = new Set();
if (global_data.invalidlinks.has(msg.data)) {
global_data.invalidlinks.delete(msg.data);
global_data.completed.push(msg.data);
}
else {
global_data.invalidlinks.add(msg.data);
}
break;
case 'completedlink':
global_data.completed.push(msg.data);
break;
case 'accountdisable':
db_post(accountdb, 'no', 'discordactive', 'email', msg.data);
break;
case 'accountupdate':
db_post(accountdb, 'yes', 'discordactive', 'email', msg.data);
break;
case 'newcontact':
contactedusers[msg.data] = true;
break;
case 'account':
db_account(accountdb, msg.data);
break;
case 'release':
global_data.activeaccounts.delete(msg.data);
break;