Created
January 28, 2014 05:03
-
-
Save maluta/8662535 to your computer and use it in GitHub Desktop.
I wanted to backup an Whatsapp previus conversation, from my old phone. It was instaled in a device CyanogenMon 2.3.x (+root) so I didn't have trouble to get msgstore.db. I personally don't know why it was store in plain-text but I need do what I have to do. I posting this just for very basic reference
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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import sqlite3 as lite | |
import sys | |
# found at /data/data/com.whatsapp/databases | |
con = lite.connect('msgstore.db') | |
''' | |
I've found this tuple when accessed Whatsapp single message | |
[] - (1676, | |
[1] - u'[email protected]', | |
[] - 1, | |
[] - u'1351774945-3', | |
[] - 5, | |
[] - 0, | |
[6] - u'MESSAGE', | |
[] - 1351777545025, | |
[] - None, | |
[] - None, | |
[] - u'0', | |
[] - 0, | |
[] - None, 0.0, 0.0, None, None, 1351777545028, -1, 1351777545497, 1351777627177, None, None, None, None, None) | |
''' | |
with con: | |
cur = con.cursor() | |
cur.execute("SELECT * FROM messages") | |
rows = cur.fetchall() | |
for row in rows: | |
phone = row[1].split('@')[0] | |
message = row[6] | |
if phone.isdigit(): # not a group (whatsapp groups contains '-') | |
if phone.find("99887766") != -1: # users's phone as shown in whatsapp | |
try: | |
if row[2] == 1: | |
print "me>", message.encode("UTF-8") | |
else: | |
print "user>", message.encode("UTF-8") | |
except: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment