HEHANG / KNOWLEDGE

wechat-decrypt-contributors

微信数据工具箱 / WeChat Decrypt Toolkit:本地数据库解密、实时监听与智能回复工作台。(说人话:微信AI回复)

仓库 README 快照,完整保留原文;功能和版本以仓库为准。

GitHub ↗ · Python

微信数据工具箱 / WeChat Decrypt Toolkit

中文 · English

Platform Python License WeChat

本项目在 Windows 本机读取和解密微信 4.x 数据库,提供实时消息监听、图片解密、聊天查询、AI 回复草稿和受控桌面自动发送。

This Windows-only toolkit reads and decrypts local WeChat 4.x databases and provides real-time monitoring, media decoding, chat queries, AI reply drafts, and controlled desktop sending.


中文说明

功能概览

所有本地服务只监听 127.0.0.1,不会开放给局域网。项目不会修改微信原始数据库。

两个网页入口

启动完整工作台后使用:

入口 地址 用途
自动发送平台 http://localhost:5678/#automation 会话、AI 草稿、白名单、发送规则、演练和真实发送控制
监听后台 http://localhost:5680/ 查看监听核心收到的新消息和 SSE 状态

5678 是日常使用的主界面;5680 主要用于确认监听核心是否正常。

已验证环境

当前版本已在以下环境实际运行:

项目 版本
Windows Windows x64
微信桌面版 4.1.12.55,进程名 Weixin.exe
Python 3.12.13 x64;支持 Python 3.10+
浏览器 Chrome、Edge 或其他现代浏览器

微信升级可能改变数据库或内存结构。如果你的微信版本不同,建议先使用测试账号验证。

1. 下载项目

powershell
git clone https://github.com/2933684073/wechat-decrypt-contributors.git
cd wechat-decrypt-contributors

也可以在 GitHub 点击 Code → Download ZIP,解压后进入项目目录。

2. 安装 Python 依赖

推荐使用独立虚拟环境:

powershell
python -m venv .venv
Set-ExecutionPolicy -Scope Process Bypass
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -r requirements.txt

验证依赖:

powershell
python -c "import Crypto, zstandard, win32crypt, win32clipboard; print('依赖正常')"

3. 找到微信数据库目录

微信 4.x 的数据库目录通常类似:

text
<微信文件目录>\xwechat_files\<你的 wxid>\db_storage

正确目录中通常可以看到:

text
session\session.db
contact\contact.db
message\message_0.db
message\message_resource.db

如果找不到,可以在磁盘中搜索 session.db。不要选择本项目生成的 decrypted 目录。

4. 配置项目

powershell
Copy-Item config.example.json config.json
notepad config.json

示例:

json
{
  "db_dir": "D:\\WeChatData\\xwechat_files\\your_wxid\\db_storage",
  "keys_file": "all_keys.json",
  "decrypted_dir": "decrypted",
  "decoded_image_dir": "decoded_images",
  "wechat_process": "Weixin.exe"
}

JSON 中的 Windows 路径必须使用双反斜杠 \\。

5. 提取数据库密钥

先启动并登录微信,打开几个最近会话,然后:

  1. 右键 01_extract_keys_as_admin_with_log.cmd;
  2. 选择 以管理员身份运行;
  3. 等待扫描完成;
  4. 查看 find_all_keys.output.log;
  5. 确认日志中至少出现 OK: session\session.db。

微信 4.1+ 会优先使用只读 Config.Cipher runtime 扫描。每个密钥都必须通过数据库第一页 HMAC 校验后才会写入 all_keys.json。

如果旧版扫描显示 0 hex模式,不一定是失败;应查看最终有多少条 OK:。提取器会保留仍然有效的旧密钥,也不会用空结果覆盖可用的密钥文件。

6. 初次解密数据库

powershell
.\.venv\Scripts\python.exe decrypt_db.py

或直接运行 02_decrypt_and_start_web.cmd。

解密结果保存在 decrypted。该目录包含聊天数据,不要上传或分享。

7. 启动完整工作台

powershell
powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\start_workspace.ps1

也可以双击 05_start_workspace.cmd。

启动脚本会依次启动:

只有监听核心成功启动后,工作台才会继续启动。出现问题时请查看:

text
monitor_core.stdout.log
monitor_core.stderr.log
workspace.stdout.log
workspace.stderr.log

8. 验证实时监听

打开 监听后台,页面应显示正在等待新消息。

让另一个账号给当前微信发送一条新消息。新消息应同时出现在:

监听核心会把启动时已有消息作为基线,因此不会把所有旧消息重新推送一遍。请使用启动后收到的新消息测试。

9. 配置 AI 回复

打开 http://localhost:5678,点击 设置中心:

  1. 填写 OpenAI 兼容模型服务地址;
  2. 填写 API 密钥;
  3. 点击 检测 获取模型;
  4. 选择或填写模型名称;
  5. 设置回复风格、语气和上下文数量;
  6. 建议开启 仅未读来信触发;
  7. 点击 测试连接;
  8. 保存设置。

