All Projects → chg-hou → Enmicromsg.db Password Cracker

chg-hou / Enmicromsg.db Password Cracker

Licence: gpl-3.0
Crack the password of EnMicroMsg.db with brute-force attack.

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Enmicromsg.db Password Cracker

Mmkv
An efficient, small mobile key-value storage framework developed by WeChat. Works on Android, iOS, macOS, Windows, and POSIX.
Stars: ✭ 13,900 (+7215.79%)
Mutual labels:  wechat
Wechatredenvelop
iOS版微信抢红包Tweak
Stars: ✭ 2,167 (+1040.53%)
Mutual labels:  wechat
Vconsole
A lightweight, extendable front-end developer tool for mobile web page.
Stars: ✭ 14,017 (+7277.37%)
Mutual labels:  wechat
Wellchat
WellChat is a Application that is a WeChat-like APP by qml.好吧~原谅我的英语。这个一个使用qml来仿制安卓微信的Qt程序,可以运行在安卓上。
Stars: ✭ 174 (-8.42%)
Mutual labels:  wechat
We Validator
💯 简单灵活的表单验证插件,支持小程序、浏览器以及Nodejs端使用
Stars: ✭ 180 (-5.26%)
Mutual labels:  wechat
Wechatvideocourse
《微信公众号+小程序快速开发》视频教程课件及代码
Stars: ✭ 185 (-2.63%)
Mutual labels:  wechat
Nine grid view
Flutter NineGridView & DragSortView. Similar to Weibo / WeChat nine grid view controls to display pictures. Flutter仿微信/微博九宫格、拖拽排序,微信群组,钉钉群组,QQ讨论组头像。
Stars: ✭ 169 (-11.05%)
Mutual labels:  wechat
Weapp Mark
🔥 豆瓣类影视查询记录小程序,附学习笔记
Stars: ✭ 187 (-1.58%)
Mutual labels:  wechat
Go Workwx
a sensible Work Weixin(企业微信, Wechat Work) SDK for Go
Stars: ✭ 181 (-4.74%)
Mutual labels:  wechat
Wxpy
微信机器人 / 可能是最优雅的微信个人号 API ✨✨
Stars: ✭ 13,057 (+6772.11%)
Mutual labels:  wechat
Weixin Java Cp Demo
基于Spring Boot 和 WxJava 实现的微信企业号/企业微信 后端Demo
Stars: ✭ 175 (-7.89%)
Mutual labels:  wechat
Weixinsdk
微信开发SDK。
Stars: ✭ 177 (-6.84%)
Mutual labels:  wechat
Wxapp Webpack Plugin
📦 微信小程序 webpack 插件
Stars: ✭ 185 (-2.63%)
Mutual labels:  wechat
Wechat Robot
✅ js微信聊天机器人(使用个人账号,非公众号) Wechat chat robot write by js.
Stars: ✭ 173 (-8.95%)
Mutual labels:  wechat
Wechat brain
知乎答题王(头脑王者)全自动答题辅助
Stars: ✭ 187 (-1.58%)
Mutual labels:  wechat
Abp.wechat
Abp 微信 SDK 模块,包含对微信小程序、公众号、企业微信、开放平台、第三方平台等相关接口封装。
Stars: ✭ 168 (-11.58%)
Mutual labels:  wechat
Gowechat
golang WeChat 封装,支持微信公众平台(订阅号,服务号)/微信商家平台/微信开放平台/微信企业号
Stars: ✭ 183 (-3.68%)
Mutual labels:  wechat
Yii2 Easy Wechat
WeChat SDK for yii2 , based on overtrue/wechat.
Stars: ✭ 188 (-1.05%)
Mutual labels:  wechat
Wepy ios top
一款可以切换国家查看不同国家iOS应用排行榜的小程序
Stars: ✭ 187 (-1.58%)
Mutual labels:  wechat
Wechatminiprogram Shopping Mall
微信小程序的个体商店前端(以下面一个开源模板为基础)和Java后台(含mysql数据库文件)
Stars: ✭ 186 (-2.11%)
Mutual labels:  wechat

EnMicroMsg.db password cracker

WARINING: This tool should ONLY be used to crack your own db. DO NOT use it in ANY illegal circumstances.

微信安卓版数据库(EnMicroMsg.db)密码破解工具

