forked from vandalise/token-scraper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
72 lines (68 loc) · 2.25 KB
/
bot.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
import subprocess as sp
import requests
import threading
import sys
import time
from colorama import Fore as COL
print(COL.YELLOW + f"Token Scraper | by King Herod | Scraping tokens...")
valid = open("valid.txt", "w")
locked = open("locked.txt", "w")
tokencount = 0
templist = []
#token checker function
def Check(auth):
global tokencount
try:
halfauth = auth[:len(auth)//2]
x = requests.get('https://discord.com/api/v9/users/@me', headers={'Authorization': auth})
if x.status_code == 200:
y = requests.get('https://discord.com/api/v9/users/@me/affinities/users', headers={'Authorization': auth})
json = x.json()
if y.status_code == 200:
print(COL.GREEN + f'VALID: {halfauth}***** {json["username"]}#{json["discriminator"]}')
valid.write(f'{auth}\n')
tokencount += 1
elif y.status_code == 403:
print(COL.YELLOW + f'LOCKED: {halfauth}***** {json["username"]}#{json["discriminator"]}')
locked.write(f'{auth}\n')
elif y.status_code == 429:
print(COL.YELLOW + f"You're being rate limited")
time.sleep(y.headers['retry-after'])
elif x.status_code == 429:
print(COL.YELLOW + f"You're being rate limited")
time.sleep(y.headers['retry-after'])
else:
print(COL.RED + f'INVALID: {auth}')
except:
pass
#find all tokens on computer
m = 0
output = sp.getoutput('find /home -name tokens.txt').splitlines()
for path in output:
for x in open(path, "r").read().splitlines():
templist.append(x)
#remove dupes
res = []
for token in templist:
if token in res:
pass
else:
res.append(token)
m += 1
#ask if you want to check tokens or not
print(COL.YELLOW + f"Token Scraper | by King Herod | Loaded {m} tokens")
opt = input("Check tokens? (y/n): ")
if opt not in("y", "Y"):
print(templist)
sys.exit()
else:
pass
#check if tokens are valid
threads = []
for token in res:
t = threading.Thread(target=Check, args=(token, ))
t.start()
threads.append(t)
for t in threads:
t.join()
print(COL.GREEN + f"Finished scraping | {tokencount} tokens saved to valid.txt.")