yashsingh1/xdaforums huggingface dataset:
[Android Apps and Games] Frantch:
decryption code of tri-crypt ?

[MENTION=5771215]TripCode[/MENTION]

For the interested, bellow the java code (based on TripCode decrypt .crypt5) to decrypt .crypt7

key = /data/data/com.whatsapp/files/key (root access)

private static void decrypt(File inputFile, File outputFile, File key) throws Exception {
BufferedInputStream localBufferedInputStream2 = null;
BufferedInputStream localBufferedInputStream1 = null;
try {
localBufferedInputStream1 = new BufferedInputStream(new FileInputStream(key));
localBufferedInputStream2 = new BufferedInputStream(new FileInputStream(inputFile));

byte[] key = new byte[' '];
localBufferedInputStream1.read(key);
byte[] IV = new byte[16];
System.arraycopy(key, 110, IV, 0, 16);
byte[] decryptionKey = new byte[32];
System.arraycopy(key, 126, decryptionKey, 0, 32);
Cipher localCipher = null;
localCipher = Cipher.getInstance("AES/CBC/NoPadding");
CipherInputStream localCipherInputStream;
FileOutputStream localFileOutputStream;
localBufferedInputStream2.read(new byte[67]);
localCipher.init(2, new SecretKeySpec(decryptionKey, "AES"), new IvParameterSpec(IV));
localCipherInputStream = new CipherInputStream(localBufferedInputStream2, localCipher);
localFileOutputStream = new FileOutputStream(outputFile);

byte[] buffer = new byte[8192];
int n;
while ((n = localCipherInputStream.read(buffer)) != -1) {
localFileOutputStream.write(buffer, 0, n);
}

localCipherInputStream.close();
localFileOutputStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
}

}

ps: Also, does the /data/data/com.whatsapp/files/key key change through time? or is it always the same ?

thanks :=)
[Android Apps and Games] TripCode:
On some of my devices it changes every 3 days. On others weekly. On my tablet it doesn't change at all. The way it currently works it's too inconsistent to give you a definitive answer on this. One thing I do know is that the cipher key is not read from the key file, but online. You can test this by taking your device offline and trying to do a backup or restore. It will fail without online connectivity. It's a possibility that they may remove the key file altogether in future as they don't actually need it. We do, which is unfortunate. :eek:
[Android Apps and Games] Frantch:
I see... yes.. I hope they won't make it online only :eek:.... freaking Facebook, couldn't they leave things as they were? :p

ps: last night I put my table (N7 running kitkat wand whatsapp 2.11.234) in flight mode and when whatsapp did the 4am backup this morning i found a

- msgstore.db.crypt7 (created at 4am) and a msgstore.db.crypt (created at 4.15am)
[Android Apps and Games] GaBOr1:
Even though this problem may be too old, I have searched for the solution in the thread and I found nothing. This happens when you provide both wa.db and msgstore.db.

The way to solve it is just to replace chats["id"] with chats["_id"] in whatsapp_xtract.py, as that's the right name for the column in the database.
[Android Apps and Games] TripCode:
I'm assuming that you have Tri-Crypt installed? The Tri-Crypt service will check for a new backup file every 15 minutes. If it finds one then it will re-crypt it to legacy crypt. I.E. WhatsApp created msgstore.db.crypt7 at 04:00. Tri-Crypt created msgstore.db.crypt at 04:15 (15 minutes later).

If the automated backup at 04:00 works in flight-mode then that's positive news as it means they're reading the key file. Hopefully they won't change that. I know you need to be online to do a manual backup, but did not test the automated one. Thanks for the info. :)
[Android Apps and Games] Frantch:
Yes i had tri-crypt thats why.

"know you need to be online to do a manual backup, but did not test the automated one"

