Giter Club home page Giter Club logo

qq-win-db-key's Introduction

解密 QQ 数据库

寻求合作者

欢迎一切 能够实现任何相关数据解析算法/乐意适配其他平台者 参与本项目以及 QQ-History-Backup 的开发!邮箱,或者直接开 PR/issue。文档的写作风格随意(但建议图片的 替代文本 和 文件名 好好写),也可以只加入一个指向你的 仓库/博客 等的链接。

关于

导出并解密 PCQQ / QQ NT 等软件的聊天记录数据库。

具体教程自行查看本目录下对应.md文件。

声明

本仓库并非面向纯小白的教程,而是在假设您已经有一定逆向、动态调试等知识的前提下提供的参考资料。尽管开发者可能会为了便捷提供详细教程或完整脚本,您也应当有一定自行修改、调试的能力。另外,请在提问前先完整阅读 qq-win-db-keyQQ-History-Backup所有 issue。如果您无论怎么改都跑不起来,请自由开 issue。(当然如果您感觉教程太烂了或者愿意补充,也可以直接开 PR,记得@QQBackup以通知维护者 merge)

如果你不太懂怎么用:强烈建议自行在B站、各个博客内寻找详细教程。

本项目仅供学习交流使用,严禁用于任何违反**大陆法律法规、您所在地区法律法规、QQ软件许可及服务协议的行为,开发者不承担任何相关行为导致的直接或间接责任。

本项目不对生成内容的完整性、准确性作任何担保,生成的一切内容不可用于法律取证,您不应当将其用于学习与交流外的任何用途。

本项目基本遵循LICENSE里的开源协议,基本接近标识项目地址禁止商用;部分文件同时以不同的协议发布,具体参见文件内对应的声明。

如果哪天完全没人维护了直接开个新仓库接着搞就行。记得保留原作者信息(比如 commit 作者),建议在本仓库的 issues 宣传一下。

qq-win-db-key's People

Contributors

alphagocc avatar fumiama avatar leng-yue avatar ljzd-pro avatar mythologyli avatar shenjackyuanjie avatar siten avatar yllhwa avatar young-lord avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qq-win-db-key's Issues

[请教] 9.9.7_21453 使用密钥解密无效

版本

WIN_NQ_9.9.7_21453

步骤

  1. 编写脚本,拿到了数据
    image
    image
  2. 没有关闭QQ,直接复制数据库 nt_msg.dbtmp 文件夹(修改时间是同一分钟)
  3. 处理得到 nt_msg.clean.db
    image
  4. 复制得到的长度为16的字符串
  5. 打开DB Browser for SQLite,粘贴字符串,修改KDF为4000
    image
  6. 点击OK

第6步后又出现密码输入框。。。

不知道哪个步骤出现问题?

Windows QQNT 如何“略加修改”

根据 repo 提供的脚本略加修改,很容易得到我们需要的 pKey 和 nKey

请务必写详细一点

我尝试改了,但并不 work

hook_script = """
function buf2hex(buffer) {
  const byteArray = new Uint8Array(buffer);
  const hexParts = [];
  for(let i = 0; i < byteArray.length; i++) {
    const hex = byteArray[i].toString(16);
    const paddedHex = ('00' + hex).slice(-2);
    hexParts.push(paddedHex);
  }
  return '0x' + hexParts.join(', 0x');
}

const wrapper_node = Module.load('wrapper.node');
function single_function(pattern) {
    pattern = pattern.replaceAll("##", "").replaceAll(" ", "").toLowerCase().replace(/\\s/g,'').replace(/(.{2})/g,"$1 ");
    var akey_function_list = Memory.scanSync(wrapper_node.base, wrapper_node.size, pattern);
    if (akey_function_list.length > 1) {
        send("pattern FOUND MULTI!!")
        send(pattern)
        send(akey_function_list)
        send("!!exit")
    }
    if (akey_function_list.length == 0) {
        send("pattern NOT FOUND!!")
        send("!!exit")
    }
    return akey_function_list[0]['address'];
}

const key_function = single_function("48 89 5C 24 08")

Interceptor.attach(key_function, {
    onEnter: function (args, state) {
        console.log("¦- nKey: " + args[2].toInt32());
        console.log("¦- *pkey: " + buf2hex(args[1].readByteArray(args[2].toInt32())));
    },
    
    onLeave: function (retval, state) {
    }

});
"""

按照NTQQ (Android).md中的方法提取,无法解密数据库文件

