文件
fenleixinxi/tmp_img/read_cookies.py
MiAn 133d425ec0 feat: 新增阿里云OSS适配器及分类图标优化
- 新增阿里云OSS SDK核心类库文件
- 新增OSS插件配置文件及钩子监听
- 新增分类图标SVG资源并优化为轻量化格式
- 替换定位接口为天地图逆地理编码接口
- 新增OSS图片缩略处理工具方法
2026-11-20 11:11:03 +08:00

72 行
2.3 KiB
Python

import sqlite3, shutil, os, sys
dbs = [
('main', 'C:/Users/ywswe/AppData/Roaming/Trae/Network/Cookies'),
('webview', 'C:/Users/ywswe/AppData/Roaming/Trae/Partitions/trae-webview/Network/Cookies'),
('crawler', 'C:/Users/ywswe/AppData/Roaming/Trae/Partitions/icube-web-crawler-shared-session-v1.0/Network/Cookies'),
]
# 尝试解密
try:
import win32crypt
HAVE_WIN32 = True
except ImportError:
HAVE_WIN32 = False
print("[!] pywin32 not installed, trying pip install...")
os.system('pip install pywin32 2>&1')
try:
import win32crypt
HAVE_WIN32 = True
except:
print("[!] still no win32crypt")
def decrypt(enc):
if not HAVE_WIN32:
return '[no_win32]'
try:
if enc[:3] == b'\x01\x00\x00':
data = enc[3:]
elif enc[:3] == b'\x0D\x00\x00':
data = enc[3:]
else:
data = enc
return win32crypt.CryptUnprotectData(data, None, None, None, 0)[1].decode('utf-8', errors='replace')
except Exception as e:
return f'[decrypt_fail:{e}]'
for name, db_path in dbs:
print(f"\n=== {name} ===")
if not os.path.exists(db_path):
print(" DB not found"); continue
tmp = f'C:/tmp_trae_{name}.db'
os.makedirs('C:/tmp_trae', exist_ok=True)
try:
shutil.copy2(db_path, tmp)
except Exception as e:
print(f" copy failed: {e}"); continue
try:
conn = sqlite3.connect(tmp)
cur = conn.cursor()
cur.execute("SELECT host_key, name, value, encrypted_value FROM cookies ORDER BY host_key")
rows = cur.fetchall()
for host, cname, val, enc_val in rows:
# 过滤:只看可能和 Trae API 相关的
if not any(k in host.lower() for k in ['trae', 'icube', 'mchost', 'bytedance', 'byteos', 'feishu', 'lark']):
continue
if enc_val and not val:
val = decrypt(enc_val)
elif enc_val and val:
# 优先解密值
dval = decrypt(enc_val)
if dval and not dval.startswith('['):
val = dval
vshort = (val[:80] + '...') if len(val) > 80 else val
print(f" {host} [{cname}] = {vshort}")
conn.close()
except Exception as e:
print(f" err: {e}")
finally:
try: os.unlink(tmp)
except: pass