I tried just now, put my N7 in flight mode, tap the manual backup. and the msgstore.de.crypt7 has been created (didn't try to decrypt but I guess it will work) ? Interesting
[Android Apps and Games] TripCode:
That is interesting. That's behaviour that wasn't observed in previous betas. Testing this further, I deleted my main database so that WhatsApp would allow me to restore from a backup. Oddly, I still have to be online to restore, but not to backup (unless I delete the key file). The good news is that this latest beta actually uses the key file so hopefully they will be keeping it. Earlier betas builds did not need it at all.
[Android Apps and Games] Frantch:
Well yes that's a good news :). I will have some free time tho weekend. I will try to go through Whatsapp code and play around with the key to understand how it get generate. :o
[Android Apps and Games] droopyar:
Yes. I agree that for non-rooted seems ok.

Other alternative which i am working is using smaili injection on whatsapp.apk to create a log file of the key to sdcard.

I have decompiled it using JEB and working on it. This is probably the partial solution.

Thats why, to be secure, downlaod whatsapp from google play directly :)
[Android Apps and Games] TripCode:
Already done this. It works in theory and if you take a backup and re-install the original WhatsApp after you have gotten your cipher then WhatsApp will give you the same cipher (most of the time). Unfortunately it rolls so a few days later you're given a completely different cipher. This means that you would have to leave the modified WhatsApp installed permanently to keep getting the latest key. You only have to change a few lines of smali to get WhatsApp to revert back to crypt or crypt5 which would be far less hassle (for the user). If they go stable with crypt7 then I will be releasing a patching app (WhatPatch) that patches the latest apk to revert back to an older crypt method or one that stores the curent key in the database file and increase its header size to accomodate it. Other patches will include the ability to disable latest version notification and the "WhatsApp has been illegally modified" warning that will randomly appear on modified apk's due to the signature verification checks. I decided a patching app would be better than releasing a modified apk because a) patching apps are not illegal, b) it gives the user a choice, c) the user doesn't have to worry about any malicious code injections and d) it will work with future builds, unless of course the code base changes drastically.

The best solution would be to crack their hashing methods, unfortunately I do not see this happening anytime soon. :(

P.S. My modified version of WhatsApp replaces the crypt7 method with my own, which is called crypt42. It's the same as crypt7, but the decryption key is stored where the challenge key should be. The database is also compressed before encryption commences so the backup files take upto 70%-80% less space on external storage compared to WhatsApp which does not compress. It's likely that if I do go ahead with WhatPatch then I will include the option to use my crypt42 method.
[Android Apps and Games] ILoveAndroid77:
Resolved. Fixed my own app :)
[Android Apps and Games] jics91:
Hello everyone, it's been a long time since I used Whatsapp Xtract to read some databases. Today I'm struggling to open the mstore... but I get this issue:

C:\Users\Joel_2\Downloads>python "C:\Users\Joel_2\Downloads\wx\wx\whatsapp_xtrac

t.py" C:\Users\Joel_2\Downloads\msgstore-2014-04-29.1.db.crypt5

Python Version 2.x

Android mode!

trying to repair android database...

trying to decrypt android database...

decrypted database written to C:\Users\Joel_2\Downloads\msgstore-2014-04-29.15.p

lain.db

trying to repair decrypted android database...

Could not open database file. Guess it's not a valid Android or Iphone database

file.

Presione una tecla para continuar (Press a button to continue) . . .

I use the ''drag and drop'' method. Any fix for that?
[Android Apps and Games] jogolos:
invalid database

First I have to say sorry for my bad english. But I hope someone understand me an can help me.

My problem is, what I have chance my phone. Now I want to reinstall whatsapp with my old database.

During the Installation whatsapp is recognise the old database, but than there is no chat in.

So I have install whatsapp_xtract an ActivePython-2.7.6.9-win32-x86.

Python is still running. But the old database of Whatsapp is not valid.

So there is a error: could not open the database file.Gues it´s not a valid Androi or Iphone database.

Can samebody tell me what is wrong?

Thanks.
[Android Apps and Games] TripCode:
Just make sure that you link the same primary gmail on your new phone as you do on your old one. If you do this then you will be able to import your messages when you install WhatsApp (i.e. message backup found). If you can't do this then you will need to recrypt using your new gmail as the target (crypt5) or new cipher key (crypt6 / crypt7). You can recrypt to/from crypt, crypt5, crypt6 and crypt7 using my app WhatCrypt: http://xdaforums.com/showthread.php?t=2689911
[Android Apps and Games] JoHnnY-Btm:
hi there peeps..

so i had i slight problem with my smartphone, and i had to reset my hole smartphone that had in this case also erased my last recent whatsapp backup because i could not acces my phone documents at that time (and also unfortunate i did not back it up at another place like my pc)

but fortunate i have some older backups that i like to merge togehter to 1 backup and restore it in the latest whatsapp version.

but here is the problem, 2 backups are from an htc desire Z type phone and 1 backup is from an HTC One x+ phone.

