AI prompts
base on 该工具用于导出正在运行中的微信进程的 key 并自动解密所有微信数据库文件以及导出 key 后数据库文件离线解密。 # wechat-dump-rs (支持微信4.0版本)
该工具用于导出正在运行中的微信进程的 key 并自动解密所有微信数据库文件以及导出 key 后数据库文件离线解密。
![demo](images/demo.gif)
> **可能存在封号风险,后果自负!!!**
>
> **使用需知**:
> 微信4.0 重构后改用 HMAC_SHA512 算法,寻找 key 的方式和 v3 不同,工具内仍然采用内存暴力搜索的方式,对于 v4 解密时将使用多线程加速,可能会导致 cpu 飙到 100%,取决于 key 离起始查找点的距离。
## 工具用法
```bash
wechat-dump-rs (1.0.13) - REinject
A wechat db dump tool
Options:
-p, --pid <PID> pid of wechat
-k, --key <KEY> key for offline decryption of db file
-f, --file <PATH> special a db file path
-d, --data-dir <PATH> special wechat data dir path (pid is required)
-o, --output <PATH> decrypted database output path
-a, --all dump key and decrypt db files
--vv <VERSION> wechat db file version [default: 4] [possible values: 3, 4]
-r, --rawkey convert db key to sqlcipher raw key (file is required)
-h, --help Print help
```
如果不带任何参数,程序只输出所有微信进程的 key、微信号、手机号、数据目录、版本等信息:
```bash
=======================================
ProcessId: 4276
WechatVersion: 4.0.0.26
AccountName: xxxxxx
NickName: xxxxxx
Phone: 15111611111
DataDir: C:\Users\xxx\Documents\xwechat_files\wxid_xxxx_xxa\
key: f11fd83bxxxxxx4f3f4x4ddxxxxxe417696b4axx19e09489ad48c
=======================================
```
使用参数 `-a` 可以直接导出所有数据库文件。
### 使用 sqlcipher browser 浏览数据库
工具自动解密后的文件可能存在畸形问题,可以直接使用 [DB Browser for SQLCipher](https://sqlitebrowser.org/) 浏览原始数据库文件。
打开 sqlcipher 数据库时,选择 “原始密钥”,微信 V3 选择 自定义(页大小4096/KDF迭代64000/HMAC算法SHA1/KDF算法SHA1),V4 选择 sqlcipher4 默认,每个数据库文件对应的原始密钥都是不一样的,获取方式如下:
微信 V3 数据库文件 rawkey:
```bash
wechat-dump-rs.exe -k xxxxxxxxxxxxxxxxx -f c:\users\xxxx\xxxx\contact.db -r --vv 3
```
微信 V4 数据库文件 rawkey:
```bash
wechat-dump-rs.exe -k xxxxxxxxxxxxxxxxx -f c:\users\xxxx\xxxx\contact.db -r --vv 4
```
## 原理
一般情况下,key 要在运行的微信进程内存中拿到,内存偏移在每个版本都不一样,大部分工具是对每个版本维护一套偏移,但是当出现新版本的时候都要重新找偏移,方法见后面有简单记录。
其实,除了这个方法外,还有一个更通用的方法就是内存暴力搜索找到能用于解密的密钥位置,当然如果对进程全部内存扫一遍肯定不行,所以项目里用下面这种方式缩小密钥内存范围加快扫描速度:
1. ~~微信登录设备类型基本只有 iphone、android,在内存中先搜到设备类型所在内存,key 就在它的前面,向前搜就行~~
2. ~~key 的内存地址和登录设备类型据我观察是 16 字节对齐的,所以每次向前 16 字节~~
还有其它一些小细节,直接看一下代码吧。
## 已测试版本列表
其它未测试版本不代表不能用,这个列表只是我本地有过的环境。
- 3.9.6.33
- 3.9.7.25
- 3.9.7.29
- 3.9.8.9
- 3.9.8.15
- 3.9.10.19
- 3.9.11.25
- 3.9.12.15
- 3.9.12.17
- 4.0.0.26
- 4.0.0.32
- 4.0.0.34
- 4.0.0.35
- 4.0.1.11
- 4.0.1.13
- 4.0.1.17
## 库表结构
- [4.0.0.26](docs/wechat_4_0_0_26_table_struct.md)
> 4.0 聊天记录内容解析参考示例 [导出聊天记录到TXT](./sample_scripts/导出聊天记录到TXT/)。
## 微信分析记录
- [微信3.9手动寻找偏移](docs/wechat_3_9_analysis.md)
- [微信4.0寻找key过程](docs/wechat_4_0_analysis.md)
## Star History
[![Star History Chart](https://api.star-history.com/svg?repos=0xlane/wechat-dump-rs&type=Date)](https://star-history.com/#0xlane/wechat-dump-rs&Date)
", Assign "at most 3 tags" to the expected json: {"id":"4085","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"