Tuesday, March 5, 2013

Python dump skype DB

據說 Skype local 端資料也是直接用 sqlite 存的

Mac OSX
~/Library/Application Support/Skype/$account/main.db

Linux
~/.Skype/$account/main.db

所以我們可以自己寫 tools 查看自己的資料 請不要拿來查看別人的資料 >_<

剛剛初步可以 Dump 出以下XD

也許這樣學習資料庫比較有趣(?


[~/.Skype/****]-[Arch Linux] $ sqlite3 main.db
SQLite version 3.7.15.2 2013-01-09 11:53:05
sqlite> .table
Accounts        ChatMembers     Conversations   Participants    Videos
Alerts          Chats           DbMeta          SMSes           Voicemails
CallMembers     ContactGroups   LegacyMessages  Transfers
Calls           Contacts        Messages        VideoMessages
sqlite> select * from Accounts;


Sample code:
#!/usr/bin/python

import sys
import sqlite3

def printProfile(skypeDB):
    conn = sqlite3.connect(skypeDB)
    c = conn.cursor()


    print "show tables:"
    c.execute("SELECT tbl_name from sqlite_master WHERE type=='table';")
    print c.fetchall()

    c.execute("SELECT fullname, skypename, city, country, \
               datetime(profile_timestamp,'unixepoch') FROM Accounts;")


    print "Dump Account: "
    print "-" * 50
    for row in c.fetchall():
        print '[*] -- Found Account --'
        print '    [+] User: ' + row[0]
        print '    [+] Skype Username: ' + row[1]
        print '    [+] Location: ' + row[2] + ',' + row[3]
        print '    [+] Profile Date: ' + row[4]

    print "Dump Contacts: "
    print "-" * 50
    c.execute("SELECT displayname, skypename, phone_mobile, \
               birthday FROM Contacts;")

    for row in c.fetchall():
        print '[*] -- Found Account --'
        print '    [+] User: ' + (row[0])
        print '    [+] Skype Username: ' + row[1]
        print '    [+] Phone_mobile: ' + str(row[2])
        print '    [+] Birthday: ' + str(row[3])


if __name__ == "__main__":
    
    printProfile(sys.argv[1])

No comments:

Post a Comment