The 2 HTC Desire Z backups are slightly newer and maybe different but i like to see if something is missing or the same etc. and i in this case think from a newer whatsapp version then used on the HTC One X= at that time. and the whatsapp backup from the HTC One x+ phone is slightly older because i had a display problem in the past so that's why the backups from the HTC Desire Z backups are newer.. my latest backup from my HTC One X+ (after i got it back repaired) in this case the phone i'm using is missing (also because i did not back it up whilest using it al this time) so that's what i lost due to my own fault..

but yes i still like to merge all of the existing backups to just 1 backup so that i still have something instead of nothing. and then i can merge it with my new made backup from a few days back with the latest whatsapp version :) can someone please tell me how to do this? and quite important to say, my phone is NOT rooted and don't want to root my phone what so ever bcz of several things.

i have attached some images of the database backup files to.

hope one of you guys can help me :) thanks up front!
[Android Apps and Games] TripCode:
It would not be worth merging the data in your backup files unless you deleted messages between the daily backup cycle. If you haven't done this (which I doubt you have considering the file sizes) then the latest backup file will contain all the messages contained in all the previous backups. WhatsApp does NOT do a daily incremental backup. It does a FULL backup every day (all messages).
[Android Apps and Games] JoHnnY-Btm:
well i don't delete anything because i like to read back stuff when needed :) ik keep everything backupped well unfortionate not the last one due to my own dumb fault were i had to reset my phone and my backup was not accesable to backup to another place.

but yeah this is the thing, the reason i like to see what's in the backups and like to merge them, is because the last HTC One X+ backup wasn't on my HTC Desire Z at that time so i made a hole new chat history at that time and after i got my HTC One X+ back i did not put the backup from the HTC Desire Z (while using it for 2 months) back on my HTC One X+... so i got seperate backups with different time stamps that i like to see in to and merge, but i don't know if that is possible with the way whatsapp is right now, because i also tried to include an older whatsapp backup and instaal the latest whatsapp but it doesn't pick up and give me the option to restore chat history in whatsapp... maybe because of the new rulings in whatsapp?

so therefor it would be great to get some help with this :)
[Android Apps and Games] McGiver93:
Wouldn't be possible to create a script that will try to decrypt the msgstore.db.crypt7 from 0000 to 9999 ? Im sure there could be a possible way for non rooted phone to decrypt messages.
[Android Apps and Games] SanDiego619:
Hello everyone. Does the new decryption only work for saved chat histories that have been saved on a SD card, or can you also decrypt messages from "sniffing" such as by using wireshark? Has anyone tried it? Please and thank you.
[Android Apps and Games] huricane_brazil:
Im sorry guys, but i have Iphone and right now its impossible to use whattsapp xtract and decrypt the "ChatStorage.sqlite".

There is a way to see the messages using iphone?
[Android Apps and Games] Aashreya:
error

getting the following error:

Import Error: No module named Crypto.Cipher

