2013-03-15

Extracting WhatsApp message logs from a WhatsApp database

Just a small update.

After returning from my long trip abroad, having used WhatsApp profusely during the time there, I had lots of conversations I wanted to export to a message log and store for future, older days. ("Wow, I can't believe she wrote me THAT! ;)")

These chat logs included lots of media (images, audio clips and videos), which I also obviously wanted to keep. I used an Android phone, so I looked for an existing solution in the Google Play store. I found an applicaton called WhatsApp to Text which is quite nice, but fails to offer the option of exporting the media. I found no other solution in the Play store.

I then looked on-line for another solution. The team of D. Cortjens, A. Spruyt and W.F.C. Wieringa from the University of Amsterdam have published the results of a research project titled WhatsApp Database Encryption. Based on the results of this project, a Python script called WhatsApp Xtract was coded, to allow the generate of WhatsApp messages logs - this time with all media intact. Great.

Only thing was, some features weren't working correctly. Media wasn't automatically detected in some cases, the generated log files were humungous, the names of contacts were sometimes not displayed, there was no way to see all media files (like in the actual WhatsApp software), it supposedly was able to repair corrupt databases (and salvage what it can from them) but didn't really, and generally it didn't satisfy my requirements.

So, I updated it a bit:
v2.5 (updated by Alon Diamant - Mar 14, 2013)
- Improved encrypted Android database detection and decryption code
- Can now repair malformed Android databases (depends on availability of sqlite3 executable)

v2.4 (updated by Alon Diamant - Mar 06, 2013)
- Generates media index file - but crappily, we should set this up better..

v2.3 (updated by Alon Diamant - Mar 05, 2013)
- now generates separate file for each contact
- fixed file search to search for image files in days prior to date given (to fix a bug where because of timezone differences the image file exists but is not found)
- fixed message counts for contacts
- does not list contacts with 0 messages
- now writes version number in generated files
- (Android Version) displays WhatsApp name (server based) if no display name is found for a contact
- (Android Version) Supports Python 2.6
It still is medicore, and I am not happy with the way it works nor the way it is coded, but it'll serve for now. I do feel like coding an Android application to do this properly on the phone, with well formatted output files that include all media. We'll see.

For now, enjoy. You can also find updated in the project repository.

9 comments:

  1. I just lost my database. i mean the file got the error ' malformed image' how do i repair that ?

    ReplyDelete
  2. i was successful in repairing the file. now is there anyway i can make the repaired file a .crypt database file again so that i can use it as a backup to restore my chats?

    ReplyDelete
  3. I made a copuple enhancements myself for personal use, sadly I could only use the iphone database, so android is still the same: https://code.google.com/p/hotoloti/issues/detail?id=7

    ReplyDelete
  4. I was using the extractor, but don't see any new messages after 1st Dec, 2013. Pretty stumped. Will try yours now.

    ReplyDelete
  5. Does anybody know where to get the log file? I have not rooted my android device yet, and I don't have an SD card.

    ReplyDelete
    Replies
    1. Download Backuptrans Android WhatsApp Transfer to directly save chats from android to computer.

      Delete
  6. Ek Room me 5 dost rehte the.1. Pagal2. Fudu3. Dimag4. Koi Nahi5. KisiEk Din Koi Nahi ne Kisi Ko Mar Diya.us waqt Dimag Bathroom me thaPagal Ne Police Ko call kiya.Hello Police Koi Nahi ne Kisi Ka Qatal Kar diya Hai.Police: Oye Kiya Tum Pagal Ho?Pagal: G Mei Pagal Hu.Police: Tere Paas Dimag Nahi Hai?Pagl: G Dimag toh Bathroom Mei Hai…Police: O FuduPagl: Nahi G Mei toh Pagal Hu. Fudu to msg padh raha hai…Hahahaha2014 ki top class beizzatiHanso mat mere saath bhi aisa hua hai jaldi forward karoWarna ye message aam ho jayega……;By Himanshu Sharma

    ReplyDelete
  7. Ek Room me 5 dost rehte the.1. Pagal2. Fudu3. Dimag4. Koi Nahi5. KisiEk Din Koi Nahi ne Kisi Ko Mar Diya.us waqt Dimag Bathroom me thaPagal Ne Police Ko call kiya.Hello Police Koi Nahi ne Kisi Ka Qatal Kar diya Hai.Police: Oye Kiya Tum Pagal Ho?Pagal: G Mei Pagal Hu.Police: Tere Paas Dimag Nahi Hai?Pagl: G Dimag toh Bathroom Mei Hai…Police: O FuduPagl: Nahi G Mei toh Pagal Hu. Fudu to msg padh raha hai…Hahahaha2014 ki top class beizzatiHanso mat mere saath bhi aisa hua hai jaldi forward karoWarna ye message aam ho jayega……;By Himanshu Sharma

    ReplyDelete