forked from Vinyzu/DiscordGenerator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
949 lines (853 loc) · 39.7 KB
/
main.py
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
# PreInstalled PyPackages
import asyncio
import logging
import os
import random
import re
import time
import tempfile
# Pip Install Packages
import numpy as np
import scipy.interpolate
import playwright_stealth
import httpx
from playwright.async_api import async_playwright
from random_user_agent.user_agent import UserAgent
from random_user_agent.params import SoftwareName, OperatingSystem
import discum
from TempMail import TempMail
# Imports from Files
from hcaptcha_challenger import (DIR_CHALLENGE, DIR_MODEL, PATH_OBJECTS_YAML,
ArmorCaptcha)
class Faker():
def __init__(self, proxy):
self.proxy = proxy
return
async def person(self, gender="random"):
url = f"https://api.namefake.com/english-united-states/{gender}"
r = httpx.get(url)
data = r.json()
self.name = data.get("name")
self.maiden_name = data.get("maiden_name")
self.birth_date = data.get("birth_data")
self.birth_year = self.birth_date.split("-")[0]
# self.birth_month = self.birth_date.split("-")[1]
# self.birth_day = self.birth_date.split("-")[2]
self.birth_month = str(random.randint(1, 12))
self.birth_day = str(random.randint(1, 12))
self.email_name = data.get("email_u")
self.email_domain = data.get("email_d")
self.email = f"{self.email_name}@{self.email_domain}"
self.username = data.get("username")
self.password = data.get("password")
self.domain = data.get("domain")
self.company = data.get("company")
self.pheight = data.get("height")
self.pweight = data.get("weight")
self.eye = data.get("eye")
self.hair = data.get("hair")
self.sport = data.get("sport")
async def geolocation(self, country=""):
url = f"https://api.3geonames.org/randomland.{country}.json"
r = httpx.get(url)
data = r.json()["nearest"]
self.latitude = data.get("latt")
self.longitude = data.get("longt")
self.city = data.get("city")
self.country = data.get("prov")
self.state = data.get("state")
self.region = data.get("region")
self.elevation = data.get("elevation")
self.timezone = data.get("timezone")
async def computer(self):
try:
# Sometimes the API is offline
while True:
url = "http://fingerprints.bablosoft.com/preview?rand=0.1&tags=Firefox,Desktop,Microsoft%20Windows"
r = httpx.get(url, proxies=self.proxy,
timeout=5.0, verify=False)
data = r.json()
self.useragent = data.get("ua")
self.vendor = data.get("vendor")
self.renderer = data.get("renderer")
self.width = data.get("width")
self.height = data.get("height")
self.avail_width = data.get("availWidth")
self.avail_height = data.get("availHeight")
# If the Window is too small for the captcha
if self.height > 810 and self.avail_height > 810:
return
except Exception as e:
# If Bablosoft Website is offline
software_names = [SoftwareName.FIREFOX.value]
operating_systems = [OperatingSystem.WINDOWS.value]
user_agent_rotator = UserAgent(
software_names=software_names, operating_systems=operating_systems, limit=1)
self.useragent = user_agent_rotator.get_random_user_agent()
self.vendor = "Google Inc."
self.renderer = "Google Inc. (AMD)"
self.width = 1280
self.height = 720
self.avail_width = 1280
self.avail_height = 720
# Shit Method To Get Locale of Country code
async def locale(self, country_code="US"):
url = f"https://restcountries.com/v3.1/alpha/{country_code}"
r = httpx.get(url)
data = r.json()[0]
self.languages = data.get("languages")
self.language_code = list(self.languages.keys())[0][:2]
self.locale = f"{self.language_code.lower()}-{country_code.upper()}"
class Proxy():
def __init__(self, proxy):
self.proxy = proxy
return
def Split(self, proxy):
if not proxy:
return ["no", "proxy"]
if "@" in proxy:
first, second = proxy.split("@")
_1, _2 = first.split(":")
_3, _4 = second.split(":")
if _2.isdigit():
return [_1, _2, _3, _4]
elif _4.isdigit():
return [_3, _4, _1, _2]
elif len(proxy.split(":")) > 2:
if proxy.split(":")[1].isdigit():
_1, _2, _3, _4 = proxy.split(":")
return [_3, _4, _1, _2]
elif proxy.split(":")[3].isdigit():
return proxy.split(":")
else:
return proxy.split(":")
# OldCheck (Rate Limitation)
class OldCheck():
def __init__(selff, client, proxy):
proxies = {"http": f"http://{proxy}",
"https": f"http://{proxy}"} if proxy else {}
r = httpx.get("http://ip-api.com/json/", proxies=proxies)
data = r.json()
selff.country = data.get("country")
selff.country_code = data.get("countryCode")
selff.region = data.get("region")
selff.city = data.get("city")
selff.zip = data.get("zip")
selff.country = data.get("country")
selff.latitude = data.get("lat")
selff.longitude = data.get("lon")
selff.timezone = data.get("timezone")
selff.ip = data.get("query")
def __str__(selff):
return str(selff.__dict__)
async def check(self, proxy):
ip_request = httpx.get('https://ifconfig.me/ip',
proxies=self.proxy, verify=False)
self.ip = ip_request.text
r = httpx.get(f"http://ip-api.com/json/{self.ip}")
data = r.json()
self.country = data.get("country")
self.country_code = data.get("countryCode")
self.region = data.get("regionName")
self.city = data.get("city")
self.zip = data.get("zip")
self.latitude = data.get("lat")
self.longitude = data.get("lon")
self.timezone = data.get("timezone")
class Generator:
async def initialize(self, proxy, mode=None, output_file="output.txt", email=True, humanize=True):
# Initializing the Thread
self.last_x, self.last_y = 0, 0
self.proxy, self.mode, self.output_file, self.email_verification, self.humanize = proxy, mode, output_file, email, humanize
# SettingUp Logger
logging.basicConfig(
format='\033[34m[%(levelname)s] - \033[94mLine %(lineno)s - \033[36m%(funcName)s() - \033[96m%(message)s\033[0m')
self.logger = logging.getLogger('logger')
self.logger.setLevel(logging.DEBUG)
# Initializing Faker, ComputerInfo, PersonInfo and ProxyInfo
self.split_proxy = Proxy(None).Split(self.proxy)
if not self.split_proxy:
print(f"Could not split Proxy: {self.proxy}")
return False
correct_proxy = f"{self.split_proxy[2]}:{self.split_proxy[3]}@{self.split_proxy[0]}:{self.split_proxy[1]}" if len(
self.split_proxy) == 4 else f"{self.split_proxy[0]}:{self.split_proxy[1]}"
self.formatted_proxy = f"http://{correct_proxy}" # Can be used later for socks
httpx_proxy = {
"all://": self.formatted_proxy,
} if self.proxy else None
self.faker, self.prox = Faker(httpx_proxy), Proxy(httpx_proxy)
await self.prox.check(self.proxy)
if not self.prox.country:
self.logger.error("Couldnt load the Proxy info")
return
await self.faker.computer()
await self.faker.person()
await self.faker.locale(self.prox.country_code)
# Initializing LocaleInfo and Browser
await self.initialize_browser()
self.logger.info("Spawned Browser successfully")
if mode == 1:
await self.generate_unclaimed()
elif mode == 2:
await self.generate_token()
elif mode == 3:
await self.check_captcha()
return
async def initialize_browser(self):
# Browser Proxy Formatter
if self.proxy:
if len(self.split_proxy) == 4:
self.browser_proxy = {
"server": f"http://{self.split_proxy[0]}:" + self.split_proxy[1], "username": self.split_proxy[2], "password": self.split_proxy[3]}
else:
self.browser_proxy = {
"server": f"http://{self.split_proxy[0]}:" + self.split_proxy[1]}
else:
self.browser_proxy = {}
# Starting Playwright
self.playwright = await async_playwright().start()
# Launching Firefox with Human Emulation
main_browser = await self.playwright.firefox.launch(devtools=True, headless=False, proxy=self.browser_proxy if self.proxy else None)
# Context for more options
browser = await main_browser.new_context(
locale="en-US", # self.faker.locale
geolocation={'longitude': self.prox.longitude,
'latitude': self.prox.latitude, "accuracy": 0.7},
timezone_id=self.prox.timezone,
permissions=['geolocation'],
screen={"width": self.faker.avail_width,
"height": self.faker.avail_height},
user_agent=self.faker.useragent,
viewport={"width": self.faker.width,
"height": self.faker.height},
proxy=self.browser_proxy if self.proxy else None,
http_credentials={
"username": self.split_proxy[2], "password": self.split_proxy[3]} if len(self.split_proxy) == 4 else None
)
# Grant Permissions to Discord to use Geolocation
await browser.grant_permissions(["geolocation"], origin="https://discord.com")
# Create new Page and do something idk why i did that lol
page = await browser.new_page()
await page.emulate_media(color_scheme="dark", media="screen", reduced_motion="reduce")
# Stealthen the page with custom Stealth Config
config = playwright_stealth.StealthConfig()
config.navigator_languages, config.permissions, config.navigator_platform, config.navigator_vendor, config.outerdimensions = False, False, False, False, False
config.vendor, config.renderer, config.nav_user_agent, config.nav_platform = self.faker.vendor, self.faker.renderer, self.faker.useragent, "Win32"
config.languages = ('en-US', 'en', self.faker.locale,
self.faker.language_code)
await playwright_stealth.stealth_async(page, config)
self.browser, self.page = browser, page
async def close(self):
try:
await self.page.close()
except:
pass
try:
await self.browser.close()
except:
pass
try:
await self.playwright.stop()
except:
pass
async def type_humanly(self, locator, text):
# Get the Element by Selector and click it
element = self.page.locator(locator)
await self.click_humanly(element, "")
# Wait some random time and
await self.page.wait_for_timeout(random.randint(2, 4)*100)
await element.type(text, delay=random.randint(150, 250))
await self.page.wait_for_timeout(random.randint(4, 8)*100)
async def click_xy_humanly(self, x, y):
# Move mouse humanly to the Coordinates and wait some random time
await self.humanize_mouse_movement(x, y)
await self.page.wait_for_timeout(random.randint(4, 8)*100)
# Click the Coordinates and wait some random time
await self.page.mouse.click(x, y, delay=random.randint(40, 100))
await self.page.wait_for_timeout(random.randint(4, 8)*100)
async def click_humanly(self, element="", locator="", timeout=30000):
# Getting Element by Selector if Element isnt passed
if not element:
element = self.page.locator(locator)
# Get a random coordinate inside the element
coordinates = await element.bounding_box(timeout=timeout)
x, y = coordinates["x"] + \
random.randint(10, 20), coordinates["y"] + random.randint(10, 20)
# Click the Coordinates and return them
await self.click_xy_humanly(x, y)
return x, y
async def humanize_mouse_movement(self, x, y):
xp, yp = [x, self.last_x], [y, self.last_y]
def midpoints(xp, yp):
new_x, new_y = xp[:], yp[:]
for x, y in zip(xp, yp):
last_x, last_y = xp[-1], yp[-1]
calc_x, calc_y = ((x + last_x)/2, (y + last_y)/2)
if calc_x not in new_x and calc_y not in new_y:
new_x.append(calc_x)
new_y.append(calc_y)
return new_x, new_y
for i in range(5):
xp, yp = midpoints(xp, yp)
# Every item but the first and last one
xp, yp = sorted(xp), sorted(yp)
nxp, nyp = xp[1:-1], yp[1:-1]
# Randomize points
sxp, syp = [], []
for x, y in zip(nxp, nyp):
sxp.append(random.uniform(x-0.4, x+0.4))
syp.append(random.uniform(y-0.4, y+0.4))
# Combine First, Last Point and new random points
xp = [*sxp, xp[-1]]
yp = [*syp, yp[-1]]
# Move Mouse to new random locations
for x, y in zip(xp, yp):
await self.page.mouse.move(x, y)
await self.page.wait_for_timeout(random.randint(20, 60))
# Set LastX and LastY cause Playwright doesnt have mouse.current_location
self.last_x, self.last_y = xp[-1], yp[-1]
def smooth_out_mouse(self):
# Get the Captcha X- and Y-Coordinates
self.x_coordinates, self.y_coordinates = [
_[0] for _ in self.captcha_points], [_[1] for _ in self.captcha_points]
# Fixxing https://github.com/Vinyzu/DiscordGenerator/issues/3 by adding an extra point
# (Its two points for real basicly you click an correct image two times again)
if len(self.x_coordinates) <= 2:
random_index = random.choice(range(len(self.x_coordinates)))
x1, x2 = self.x_coordinates[random_index] + 0.1, self.x_coordinates[random_index] - 0.1
self.x_coordinates.extend([x1, x2])
y1, y2 = self.y_coordinates[random_index] + 0.1, self.y_coordinates[random_index] - 0.1
self.y_coordinates.extend([y1, y2])
# Devide x and y coordinates into two arrays
x, y = np.array(self.x_coordinates), np.array(self.y_coordinates)
# i dont even know, copy pasted from this so https://stackoverflow.com/a/47361677/16523207
x_new = np.linspace(x.min(), x.max(), 200)
f = scipy.interpolate.interp1d(x, y, kind='quadratic')
y_new = f(x_new)
# Converting NpArrays to lists
y_new = y_new.tolist()
x_new = x_new.tolist()
# Randomize Points to emulate human mouse wobblyness
x_new = [random.uniform(
x-random.randint(5, 20)/10, x+random.randint(5, 20)/10) for x in x_new]
y_new = [random.uniform(
y-random.randint(5, 20)/10, y+random.randint(5, 20)/10) for y in y_new]
return x_new, y_new
async def log_captcha(self):
async def check_json(route, request):
await route.continue_()
try:
response = await request.response()
await response.finished()
json = await response.json()
if json.get("generated_pass_UUID"):
self.captcha_token = json.get("generated_pass_UUID")
except Exception:
pass
await self.page.route("https://hcaptcha.com/checkcaptcha/**", check_json)
async def captcha_solver(self):
# Setup CaptchaToken Logger
self.captcha_token = None
await self.log_captcha()
# Second Frame is Captcha Frame (With Captcha Images)
# captcha_frame = self.page.frames[1]
try:
captcha_frames = self.page.frame_locator(
"//iframe[contains(@title,'content')]")
captcha_frame = captcha_frames.first
except Exception as e:
self.logger.debug(f"Captcha Exception: {str(e)}")
self.logger.info("Captcha Passed successfully!")
return True
# Getting Question and Label of the Captcha
try:
question_locator = captcha_frame.locator(
"//h2[@class='prompt-text']")
question = await question_locator.text_content()
except Exception as e:
self.logger.error("Captcha Question didnt load")
await self.close()
return False
self.label = re.split(
r"containing a", question)[-1][1:].strip() if "containing" in question else question
self.label = self.label.replace(".", "")
self.logger.info(f"Got Captcha QuestionLabel: {self.label}")
# Initializing ArmorCaptcha
self.challenger = ArmorCaptcha(dir_workspace=DIR_CHALLENGE, dir_model=DIR_MODEL, lang='en', debug=True,
path_objects_yaml=PATH_OBJECTS_YAML, onnx_prefix="yolov5s6")
# Getting Lavel and Model from AI
self.challenger.label = self.label
self.model = self.challenger.switch_solution() # DIR_MODEL, None
# Solving Captcha with AI
self.results, timee = [], time.perf_counter()
# Getting first 9 of the logged Images (First nine are the CaptchaImages)
for image_url in self.images[:9]:
# Getting Content of Image
data = httpx.get(image_url).content
# Getting Result from AI and appending it to list
try:
result = self.model.solution(
img_stream=data, label=self.challenger.label_alias[self.label])
except KeyError:
self.logger.error(f"AI doesnt support {self.label} yet!")
self.images = []
await self.click_humanly(self.checkbox, "")
await self.page.wait_for_timeout(2000)
await self.click_humanly(self.checkbox, "")
await self.captcha_solver()
return
self.results.append(result)
await self.page.wait_for_timeout(1000)
# If Results are Invalid Reload Captcha and Recurse
if not any(self.results):
self.logger.warning("AI Results were incorrect, redoing Captcha")
self.images = []
await self.click_humanly(self.checkbox, "")
await self.page.wait_for_timeout(2000)
await self.click_humanly(self.checkbox, "")
await self.captcha_solver()
self.logger.info(
f"AI-Results (solved in {round(time.perf_counter() - timee, 5)}s): {self.results}")
# More Realistic Human Behaviour
await self.page.wait_for_timeout(6000)
# Get All of the Images
image_locator = captcha_frame.locator("//div[@class='task-image']")
self.image_elements = await image_locator.element_handles()
# Define Captcha Points and Used Captha points
self.captcha_points, self.used_captcha_points = [], []
# Getting Random Coordinate from Image if Image is Correct
for result, element in zip(self.results, self.image_elements):
if result:
# Getting X,Y, Width and Height of Captcha Image if its True/Valid
boundings = await element.bounding_box()
x, y, width, height = boundings.values()
# Clicking on random Location in the Picture for better MotionData
while True:
random_x, random_y = random.randint(int(x), int(
x + width)), random.randint(int(y), int(y + height))
if random_x not in [_[0] for _ in self.captcha_points]:
self.captcha_points.append([random_x, random_y])
break
self.logger.debug(self.captcha_points)
# Get Coodinates of Smooth out mouse line
self.x_new, self.y_new = self.smooth_out_mouse()
# Method to insert the Original Captcha Points into the Curve Points
self.zipped_rounded_points = [list(a) for a in zip(
[int(x) for x in self.x_new], [int(y) for y in self.y_new])]
for point in self.captcha_points:
# Check if Point is not in the Curve Points
if point not in self.zipped_rounded_points:
best_index, best_difference = 0, 1000
for i, difference_point in enumerate(self.zipped_rounded_points):
# Check Difference between Point and DifferencePoint
x_difference = point[0] - difference_point[0]
y_difference = point[1] - difference_point[1]
# Make Negative Number Positive with the Abs() Function
difference = abs(x_difference) + abs(y_difference)
# Check if DifferencePoint is newest to given Point
if difference < best_difference:
best_index, best_difference = i, difference
# Insert the Point at the best calculated Point
self.x_new.insert(best_index+1, point[0])
self.y_new.insert(best_index+1, point[1])
for x, y in zip(self.x_new, self.y_new):
x, y = int(x), int(y)
# Check if coordinate is in the captcha_point (If yes, click it)
# Also Check if the captcha was already clicked
if any(x == int(_) for _ in self.x_coordinates) and x not in self.used_captcha_points:
await self.page.mouse.move(x, y)
await self.page.wait_for_timeout(random.randint(100, 300))
await self.page.mouse.click(x, y, delay=random.randint(40, 100))
# Append Coordinat to Used Captcha Points
self.used_captcha_points.append(x)
await self.page.wait_for_timeout(random.randint(5, 20))
else:
await self.page.mouse.move(x, y)
await self.page.wait_for_timeout(random.randint(5, 20))
await self.page.wait_for_timeout(600)
# Clicking Submit Button
submit_button = captcha_frame.locator(
"//div[@class='button-submit button']").first
await self.click_humanly(submit_button, "")
# Checking if Captcha was Bypassed
for _ in range(100):
if self.captcha_token:
censored_token = f"{self.captcha_token.split('.')[0]}.{self.captcha_token.split('.')[1][:10]}*****"
self.logger.info(
f"Bypassed Captcha Successfully: {censored_token}")
return True
else:
await self.page.wait_for_timeout(100)
# If Captcha Token wasnt fetched redo Captcha
self.logger.warning(
"Captcha Solution was Incorrect or another is needed")
self.images = []
await self.click_humanly(self.checkbox, "")
await self.page.wait_for_timeout(2000)
await self.click_humanly(self.checkbox, "")
await self.captcha_solver()
# Main Functions
async def check_captcha(self):
try:
await self.page.goto("https://democaptcha.com/demo-form-eng/hcaptcha.html")
except:
self.logger.error("Site didn´t load")
return False
# Collecting all Images requested from hCaptcha (Captcha Images)
self.images = []
async def image_append(route, request):
if request.resource_type == "image" and "hcaptcha" in request.url:
self.images.append(request.url)
await route.continue_()
await self.page.route("https://imgs.hcaptcha.com/*", image_append)
# Clicking Captcha Checkbox
try:
self.checkbox = self.page.frame_locator(
'[title *= "hCaptcha security challenge"]').locator('[id="checkbox"]')
await self.checkbox.scroll_into_view_if_needed(timeout=5000)
except Exception as e:
self.logger.error("Captcha didn´t load")
return False
await self.click_humanly(self.checkbox, "")
await self.page.wait_for_timeout(2000)
captcha = await self.captcha_solver()
await self.close()
async def generate_unclaimed(self):
# Going on Discord Register Site
try:
await self.page.goto("https://discord.com/")
except:
self.logger.error("Site didn´t load")
await self.close()
return False
# Setting Up TokenLog
await self.log_token()
self.token = None
# Click Open InBrowser Button
await self.click_humanly("", '[class *= "gtm-click-class-open-button"]')
# Typing Username
await self.type_humanly('[class *= "username"]', self.faker.username)
# Clicking Tos and Submit Button
try:
await self.click_humanly("", "[class *='termsCheckbox']", timeout=5000)
except Exception as e:
self.logger.debug("No TOS Checkbox was detected")
pass
await self.click_humanly("", '[class *= "gtm-click-class-register-button"]')
# Collecting all Images requested from hCaptcha (Captcha Images)
self.images = []
async def image_append(route, request):
if request.resource_type == "image" and "hcaptcha" in request.url:
self.images.append(request.url)
await route.continue_()
await self.page.route("https://imgs.hcaptcha.com/*", image_append)
# Clicking Captcha Checkbox
try:
self.checkbox = self.page.frame_locator(
'[title *= "hCaptcha security challenge"]').locator('[id="checkbox"]')
await self.checkbox.scroll_into_view_if_needed(timeout=5000)
except:
self.logger.error("Captcha didn´t load")
await self.close()
return False
await self.click_humanly(self.checkbox, "")
await self.page.wait_for_timeout(2000)
captcha = await self.captcha_solver()
while not self.token:
await self.page.wait_for_timeout(2000)
self.logger.info(f"Generated Token: {self.token}")
await asyncio.sleep(2)
is_locked = await self.is_locked()
if is_locked:
self.logger.error(f"Token {self.token} is locked!")
await self.close()
return
else:
self.logger.info(
f"Token: {self.token} is unlocked! Flags: {self.flags}")
await self.page.wait_for_timeout(3000)
try:
await self.type_humanly('[id="react-select-2-input"]', self.faker.birth_day)
await self.page.keyboard.press("Enter")
await self.type_humanly('[id="react-select-3-input"]', self.faker.birth_month)
await self.page.keyboard.press("Enter")
await self.type_humanly('[id="react-select-4-input"]', self.faker.birth_year)
await self.page.keyboard.press("Enter")
await self.page.wait_for_timeout(1000)
await self.page.keyboard.press("Enter")
except:
pass
self.bot = discum.Client(
token=self.token, log=True, user_agent=self.faker.useragent, proxy=self.formatted_proxy if self.proxy else None)
if self.email_verification:
self.logger.info("Claiming Account...")
claim = await self.claim_account()
if claim:
self.logger.info("Verifying email...")
email_v = await self.confirm_email()
self.bot.switchAccount(self.token)
if self.humanize:
await self.humanize_token()
with open(self.output_file, 'a') as file:
file.write(
f"{self.token}:{self.inbox.address}:{self.faker.password}\n")
await self.close()
async def generate_token(self):
# Going on Discord Register Site
try:
await self.page.goto("https://discord.com/register")
except:
self.logger.error("Site didn´t load")
await self.close()
return False
# Setting Up TokenLog
await self.log_token()
self.token = None
# Typing Email, Username, Password
self.inbox = TempMail.generateInbox()
await self.type_humanly('[name="email"]', self.inbox.address if self.email_verification else str(self.person.username+f"{random.randint(10, 99)}@gmail.com"))
await self.type_humanly('[name="username"]', self.faker.username)
await self.type_humanly('[name="password"]', self.faker.password)
# Typing BirthDay, BirthMonth, BirthYear
await self.type_humanly('[id="react-select-2-input"]', self.faker.birth_day)
await self.page.keyboard.press("Enter")
await self.type_humanly('[id="react-select-3-input"]', self.faker.birth_month)
await self.page.keyboard.press("Enter")
await self.type_humanly('[id="react-select-4-input"]', self.faker.birth_year)
# Clicking Tos and Submit Button
try:
await self.click_humanly("", "[type='checkbox']")
except Exception as e:
self.logger.debug("No TOS Checkbox was detected")
pass
await self.click_humanly("", '[type="submit"]')
# Collecting all Images requested from hCaptcha (Captcha Images)
self.images = []
async def image_append(route, request):
if request.resource_type == "image" and "hcaptcha" in request.url:
self.images.append(request.url)
await route.continue_()
await self.page.route("https://imgs.hcaptcha.com/*", image_append)
# Clicking Captcha Checkbox
try:
self.checkbox = self.page.frame_locator(
'[title *= "hCaptcha security challenge"]').locator('[id="checkbox"]')
await self.checkbox.scroll_into_view_if_needed(timeout=5000)
except:
self.logger.error("Captcha didn´t load")
await self.close()
return False
await self.click_humanly(self.checkbox, "")
await self.page.wait_for_timeout(2000)
captcha = await self.captcha_solver()
while not self.token:
await self.page.wait_for_timeout(2000)
self.logger.info(f"Generated Token: {self.token}")
await self.page.wait_for_timeout(2000)
is_locked = await self.is_locked()
if is_locked:
self.logger.error(f"Token {self.token} is locked!")
await self.close()
return
else:
self.logger.info(
f"Token: {self.token} is unlocked! Flags: {self.flags}")
self.bot = discum.Client(
token=self.token, log=False, user_agent=self.faker.useragent, proxy=self.formatted_proxy if self.proxy else None)
if self.email_verification:
self.logger.info("Verifying email...")
email_v = await self.confirm_email()
self.bot.switchAccount(self.token)
if self.humanize:
await self.humanize_token()
with open(self.output_file, 'a') as file:
file.write(
f"{self.token}:{self.inbox.address}:{self.faker.password}\n")
self.logger.info("Successfully Generated Account! Closing Browser...")
await self.close()
# Discord Helper Functions
async def log_token(self):
async def check_json(route, request):
await route.continue_()
try:
response = await request.response()
await response.finished()
json = await response.json()
if json.get("token"):
self.token = json.get("token")
except Exception:
pass
await self.page.route("https://discord.com/api/**", check_json)
async def is_locked(self):
token_check = httpx.get('https://discord.com/api/v9/users/@me/library',
headers={"Authorization": self.token}).status_code == 200
if token_check:
r = httpx.get(
'https://discord.com/api/v9/users/@me', headers={"Authorization": self.token})
response = r.json()
self.id = response.get("id")
self.email = response.get("email")
self.username = response.get("username")
self.discriminator = response.get("discriminator")
self.tag = f"{self.username}#{self.discriminator}"
self.flags = response.get("public_flags")
return not token_check
async def humanize_token(self):
self.logger.info("Humanizing Token...")
# Setting Random Avatar
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp:
pics = httpx.get(
"https://api.github.com/repos/itschasa/Discord-Scraped/git/trees/cbd70ab66ea1099d31d333ab75e3682fd2a80cff")
random_pic = random.choice(pics.json().get("tree")).get("path")
pic_url = f"https://raw.githubusercontent.com/itschasa/Discord-Scraped/main/avatars/{random_pic}"
pic = httpx.get(pic_url)
tmp.write(pic.content)
tmp.seek(0)
self.bot.setAvatar(tmp.name)
# Setting AboutME
quote = httpx.get("https://free-quotes-api.herokuapp.com")
quote = quote.json().get("quote")
self.bot.setAboutMe(quote)
# Setting Hypesquad
hypesquad = random.choice(
["bravery", "brilliance", "balance"])
self.bot.setHypesquad(hypesquad)
self.logger.info(f"Set Hypesquad, Bio and ProfilePic!")
async def claim_account(self):
self.inbox = TempMail.generateInbox()
self.bot._Client__user_password = self.faker.password
response = self.bot.setEmail(self.inbox.address)
if not response.status_code == 200:
try:
self.logger.error(
f"Couldnt set email! Response: {response.json()}")
except:
self.logger.error(f"Couldnt set email!")
return False
else:
self.logger.info("Successfully set email! Verifying...")
try:
if response.json().get("token"):
self.token = response.json().get("token")
except:
pass
return True
async def confirm_email(self):
before_token = self.token
self.logger.info("Confirming Email...")
# Getting the email confirmation link from the email
self.scrape_emails = True
while self.scrape_emails:
emails = TempMail.getEmails(self.inbox)
for mail in emails:
if "mail.discord.com" in str(mail.sender):
for word in mail.body.split():
if "https://click.discord.com" in word:
self.email_link = word
self.scrape_emails = False
break
# Confirming the email by link
await self.page.goto(self.email_link)
# Collecting all Images requested from hCaptcha (Captcha Images)
self.images = []
async def image_append(route, request):
if request.resource_type == "image" and "hcaptcha" in request.url:
self.images.append(request.url)
await route.continue_()
await self.page.route("https://imgs.hcaptcha.com/*", image_append)
# Clicking Captcha Checkbox
try:
self.checkbox = self.page.frame_locator(
'[title *= "hCaptcha security challenge"]').locator('[id="checkbox"]')
await self.checkbox.scroll_into_view_if_needed(timeout=5000)
except:
self.logger.info("No Email Captcha was detected!")
return True
await self.click_humanly(self.checkbox, "")
await self.page.wait_for_timeout(2000)
captcha = await self.captcha_solver()
# Waiting until new token is set
while self.token == before_token:
await asyncio.sleep(2)
return True
# Testing (Maybe used later?)
async def login_token(self):
# Going on Discord Register Site
try:
await self.page.goto("https://discord.com/register")
except:
self.logger.error("Site didn´t load")
return False
await self.page.evaluate(str('setInterval(() => {document.body.appendChild(document.createElement `iframe`).contentWindow.localStorage.token = `"' + self.token + '"`}, 2500); setTimeout(() => {location.reload();}, 2500);'))
await self.page.wait_for_timeout(5000)
# self.logger.info("Claiming Account...")
# claim = await self.claim_account()
# if not claim:
# return False
# self.logger.info("Verifying email...")
# email_v = await self.confirm_email()
# self.logger.info(self.token)
await self.humanize_token()
await self.close()
async def main():
print(""" _____ __ ______ __ ______ ______ __ __
/\ __-. /\ \ /\ ___\ /\ \ /\ __ \ /\ ___\ /\ \/ /
\ \ \/\ \ \ \ \ \ \___ \ \ \ \____ \ \ \/\ \ \ \ \____ \ \ _"-.
\ \____- \ \_\ \/\_____\ \ \_____\ \ \_____\ \ \_____\ \ \_\ \_\
\/____/ \/_/ \/_____/ \/_____/ \/_____/ \/_____/ \/_/\/_/ | Made by Vinyzu
| https://github.com/Vinyzu/DiscordGenerator""")
mode = input("[Select] - [Generation Mode]\n" + "<1> Generate Unclaimed Token\n" +
"<2> Generate Token\n" + "<3> Test Captcha\n" + "</> ")
if mode not in ("1", "2", "3"):
raise ValueError("Invalid Mode provided")
else:
mode = int(mode)
if mode in (1, 2):
email = input("[Select] - [Email Verification]\n" + "<1> Verification Enabled\n" +
"<2> No Verification\n" + "</> ")
if email not in ("1", "2"):
raise ValueError("Invalid Mode provided")
else:
email = True if email == "1" else False
else:
email = False
if mode in (1, 2):
humanize = input("[Select] - [Token Humanization]\n" + "<1> Humanization Enabled\n" +
"<2> No Humanization\n" + "</> ")
if humanize not in ("1", "2"):
raise ValueError("Invalid Mode provided")
else:
humanize = True if humanize == "1" else False
else:
humanize = False
threads = input("[Input] - [Threads Amount]\n" + "</> ")
try:
threads = int(threads)
except:
raise ValueError("Invalid ThreadAmount provided")
proxy_file = input("[Drag&Drop] - [Proxy File]\n" +
"<?> Or Leave empty for Proxyless Mode\n" + "</> ")
if proxy_file:
if not os.path.isfile(proxy_file):
raise ValueError("Provided ProxyPath isnt a file!")
proxies = open(proxy_file, 'r').readlines()
else:
proxies = None
output_file = input("[Drag&Drop] - [Output File]\n" +
"<?> Or Leave empty to use output.txt\n" + "</> ")
if output_file:
if not os.path.isfile(output_file):
raise ValueError("Provided OutputPath isnt a file!")
else:
output_file = "output.txt"
os.system('cls' if os.name == 'nt' else 'clear')
while True:
threadz = []
for _ in range(threads):
proxy = random.choice(proxies) if proxies else None
threadz.append(Generator().initialize(
proxy, mode, output_file, email, humanize))
await asyncio.gather(*threadz)
await asyncio.sleep(2)
if __name__ == '__main__':
asyncio.run(main())