Commit Graph

36 Commits (3d58b6508ce9837ad553efc1147c512e04be0f05)
 

Author SHA1 Message Date
PeanutSplash 3d58b6508c fix(linux): validate SUDO_USER and use prefix matching for interpreters
- Validate SUDO_USER via pwd.getpwnam() to prevent path injection
- Use prefix matching for interpreter detection to cover python3.10+ etc.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 21:35:24 +08:00
PeanutSplash bf77cc97d8 refactor(linux): improve wechat detection and sudo db path fallback 2026-03-07 21:35:24 +08:00
PeanutSplash bc80a1578d refactor(find_all_keys_windows): drop unused constants imports 2026-03-07 21:35:24 +08:00
PeanutSplash 6d9b2c0fe4 refactor(find_all_keys): extract shared key scan logic 2026-03-07 21:35:24 +08:00
PeanutSplash 872e3f58dc fix: handle exited PIDs and narrow message DB keys 2026-03-07 21:35:24 +08:00
PeanutSplash f9c338b48d feat: add Linux support with cross-platform memory scanning
- Add Linux memory scanner (`find_all_keys_linux.py`) using `/proc/<pid>/mem`,
  same approach as Windows/macOS — no GDB, no function offsets, no restart needed
- Extract Windows-specific code to `find_all_keys_windows.py`
- Make `find_all_keys.py` a platform dispatcher (Windows / Linux)
- Add `key_utils.py` for cross-platform path matching (`/` vs `\` in all_keys.json)
- Update `config.py` with Linux auto-detection of db_storage paths
- Update all consumers (decrypt_db, monitor, monitor_web, mcp_server) to use
  `get_key_info()` for platform-agnostic key lookup

Tested on remote Linux container: 15/15 DBs scanned, decrypted, and verified.
2026-03-07 21:35:24 +08:00
ylytdeng 5879b58239 Merge PR #15: feat: macOS 图片密钥扫描器 + 批量解密器 (C)
新增 find_image_key.c 和 decrypt_images.c,
通过 Mach VM API + CommonCrypto 实现 macOS 图片解密。

Co-authored-by: bbingz
2026-03-07 21:35:08 +08:00
bbingz e84f1d5130 fix: fallback key in multi-key mode + bound printf context
- decrypt_images.c: try image_keys.json lookup first, fall back to
  config.json single key when CT pattern not mapped (previously returned
  -5 immediately in multi-key mode)
- find_image_key.c: cap ASCII context printf to remaining buffer length,
  preventing out-of-bounds read near region end
2026-03-07 21:35:00 +08:00
bbingz 96c1a5ac2e fix: add file size validation and clarify Method 2 intent
- decrypt_images.c: validate aes_ct_size + xor_size fits within file
  before reading, preventing out-of-bounds reads on corrupt files
- decrypt_images.c: remove unused bytes2hex function
- find_image_key.c: add comment explaining Method 2 design intent —
  hex ASCII bytes used directly as AES key (not hex-decoded)
2026-03-07 21:35:00 +08:00
bbingz 03582dd82c fix: narrow Method 2 scan to hex charset [0-9a-f]
Previous range [a-z0-9] was too broad, matching non-hex characters
g-z which wastes CPU on false candidates. WeChat image keys are
lowercase hex strings.
2026-03-07 21:35:00 +08:00
bbingz 0576151b67 feat: add macOS image key scanner and batch decryptor (C)
- find_image_key.c: scans WeChat process memory for V2 image AES keys
  using Mach VM API + CommonCrypto batch decryption
- decrypt_images.c: batch decrypts V2 .dat image files using keys
  from image_keys.json, handles AES-ECB + XOR + raw_data segments

Build: cc -O3 -o find_image_key find_image_key.c -framework Security
       cc -O3 -o decrypt_images decrypt_images.c -framework Security
2026-03-07 21:35:00 +08:00
ylytdeng 2b03a81a8f fix: 统一路径分隔符为正斜杠,修复 macOS/Linux 兼容性
all_keys.json 中的 key 统一使用 `/` 作为路径分隔符,
消除 Windows 反斜杠硬编码,确保跨平台兼容。

涉及文件: find_all_keys.py, decrypt_db.py, monitor.py,
monitor_web.py, mcp_server.py, decode_image.py, latency_test.py

Fixes #17

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 00:53:48 +08:00
joshua-deng 1294953681
Merge pull request #14 from bbingz/pr/macos-c-scanner
核心功能已验证,新增独立文件不影响现有功能。
2026-03-06 09:29:42 +08:00
joshua-deng fc2ae833dc
Merge pull request #13 from bbingz/pr/macos-docs
文档质量高,实测数据详实。剩余小问题不阻塞合并。
2026-03-06 09:29:35 +08:00
bbingz 992c3f5ee4 fix: replace nonexistent scan_keys.js with actual tools in quickstart
Quickstart step 4 referenced scan_keys.js which doesn't exist in the
repo. Replace with find_all_keys_macos.c (Method A) and note Frida as
Method B requiring user's own script. Also add config.json note for
step 5.
2026-03-05 23:26:55 +08:00
bbingz 18ffb2e7fa fix: use forward slashes in JSON output and add size==0 guard
- Remove forward-to-backslash conversion in JSON keys — forward slashes
  are native macOS paths and don't need JSON escaping (backslash paths
  like \b would be misinterpreted as escape sequences by JSON parsers)
- Add size==0 guard after mach_vm_region to prevent infinite loop
2026-03-05 23:19:22 +08:00
bbingz 76dd2b6d95 fix: clear header reserved-space field and add per-page HMAC note
- Zero out SQLite header offset 20 (reserved-space) after decryption,
  otherwise SQLite miscalculates usable page size
- Add comment noting production code should verify HMAC on every page,
  not just page 1
2026-03-05 23:18:03 +08:00
bbingz d38d7ebf9c fix: replace glob() with nftw() and add chunk overlap
- glob() does not support ** recursive matching on macOS (POSIX).
  Replace with nftw() + opendir to recursively walk db_storage/.
- Add overlap between memory chunks to catch x'...' patterns
  spanning chunk boundaries.
2026-03-05 22:02:49 +08:00
bbingz d4314c4857 fix: address review feedback on docs
- decrypt_page: zero-fill reserve for all pages (consistency)
- Move reserve into configs tuple for clarity
- Remove unused import os
- Trim duplicated permission content, reference permission guide
- Replace empty scan_keys.js shell with find_all_keys_macos reference
2026-03-05 21:55:10 +08:00
bbingz 1f9ca3792a feat: add macOS C memory key scanner
Scans WeChat process memory for SQLCipher encryption keys using
Mach VM API. Outputs all_keys.json compatible with decrypt_db.py.

Build: cc -O2 -o find_all_keys_macos find_all_keys_macos.c -framework Foundation
Usage: sudo ./find_all_keys_macos [pid]
2026-03-05 21:49:00 +08:00
bbingz 98933d5987 docs: add macOS permission guide and 3.x vs 4.x decryption comparison
- macOS permission guide: SIP, task_for_pid, codesign requirements
- 3.x vs 4.x decryption guide: SQLCipher parameter differences,
  multi-config DB handling, complete Python decryption examples
2026-03-05 21:48:35 +08:00
ylytdeng 3b4b811cc3 fix: 清理调试代码 + 提升服务稳定性
- 移除 _debug_log、signal handler、atexit 等调试代码
- 添加 allow_reuse_address 防止重启端口占用
- warmup 线程加外层异常捕获防止静默崩溃
- 恢复启动自动打开浏览器

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 20:41:36 +08:00
ylytdeng 73598751a0 fix: MCP DBCache 使用固定文件名 + 持久化缓存,重启秒恢复
- 缓存文件改用 md5(rel_key) 固定命名,放在 Temp/wechat_mcp_cache/
- mtime 映射持久化到 _mtimes.json,重启后验证一致直接复用
- 避免 mkstemp 随机文件名导致崩溃后临时文件堆积

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 15:10:25 +08:00
ylytdeng 121fa9f7bd feat: 自动检测WeChat路径 + 通知过滤规则
- config.py: 自动从 %APPDATA% ini 读取数据盘符,扫描 xwechat_files
  找到 db_storage 路径,多账号时交互选择,首次运行免手动配置
- monitor_web.py: 右侧设置面板支持自定义通知规则(群名/发送人模糊
  匹配),命中时触发浏览器通知 + 蜂鸣声 + 金色高亮,规则存 localStorage

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 22:58:30 +08:00
joshua-deng e3efaac510
feat: auto-detect config, unified entry point & multi-process key extraction (#8)
feat: auto-detect config, unified entry point & multi-process key extraction
2026-03-03 22:56:52 +08:00
PeanutSplash fd4a2fce31
fix(config): handle corrupted config file and improve encoding detection 2026-03-03 22:49:03 +08:00
PeanutSplash eb6471d42c
fix: Updated prompt messages for detecting multiple data directories and added instructions for users to select their current WeChat account. 2026-03-03 22:23:41 +08:00
PeanutSplash 6898a065d7
feat: add unified entry point and multi-process key extraction
Add main.py as single entry point that auto-detects config, extracts keys, and launches Web UI or decrypts databases in one command.
Refactor find_all_keys to scan all Weixin.exe processes instead of only the largest one, enabling multi=account support.
2026-03-03 22:20:12 +08:00
PeanutSplash bf68409c39
docs: Updated configuration instructions to automatically detect the WeChat data directory and generate config.json. 2026-03-03 21:43:40 +08:00
PeanutSplash 2fa95b283f
feat: Added automatic detection of WeChat data directories and optimized configuration loading process 2026-03-03 21:42:31 +08:00
ylytdeng c85367ff08 feat: 富媒体内容解析、表情包显示、组合消息修复
- 表情包内联显示: emoticon.db CDN映射 + 下载缓存
- 富媒体内容: 链接卡片/文件/视频号/小程序/引用/位置等完整渲染
- 修复文字+图片组合消息丢失 (前端去重key加消息类型)
- 新增隐藏消息检测: 异步查message DB找回同秒内其他消息
- MonitorDBCache线程安全: per-key锁防并发解密损坏
- Web UI优化: 气泡样式/群聊发送者/图片点击放大

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 11:55:11 +08:00
ylytdeng 24ae180669 Update README with image decryption docs and V2 format details
Add usage instructions for image key extraction, file descriptions
for new modules, and technical details of the three .dat encryption
formats (old XOR, V1, V2).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 00:40:25 +08:00
ylytdeng da7525db95 Add image decryption and inline preview for WeChat V2 format
Support all three .dat encryption formats:
- Old XOR format: single-byte XOR, auto-detect key from magic bytes
- V1 format: AES-ECB with fixed key (md5("0")[:16]) + XOR tail
- V2 format (2025-08+): AES-128-ECB + raw middle + XOR tail

New files:
- decode_image.py: unified image decryption module (XOR/V1/V2)
- find_image_key.py: extract AES key from WeChat process memory
- find_image_key_monitor.py: continuous monitoring version for key capture

monitor_web.py changes:
- Inline image preview in Web UI with async decryption
- MonitorDBCache for mtime-based DB decryption caching
- username-to-DB mapping for image resolution chain
- /img/ endpoint for serving decoded images
- SSE image_update events for real-time preview updates

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 00:30:01 +08:00
ylytdeng 05b8ba4d45 Add MCP usage examples with redacted real outputs 2026-02-28 16:58:46 +08:00
joshua-deng 5057206222 Add MCP server for Claude AI integration
New mcp_server.py provides 5 tools (get_recent_sessions, get_chat_history,
search_messages, get_contacts, get_new_messages) via FastMCP stdio transport.
Features on-demand decryption with mtime-based caching and WAL support.
2026-02-28 12:22:50 +08:00
joshua-deng 4c91eb34ef WeChat 4.0 database decryptor and real-time message monitor
Extract encryption keys from Weixin.exe process memory, decrypt all
SQLCipher 4 databases, and monitor new messages via Web UI with ~100ms latency.
2026-02-28 12:03:38 +08:00