· WhatsApp Metadata Extractor :
- main_manage.py (main de consola en forma de cliente)
- DB_Extractor.py (extrae los metadatos de la BD)
- metaimg_extractor.py (extrae los metadatos de los .jpg encontrados)
main_manage.py :
# -*- coding: utf-8 *-*
import DB_Extractor, metaimg_extractor
class WhatsApp_Extractor():
def __init__(self):
self.__opt()
def __opt(self):
#Uncomment the OPTION that you want to use
#self.__opt1() #-> DB METADATA EXTRACTOR
self.__opt2() #-> IMG METADATA EXTRACTOR
#self.__opt3() #-> BOTH, OPT1 AND OPT2
def __opt1(self):
print "DB METADATA"
print "------------"
DB_Extractor.DB_Extractor()
print "------------"
def __opt2(self):
print "IMG META"
print "------------"
metaimg_extractor.IMG_Meta()
print "------------"
def __opt3(self):
print "DB METADATA"
print "------------"
DB_Extractor.DB_Extractor()
print "------------"
print "\nIMG META"
print "------------"
metaimg_extractor.IMG_Meta()
print "------------"
WhatsApp_Extractor()
DB_Extractor.py :
# -*- coding: utf-8 *-*
#Script to extract the metadata from the WhatsApp crypted DB
import sqlite3
from Crypto.Cipher import AES
class DB_Extractor():
def __init__(self):
self._manage_do()
def _manage_do(self):
try:
self.__DB_Breaker('msgstore.db.crypt')
self.__DB_conn()
self.__SQL_Consulter()
#Log exporter
except:
print "Error starting the script"
def __DB_Breaker(self, DBPath):
self.DBPath = DBPath
#breaking the hash
f = open(self.DBPath, 'rb')
key = "346a23652a46392b4d73257c67317e352e3372482177652c"
#triying to break the hash
try:
key = key.decode('hex')
cipher = AES.new(key, 1)
decoded = cipher.decrypt(f.read())
#Saving into a new db file
try:
decoded_DB = open('metadb.db', 'wb')
decoded_DB.write(decoded)
decoded_DB.close()
print "metadb.db has been created in the same directory"
except:
print "An error has ocurred creating the decoded DB"
except:
print "Error decoding the hash"
def __DB_conn(self):
#triying to connect with the sqlite database
try:
self.conn = sqlite3.connect('metadb.db')
self.consult = self.conn.cursor()
except:
print "An error has ocurred connecting with the SQLite DB"
def __SQL_Consulter(self):
#Divided in :
# Messages
# Chat_list
def __Messages():
#SQLConsult
try:
self.consult.execute("SELECT key_remote_jid, key_from_me, \
remote_resource, status, datetime(timestamp), data, media_url, media_mime_type, \
media_size, latitude, longitude FROM messages;")
except:
print "An error has ocurred doing the SQL Consult"
def __Shower():
#Message details
#nota : parsear status, comprobar si yo envio o recivo
for data in self.consult:
try:
print "\nMessages Details:"
print "----------------------"
if str(data[2]):
if str(data[1]) == '1':
print "From: me"
print "To: %s(group), integrant: %s"%(str(data[0]), str(data[2]))
else:
print "From: %s(group), integrant: %s"%(str(data[0]), str(data[2]))
print "To: me"
else:
if str(data[1]) == '1':
print "From: me"
print "To: " + str(data[0])
else:
print "From: " + str(data[0])
print "To: me"
print "Status: " + str(data[3])
print "Timestamp: " + str(data[4])
print "Message: " + str(data[5])
print "Media content: %s, type: %s, size: %s"%(str(data[6]), str(data[7]), str(data[8]))
print "Location(Lat: %s, Long: %s)"%(str(data[9]), str(data[10]))
print "----------------------"
except:
continue
print "ERROR showing message details"
__Shower()
def __Chat_list():
#SQLConsult
try:
self.consult.execute("SELECT id, \
key_remote_jid FROM chat_list;")
except:
print "An error has ocurred doing the SQL Consult"
def __Shower():
#Chat list details
for data in self.consult:
try:
print "\nChat_list"
print "ID: " + str(data[0])
print "Number: " + str(data[1])
print "----------------------"
except:
continue
print "ERROR showing chat list details"
__Shower()
#Initializing
__Messages()
__Chat_list()
metaimg_extractor.py :
# -*- coding: utf-8 *-*
import os, exif
class IMG_Meta():
def __init__(self):
try:
self.__Media_extractor()
print "------------------------------------------------------\n"
self.__Profile_extractor()
except:
print "An error has ocurred starting the script"
def __Media_extractor(self):
try:
images = os.listdir('Media/WhatsApp Images/')
except:
print "An error has ocurred listing the files into the directory"
def __Shower():
for i in images:
print "-------------"
print i
obj = exif.extract_EXIF('Media/WhatsApp Images/%s' % i)
print "-------------"
__Shower()
def __Profile_extractor(self):
try:
images = os.listdir('Profile Pictures/')
except:
print "An error has ocurred listing the files into the directory"
def __Shower():
for i in images:
print "-------------"
print i
obj = exif.extract_EXIF('Profile Pictures/%s' % i)
print "-------------"
__Shower()
Trabajando :
(http://1.bp.blogspot.com/-AQ9Ye_oYlqw/UZFKsU6iWAI/AAAAAAAAAJQ/uPeKm69ATeI/s400/Pantallazo.png)
(http://2.bp.blogspot.com/-tjuxfmsUiO4/UZFLDKxiqZI/AAAAAAAAAJg/lJSCGWM1p8U/s400/Pantallazo-1.png)
Saludos.
Como siempre excelente compañero, enhorabuena ;D
-Saludos-