GithubHelp home page GithubHelp logo

tlntin / wechat-dump Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ppwwyyxx/wechat-dump

0.0 1.0 0.0 3.89 MB

Cracking encrypted wechat message history from android

License: GNU General Public License v3.0

Shell 5.32% Python 90.24% HTML 3.52% Smarty 0.11% JavaScript 0.82%

wechat-dump's Introduction

Dump WeChat Messages from Android

导出安卓微信消息记录

WeChat, as the most popular mobile IM app in China, doesn't provide any options to export structured message history. This tool can decrypt and parse WeChat messages on a rooted android phone, and dump messages into self-contained html files including voice messages, images, emojis, videos, etc.

If the tool works for you, please take a moment to add your phone/OS to the wiki.

How to use:

Dependencies:

  • 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
  • sqlcipher >= 4.1
  • sox (command line tools)
  • Silk audio decoder (included; build it with ./third-party/compile_silk.sh)
  • Other python dependencies: pip install -r requirements.txt.

Get Necessary Data:

  1. Pull database file and avatar index:
  • Automatic: ./android-interact.sh db. It may use an incorrect userid.
  • Manual:
    • Figure out your ${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.
    • Get /data/data/com.tencent.mm/MicroMsg/${userid}/{EnMicroMsg.db,sfs/avatar.index} from the device.
  1. Decrypt database file:
  • Automatic: ./decrypt-db.py decrypt --input EnMicroMsg.db
  • Manual:
    • Get WeChat uin (an integer), possible ways are:

      • ./decrypt-db.py uin, which looks for uin in /data/data/com.tencent.mm/shared_prefs/
      • Login to web wechat, get wxuin=1234567 from document.cookie
    • Get your device id (a positive integer), possible ways are:

      • ./decrypt-db.py imei implements some ways to find device id.
      • Call *#06# on your phone
      • Find IMEI in system settings
    • Decrypt 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 decryption doesn't work, you can also try the password cracker to brute-force the password.

  1. Copy the WeChat user resource directory /mnt/sdcard/tencent/MicroMsg/${userid}/{avatar,emoji,image2,sfs,video,voice2} from the phone to the resource directory:

    • ./android-interact.sh res
    • You might need to change RES_DIR in the script if the default is incorrect on your phone.
    • This can take a while. One way that might be slightly faster:
    • If there's enough free space on your phone, you can log in and archive all required files via tar with or without compression, and use adb pull to copy the archive. Note that busybox tar is recommended as the Android system's tar may choke on long paths.
    • What is needed in the end is a resource directory with the following subdir: avatar,emoji,image2,sfs,video,voice2.
  2. (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
    

Run:

  • 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, avatar.index, and resource):

    ./dump-html.py "<contact_display_name>"
    

    The output file is output.html.

    Check ./dump-html.py -h to use different paths.

Examples:

Screenshots of generated html:

byvoid

See here for an example html.

TODO List

  • Fix rare unhandled message types: > 10000 and < 0
  • Better user experiences... see grep 'TODO' wechat -R

Donate!

[paypal]

wechat-dump's People

Contributors

ppwwyyxx avatar trammel avatar swordyork avatar chaserhkj avatar vuryleo avatar weakish avatar jia-kai avatar futurewrg avatar mygod0rz avatar ymy513 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.