(This tool may solve issues listed in https://github.com/ppwwyyxx/wechat-dump/wiki, pysqlcipher.dbapi2.DatabaseError: file is encrypted or is not a database )

With some devices, you may get the error message: "file is encrypted or is not a database", when trying to decrypt EnMicroMsg.db with "md5(imei + uin)[:7]". One possible reason is that WeChat uses other device IDs instead of IMEI to generate a password.

It is lucky for us that the 28-bit password (total 16^7 combinations) is not strong enough to resist brute-force attack.

WeChat uses sqlcipher v2 to encrypt the database. Parts of the security features are listed as follows (from https://www.zetetic.net/sqlcipher/design/):

  1. Each database page is encrypted and decrypted individually. This means we just need to handle the first 1024B, which is the default page size.
  2. The default algorithm is 256-bit AES in CBC mode.
  3. Each page has it’s own initialization vector, which is stored at the last 16B.
  4. Message authentication code (HMAC) is disabled in EnMicroMsg.db (see https://github.com/ppwwyyxx/wechat-dump/blob/master/decrypt-db.py, line 50). So we just ingore HMAC.
  5. Then comes the time consuming part. The first 16 bytes of the file store the salt to derive the key (don't confuse this "key" and the 7 characters "passphrase"). In PBKDF2, 4000 iterations (sqlcipher v2, 64000 iterations for v3. Luckily WeChat uses the former version. 64000 iterations will cost much more time.) are used for key derivation.

So, the fellowing is our strategy: get the first page; obtain IV from the last 16B and salt from the first 16B; iterate over all combinations of the possible passphrases; derivate the corresponding key. Decrypt the db.

We know that the original header of sqlite db is a 16B string: "SQLite format 3\0", which is replaced by the salt in the encrypted case. Following are 2B to describe page size (0x04 0x00), 1B write version (0x01 0x02) and 1B read version (0x01 0x02). We have 4 identical bytes to test whether we get the correct plain text. (2019-04-12) From Wechat 7, Tencent uses new write/read version (0x02), which will break our former detection. Now we will use the following three fixed bytes to test whether we get the correct plain text: 1. maximum embedded payload fraction (0x40) with offset 5; 2. minimum embedded payload fraction (0x20) with offset 6; 3. leaf payload fraction (0x20) with offset 7. (Here we can just ignore collision. If you successfully get the pass but still cannot open the db, just skip the "false alert" and start from the next pass.)

It takes about 5 ms to do a single PBKDF2 with 4000 iterations. So in the worst case, it will take 16^7 * 0.005 /3600/24 = 15.5 days to crack. On a 8-core PC, it reduces to 2 days (sounds reasonable now).

How to use?:

Before cracking, please use extract_key_from_cfg_files.py to get the key if systemInfo.cfg and CompatibleInfo.cfg are available.

There are two versions to choose: a C version and a Python one. The former should be a bit faster (the core relies on openssl. No difference in calculating the 4000 iterations).

C version:

  1. install openssl dev package (tested with openssl 1.0.2g and openssl 1.1.0.g (issue #4) ):
    $ sudo apt-get install libssl-dev
  1. compile password_cracker.c :
    $ gcc password_cracker.c  -l crypto -o password_cracker.o
  1. modify parameters in "crack_enmicromsg_db_(C_version)". process_no: total cores used. Note: If you successful get the pass but still cannot open the db, start from the next pass by change "pass_start".

  2. start:

    $ python2 crack_enmicromsg_db_\(C_version\).py

Python version:

Dependencies:

Demo purpose. Not well written.

Got the pass, and then?

Use the wonderful wechat-dump written by Yuxin Wu to dump the whole db. You need to tweak a few lines in "decrypt-db.py" to use the key. Have fun!

Scripts in tools folder

  • decrypt_db_with_password.py: when you have already known the password, use this script to get an decrypted database which can be viewed/edited by DB Browser for SQLite.

  • encrypt_db_again.py: encrypting the db again. Note: (2018 Feb 04) not tested whether WeChat can open it correctly.

  • extract_key_from_cfg_files.py : this script can extract key from CompatibleInfo.cfg and systemInfo.cfg. Please note that it is written in Python 3. Change the search_path first and then run the script with

    $ python3 extract_key_from_cfg_files.py

Acknowledge

sqlcipher-tools/decrypt.c helps me a lot to understand how sqlcipher works.

wechat-dump/decrypt-db.py provides key parameters of WeChat db.

sqlcipher documentation : its detailed security features.

Fix issue #4: Will not compile against openssl 1.1 : thanks @couling for the openssl 1.1 patch.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].