Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2024-12 的数据库加密已改为了 SHA512,本人困惑许久,特此更新 #50

Open
Dao1023 opened this issue Jan 2, 2025 · 4 comments

Comments

@Dao1023
Copy link

Dao1023 commented Jan 2, 2025

本页面参考了此文档,可以作为一个更适合小白的教程指导

本文含有部分 Obsidian 的图片与 md 引用,这里暂不展示

反编译以读取登录 key

使用 IDA 等反编译工具打开验证程序

C:\Program Files\Tencent\QQNT\versions\9.9.17-30594\resources\app\wrapper.node

第一次反编译时间会比较久

在 String View 中查找 sqlite3_key_v2 ,双击发现在如下汇编位置

.rdata:0000000183D406CE aNtSqlite3KeyV2 db 'nt_sqlite3_key_v2: db=%p zDb=%s',0
.rdata:0000000183D406CE                                         ; DATA XREF: sub_182703A10+15o

对这个位置 JumpOpXref 后发现在

.text:0000000182703A25                 lea     rdx, aNtSqlite3KeyV2 ; "nt_sqlite3_key_v2: db=%p zDb=%s"
# .text 地址段位置lea 寄存器为有效地址而非内存地址rdx  x64 寄存器后面为变量名和注释

按下 F5,会自动把汇编反编译成 C/C++ 函数,并在 Pseudocode-A 打开
我们在 sub_182703A25 处打个断点,此时这个 dll 我们已经注入进去了
接下来就是附着到 QQ.exe ,当发现 dll 被调用时停止程序,并获取当前的数据

我们重新打开 QQ,并打开 IDA Debug -> Attach to Process ,选择 QQ.exe
,些许等待后发现程序已经被停止了,卡在了登录界面,我们点一下继续,让它先跑起来
然后登录 QQ,此时成功在断点处停下,我们打开 Locals 就可以看到一些变量

右击变量 a3 并 Jump to ,可以获得参数值
这是一个 16 位的字符串,这是 passphrase

解密数据库

# 聊天记录数据库
C:\Users\Dao\Documents\Tencent Files\xxxxxxxxx\nt_qq\nt_db\nt_msg.db

清理前 1024 位

python -c "open('nt_msg.clean.db','wb').write(open('nt_msg.db','rb').read()[1024:])"

使用任意 SQLCipher 工具打开
比如:[[DB Browser for SQLite]]、[[SQLiteStudio]]、[[sqlcipher CLI]]
如果报错 file is not a database,则你的工具错了,不要用 SQLite,而是 SQLCipher,@ Issue #47 · QQBackup/qq-win-db-key

配置参考,也可以作为 sqlcipher CLI 命令

sqlcipher nt_msg.clean.db

PRAGMA key = 'xxxxxxxxxxxxxxxx';
PRAGMA cipher_page_size = 4096;
PRAGMA kdf_iter = '4000';
PRAGMA cipher_hmac_algorithm = HMAC_SHA1;
PRAGMA cipher_default_kdf_algorithm = PBKDF2_HMAC_SHA512;
PRAGMA cipher = 'aes-256-cbc';

.tables

.exit

其中 cipher_hmac_algorithm 并不是 SHA1,在 2024-12 已变成了 SHA512,我因为这个错误困惑许久

@weasUXL
Copy link

weasUXL commented Jan 4, 2025

十分感谢提议,现在我才发现我图片引用错位的问题(
我对其中的部分内容进行了整合,希望能更适合小白吧

@Young-Lord
Copy link
Member

Young-Lord commented Jan 5, 2025

@weasUXL 你方便把这个issue的详细内容合并一下吗?
另外要不把 qq-win-db-key 最近几个更改整合到 QQDecrypt 里,然后把 qq-win-db-key 废弃掉吧

@weasUXL
Copy link

weasUXL commented Jan 5, 2025

@weasUXL 你方便把这个issue的详细内容合并一下吗?

昨晚我整合了的,内容补充到了myth的方法中去

另外要不把 qq-win-db-key 最近几个更改整合到 QQDecrypt 里,然后把 qq-win-db-key 废弃掉吧

仓库看你,我建议维持原样😳

@yhLi9
Copy link

yhLi9 commented Jan 13, 2025

本人逆向0基础,参照本issue,发现最后还是 SHA1,qq_nt版本 9.9.17-30594
微信截图_20250113163813

微信截图_20250113163840

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants