[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-80680":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":14,"subscribersCount":14,"size":14,"stars1d":14,"stars7d":15,"stars30d":15,"stars90d":14,"forks30d":14,"starsTrendScore":14,"compositeScore":16,"rankGlobal":9,"rankLanguage":9,"license":9,"archived":17,"fork":17,"defaultBranch":18,"hasWiki":19,"hasPages":17,"topics":20,"createdAt":9,"pushedAt":9,"updatedAt":21,"readmeContent":22,"aiSummary":23,"trendingCount":14,"starSnapshotCount":14,"syncStatus":24,"lastSyncTime":25,"discoverSource":26},80680,"weixin-decrypte-script","ZedeX\u002Fweixin-decrypte-script","ZedeX","Decrypte WeiXin 4.x key",null,"Python",51,28,47,0,4,4.39,false,"main",true,[],"2026-06-12 02:04:05","# WeChat Decrypt Script\n\nWindows 微信 4.x 本地数据解密工具集，支持数据库解密、消息读取、图片文件解密，以及 JSON API 服务。\n\n> 基于 [xuxinhang 的技术文章](https:\u002F\u002Fmp.weixin.qq.com\u002Fs\u002FJbyzB3NmFbHlGQJlgVGuDw) 方法\n\n## 功能\n\n- 从微信进程内存提取 SQLCipher 4 数据库密钥\n- 批量解密数据库文件（contact、message、session 等）\n- 读取并解压 ZSTD 压缩的消息内容\n- 解密 DAT 图片文件，支持三种加密格式：\n  - 旧版 XOR（单字节异或，自动检测密钥）\n  - V1 格式（AES-128-ECB + XOR，固定密钥 `cfcd208495d565ef`）\n  - V2 格式（AES-128-ECB + XOR，从内存提取密钥）\n- **JSON API 服务**：将聊天记录以 RESTful API 方式提供，支持查询消息、联系人、群聊、会话，支持关键词搜索和多格式输出（JSON\u002FCSV\u002FText）\n- **一键启动**：自动扫描密钥 → 自动解密数据库 → 启动 API 服务\n\n## 环境要求\n\n- Windows 10\u002F11 x64\n- Python 3.8+\n- 微信 4.x（已登录）\n- 管理员权限（密钥提取需要）\n\n## 安装\n\n```bash\npip install pymem psutil pycryptodome zstandard flask flask-cors\n```\n\n## 快速开始\n\n### 方式一：一键启动 API 服务（推荐）\n\n类似 [chatlog](https:\u002F\u002Fgithub.com\u002Fsjzar\u002Fchatlog) 的体验，一条命令完成所有操作：\n\n```bash\n# 全自动：微信运行中，自动扫描密钥 + 解密 + 启动\npython api_server.py \"C:\\Users\\\u003CUSER>\\Documents\\xwechat_files\\\u003Cwxid>\"\n\n# 指定密钥启动\npython api_server.py \"C:\\Users\\\u003CUSER>\\Documents\\xwechat_files\\\u003Cwxid>\" --key \u003Chex_key>\n\n# 指定密钥文件启动\npython api_server.py \"C:\\Users\\\u003CUSER>\\Documents\\xwechat_files\\\u003Cwxid>\" --key-file found_keys.txt\n\n# 跳过解密（已有 .decrypted.db 文件）\npython api_server.py \"C:\\Users\\\u003CUSER>\\Documents\\xwechat_files\\\u003Cwxid>\" --no-decrypt\n```\n\n启动后访问 `http:\u002F\u002Flocalhost:5050` 即可使用 API。\n\n### 方式二：分步操作\n\n#### 1. 提取数据库密钥\n\n```bash\n# 以管理员身份运行，微信必须已登录\npython scan_keys.py\n```\n\n#### 2. 解密数据库\n\n```bash\n# 批量解密\npython decrypt_db.py --auto \"C:\\Users\\\u003CUSER>\\Documents\\xwechat_files\" found_keys.txt\n\n# 单个文件\npython decrypt_db.py \u003Cdb_path> \u003Chex_key>\n```\n\n#### 3. 读取消息\n\n```bash\npython read_messages.py \u003Cdecrypted_db_path>\n\n# 批量读取\npython read_messages.py --batch \"C:\\Users\\\u003CUSER>\\Documents\\xwechat_files\"\n```\n\n#### 4. 解密图片\n\n```bash\n# XOR 格式（自动检测密钥）\npython decrypt_dat.py --batch \u003Cattach_dir> \u003Coutput_dir>\n\n# V2 格式（需先提取 AES 密钥）\n# 方法1: 一次性扫描（先在微信中查看2-3张图片，再运行）\npython find_image_key.py \u003Cattach_dir>\n\n# 方法2: 持续监控（推荐，启动后在微信中查看图片即可）\npython monitor_image_key.py \u003Cattach_dir>\n\n# 使用提取到的密钥批量解密\npython decrypt_dat.py --batch \u003Cattach_dir> \u003Coutput_dir> --aes-key \u003C16字节密钥> --xor-key 0x5f\n```\n\n## JSON API 文档\n\n### API 端点\n\n| 端点 | 说明 |\n|------|------|\n| `GET \u002Fhealth` | 健康检查 |\n| `GET \u002Fapi\u002Fv1\u002Fchatlog` | 查询聊天记录 |\n| `GET \u002Fapi\u002Fv1\u002Fcontact` | 查询联系人 |\n| `GET \u002Fapi\u002Fv1\u002Fchatroom` | 查询群聊 |\n| `GET \u002Fapi\u002Fv1\u002Fsession` | 查询最近会话 |\n| `GET \u002Fapi\u002Fv1\u002Fsearch` | 全文搜索消息 |\n\n### 查询聊天记录\n\n```\nGET \u002Fapi\u002Fv1\u002Fchatlog?talker=\u003Cid>&time=\u003Crange>&keyword=\u003Ctext>&limit=50&offset=0&format=json\n```\n\n| 参数 | 必填 | 说明 |\n|------|------|------|\n| `talker` | 是 | 微信 ID 或群聊 ID，逗号分隔多个 |\n| `time` | 否 | 时间范围，如 `2025-01-01` 或 `2025-01-01,2025-06-01` |\n| `sender` | 否 | 按发送者过滤 |\n| `keyword` | 否 | 按关键词过滤 |\n| `limit` | 否 | 返回数量，默认 50 |\n| `offset` | 否 | 分页偏移，默认 0 |\n| `format` | 否 | 输出格式：`json` \u002F `csv` \u002F `text`，默认 `json` |\n\n**示例：**\n\n```bash\n# 查询群聊最近 10 条消息\ncurl \"http:\u002F\u002Flocalhost:5050\u002Fapi\u002Fv1\u002Fchatlog?talker=12345678@chatroom&limit=10\"\n\n# 查询指定时间范围的消息\ncurl \"http:\u002F\u002Flocalhost:5050\u002Fapi\u002Fv1\u002Fchatlog?talker=wxid_xxx&time=2025-01-01,2025-06-30\"\n\n# 关键词搜索\ncurl \"http:\u002F\u002Flocalhost:5050\u002Fapi\u002Fv1\u002Fchatlog?talker=12345678@chatroom&keyword=hello\"\n\n# 导出为 CSV\ncurl \"http:\u002F\u002Flocalhost:5050\u002Fapi\u002Fv1\u002Fchatlog?talker=wxid_xxx&format=csv\" -o chatlog.csv\n\n# 导出为纯文本\ncurl \"http:\u002F\u002Flocalhost:5050\u002Fapi\u002Fv1\u002Fchatlog?talker=wxid_xxx&format=text\"\n```\n\n**响应示例：**\n\n```json\n{\n  \"total\": 169737,\n  \"limit\": 3,\n  \"offset\": 0,\n  \"items\": [\n    {\n      \"seq\": 1660613074000,\n      \"time\": \"2022-08-16 09:24:34\",\n      \"talker\": \"12345678@chatroom\",\n      \"talker_name\": \"My Group\",\n      \"is_chatroom\": true,\n      \"sender\": \"system\",\n      \"sender_name\": \"\",\n      \"is_self\": false,\n      \"type\": 10000,\n      \"sub_type\": 0,\n      \"content\": \"You joined the group chat\"\n    }\n  ]\n}\n```\n\n### 查询联系人\n\n```\nGET \u002Fapi\u002Fv1\u002Fcontact?keyword=\u003Cname>&limit=50&offset=0\n```\n\n```bash\n# 搜索联系人\ncurl \"http:\u002F\u002Flocalhost:5050\u002Fapi\u002Fv1\u002Fcontact?keyword=John\"\n\n# 列出所有联系人\ncurl \"http:\u002F\u002Flocalhost:5050\u002Fapi\u002Fv1\u002Fcontact?limit=100\"\n```\n\n### 查询群聊\n\n```\nGET \u002Fapi\u002Fv1\u002Fchatroom?keyword=\u003Cname>&limit=50&offset=0\n```\n\n```bash\n# 搜索群聊\ncurl \"http:\u002F\u002Flocalhost:5050\u002Fapi\u002Fv1\u002Fchatroom?keyword=tech\"\n```\n\n### 查询会话\n\n```\nGET \u002Fapi\u002Fv1\u002Fsession?keyword=\u003Cname>&limit=50&offset=0\n```\n\n```bash\n# 最近会话\ncurl \"http:\u002F\u002Flocalhost:5050\u002Fapi\u002Fv1\u002Fsession?limit=10\"\n```\n\n### 全文搜索\n\n```\nGET \u002Fapi\u002Fv1\u002Fsearch?keyword=\u003Ctext>&limit=50&offset=0\n```\n\n```bash\n# 跨所有聊天记录搜索\ncurl \"http:\u002F\u002Flocalhost:5050\u002Fapi\u002Fv1\u002Fsearch?keyword=hello\"\n```\n\n### 消息类型说明\n\n| type | 说明 |\n|------|------|\n| 1 | 文本消息 |\n| 3 | 图片 |\n| 34 | 语音 |\n| 43 | 视频 |\n| 47 | 表情动画 |\n| 49 | 分享\u002F链接\u002F小程序等 |\n| 10000 | 系统消息 |\n\n## 脚本说明\n\n| 脚本 | 功能 |\n|------|------|\n| `api_server.py` | JSON API 服务（支持一键启动，自动解密） |\n| `decrypt_engine.py` | 解密引擎模块（密钥扫描 + 数据库解密） |\n| `models.py` | 数据模型（消息\u002F联系人\u002F群聊\u002F会话） |\n| `db_service.py` | 数据库服务层（查询\u002F搜索） |\n| `scan_keys.py` | 从微信进程内存提取数据库加密密钥 |\n| `decrypt_db.py` | 解密 SQLCipher 4 数据库 |\n| `read_messages.py` | 读取解密后的消息（含 ZSTD 解压） |\n| `decrypt_dat.py` | 解密 DAT 图片文件（XOR\u002FV1\u002FV2） |\n| `find_image_key.py` | 一次性扫描 V2 图片 AES 密钥 |\n| `monitor_image_key.py` | 持续监控自动捕获 V2 图片 AES 密钥 |\n\n## 技术原理\n\n### 数据库加密\n\n微信 4.x 使用 SQLCipher 4（AES-256-CBC + HMAC-SHA512），密钥以 `x'\u003C64位hex>'` 格式常驻进程内存，通过内存扫描提取。\n\n### 图片加密\n\n| 格式 | 文件头 | 加密方式 | 密钥来源 |\n|------|--------|---------|---------|\n| 旧版 XOR | 不固定 | 单字节 XOR | 自动检测 |\n| V1 | `07 08 56 31 08 07` | AES-128-ECB + XOR | 固定 `cfcd208495d565ef` |\n| V2 | `07 08 56 32 08 07` | AES-128-ECB + XOR | 内存提取 |\n\n> V2 AES 密钥仅在微信查看图片时临时加载到内存，需先查看图片再扫描。\n\n### API 服务架构\n\n```\napi_server.py (Flask HTTP API)\n    |\n    +-- decrypt_engine.py (自动解密: 密钥扫描 + SQLCipher 解密)\n    |\n    +-- db_service.py (数据库查询: 消息\u002F联系人\u002F群聊\u002F会话\u002F搜索)\n         |\n         +-- models.py (数据模型: Message\u002FContact\u002FChatRoom\u002FSession)\n```\n\n启动流程：自动扫描密钥 → 增量解密数据库 → 加载数据 → 启动 HTTP 服务\n\n详细技术文档见 [WEIXIN_DECRYPT_GUIDE.md](WEIXIN_DECRYPT_GUIDE.md)。\n\n## 声明\n\n本项目仅供个人数据备份与恢复等合法用途。请遵守相关法律法规，尊重他人隐私。\n","ZedeX\u002Fweixin-decrypte-script 是一个用于解密 Windows 微信 4.x 本地数据的工具集，支持数据库解密、消息读取、图片文件解密以及提供 JSON API 服务。其核心功能包括从微信进程内存中提取 SQLCipher 4 数据库密钥、批量解密数据库文件（如联系人、消息、会话等）、解压 ZSTD 压缩的消息内容及解密三种不同加密格式的 DAT 图片文件。此外，项目还提供了一个 RESTful API 接口，便于用户以多种格式查询和导出聊天记录、联系人、群聊和会话信息。该工具适用于需要对微信本地数据进行分析或备份的场景，特别适合开发者和研究人员使用。",2,"2026-06-11 04:01:37","CREATED_QUERY"]