API 密钥使用当前 Windows 用户的 DPAPI 加密保存,不会在网页中回显明文。

10. 配置自动发送平台

打开 自动发送平台,或在左侧点击 自动化管理。

10.1 添加白名单

在左侧联系人列表中选择允许自动回复的私聊联系人,然后点击 保存全部规则。只有私聊联系人可以加入白名单,群聊不会自动回复。

10.2 设置发送规则

建议首次测试使用:

设置 建议值
白名单 只选择 1 个测试联系人
联系人冷却 30 秒或更长
统计窗口 300 秒
窗口内最多发送 1 条
敏感词拦截 开启
演练模式 开启

10.3 自动发送按钮在哪里

自动发送开关位于:

自动化管理 → 运行方式 → 启用自动发送模块

在同一个 运行方式 区域中还有:

只勾选“启用自动发送模块”不会立即开启真实发送。默认仍处于演练模式。

11. 校准微信发送坐标

真实发送前必须校准:

  1. 保持微信主窗口可见,并固定窗口位置和大小;
  2. 双击 07_calibrate_sender.cmd;
  3. 按提示记录微信搜索框中心;
  4. 记录搜索结果第一项中心;
  5. 记录消息输入框中心;
  6. 完成后生成 wechat_sender_calibration.json。

校准程序只读取鼠标坐标,不会点击或发送消息。更改分辨率、缩放比例、显示器或微信窗口布局后,需要重新校准。

12. 从演练切换到真实发送

请按顺序操作:

  1. 白名单只保留一个测试联系人;
  2. 在 自动化管理 → 运行方式 中勾选 启用自动发送模块;
  3. 保持 演练模式 开启并保存;
  4. 让测试联系人发送一条普通文本;
  5. 确认工作台生成了草稿,服务记录显示“演练”,微信没有发送;
  6. 完成坐标校准;
  7. 回到 自动化管理 → 运行方式,关闭 演练模式 并保存;
  8. 在右侧 自动发送控制 中点击 解锁真实自动发送;
  9. 确认安全提示;
  10. 再发送一条测试消息,检查联系人和回复是否正确。

真实自动发送必须同时满足:

系统会从 3 条 AI 草稿中选择第一条发送。

13. 立即急停

如果联系人、坐标或回复有任何异常,立即点击右侧的 立即急停。

急停后,后续消息不会真实发送,真实发送解锁状态也会被清除。恢复时必须先点击 恢复演练,完成演练验证后才能再次解锁。

14. 运行截图

15. 停止服务

双击 06_stop_workspace.cmd。脚本会按当前监听端口查找服务,避免因为 PID 被 Windows 复用而结束无关程序。

16. 常见问题

5678 打不开

powershell
Get-NetTCPConnection -State Listen -LocalPort 5678,5680
Get-Content .\monitor_core.stderr.log -Tail 80
Get-Content .\workspace.stderr.log -Tail 80

如果 5680 没有启动,5678 也无法获得实时消息。

能看到会话,但没有新消息

请使用另一个账号发送一条启动后到达的新消息。旧会话只用于加载联系人列表,不会全部重新进入实时记录。

能生成草稿,但不发送

重点检查:

自动发送点错位置

立即急停,恢复演练,固定微信窗口后重新校准。当前实现会搜索联系人显示名并点击第一条结果,因此不要为重名联系人开启真实自动发送。

图片无法预览

文字监听只依赖 session 数据库。图片预览还需要消息资源密钥和图片密钥;可根据日志提示运行 find_image_key.py。

17. 主要文件

文件 用途
find_all_keys.py 从微信进程只读提取并校验数据库密钥
decrypt_db.py 解密微信数据库
monitor_web_core.py 5680 实时监听核心
wechat_workspace.py 5678 AI 与自动发送工作台
wechat_sender.py 受控微信桌面发送层
calibrate_wechat_sender.py 发送坐标校准
mcp_server.py 为本地 AI 客户端提供查询接口
decode_image.py 解密微信图片
docs/USER_GUIDE_ZH.md 更完整的中文使用与排错说明
docs/CONTRIBUTOR_ONBOARDING.md 贡献者开发指南

18. 隐私与安全

以下内容绝不能提交到 GitHub:

提交前请执行:

powershell
git status --short
git check-ignore config.json all_keys.json smart_reply_config.json wechat_sender_calibration.json

完整中文说明见 docs/USER_GUIDE_ZH.md。


English

What This Project Does

All HTTP services bind to 127.0.0.1 only. The project does not modify the original WeChat databases.

Web Interfaces

Interface URL Purpose
Automation platform http://localhost:5678/#automation Sessions, AI drafts, whitelist, safety rules, dry-run, and real-send controls
Monitor backend http://localhost:5680/ Live message feed and SSE monitor status

Use port 5678 for normal operation. Port 5680 is mainly for checking the monitoring core.

Tested Environment

