android qq聊天记录导出大致流程
tested on android 6 tencent qq
设法将
/data/data/com.tencent.*/databases
目录拷贝出来,我假设你了解如何做到这一点。运行以下命令。我假设你了解如何安装/使用sqlite,我假设你了解linux基本知识。
$ sqlite3 872222222-IndexQQMsg.db
sqlite> .output /home/recolic/extraDisk/tmp/tmp.out
sqlite> select * from IndexContent_content ;
sqlite> .quit
拿到输出的文件,跑下面的这个qqmsg_decoder.py就可以了。如果你需要filter等自定义功能,我假设你了解如何使用python。
注意到这个聊天记录似乎有丢失,总觉得少了点什么。感谢补充。
qqmsg_decoder.py
#!/usr/bin/env python3
# $ sqlite3 872222222-IndexQQMsg.db
# sqlite> .output /home/recolic/extraDisk/tmp/tmp.out
# sqlite> select * from IndexContent_content ;
# sqlite> .quit
import sys
import base64
import datetime
############## User defined
def _filter(line):
#return '111222333' in line
#return '257112220' in line
return True
##############
def decode_qtimestamp(s):
# print('debug', s, file=sys.stderr)
if s == '':
return 0
ts = base64.b64decode(s)[4:8]
return sum([int(ts[i])*(256**(3-i)) for i in range(4)])
def timestamp_to_str(int_ts):
return datetime.datetime.fromtimestamp(int_ts).strftime('%Y-%m-%d %H:%M:%S')
with open(sys.argv[1]) as f:
cont = f.read()
for line in cont.split('\n'):
if line == '':
continue
ar = line.split('|')
timestamp = timestamp_to_str(decode_qtimestamp(ar[-1]))
ar = ar[:-1]
line = '|'.join([ar[0]] + [base64.b64decode(ele.encode()).decode(errors='ignore') for ele in ar[1:]])
line += '|' + timestamp
if _filter(line):
print(line)
Leave a Reply