Dump wechat messages from android
Yuxin Wu c09323fd44 support downloading avatar | hace 1 día | |
---|---|---|
WXGFDecoder | hace 3 días | |
legacy | hace 4 años | |
screenshots | hace 10 años | |
third-party | hace 3 semanas | |
hace 1 día | ||
.gitattributes | hace 9 años | |
.gitignore | hace 4 años | |
LICENSE.txt | hace 10 años | |
README.md | hace 1 día | |
android-interact.sh | hace 3 semanas | |
count-message.sh | hace 7 años | |
decrypt-db.py | hace 3 semanas | |
dump-audio.py | hace 4 años | |
dump-html.py | hace 1 día | |
dump-msg.py | hace 4 años | |
emoji-cache-tool.py | hace 4 años | |
list-chats.py | hace 4 años | |
plot-num-msg-by-time.py | hace 1 día | |
requirements.txt | hace 3 días |
WeChat, as the most popular mobile IM app in China, doesn't provide any methods to export structured message history.
We reverse-engineered the storage protocol of WeChat messages, and provide this tool to decrypt and parse WeChat messages on a rooted android phone. It can also render the messages into self-contained html files including voice messages, images, emojis, videos, etc.
The tool is last verified to work with latest version of WeChat on 2025/01/01. If the tool works for you, please take a moment to add your phone/OS to the wiki.
./third-party/compile_silk.sh
)pip install -r requirements.txt
../android-interact.sh db
. It may use an incorrect userid.${userid}
by inspecting the contents of /data/data/com.tencent.mm/MicroMsg
on the root filesystem of the device.
It should be a 32-character-long name consisting of hexadecimal digits./data/data/com.tencent.mm/MicroMsg/${userid}/EnMicroMsg.db
from the device.Decrypt database file:
./decrypt-db.py decrypt --input EnMicroMsg.db
./decrypt-db.py uin
, which looks for uin in /data/data/com.tencent.mm/shared_prefs/
document.cookie
./decrypt-db.py imei
implements some ways to find device id.*#06#
on your phoneDecrypt database with combination of uin and device id:
./decrypt-db.py decrypt --input EnMicroMsg.db --imei <device id> --uin <uin>
NOTE: you may need to try different ways to get device id and find one that can decrypt the
database. Some phones may have multiple IMEIs, you may need to try them all.
See #33.
The command will dump decrypted database at EnMicroMsg.db.decrypted
.
If the above decryption doesn't work, you can also try the password cracker to brute-force the key. The encryption key is not very strong.
Copy the WeChat user resource directory /data/data/com.tencent.mm/MicroMsg/${userid}/{avatar,emoji,image2,sfs,video,voice2}
from the phone to the resource
directory:
./android-interact.sh res
RES_DIR
in the script if the location of these directories is different on your phone.
For older version of WeChat, the directory may be /mnt/sdcard/tencent/MicroMsg/
tar
with or without compression, and then copy the archive,
busybox tar
is recommended as the Android system's tar
may choke on long paths.resource
directory with the following subdir: avatar,emoji,image2,sfs,video,voice2
.(Optional) Install and start a WXGF decoder server on an android device. Without this, certain WXGF images will not be rendered or will be rendered in low resolution. See WXGFDecoder for instructions.
(Optional) Download the emoji cache from here
and decompress it under wechat-dump
. This will avoid downloading too many emojis during rendering.
wget -c https://github.com/ppwwyyxx/wechat-dump/releases/download/0.1/emoji.cache.tar.bz2
tar xf emoji.cache.tar.bz2
Parse and dump text messages of every chat (requires decrypted database):
./dump-msg.py decrypted.db output_dir
List all chats (required decrypted database):
./list-chats.py decrypted.db
Generate statistics report on text messages (requires output_dir
from ./dump-msg.py
):
./count-message.sh output_dir
Dump messages of one contact to html, containing voice messages, emojis, and images (requires decrypted database and resource
):
./dump-html.py "<contact_display_name>"
output.html
. Check ./dump-html.py -h
to use different input/output paths.--wxgf-server ws://xx.xx.xx.xx:xxxx
to use a WXGF decoder server.Screenshots of generated html:
See here for an example html.
EmojiInfo
table don't have corresponding URLs but only a md5 -
they are not downloaded by WeChat until the message needs to be displayed. We don't know how to manually download these emojis.grep 'TODO' wechat -R