Wx Favorites Report banner
zhuyansen zhuyansen

Wx Favorites Report

Development community

Description

微信收藏可视化 Claude Code Skill — 从加密 DB 到交互式 HTML 报告的端到端管线

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

微信收藏可视化 (wechat-favorites-viz)

从加密的微信 Mac 本地数据库中提取收藏数据,生成交互式可视化 HTML 报告。

效果预览

报告包含:统计仪表盘、月度趋势、类型分布、来源排行、活跃热力图、词云、标签云,以及可按类型/标签筛选的收藏浏览区。

截图请打开 `report.html` 后自行截取(数据含个人信息,不宜公开分享截图)

快速开始(macOS)

前置条件

  • macOS (Apple Silicon 或 Intel)
  • 微信 Mac 4.x 已登录
  • Python 3.9+
  • Claude Code(推荐,自动执行全流程)

方式一:用 Claude Code 一键执行

# 在 Claude Code 中说:
微信收藏可视化

Claude 会自动完成密钥提取、解密、解析、报告生成全流程。

方式二:手动分步执行

Step 1: 安装依赖

pip3 install frida frida-tools pycryptodome

Step 2: 准备签名副本

微信 App Store 版有 Hardened Runtime 保护,需要复制一份去掉签名限制:

cp -R /Applications/WeChat.app ~/Desktop/WeChat.app
codesign --force --deep --sign - ~/Desktop/WeChat.app

Step 3: 提取加密密钥

关闭当前微信,用 frida 启动桌面版微信:

killall WeChat 2>/dev/null; sleep 2

# 运行 frida hook 脚本(见 SKILL.md 中完整代码)
# 微信启动后:登录 → 打开「收藏」页面 → 等待 60 秒

frida 会 hook `CCKeyDerivationPBKDF` 函数,捕获所有 PBKDF2 密钥派生调用。

输出文件:`/tmp/wechat_frida_keys.log`

Step 4: 解密数据库

从 frida 日志中找到 favorite.db 对应的 enc_key(通过 salt 匹配),用 Python 解密:

# favorite.db 路径:
# ~/Library/Containers/com.tencent.xinWeChat/Data/Documents/
#   xwechat_files//db_storage/favorite/favorite.db

# 解密参数: SQLCipher 4
# AES-256-CBC, HMAC-SHA512, PBKDF2 256000 轮, page_size=4096, reserve=80

Step 5: 生成报告

# 解析数据
python3 parse_favorites.py --input favorite_decrypted.db --output data.json

# 生成 HTML 报告
python3 generate_report.py --input data.json --output report.html

# 打开(推荐用 http server)
cd <输出目录> && python3 -m http.server 8765
open http://localhost:8765/report.html

踩坑记录

在实现过程中经历了 6 轮迭代,以下是关键经验:

密钥提取(最难的部分)

尝试 方法 结果 原因
1 C 内存扫描 x'hex' 格式 0 keys WeChat 4.x 不用此格式存密钥
2 搜索原始 salt 字节 误匹配 匹配到 ASCII 字符串不是真密钥
3 HMAC 暴力验证 (8B对齐) 未找到 过滤条件跳过了真正位置
4 无过滤暴力 (4B对齐) 未找到 密钥经 PBKDF2 派生后存储,不是原始 enc_key
5 DYLD hook / lldb 被阻止 macOS SIP + Hardened Runtime
6 frida + CCKeyDerivationPBKDF **