使用pysqlcipher3处理微信数据库

以下内容可在 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:

python - Issue in installing pysqlcipher3 - Stack Overflow
GitHub - rotki/pysqlcipher3: Configuration to build and publish pysqlcipher3 with wheels for rotki
【个人开发】通过python导出微信聊天记录_如何使用python导出企业微信的聊天内容-CSDN博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值