-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.py
429 lines (415 loc) · 15.9 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
import os
from sys import executable
try:
import asyncio
import logging
import random
import traceback
import botright
import httpx
from pyfadecolor import Fore
import validators
os.system('cls')
except:
os.system(f"{executable} -m pip install -U logging")
os.system(f"{executable} -m pip install -U asyncio")
os.system(f"{executable} -m pip install -U botright")
os.system(f"{executable} -m pip install -U pyfadecolor")
os.system(f"{executable} -m pip install -U httpx")
os.system(f"{executable} -m pip install -U validators")
import asyncio
import logging
import random
import traceback
import botright
from pyfadecolor import Fore
import httpx
import validators
os.system('cls')
from modules.discord import Discord
from modules.tempmail import TempMail
class Generator:
async def initialize(
self,
botright_client,
proxy,
mode=None,
output_file="output.txt",
email=True,
humanize=True,
output_format="token:email:pass",
invite_link="",
):
self.output_file, self.output_format = output_file, output_format
self.email_verification, self.humanize, self.invite_link = (
email,
humanize,
invite_link,
)
self.token, self.email, self.output = "", "", ""
logging.basicConfig(
format="\x1b[34m[%(levelname)s] - \x1b[94mLine %(lineno)s - \x1b[36m%(funcName)s() - \x1b[96m%(message)s\x1b[0m"
)
self.logger = logging.getLogger("logger")
self.logger.setLevel(logging.DEBUG)
self.browser = await botright_client.new_browser(proxy)
self.logger.info("Spawned Browser successfully")
self.page = await self.browser.new_page()
if mode == 1:
await self.generate_unclaimed()
elif mode == 2:
await self.generate_token()
elif mode == 3:
await self.check_captcha()
return
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)
def log_output(self):
output = ""
for item in self.output_format.split(":"):
if "token" in item and self.token:
output += self.token + ":"
if "email" in item and self.email:
output += self.email + ":"
if "pass" in item:
output += self.browser.faker.password + ":"
if "proxy" in item and self.browser.proxy:
output += self.browser.proxy + ":"
output = output[:-1]
self.output = output
async def close(self):
try:
await self.page.close()
except:
pass
try:
await self.browser.close()
except:
pass
async def generate_unclaimed(self):
try:
try:
await self.page.goto("https://discord.com/")
except:
self.logger.error("Site didn´t load")
await self.close()
return False
await self.log_token()
await self.page.click('[class *= "gtm-click-class-open-button"]')
await self.page.type('[class *= "username"]', self.browser.faker.username)
try:
await self.page.click("[class *= 'checkbox']", timeout=10000)
except Exception as e:
self.logger.debug("No TOS Checkbox was detected")
pass
await self.page.click('[class *= "gtm-click-class-register-button"]')
await self.page.solve_hcaptcha()
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 Discord.is_locked(self)
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.log_output()
await self.page.wait_for_timeout(3000)
try:
await self.page.type(
'[id="react-select-2-input"]', self.browser.faker.birth_day
)
await self.page.keyboard.press("Enter")
await self.page.type(
'[id="react-select-3-input"]', self.browser.faker.birth_month
)
await self.page.keyboard.press("Enter")
await self.page.type(
'[id="react-select-4-input"]', self.browser.faker.birth_year
)
await self.page.keyboard.press("Enter")
await self.page.wait_for_timeout(1000)
await self.page.keyboard.press("Enter")
except:
pass
for _ in range(2):
try:
await self.page.click("[class *= 'closeButton']", timeout=5000)
except:
pass
if self.email_verification:
self.inbox = TempMail.generateInbox()
self.logger.info("Claiming Account...")
await Discord.set_email(self, self.inbox.address)
await self.page.wait_for_timeout(2000)
self.logger.info("Verifying email...")
await Discord.confirm_email(self)
self.log_output()
await self.page.wait_for_timeout(2000)
if self.humanize:
await Discord.humanize_token(self)
await self.page.wait_for_timeout(2000)
if self.invite_link:
await Discord.join_server(self)
self.log_output()
with open(self.output_file, "a") as file:
file.write(f"{self.output}\n")
self.logger.info("Successfully Generated Account! Closing Browser...")
await self.close()
except:
self.logger.error(
f"Catched Exception, trying to save Token anyways... \n Error: \n {traceback.format_exc()}"
)
if self.output:
with open(self.output_file, "a") as file:
file.write(f"{self.output}\n")
async def generate_token(self):
try:
try:
await self.page.goto("https://discord.com/register")
except:
self.logger.error("Site didn´t load")
await self.close()
return False
await self.log_token()
self.email = (
f"{self.browser.faker.username}{random.randint(10,99)}@gmail.com"
)
if self.email_verification:
self.inbox = TempMail.generateInbox()
self.email = self.inbox.address
await self.page.type('[name="email"]', self.email)
await self.page.type('[name="username"]', self.browser.faker.username)
await self.page.type('[name="password"]', self.browser.faker.password)
await self.page.type(
'[id="react-select-2-input"]', self.browser.faker.birth_day
)
await self.page.keyboard.press("Enter")
await self.page.type(
'[id="react-select-3-input"]', self.browser.faker.birth_month
)
await self.page.keyboard.press("Enter")
await self.page.type(
'[id="react-select-4-input"]', self.browser.faker.birth_year
)
try:
tos_box = self.page.locator("[type='checkbox']").first
await tos_box.click()
except Exception as e:
self.logger.debug("No TOS Checkbox was detected")
pass
await self.page.click('[type="submit"]')
await self.page.solve_hcaptcha()
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 Discord.is_locked(self)
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.log_output()
await self.page.wait_for_timeout(2000)
for _ in range(2):
try:
await self.page.click("[class *= 'closeButton']", timeout=5000)
except:
pass
if self.email_verification:
self.logger.info("Verifying email...")
await Discord.confirm_email(self)
self.log_output()
await self.page.wait_for_timeout(2000)
if self.humanize:
await Discord.humanize_token(self)
await self.page.wait_for_timeout(2000)
if self.invite_link:
await Discord.join_server(self)
self.log_output()
with open(self.output_file, "a") as file:
file.write(f"{self.output}\n")
self.logger.info("Successfully Generated Account! Closing Browser...")
await self.close()
except:
self.logger.error(
f"Catched Exception, trying to save Token anyways... \n Error: \n{traceback.format_exc()}"
)
if self.output:
with open(self.output_file, "a") as file:
file.write(f"{self.output}\n")
async def login_token(self):
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)
if self.email_verification:
self.inbox = TempMail.generateInbox()
self.logger.info("Claiming Account...")
await Discord.set_email(self, self.inbox.address)
await self.page.wait_for_timeout(2000)
self.logger.info("Verifying email...")
await Discord.confirm_email(self)
if self.invite_link:
await Discord.join_server(self)
self.log_output()
with open(self.output_file, "a") as file:
file.write(f"{self.output}\n")
self.logger.info("Successfully Generated Account! Closing Browser...")
await self.close()
async def main():
botright_client = await botright.Botright(headless=False)
print(
' _____ __ ______ __ ______ ______ __ __\n/\\ __-. /\\ \\ /\\ ___\\ /\\ \\ /\\ __ \\ /\\ ___\\ /\\ \\/ /\n\\ \\ \\/\\ \\ \\ \\ \\ \\ \\___ \\ \\ \\ \\____ \\ \\ \\/\\ \\ \\ \\ \\____ \\ \\ _"-.\n \\ \\____- \\ \\_\\ \\/\\_____\\ \\ \\_____\\ \\ \\_____\\ \\ \\_____\\ \\ \\_\\ \\_\\\n \\/____/ \\/_/ \\/_____/ \\/_____/ \\/_____/ \\/_____/ \\/_/\\/_/ | Made by TheTorren\n | https://github.com/TheTorren/discord-token-generator'
)
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"
+ "</> "
).replace('"', "")
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"
+ "</> "
).replace('"', "")
if output_file:
if not os.path.isfile(output_file):
raise ValueError("Provided OutputPath isnt a file!")
else:
output_file = "output.txt"
invite = input(
"[Input] - [Invite Link]\n"
+ "<?> Either parse a InviteLink, or an InviteCode\n"
+ "</> "
)
if not validators.url(invite) and invite:
invite_link = f"https://discord.gg/{invite}"
if (
not validators.url(invite_link)
or not httpx.get(
f"https://discordapp.com/api/v8/invites/{invite}"
).is_success
):
raise ValueError(f"Invalid InviteLink: {invite}")
else:
invite_code = invite.split("/")[-1]
if (
invite
and not httpx.get(
f"https://discordapp.com/api/v8/invites/{invite_code}"
).is_success
):
raise ValueError(f"Invalid InviteLink: {invite}")
invite_link = invite
output_format = input(
"[Input] - [Output Format]\n"
+ "<?> Token: token, Email: email, Password: pass, Proxy: proxy\n"
+ "<?> Leave empty for standart output: token:email:pass\n"
+ "</> "
)
if not output_format:
output_format = "token:email:pass"
for item in output_format.split(":"):
if item not in ["token", "email", "pass", "proxy"]:
raise ValueError(f"Invalid OutputItem: {item}")
os.system("cls" if os.name == "nt" else "clear")
try:
while True:
threadz = []
for _ in range(threads):
proxy = random.choice(proxies) if proxies else None
threadz.append(
Generator().initialize(
botright_client,
proxy,
mode,
output_file,
email,
humanize,
output_format,
invite_link,
)
)
await asyncio.gather(*threadz)
except KeyboardInterrupt:
await botright_client.close()
except Exception:
print(traceback.format_exc())
await botright_client.close()
if __name__ == "__main__":
asyncio.run(main())