Once I wanted to keep all the Whatsapp massages in separate place and clear the all the massages from Whatsapp. I wanted that because, as it growing my chats it takes more space. Whatsapp backups your massages in both local and google drive(if you have allowed). It keeps several backups for recent days.When massages count grows backup also takes more space. Also when I open some chats they might lag at opening. So I wanted to delete them but If I need them later their must be way to retrieve them.
Let’s dig more into internal structure of Whatsapp.
Actually I’m talking about android, but procedure may be same for other OS. Whatsapp keep data locally in two separate locations. One is app’s private folder which user don’t have access without root access. Other is in internal SD card(user can read/write). Whatsapp encrypt your chats into crypt12database file with AES-256 encryption(crypt12 is extension to encrypt sqlite db files) and store in your phone. You can see several files that have extension of .crypt12 inside Whatsapp/database folder. All the crypt12 files are encrypted with one key. Even if you switch into new phone with same account key won’t change. So where is the key? The key is created when you first created whatsapp account and it stores in apps private folder /data/data/com.whatsapp/files/key. Getting that key is almost impossible without root access. I have seen several websites saying They can decrypt those crypt12 file and then asking for human verification, they are totally fake. Actually you cannot view your friends/girlfriend/boyfriend massages without that key. 😋 To get key you need the root access.
So whats next if you have the key. Where do I enter the key. Even if you have the key you need some kind of script to do that. Let’s go to the task.
I will list some prerequisite before start.
- msgstore.db.crypt12 or similar file from Whatsapp/Databases
- key file obtained from /data/data/com.whatsapp/files/key (Need root access)
- A computer that installed java (JRE) 8+ (Add java to your Path variable if not added to run java command from command line)
- Download jar file from here
- Sqlite browser
If you have all above things, It is one line of command to boom.
Keep all the files that I have mentioned above in one directory in your machine. Then open terminal or command line execute follows assuming jar file is decrypt12.jar, encrypted database is msgstore.db.crypt12 and output file name that is decrypted is msgstore.db.
Then execute following in your command line
java -jar decrypt12.jar key msgstore.db.crypt12 msgstore.db
Then you have a file called msgstore.db and open it with sqlite browser. Now you can see all the massages,group,contacts and many attributes which are saved in your Whatsapp account.
And if you are interested in source code here is the link