以下内容可在 Mac 的 M1 系列电脑上运行。

安装依赖

1
2
brew install sqlcipher
pip install rotki-pysqlcipher3

查询记录

参考这里,写 Python 代码。

Key,为上一篇获取到的 key 信息。Chat_table 为上面数据库查到的表名,可以在微信聊天对话框中,随便选择一张图片,查看原文件,打开的文件夹 ID 即为 Table 的 ID。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import pandas as pd
import pysqlcipher3.dbapi2 as sqlite

key = '0x68*********************************'
chat_table = 'Chat_******************************'

db= sqlite.connect('WeChatDB/msg_1.db')
db_cursor = db.cursor()
db_cursor.execute(f"PRAGMA key='x''{key[2:]}''';")
db_cursor.execute("PRAGMA cipher_compatibility=3;")
db_cursor.execute("PRAGMA cipher_page_size=1024;")
db_cursor.execute("PRAGMA kdf_iter=64000;")
db_cursor.execute("PRAGMA cipher_hmac_algorithm=HMAC_SHA1;")
db_cursor.execute("PRAGMA cipher_kdf_algorithm=PBKDF2_HMAC_SHA1;")


resoverall = db_cursor.execute(f"SELECT * FROM {chat_table};")
data_list = resoverall.fetchall()
table_df = pd.DataFrame(data_list)
table_df.columns = [i[0]for i in resoverall.description]

这样,就可以直接在程序中导出 table_df 内容了。

Ref:

https://stackoverflow.com/questions/55446420/issue-in-installing-pysqlcipher3
https://github.com/rotki/pysqlcipher3
https://blog.csdn.net/weixin_44505713/article/details/138392189