Please help
[Android Apps and Games] huricane_brazil:
Someone to help me?
[Android Apps and Games] TripCode:
Crypt7 databases are encrypted with a 32bit cipher key which is generated online by WhatsApp. These keys appear to be generated using SHA-256 and an udisclosed hashing method, which is most certainly salted at least once. Without knowing their hasing method (WhatsApp aren't going to tell us), cracking it woud be on a par with finding a collision in the actual algorithm itself. This is a practical impossibility. I won't break down the maths, but the computations involved would roughly be the same as sitting down and counting every single atom in the known universe.

I have no idea what you meant by 0000 to 9999? Crypt7 (without a disclosed hashing method) would take approximately 500+ million years to crack using the combined resources of every computer on the planet and that's just to decrypt one single database. I don't think any of us can wait that long! :eek:
[Android Apps and Games] ageofstupid:
hello peeps, i've got a question: is there a way to hack the whatsapp in order to get an update of conversations every day? like receiving the db crypt to email or something
[Android Apps and Games] azizulrejab:
Whatsapp Xtract: Backup Messages Extractor

im fail to do this step. im trying so many time. im having crypt7 database.

I need some one help and its urgent.

willing to pay via pay pal.

can PM me or ctc me at azizul_rejab@yahoo.com

Thanks
[Android Apps and Games] SpudNL:
Does this still work with whatsapp version 2.11.238, it does not seem to work for me:

I get this error while trying to xtract:

Python Version 2.x
Android mode!

trying to repair android database...
trying to decrypt android database...
Error during decrypting: Input strings must be a multiple of 16 in length
Could not decrypt database file. Guess it's not a valid Android/Iphone database
file or Whatsapp changed the encryption.
Press any key to continue . . .

Thnx in advance!
[Android Apps and Games] xCoNDex:
any program to decrypt crypt7 files on PC?

thanks
[Android Apps and Games] jfarreola:
I'm attaching the files you need. I'ts bascally WhatsApp Viewer 1.5 (found here) along with WhatsApp Xtract v2.1. You can find your key file in /data/data/com.whatsapp/files/key
[Android Apps and Games] rohitshakti:
I am getting the following error which is shown in the enclosed jpg image.

[url=http://postimg.org/image/70x3r5ext/][/URL]
[Android Apps and Games] rohitshakti:
And if we are able to see these messages on pc can we take a print out of these messages via printer.
[Android Apps and Games] simoware:
I confirm that the key is generated online. I did a small test by copying my whatsapp folder from my first phone (N7200 official rom unrooted) to a second phone (I9000 cyanogenmod rooted). I uninstalled the app from the first phone and installed it in the second. both phones are registered with the same gmail address. I was able to recoved all my conversations on the second, which prouves the key was downloaded after install.

The strange thing is, I used the phone number from my N7200 in the I9000 registration and I did not receive the confirmation code as I expected, the I9000 simply showed my conversations and did not ask for a code.

Did they change the registration process? anyone have experienced the same ?
[Android Apps and Games] jfarreola:
The process you need to follow is:

1. Download and unzip the attached .zip in my previous post.

2. Use WhatsApp Viewer to decrypt the .crypt5 and/or .crypt7 file.

3. Use the decrypted .db file in WhatsApp Xtract drag'n'drop .bat.

4. Done.

Can you confirm you did as above? Because what I see in your screenshot is that you tried to decrypt directly from WhatsApp Xtract.
[Android Apps and Games] spilot:
I'm not the same guy as the above but your steps made it work for me. Thanks.
[Android Apps and Games] ChaN21:
help is needed

what's up guys. im new and a noob when it comes to things like this. im not sure whether im posting at the right place or not but i hope any of you would help me :) here's my prob

i have been trying to play around with whatsapp recently. trying to back up my chat history. may i know whats the difference between crypt5 and crypt 7?

also, when i back up my chat, i realised there were several versions of crypt7 with dates. there was once i back up my messages (copied the whatsapp file to my pc) manually and only crypt7 was copied onto my pc. crypt5 and the rest went missing. i tried to copy the whole thing once again and this time the whole database file is missing. why so?
[Android Apps and Games] jfarreola:
The difference is the encryption type, that's the only thing I know :p

Regarding the files, crypt7 replaces crypt5, and for the missing ones, I'm sure WhatsApp just keeps the backup of 4 days separated (the files with the dates) and a main db that's supposed to have all your chats. Not sure why your db is missing, maybe you cutted it instead of copying it??
[Android Apps and Games] ichigo786:
Cannot restore backup history :(

Hi, i recently updated to the latest WhatsApp version and then my WhatsApp started to

crash. I tried to restore messages via the database files (crypt5 files) but it

kept crashing, then i cleared data / cache from the App and when it would

try to restore messages after about 10 seconds i would get a

message saying

Alert

Sorry, we were unable to restore any of your message history backups.

I have tried to restore it on numerous times on my S2, i even bought a new phone Moto G for £100 but the same issue happens on the new phone too. All my, last 6, database crypt5 files when i try to restore them give the same error.

Please someone help me, what do i do. i have had my whatsapp for more than 3 years now and ive got tonnes of messages from my parents and family, some who have sadly passed on.

Can i recover my messages? and have them brought back to my phone.

any help greatly appreciated.
[Android Apps and Games] joluke:
EVERYONE:

USE THIS APP:

Whatsapp Crypt-DB Converter

IT WILL CONVERT THE DATABASES CRYPT7 AND CRYPT5 TO CRYPT and you can use this tool! :D

Worked for me BUT YOU NEED ROOT
[Android Apps and Games] droopyar:
recover delete messages

Hi,

Someone knows the trick to recover delete messages from database?

I read that it is possible on sqlite databases.

If someone has a working source code for this in java for android or references to implement it please PM urgent.

regards.
[Android Apps and Games] sigaieu:
Key file from another phone

Good morning! I have access to the database files from a phone I don´t have physical access. That phone is not rooted, so I can´t access the Key File. Can anyone tell me what a key file is consisted of? Can I use my key file or any key file in order to decrypt the crypt7 database? If so, can anyone provide me one generic key file? Thank you!
[Android Apps and Games] TripCode:
The above app will only work with relatively small database files. This is because the recryption routine is processed in the GUI thread instead of in the background (which is where this routine belongs). It also only works with Android 4.0+ which means a lot of users on older devices will not be able to use it at all.

There is an excellent guide here: How to convert WhatsApp CRYPT files for anyone who wishes to convert the latest WhatsApp Crypt files with more reliable and stable methods.

Sorry. You will need the key file from the device that created the crypt7 file in order to decrypt it. You will need both physical access to the device and root permissions in order to succeed. Without this, what you're attempting to do is impossible. There are no generic keys. Each key is personal to each device and even then, they're updated periodically, which means even if you do eventually get the key, it may not work if the key has been updated (rolled). Crypt7 is secure enough to take millions of years to decrypt if you do not have the correct cipher key.

TLDR; No key = no decrypt!
[Android Apps and Games] sigaieu:
Figured

Thank you! I imagined that. Now I am going to try and convert crypt7 to crypt5 and then try to decrypt it.

Sorry. You will need the key file from the device that created the crypt7 file in order to decrypt it. You will need both physical access to the device and root permissions in order to succeed. Without this, what you're attempting to do is impossible. There are no generic keys. Each key is personal to each device and even then, they're updated periodically, which means even if you do eventually get the key, it may not work if the key has been updated (rolled). Crypt7 is secure enough to take millions of years to decrypt if you do not have the correct cipher key.

TLDR; No key = no decrypt![/QUOTE]
[Android Apps and Games] joluke:
Thanks for the tip

Sent from my Note 3 (SM-N9005) using Civz ROM [v2.8] with Kernel SkyHigh TW Kernel [1.4]
[Android Apps and Games] TripCode:
I retract the above statement since I have now devised a method to extract a WhatsApp Crypt Key file on a non-rooted device.

XDA Thread: [Tool] WhatsApp Key/DB Extractor | CRYPT7 | NON-ROOT

My new statement on this is: You will need physical access to the device and the device needs to be on Android 4.0 or higher. If the Android version is lower than 4.0 then you will still need root permissions.
[Android Apps and Games] mhammadakkad:
crypt7 to DB help

hello

now whatsapp Xtract cant decrypt whatsapp databases.crypt7 right? "and i'm not rooted"

so we need to use WhatsAppKeyExtract and then we have 3 files (msgstore.db.plain.db || wa.db || whatsapp.key )

the problem that i need to decrypt and read specific msgstore that stored in SD card not the one that WhatsAppKeyExtract give me?

how to do it ?? can i use the (wa.db || whatsapp.key) files and some one give me a program to convert msgstore to DB ?

please HELP ME :(
[Android Apps and Games] TripCode:
If you have used WhatsAppKeyExtract and have your whatsapp.key file and crypt7 database backups then you're pretty much there already.

You could copy these files to any Android device and use WhatCrypt Android App to recrypt crypt7 to crypt or decrypt to db. Then you could use Whatsapp Xtract to convert your messages on your PC to html.

or

You could upload your key file here and use the WhatCrypt online exporter here to generate "WhatsApp-Style" html. You would just need to upload your crypt7 file and wa.db and click on "Process/Download Zip". This will turn all your messages into something that looks like this.
[Android Apps and Games] mhammadakkad:
very cool thank you but where to put the key in the other android ?? cuz WhatCrypt Android App telling me error no key or some thing like that

sorry for bad English
[Android Apps and Games] TripCode:
Copy your whatsapp.key file and the crypt7 file that you want to decrypt to your sd card. Then open up the WhatCrypt App. Then go into WhatCrypt Settings and change "Backup Database Path" to the path of your crypt7 file and "Key File Path (Crypt 6/7)" to the path of your whatsapp.key. Return to the main menu and tap "Decrypt WhatsApp Database" to decrypt your crypt7 file to db format or go into "Recrypt WhatsApp Database" if you want to recrypt it to crypt, crypt5, crypt6 or crypt7.