import sqlite3, os # Fix: win32crypt try: import win32crypt HAVE_WIN32 = True except ImportError: try: from win32crypt import CryptUnprotectData HAVE_WIN32 = True def decrypt(enc): try: return CryptUnprotectData(enc[3:] if len(enc) > 3 else enc, None, None, None, 0)[1].decode('utf-8', errors='replace') except: return None except: HAVE_WIN32 = False def decrypt(enc): if not HAVE_WIN32 or not enc: return None try: return CryptUnprotectData(enc[3:], None, None, None, 0)[1].decode('utf-8', errors='replace') except Exception as e: return None dbs = [ 'C:/Users/ywswe/AppData/Roaming/Trae/Network/Cookies', 'C:/Users/ywswe/AppData/Roaming/Trae/Partitions/trae-webview/Network/Cookies', 'C:/Users/ywswe/AppData/Roaming/Trae/Partitions/icube-web-crawler-shared-session-v1.0/Network/Cookies', ] for db_path in dbs: name = os.path.basename(os.path.dirname(os.path.dirname(db_path))) print(f"\n=== {name} ===") try: # 只读打开 conn = sqlite3.connect(f'file:{db_path}?mode=ro', uri=True, timeout=1) cur = conn.cursor() cur.execute("SELECT host_key, name, value, encrypted_value FROM cookies") rows = cur.fetchall() conn.close() except Exception as e: print(f" open fail: {e}") continue hits = 0 for host, cname, val, enc_val in rows: host_lower = host.lower() if not any(k in host_lower for k in ['trae', 'icube', 'mchost', 'bytedance', 'byteos', 'feishu', 'lark']): continue if enc_val: d = decrypt(enc_val) if d: val = d vshort = (val[:100] + '...') if len(val) > 100 else val print(f" {host} [{cname}]") print(f" = {vshort}") hits += 1 if hits == 0: print(" (no matching cookies)")