Component Version
Windows Windows x64
WeChat Desktop 4.1.12.55, process name Weixin.exe
Python 3.12.13 x64; Python 3.10+ supported
Browser Chrome, Edge, or another modern browser

1. Download and Install

powershell
git clone https://github.com/2933684073/wechat-decrypt-contributors.git
cd wechat-decrypt-contributors

python -m venv .venv
Set-ExecutionPolicy -Scope Process Bypass
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -r requirements.txt

2. Configure the Database Path

powershell
Copy-Item config.example.json config.json
notepad config.json

Set db_dir to the current account's db_storage directory. It normally looks like:

text
<WeChat data root>\xwechat_files\<your wxid>\db_storage

The directory should contain files such as session\session.db, contact\contact.db, and message\message_0.db.

3. Extract Database Keys

Keep WeChat running and logged in. Right-click 01_extract_keys_as_admin_with_log.cmd and choose Run as administrator.

Check find_all_keys.output.log and make sure it includes:

text
OK: session\session.db

WeChat 4.1+ uses the read-only Config.Cipher runtime scan first. Every candidate must pass page-one HMAC verification before it is stored.

4. Decrypt the Databases

powershell
.\.venv\Scripts\python.exe decrypt_db.py

Decrypted files are written to decrypted. Never upload that directory.

5. Start the Full Workspace

powershell
powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\start_workspace.ps1

The launcher starts:

Open the monitor backend and send a new message from another account to verify the live feed. Messages that existed before startup are used as the baseline and are not replayed as new events.

6. Configure the AI Model

Open http://localhost:5678 and select Settings:

  1. Enter an OpenAI-compatible API endpoint;
  2. Enter the API key;
  3. Detect or enter the model name;
  4. Configure reply style and context size;
  5. Keep “unread messages only” enabled for initial testing;
  6. Test the connection and save.

The API key is encrypted with Windows DPAPI for the current Windows user.

7. Configure Automation

Open the automation platform, or click Automation Management in the left navigation.

Add only one controlled test contact to the whitelist first. Groups are never eligible for automatic replies.

The auto-send switch is located at:

Automation Management → Run Mode → Enable Auto-Send Module

The same Run Mode section also contains Dry Run. With dry-run enabled, the system only records planned actions and never clicks or sends in WeChat.

Recommended initial settings:

Setting Recommended value
Whitelist One controlled test contact
Per-contact cooldown 30 seconds or longer
Rate window 300 seconds
Maximum sends in the window 1
Sensitive-term blocking Enabled
Auto-send module Enabled
Dry run Enabled

8. Calibrate Desktop Sending

Keep the WeChat main window visible and fixed, then run 07_calibrate_sender.cmd.

Record these three positions as instructed:

  1. WeChat search box;
  2. First search result;
  3. Message input box.

The calibration tool only reads cursor coordinates. It does not click, type, or send.

Recalibrate after changing display resolution, scaling, monitor layout, or WeChat window position.

9. Enable Real Sending

Follow this order:

  1. Keep only one test contact in the whitelist;
  2. Enable Automation Management → Run Mode → Enable Auto-Send Module;
  3. Keep Dry Run enabled and save;
  4. Send a harmless test message from the test contact;
  5. Confirm that drafts are created but WeChat does not send anything;
  6. Complete coordinate calibration;
  7. Disable Dry Run and save;
  8. Click Unlock Real Auto-Send in the right-side send controls;
  9. Confirm the warning;
  10. Send another test message and verify the recipient and reply.

Real sending requires all of these conditions:

The first of the three generated AI drafts is selected for automatic sending.

10. Emergency Stop

Click Emergency Stop immediately if a contact, coordinate, or reply looks wrong. This disables later real sends and clears the armed state. Resume in dry-run mode, verify again, and only then re-arm.

11. Screenshots

The three screenshots are shown in the Chinese section above.

12. Stop the Services

Run 06_stop_workspace.cmd. It resolves the current listeners on ports 5678 and 5680 instead of blindly trusting stale PID files.

13. Troubleshooting

If port 5678 does not open:

powershell
Get-NetTCPConnection -State Listen -LocalPort 5678,5680
Get-Content .\monitor_core.stderr.log -Tail 80
Get-Content .\workspace.stderr.log -Tail 80

If sessions load but no new messages appear, send a new message after the listener has started.

If drafts are generated but nothing is sent, verify the whitelist, Run Mode auto-send switch, dry-run state, real-send arm, calibration, sensitive-term block, and cooldown limits.

If desktop clicks target the wrong location, use Emergency Stop, return to dry-run, fix the WeChat window position, and recalibrate.

14. Privacy and Security

Never commit or upload:

See docs/USER_GUIDE_ZH.md for the full Chinese guide and docs/CONTRIBUTOR_ONBOARDING.md for contributor documentation.

License

MIT License. See LICENSE for details.

音乐

我是你的小狗

西彬

0:000:00

搜索知识与记录

Esc 关闭 · 打开搜索页