Created
June 30, 2017 21:24
-
-
Save nlitsme/b079f351eb1bf9c3d356ce988bb6afdc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Example how to decrypt whatsapp msgstore backups with extension .crypt12. | |
Author: Willem Hengeveld <[email protected]> | |
""" | |
from Crypto.Cipher import AES | |
import zlib | |
import sys | |
datafile = keyfile = None | |
if len(sys.argv)==1: | |
print("Usage: decrypt12.py <keyfile> <msgstore.db.crypt12>") | |
print(" the key file is commonly found in /data/data/com.whatsapp/files/key") | |
print(" the crypt file is commonly found in the directory: /data/media/0/WhatsApp/Databases/") | |
exit(1) | |
for arg in sys.argv[1:]: | |
if arg.find('crypt12')>0: | |
datafile = arg | |
elif arg.find('key')>0: | |
keyfile = arg | |
else: | |
print("unknown arg", arg) | |
with open(keyfile, "rb") as fh: | |
keydata = fh.read() | |
key = keydata[126:] | |
with open(datafile, "rb") as fh: | |
filedata = fh.read() | |
iv = filedata[51:67] | |
aes = AES.new(key, mode=AES.MODE_GCM, nonce=iv) | |
with open("msg-decrypted.db", "wb") as fh: | |
fh.write(zlib.decompress(aes.decrypt(filedata[67:-20]))) | |
Hi! Can anyone help me. I have the crypt 12 files on my pc in a word file. How can i ever read these??
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, just used this program to decrypt my WhatsApp backup. It still works great. Thank you!
Two issues I ran in to and how to solve them:
unknown arg key
and error when using a keyfile that was simply namedkey
. Solved by changingarg.find('key')>0
toarg.find('key')>=0
.no attribute 'MODE_GCM'
when using the default PyCrypto library (version 2.6.1 on my system). Solved by using apipenv
environment with the PyCryptodome library.