diff --git a/README.md b/README.md index aa5b311..a617f89 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,14 @@ ## 导出安卓微信聊天数据 -WeChat(微信), as the most popular mobile IM app in China, doesn't give users any method to export well-formatted history message. +WeChat(微信), as the most popular mobile IM app in China, doesn't give users any way to export well-formatted history messages. This tool can parse and export WeChat messages on a rooted android phone. -Right now it can dump messages in text-only mode, or generate a single-file html containing voice messages, images, emoji, etc. +Right now the tool can dump chat messages to self-contained html files including voice messages, images, emojis, videos, etc. +It can also dump messages to texts. If this tools works for you, please take a moment to __add your phone/OS to__ [the wiki](https://github.com/ppwwyyxx/wechat-dump/wiki). -If it doesn't work, you probably have to investigate it as the behavior may be different on each phone. +If it doesn't work, you probably have to do some investigation before posting an issue, as the behavior may be different on each phone. ### How to use: @@ -16,11 +17,10 @@ If it doesn't work, you probably have to investigate it as the behavior may be d + adb and rooted android phone connected to a Linux/Mac OSX/Win10+Bash. If the phone does not come with adb support, you can download an app such as https://play.google.com/store/apps/details?id=eu.chainfire.adbd + Python >= 3.6 -+ [PyQuery](https://pypi.python.org/pypi/pyquery/), [javaobj-py3](https://pypi.org/project/javaobj-py3), [PyCryptodome](https://github.com/Legrandin/pycryptodome) Pillow, requests -+ [sqlcipher](https://github.com/sqlcipher/sqlcipher) >= 4.1, [pysqlcipher3](https://pypi.python.org/pypi/pysqlcipher3) ++ [sqlcipher](https://github.com/sqlcipher/sqlcipher) >= 4.1 + sox (command line tools) -+ csscompressor (suggested, optional) -+ Silk audio decoder (included; build with `./third-party/compile_silk.sh`) ++ Silk audio decoder (included; build it with `./third-party/compile_silk.sh`) ++ Other python dependencies: `pip install -r requirements.txt`. #### Get Necessary Data: @@ -104,10 +104,6 @@ Screenshots of generated html: See [here](http://ppwwyyxx.com/static/wechat/example.html) for an example html. ### TODO List -+ Crack emoji encryption to handle some missing emojis. - * __HELP WANTED__: Starting from May 2016, the first 1KB of all emojis in `resource/emoji` are encrypted. Right now I'm using emoji URL which covers most of them. - Any thoughts on how they are encrypted are appreciated. - It is also possible to recover the image without knowing the first 1KB (just have to detect chunks without knowing metadata). + Fix rare unhandled message types: > 10000 and < 0 + Better user experiences... see `grep 'TODO' wechat -R` diff --git a/decrypt-db.py b/decrypt-db.py index 8d763f8..04fd32c 100755 --- a/decrypt-db.py +++ b/decrypt-db.py @@ -7,6 +7,7 @@ import re import struct import argparse import logging +import javaobj from pyquery import PyQuery from pysqlcipher3 import dbapi2 as sqlite from hashlib import md5 @@ -66,6 +67,16 @@ def get_uin(): else: candidates.append(uin) logger.info(f"found uin={uin} in auth_info_key_prefs.xml") + + try: + out = subproc_succ(f"adb shell cat {MM_DIR}/MicroMsg/systemInfo.cfg") + uin = javaobj.loads(out).get(1, 0) + except: + logger.warning("default uin not found in systemInfo.cfg") + else: + candidates.append(uin) + logger.info(f"found uin={uin} in systemInfo.cfg") + candidates = list({x for x in candidates if x != 0}) logger.info(f"Possible uin: {candidates}") return candidates @@ -97,7 +108,6 @@ def get_imei(): out = subproc_succ(f"adb shell cat {MM_DIR}/MicroMsg/CompatibleInfo.cfg") try: # https://gist.github.com/ChiChou/36556fd412a9e3216abecf06e084e4d9 - import javaobj jobj = javaobj.loads(out) imei = jobj[258] except: diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..6722e76 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,8 @@ +pyquery +javaobj-py3>=0.4.1 +pycryptodome +pillow>=7.0 +requests +pysqlcipher3>=1.0.3 +csscompressor + diff --git a/third-party/compile_silk.sh b/third-party/compile_silk.sh index 349057b..532000b 100755 --- a/third-party/compile_silk.sh +++ b/third-party/compile_silk.sh @@ -1,7 +1,4 @@ #!/bin/bash -e -# File: compile_silk.sh -# Date: Tue Jun 16 22:26:49 2015 +0800 -# Author: Yuxin Wu cd `dirname "$0"`/silk make