Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,807,045 Members 38,362 Now Online
XDA Developers Android and Mobile Development Forum

[TOOL] Whatsapp Xtract: Backup Messages Extractor / Database Analyzer / Chat-Backup

Tip us?
 
ztedd
Old
(Last edited by ztedd; 5th January 2013 at 04:02 AM.) Reason: new version 2.2 on November 17th, 2012
#1  
Senior Member - OP
Thanks Meter 239
Posts: 204
Join Date: Feb 2011
Smile [TOOL] Whatsapp Xtract: Backup Messages Extractor / Database Analyzer / Chat-Backup

Have you ever wanted to
- have a useful backup of your whatsapp chats?
- be able to read your whatsapp chats again using a backup file?
- delete the grown-too-big message history of whatsapp without losing the possibility to read the old conversations?
- read older messages without the need of endlessly pressing the annoying "load older messages" button?
- be able to search old messages?
- ...?

Here is a little Tool to display whatsapp chats on your computer, using the database files from your android installation of whatsapp.

It's called WhatsApp Xtract and was created by Fabio Sangiacomo and me.

https://code.google.com/p/hotoloti/downloads/list
(careful, the downloads on google code are outdated! Please use the download links provided here)

Preview of the result:


So here is WhatsApp Xtract v2.2
Released on November 17th, 2012
Last Update on November 17th, 2012 (v2.2)

Tested with Whatsapp (Android) 2.8.5732
Tested with Whatsapp (iPhone) 2.5.1

CHANGELOG:

v2.2 (updated by Martina Weidner - Nov 17, 2012)
- now supports new emoji smileys
- (Android Version) hotfix for TypeError in b64encode
- (Android Version) decoded file won't be deleted even if it can't be opened

v2.1 (updated by Fabio Sangiacomo and Martina Weidner - May 7th, 2012)
- improved install pyCrypto.bat
- added easy drag and drop possibility with whatsapp_xtract_drag'n'drop_database(s)_here.bat
- (Android Version) added support to fix corrupted android whatsapp database (needs sqlite3, for windows sqlite3.exe is contained in the archive)
- (Android Version) removed wrong extraction of owner in android version
- (Iphone Version) information from Z_METADATA table will be printed to shell
- (Iphone Version) fixed bug in support of older Iphone whatsapp databases

