From 050a64ab60f6cb536ea7ed55620e5712542dfeda Mon Sep 17 00:00:00 2001 From: thgb Date: Fri, 16 May 2014 02:36:26 +0100 Subject: [PATCH 1/2] Update 5-skypeParse.py Fix contact search so it can deal with non-ascii characters in skype names. Required changing str() functions to objects treated as strings. Main change is line 31: print (u'[+] User : %s ' % (row[0],)).encode('utf-8') --- Chapter-3/5-skypeParse.py | 52 ++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/Chapter-3/5-skypeParse.py b/Chapter-3/5-skypeParse.py index 668d02f..ef63466 100644 --- a/Chapter-3/5-skypeParse.py +++ b/Chapter-3/5-skypeParse.py @@ -3,6 +3,7 @@ import sqlite3 import optparse import os +import sys, codecs, locale def printProfile(skypeDB): @@ -12,63 +13,58 @@ def printProfile(skypeDB): datetime(profile_timestamp,'unixepoch') FROM Accounts;") for row in c: - print '[*] -- Found Account --' - print '[+] User : '+str(row[0]) - print '[+] Skype Username : '+str(row[1]) - print '[+] Location : '+str(row[2])+','+str(row[3]) - print '[+] Profile Date : '+str(row[4]) + print 'Found Account' + print 'User : %s ' % (row[0],) + print 'Skype Username : %s ' % (row[1],) + print 'Location : %s %s' % (row[2], row[3],) + print 'Profile Date : %s ' % (row[4],) def printContacts(skypeDB): conn = sqlite3.connect(skypeDB) c = conn.cursor() c.execute("SELECT displayname, skypename, city, country,\ - phone_mobile, birthday FROM Contacts;") + phone_mobile, birthday FROM Contacts ORDER BY skypename;") for row in c: print '\n[*] -- Found Contact --' - print '[+] User : ' + str(row[0]) - print '[+] Skype Username : ' + str(row[1]) - - if str(row[2]) != '' and str(row[2]) != 'None': - print '[+] Location : ' + str(row[2]) + ',' \ - + str(row[3]) - if str(row[4]) != 'None': - print '[+] Mobile Number : ' + str(row[4]) - if str(row[5]) != 'None': - print '[+] Birthday : ' + str(row[5]) + print (u'[+] User : %s ' % (row[0],)).encode('utf-8') + print '[+] Skype Username : %s ' % (row[1],) + if (row[2]) != '' and (row[2]) != 'None': + print '[+] Location : %s %s ' % (row[2], row[3],) + if (row[4]) != 'None': + print '[+] Mobile Number : %s ' % (row[4],) + if (row[5]) != 'None': + print '[+] Birthday : %s ' % (row[5]) def printCallLog(skypeDB): conn = sqlite3.connect(skypeDB) c = conn.cursor() - c.execute("SELECT datetime(begin_timestamp,'unixepoch'), \ - identity FROM calls, conversations WHERE \ + c.execute("SELECT datetime(begin_timestamp,'unixepoch'), identity FROM calls, conversations WHERE \ calls.conv_dbid = conversations.id;" ) print '\n[*] -- Found Calls --' for row in c: - print '[+] Time: '+str(row[0])+\ - ' | Partner: '+ str(row[1]) + print '[+] Time: %s ' % (row[0])+\ + ' | Partner: %s ' % (row[1]) def printMessages(skypeDB): conn = sqlite3.connect(skypeDB) c = conn.cursor() - c.execute("SELECT datetime(timestamp,'unixepoch'), \ - dialog_partner, author, body_xml FROM Messages;") + c.execute("SELECT datetime(timestamp,'unixepoch'), dialog_partner, author, body_xml FROM Messages;") print '\n[*] -- Found Messages --' for row in c: try: - if 'partlist' not in str(row[3]): - if str(row[1]) != str(row[2]): - msgDirection = 'To ' + str(row[1]) + ': ' + if 'partlist' not in (row[3]): + if (row[1]) != (row[2]): + msgDirection = 'To %s :' % (row[1]) else: - msgDirection = 'From ' + str(row[2]) + ' : ' - print 'Time: ' + str(row[0]) + ' ' \ - + msgDirection + str(row[3]) + msgDirection = 'From %s :' % (row[2]) + print 'Time: %s %s' + (row[0], row[3]) except: pass From a27b2a69469117dd9f5fdd7fc0b0faf691f54e9c Mon Sep 17 00:00:00 2001 From: thgb Date: Fri, 16 May 2014 03:06:43 +0100 Subject: [PATCH 2/2] Bugfix 5-skypeParse.py Fixed a few bugs that prevented any messages being printed. --- Chapter-3/5-skypeParse.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Chapter-3/5-skypeParse.py b/Chapter-3/5-skypeParse.py index ef63466..ed08b3a 100644 --- a/Chapter-3/5-skypeParse.py +++ b/Chapter-3/5-skypeParse.py @@ -58,15 +58,13 @@ def printMessages(skypeDB): print '\n[*] -- Found Messages --' for row in c: - try: if 'partlist' not in (row[3]): if (row[1]) != (row[2]): msgDirection = 'To %s :' % (row[1]) else: msgDirection = 'From %s :' % (row[2]) - print 'Time: %s %s' + (row[0], row[3]) - except: - pass + print 'Time: %s %s' % (row[0], row[3]) + def main():