Android QQ版本v9.0.65.17370
使用方法二,成功得到一串32位的pKey
d68740a11614da1d602c85c12f50ac1d
并且将nt_msg.db提取到电脑上,用下图命令去除纯文本头
image
从纯文本头中看出,使用的HMAC加密是SHA1
image
填入密钥对nt_msg.clean.db数据库文件解密,失败。
image

使用方法三,执行后自动跳转qq,几秒后跳转回终端页面,但/sdcard/0/Downloads文件夹中没有看见生成的数据库文件
3fab71f80e7cea571e33148c98c5f6a6
求各位大佬支招!!(滑跪

[求助] Windows QQNT 9.9.9-22961提取不到Key

我使用了msojocs/nt-hook这里的脚本进行hook,在QQ启动但还未登录时开始hook,得到的信息有一万多行,并且QQ登录后hook这边就报错退出了

Fatal Python error: none_dealloc: deallocating None: bug likely caused by a refcount error in a C extension
Python runtime state: initialized

Current thread 0x00001d6c (most recent call first):
  <no Python frame>

Thread 0x0000aae4 (most recent call first):
  File "C:\Users\BrianLeng\Desktop\nt-hook-main\nt.py", line 88 in <module>

Extension modules: psutil._psutil_windows (total: 1)

在已经得到的信息里面过滤出a3 str为16位的字符串,里面没有看起来像key的:

a3 str: NTWrapperSession
...
a3 str: NTWrapperSession
a3 str: qqplay_open_auth
a3 str: NTWrapperSession
...
a3 str: NTWrapperSession
a3 str: RMFile-Down-File
a3 str: RMFile-Down-File

(省略号表示与前后字符串相同)

另外,我的QQNT使用了LiteLoaderQQNT插件,不知道是不是这个有影响。

请问有什么办法能解决吗

MsgContent 字段里的十六进制数据如何解密

Msg3.0.db 我已经按照 qq-win-db-key 给的方法解密了。可以用任何sqlite客户端打开。但是 group_123123 这种表里的 MsgContent ,Info 字段里存的都是类似 0x4D53470000000000... 这种经过混淆后的十六进制数据。请教下,这类数据如何解

修正Android文档中部分内容

  • 版本较高(9.0.75 一类的)
  • 路径中的hash与key中的hash生成算法不同(分别写清楚)
  • md5结果均为小写,32位
  • 可以根据文件头初步判断cipher_hmac_algorithm,有的话按照文件头内容写,没有的话可以试试HMAC_SHA512(默认值)或HMAC_SHA256
  • 说明文件头是个Protobuf
  • 方法2、3的结构可能有点乱?

#29 (comment)
#29 (comment)
#29 (comment)

NT QQ 消息数据解码

感谢各位作者!

参考仓库教程,现在已经成功解密了 nt_msg.db。但是聊天记录是用二进制储存的,我只发现里面的文本应该是 UTF-8。试了一下之前的项目,好像不能正常工作,也许腾讯改格式了。各位大佬有什么想法吗?

key not found

  • win10
  • qq版本:9.7.3.28.946
    提示一直没找到key:
    image

Feature request: 读取新版QQNT数据库

现在腾讯在推NT架构的QQ,要搞全平台统一,然后手机版的NT架构的QQ也开始内测了。
最新的手机版内测QQNT上的数据库架构已经大改了,变得和Windows/Mac/Linux版QQNT一样了。
版本:8.9.58.11050
如图 老版本的数据库仍然存在,但是很明显聊天记录已经不存放在老库里面了
image
S30425-20053693

现在新QQNT聊天记录数据库的位置是/databases/nt_db
S30425-20055692
S30425-20054788

从文件名来看这个数据库架构和电脑版QQNT是一样的
image
(Windows版QQNT数据库)
目前还没研究出新数据库密钥存放的位置以及新数据库的格式
image
(从文件头来看是SQLite3?)

不知道有没有希望搞定新版的数据库解密

另:手机版QQNT内测包下载链接:https://downv6.qq.com/qqweb/QQ_1/android_apk/qq_8.9.58.11050_64.apk
(就算没有内测资格也能用,在弹出内测活动已结束的窗口的时候按两下返回就可以把那个窗口关掉)
(不建议用大号测试,这个内测QQNT一旦登录之后就会把所有的老库里的聊天记录全都迁移进新库,无法撤销)

另2:MacQQNT的数据库位置:/Users/{用户名}/Library/Containers/com.tencent.qq/Data/Library/Application Support/QQ/nt_qq_{一串ID}/nt_db
目测数据库格式和其他平台是一样的
image

frida 错误

❯ python3.10 pcqq_dump.py
QQ pid is: 44980
Traceback (most recent call last):
  File "V:\githubs\qqdb\pcqq_dump.py", line 178, in <module>
    session = frida.get_local_device().attach(QQ_PID)
  File "D:\APPS\CPython\Python310\lib\site-packages\frida\core.py", line 86, in wrapper
    return f(*args, **kwargs)
  File "D:\APPS\CPython\Python310\lib\site-packages\frida\core.py", line 1010, in attach
    return Session(self._impl.attach(self._pid_of(target), **kwargs))  # type: ignore
frida.PermissionDeniedError: error creating directory C:\Users\SHENJA~1.SHE\AppData\Local\Temp\frida-d0ee0fb3c91dec79c5b4bd5f26cdb016\32: Permission denied

PC端尝试手动解密数据库,rekey返回值26

想要解密一个几年前备份留下的Msg3.0.db,按照教程手动得到了该消息记录的账号的key替换了pcqq_rekey_to_none.cpp的313行,把Msg3.0.db和编译的a.exe丢到Bin下后运行a.exe,Msg3.0.db除了修改时间元数据变化没有任何改变(md5相同),输出如下:
open iRet=0
key iRet=0
====EXEC=========
exec iRet=0
rekey iRet=26
====END=========
我看到返回值26似乎是说被打开的文件不是一个数据库文件,这是数据库损坏了吗?为什么open,key和exec的返回值是正常的?

关于Uin获取更快的方法

因为在/data/user/0/com.tencent.mobileqq/databases/beacon_db_com.tencent.mobileqq中未找到uid,所以尝试了另一种方法

要求: QQpatch了QAuxiliary模块

步骤

  1. 依次找到侧边栏-设置-QAuxiliary-[辅助功能]聊天和消息-[消息]转发消息点头像查看详细信息,开启该功能
  2. 向任意联系人发送任意消息(也可以是之前发送的消息,只要是自己发的消息就行)
  3. 长按该消息-多选-合并转发
  4. 转发给任意联系人或群组(建议发给我的电脑)
  5. 打开该转发消息,点自己的的头像
  6. 点击详情
  7. 你会看到如下内容(已格式化)
MsgRecord{
  msgId=739329401601xxxx,
  msgRandom=49205xxxx,
  msgSeq=19xx,
  cntSeq=0,
  chatType=1,
  msgType=11,
  subMsgType=7,
  sendType=2,
  senderUid=u_xxxx,
  peerUid=xxxx,
  channelId=,
  guildId=,
  guildCode=0,
  fromUid=0,
  fromAppid=0,
  msgTime=1721206556,
  msgMeta=[
  B@a00ceba,
  sendStatus=2,
  ...(省略)
  "prompt":"[聊天记录]",
  "ver":"0.0.0.5",
  "view":"contact"
}
  1. 其中senderUid即为你的uid

新版本 QQNT (Android) 中函数位置改变

丢进libbasic_share里了,同时把函数的符号加了回来
需要适配一下(具体来说要在libkernel中找不到函数时尝试在libbasic_share中找,并且优先使用findExportByName来利用符号信息)

AndroidNT pkg in frida frida-python无法安装

AndroidNT 教程中:

pkg in frida frida-python

无法安装:

~ $ pkg up
Checking availability of current mirror:
[*] https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main: ok
Hit:1 https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main stable InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
~ $ termux-setup-storage

It appears that directory '~/storage' already exists.
This script is going to rebuild its structure from
scratch, wiping all dangling files. The actual storage
content IS NOT going to be deleted.

Do you want to continue? (y/n) y
~ $ pkg in frida frida-python
Checking availability of current mirror:
[*] https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main: ok
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package frida
E: Unable to locate package frida-python
~ $ 

pkg已经换清华源.已经执行pkg uptermux-setup-storage

Android 7 光速虚拟机内 Frida 无法正常运行

采用光速虚拟机提供手机上的安卓7模拟器,内核可能是anbox。(x86的模拟器不支持这个项目)

selinux已经调整为宽松模式
在su环境下运行了frida-server
根本没有安装magisk,不存在magisk hide干扰问题。

始终报这个错。

zygote进程存在,但还有一个zygote64?
是不是要访问另一个?

hook出的key带有问号

Screenshot_2024-05-26-13-16-39-167_com termux
正如图片正如图片那样我所得到的key
Pattern: fd 7b bd a9 f6 57 01 a9 f4 4f 02 a9 fd 03 00 91 f6 03 01 aa f5 03 00 aa ?? ?? ?? ?? f3 03 03 2a f4 03 02 aa
Attach key_v2_function addr: 0x78b8f6fb4c
Frida script injected.
带有问号,请问他是正常的吗。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.