V2.0 (updated by Fabio Sangiacomo and Martina Weidner - Apr 28, 2012)
- supports WhatsApp DBs coming from both Android and iPhone platforms
- (Android Version) wa.db is optional
- (Android Version) now also crypted msgstore.db.crypt from the SD card can be imported
- chat list is sorted by the last sent message
- fixed some bugs (e.g. that the script didn't work with python 3)

How to use:
(instrucciones en espaņol / deutsche Anleitung)
  1. You need to copy the whatsapp database.

    On Android, either get this file:

    /sdcard/WhatsApp/Databases/msgstore.db.crypt
    (crypted database on SD card, can be created by starting backup from whatsapp advanced settings: settings - more - Backup Chats)

    or these files:
    /data/data/com.whatsapp/databases/msgstore.db and wa.db
    (for this you need root access. detailed instructions in the bottom of this file. the advantage is that the corresponding contact names of phone numbers will be displayed.)

    On IPhone, get this file:

    net.whatsapp.WhatsApp/Documents/ChatStorage.sqlite
    (You can use an Iphone Backup Tool to get the file, e.g. I-Twin or Iphone Backup Extractor. Make sure to create an unencrypted backup with Itunes, as these tools can't handle encrypted backups. Another possibility are forensic tools like UFED Physical Analyzer.)

  2. Extract this archive (Whatsapp_Xtract....zip) to a certain folder on your computer, e.g. C:\WhatsApp.

  3. Copy the database(s) to e.g. C:\WhatsApp (on Android, you simply copy the whole folder WhatsApp on SD card to your computer e.g. to C:\WhatsApp and then copy the database file from C:\WhatsApp\Databases to C:\WhatsApp)

  4. You need Python and (for Android msgstore.db.crypt decryption) the PyCrypto library

    The easiest way is to install ActivePython
    !! on Windows choose 32bit/x86 version even if you have 64bit windows (if not you will get an "requires Business Edition subscription" error!):
    http://www.activestate.com/activepython/downloads
    It's available for Windows, Linux and Mac. However in my HowTo, I focus on Windows.

    and then run !install pyCrypto.bat (contained in this archive. The best is to rightclick on it and choose "run as administrator".)

    If you have troubles installing pyCrypto this way, then please try to install it using an installation package from this site (Thanks, andcha!): http://www.voidspace.org.uk/python/m...shtml#pycrypto

  5. Now run whatsapp_xtract_android.bat or whatsapp_xtract_android_crypted.bat or whatsapp_xtract_iphone.bat

    OR simply drag and drop the database file(s) to whatsapp_xtract_drag'n'drop_database(s)_here.bat

    OR whatsapp_xtract_console.bat and then manually specify the input file with one of these commands:

    COMMAND LINE OPTIONS:

    Quote:
    For Android DB:
    python whatsapp_xtract.py msgstore.db -w wa.db
    OR (if wa.db is unavailable)
    python whatsapp_xtract.py msgstore.db
    OR (for crypted db)
    python whatsapp_xtract.py msgstore.db.crypt

    For iPhone DB: (-w option is ignored)
    python whatsapp_xtract.py ChatStorage.sqlite
    Once finished, your browser will open and show the chats.
    The resulting file size of the .html file will be slightly bigger than the size of the .db database.

Attachment:

Whatsapp_Xtract_V2.2_2012-11-17.zip (~ 1,8 MB)
contains:
!install pyCrypto.bat
!README.txt
bplist.py
convert_smileys_python_2.py
SetEnv.exe
sqlite3.exe
whatsapp_xtract.py
whatsapp_xtract_android.bat
whatsapp_xtract_android_crypted.bat
whatsapp_xtract_iphone.bat
whatsapp_xtract_console.bat
whatsapp_xtract_drag'n'drop_database(s)_here.bat
folder: data
samples of needed input files and Media folder


also available here:

http://freakshare.com/files/iykgyxrn...11-17.zip.html

IF SOMETHING DOESN'T WORK:

1. First check if you already have the newest download (check full name of the .zip file: is it the same as in mentioned in this thread?). Maybe your error already has been fixed.
2. Read the post Some additional information and read the last pages of this thread to see if your problem is already being discussed.
Use the Search inside this thread function! (e.g. the "requires Business Edition subscription" error was already answered a "100" times!)
3. If not or if it doesn't help, post your error with a detailed description (and error message) in the thread.
Attached Thumbnails
Click image for larger version

Name:	Whatsapp_Xtract_v2.0.jpg
Views:	1439872
Size:	36.5 KB
ID:	1028161  
Attached Files
File Type: zip Whatsapp_Xtract_V2.2_2012-11-17.zip - [Click for QR Code] (1.79 MB, 169558 views)
The Following 144 Users Say Thank You to ztedd For This Useful Post: [ Click to Expand ]
 
ztedd
Old
(Last edited by ztedd; 9th February 2013 at 05:39 PM.) Reason: Whatsapp_Xtract_V2.2_2012-11-17.zip / support for newer emoji smileys included
#2  
Senior Member - OP
Thanks Meter 239
Posts: 204
Join Date: Feb 2011
Default Changelog, Recent Bugfixes, Feature Requests

CHANGELOG:

v2.2 (updated by Martina Weidner - Nov 17, 2012)
- now supports new emoji smileys
- (Android Version) hotfix for TypeError in b64encode
- (Android Version) decoded file won't be deleted even if it can't be opened

v2.1-bugsfixed-4 (2012-05-16)
- fixed .bat files again to support script execution from each external directory
- fixed .bat files if error "python" not found occurs (if you get that error, run !install pyCrypto.bat first; rightclick on it and choose "run as administrator")
- updated compatibility for newer android whatsapp versions to show media files with thumbnails correctly

v2.1 (updated by Fabio Sangiacomo and Martina Weidner - May 7th, 2012)
- improved install pyCrypto.bat
- added easy drag and drop possibility with whatsapp_xtract_drag'n'drop_database(s)_here.bat
- (Android Version) added support to fix corrupted android whatsapp database (needs sqlite3, for windows sqlite3.exe is contained in the archive)
- (Android Version) removed wrong extraction of owner in android version
- (Iphone Version) information from Z_METADATA table will be printed to shell
- (Iphone Version) fixed bug in support of older Iphone whatsapp databases

v2.0-bugsfixed-10
file: Whatsapp_Xtract_V2.0_2012-05-02-3.zip
- On errors, now the window will not close but show you an error message
- Now installation of PyCrypto is indeed optional. You only need it if you want to import a crypted db.
- added some advanced instructions in the Readme on how to use this script with the command line (also added a .bat that will open the command prompt and show the help message of the script)
- changed error management to let the script continue on errors like these:
* 'NoneType' object is not subscriptable in line 1028
* 'NoneType' object is not subscriptable in line 1126
The errors will be displayed in the message table and in the DOS Box, but the script will go on
- fixed syntax error in line 216
- fixed error that it tries to name output file "N/A" which is not possible because of the "/"
- fixed error of handling timestamps in Iphone database
- fixed " AttributeError: 'int' object has no attribute 'split' "
- changed parsing of sqlite databases, columns are now accessed by name and not by number (e.g., msgs["ZTEXT"] instead of msgs[10])
- included Iphone support for images, videos, vcard and (beta) gps. Fixed bug of opening a wrong output file in browser.
- changed install pyCrypto.bat

V2.0 (updated by Fabio Sangiacomo and Martina Weidner - Apr 28, 2012)
- supports WhatsApp DBs coming from both Android and iPhone platforms
- (Android Version) wa.db is optional
- (Android Version) now also crypted msgstore.db.crypt from the SD card can be imported
- chat list is sorted by the last sent message
- fixed some bugs (e.g. that the script didn't work with python 3)

V1.3 (updated by Martina Weidner - Apr 17, 2012)
- corrected linking of offline files (now linking according to media file size)

V1.2 (updated by Martina Weidner - Apr 5, 2012)
- media files also linked to offline files
- corrected hyperlinks

V1.1 (updated by Martina Weidner - Apr 5, 2012)
- changed database structure, Android only
- show contact names
- show smileys
- show images
- link / popup for images, video, audio, gps
- clickable links

V1.0 (created by Fabio Sangiacomo - Dec 10, 2011)
- first release, iPhone only:
it takes in input the file "ChatStorage.sqlite",
extracts chat sessions and the bare text
- sortable js allows table sorting to make chat sessions easily readable



CHANGELOG RECENT BUGFIXES:

- none yet


TODO:

- include Iphone support for audio, gps, gps of a place (like a restaurant), group messages and change of group name -> I need an Iphone sample database containing these message types!



FEATURE REQUESTS:

These features are requested but are not supported, at least now. Everyone who can help to include them may post information on how to do this.

- Blackberry Support: Step 1 - How is it possible to get the unencrypted messagestore.db file from Blackberry Whatsapp? (valek07); Step 2 - get a sample db file (see how to create sample db) and include Blackberry support
- Nokia Support: Step 1 - How to get the database file from Nokia? (oscargpes) Step 2 - Get a sample db file (see how to create sample db) and include Nokia support
- Windows Phone Support (beastie_carrion): Step 1 - How to get the database file from Windows Phone? Step 2 - Get a sample db file (see how to create sample db) Step 3 - include Windows Phone support
- create an android app for this, ideally offering "export to googlemail" function as in SMS Backup + (nomad4ever)
/ conversion of whatsapp to sms xml (ofmb)
- conversion between Android and Iphone database:
-- Android -> Iphone: ark0n3 is working on a Java tool called WhatsAppMigrator, here you can download WhatsAppMigrator
-- Iphone -> Android: no solution yet
- merge multiple backup files (darKpoiSonend) (you can use the tool SQLite Compare as a workaround, see howto in this post by ztedd)
- extract deleted messages (sometimes deleted messages remain in the database file but can't be accessed with normal Sqlite commands anymore) (Rauken)
The Following 18 Users Say Thank You to ztedd For This Useful Post: [ Click to Expand ]
 
ztedd
Old
(Last edited by ztedd; 17th July 2012 at 02:34 PM.) Reason: added how to repair corrupted database, linked how to merge multiple backup files
#3  
Senior Member - OP
Thanks Meter 239
Posts: 204
Join Date: Feb 2011
Default Some Additional Information

General advice on how to backup Whatsapp

Some general advice on how to backup Whatsapp and get the database file:

Android:
- In Whatsapp go to settings - more - Backup Chats
- Copy the folder "Whatsapp" on the SD card to your backup location (e.g., PC)
- (ideally also) use the app Titanium Backup to backup the full whatsapp application together with its data, copy the backup from the folder "TitaniumBackup" on the SD card to your backup location (e.g., PC)
- Use this tool Whatsapp Backup Extractor (download in this thread) to show the chats in a friendly readable format. The necessary files "wa.db" and "msgstore.db" you will find inside the Titanium Backup archive "com.whatsapp-[Date]-[some digits].tar.gz", alternatively (without Titanium Backup) you can use the msgstore.db.crypt file from the folder Whatsapp/Databases on the SD card.

Iphone:
- use Itunes to create an unencrypted Backup
- use an Iphone Backup Tool to get the file net.whatsapp.WhatsApp/Documents/ChatStorage.sqlite, e.g. I-Twin or Iphone Backup Extractor. Make sure to create an unencrypted backup with Itunes, as these tools can't handle encrypted backups. Another possibility are forensic tools like UFED Physical Analyzer.)

Blackberry:
- sync your blackberry with desktop manager and then copy the messagestore.db file from SD
- however, it seems that this file is encrypted? Currently we don't know how to get the unencrypted messagestore.db file
- Blackberry not supported yet!

Nokia:
- not known yet
- Nokia not supported yet!

CHECK IF DATABASE FILE CAN BE OPENED / EDIT CHAT MESSAGES INSIDE DATABASE

You may want to open the decrypted whatsapp database (ChatStorage.sqlite, msgstore.db or msgstore.plain.db) without this tool, e.g. if something goes wrong to check if it can be opened at all or to edit chat messages.
For this use SQLite Database Browser ( http://sqlitebrowser.sourceforge.net/ ).
However it is much more confusing and the messages are ordered by date, not by conversations. Also you won't see the smileys and media files...

IF DATABASE CAN'T BE OPENED: REPAIR DATABASE

Update: This function is now included in Whatsap Xtract 2.1.
If you get an error like this: Error: file is encrypted or is not a database and you tried to open the unencrypted database with SQLite Database Browser but it can't be opened with it, then try the following:
Open the database with Editor, can you see it starts with "SQLite format 3"? Then you may try to repair the database.
Thanks to hape70 for the instructions on how to repair (I translated it from German to English):
Quote:
- download sqlite3.exe from http://www.sqlite.org/download.html
- start whatsapp_xtract_console.bat and then type:
- echo .dump | sqlite3.exe msgstore.db > Temp.sql
- echo .quit | sqlite3.exe -init Temp.sql msgstore_new.db
- python whatsapp_xtract.py msgstore_new.db
(make sure to replace the underlined msgstore.db with the name of the database that is unencrypted but can't be opened, sometimes it will be msgstore.plain.db)
MEDIA FILES

If you want to watch the videos, audios and images, you can click on the thumbnails and media links. Popups should open displaying the media.
However, online media files are available only for the last ~ 3 weeks.
But you still can open the offline media files, they are linked as well.
For this it is necessary to at first copy the folder "Media" from /sdcard/Whatsapp (Android) or net.whatsapp.WhatsApp (Iphone) to the certain folder of your computer where this tool is installed. Then run the script. Now the media files should be correctly linked.

HOW TO MERGE MULTIPLE DATABASE FILES WITH SQLite Compare

Merging of multiple backup files is still on the feature request list, but you can use the tool SQLite Compare as a workaround, see howto in this post by ztedd.
The Following 12 Users Say Thank You to ztedd For This Useful Post: [ Click to Expand ]
 
fudensinho
Old
(Last edited by fudensinho; 7th April 2012 at 08:57 PM.)
#4  
fudensinho's Avatar
Senior Member
Thanks Meter 18
Posts: 134
Join Date: Jul 2011
Worked here!

Thanks a lot!
 
ztedd
Old
#5  
Senior Member - OP
Thanks Meter 239
Posts: 204
Join Date: Feb 2011
Glad you can use it!
 
abumhmmd1
Old
#6  
abumhmmd1's Avatar
Senior Member
Thanks Meter 211
Posts: 2,064
Join Date: Nov 2006
Location: RIYADH

 
DONATE TO ME
any way to ADD more emjoyies ... if OK ... how ??
 
ztedd
Old
#7  
Senior Member - OP
Thanks Meter 239
Posts: 204
Join Date: Feb 2011
Quote:
Originally Posted by abumhmmd1 View Post
any way to ADD more emjoyies ... if OK ... how ??
What do you mean? Do you want to be able to post more emoticons in the android whatsapp app?
 
jasaad
Old
(Last edited by jasaad; 13th April 2012 at 11:09 AM.)
#8  
Member
Thanks Meter 3
Posts: 55
Join Date: Apr 2012
i did what is said above, but when i use xtract.bat nothing happen,
just a cmd popup and close but nothing else open

edit: my files are .db.crypt
 
ztedd
Old
(Last edited by ztedd; 28th April 2012 at 12:18 AM.) Reason: update on new version solving the problem
#9  
Senior Member - OP
Thanks Meter 239
Posts: 204
Join Date: Feb 2011
Default msgstore.db <--> msgstore.db.crypt

Quote:
Originally Posted by jasaad View Post
i did what is said above, but when i use xtract.bat nothing happen,
just a cmd popup and close but nothing else open

edit: my files are .db.crypt
It won't work with the .db.crypt files from the SD card. You need the unencrypted msgstore.db that you can get from the internal memory, location:
/data/data/com.whatsapp/databases

I guess you will need a rooted android to access this.

I updated the Readme to show 3 different ways how to do this, e.g. using Titanium Backup.

Update 2012-04-28: new version 2.0 supports android whatsapp .db.crypt files!
 
Clair.f
Old
#10  
Junior Member
Thanks Meter 1
Posts: 1
Join Date: Apr 2012
Quote:
Originally Posted by ztedd View Post
Have you ever wanted to
- have a useful backup of your whatsapp chats?
- be able to read your whatsapp chats again using a backup file?
- delete the grown-too-big message history of whatsapp without losing the possibility to read the old conversations?
- read older messages without the need of endlessly pressing the annoying "load older messages" button?
- be able to search old messages?
- ...?

Here is a little Tool to display whatsapp chats on your computer, using the database files from your android installation of whatsapp.

It's called WhatsApp Extractor and was created by Fabio Sangiacomo on Dec 10, 2011.
blog.digital-forensics.it/2011/12/whatsapp-xtract.html
code.google.com/p/hotoloti/

Preview of the result (old version):


I found the script and realized it didn't work anymore, so I updated it and along that opportunity added some improvements.


So here is WhatsApp Extractor for Android v1.2
Updated on April 5, 2012
Tested with Whatsapp (Android) 2.7.5613

Changelog:
V1.2
- media files also linked to offline files
- corrected hyperlinks
V1.1
- updated database structure, old version didn't work anymore
- show contact names
- show smileys
- show images
- link / popup for images, video, audio, gps
- clickable links

How to use:
  1. Root your android phone or use any other method to get access to the folder
    /data/data/com.whatsapp/databases
  2. copy the files "msgstore.db" and "wa.db" to a certain folder of your computer

    You can do this by

    - using the App RootExplorer (first copy to SD, then mount phone to computer)
    - or using adb: open cmd and type "adb pull /data/data/com.whatsapp/databases/msgstore.db C:\Whatsapp" (replace C:\Whatsapp by the location of the certain folder of your computer)
    - or using the app Titanium Backup. Use Titanium Backup to backup the full whatsapp application together with its data, copy the backup from the folder "TitaniumBackup" on the SD card to your PC, then extract the files "wa.db" and "msgstore.db" that you will find inside the Titanium Backup archive "com.whatsapp-[Date]-[some digits].tar.gz" to the certain folder.

  3. Download and Install Python python.org/getit/
  4. Extract the attached archive Whatsapp Extractor for Android V1.1 2012-04-05.zip (whatsapp_xtract.py, whatsapp_xtract.bat, folders emoji and sort-table) to the certain folder and run whatsapp_xtract.bat (on windows, other OS different)
  5. Once finished, your browser will open and show you your chats.

    The resulting file size of the .htm file will be slightly bigger than the size of the .db database.



Attachment:

Whatsapp Extractor for Android V1.2 2012-04-05.zip (~ 500 KB)
contains:
whatsapp_xtract.py
whatsapp_xtract.bat
folder: emoji
folder: sort-table


also available here:
freakshare.com/files/im8s5y35/Whatsapp-Extractor-for-Android-V1.2-2012-04-05.zip.html
I don't suppose there is a video tut to go with this is there? I am finding it hard to follow.. Thanks

The Following User Says Thank You to Clair.f For This Useful Post: [ Click to Expand ]
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes