Dear iPhone: Give me my data!
Apple’s iPhone allows users to input notes, bookmarks, contacts, and all sorts of other data. However, the user is only allowed limited access to a portion of this data via iTunes. For example, the only way to get notes off the phone is for the user to email the note to himself or herself.
However, all data is available on the user’s computer in the form of an iPhone back up. An iPhone back up is made whenever an iPhone is synchronized. This backup contains everything from the user’s web history, bookmarks, and cookies to their contact lists and SMS chat history.
In order to spur further development of iPhone data extraction tools, I have created a script that will extract all files from an iPhone backup into a format that is easily readable. This script, called extract_iphone_backup.py (source code here), will look for any iPhone back ups, process them, and dump the data files. Note: Currently, this script will only run on OSX.
To use the script:
- Download the script and save it to your Home folder.
- Run Applications > Utilities > Terminal in Finder.
- In the terminal window, type:
- python extract_iphone_backup.py
- Watch as all the settings files from your iPhone are extracted to a folder called “iphone_backup”. Inside of that folder, there will be a folder for each iPhone. The name of the folder will match the phone number of the iPhone.
So what’s inside?
Here are some of the interesting things you can do with your iPhone’s files. To make the most use of these files, you will want to download Sqlite Database Browser.
- Review your call history
Open the file Library_CallHistory_call_history.db with Sqlite Database Browser. Click on “Browse Data” and choose “call” from the table drop-down. This table contains the last 100 calls you have made.
- Read logs of your SMS (Text Message) chats
Use Sqlite Database Browser to look in Library_SMS_sms.db in the table “message”.
- Access notes written on your iPhone
Use Sqlite Database Browser to look in Library_Notes_notes.db in the table “Note”.
- Access your raw contacts list
Use Sqlite Database Browser to look in Library_AddressBook_AddressBook.sqlitedb in tables “ABPerson” and “ABMultiValue”.
- Look at your web bookmarks, cookies, and history.
Try opening Library_Safari_Bookmarks.plist, Library_Cookies_Cookies.plist, and Library_Safari_History.plist in Text Edit.
And there is a lot more…
While all of this may not be very useful for the average user, there is a wealth of settings information here from all the basic iPhone apps for developers to look at and play with. Using this information, it will be easy for developers to write user-friendly tools to access or update all of the data stored in the iPhone back ups. Have fun!
6 Comments so far
Leave a reply
I got this error…
mactel:~ andrewmyers$ python extract_iphone_backup.py
Traceback (most recent call last):
File “extract_iphone_backup.py”, line 39, in ?
phoneNum = getIPhoneNumber(backupPath)
File “extract_iphone_backup.py”, line 28, in getIPhoneNumber
pl = plistlib.readPlist(path+”/Info.plist”)
AttributeError: ‘module’ object has no attribute ‘readPlist’
mactel:~ andrewmyers$
Not a pro at python, any suggestions? THANKS for the killer script and instructions by the way…
Any details on what the information in the DB’s mean?
I’m looking at the call db right now. What are the “flags” and “id”?
Does the DB only list outgoing calls, or do either the flags or id indicate “answered, outgoing, missed?”
Andy, I think it is a problem with the version of python shipped with your copy of OSX. What version of OSX are you using?
G.S., here’s what I know about the call table:
rowid - primary key
address - the phone number
date - unix timestamp of call. You could convert this with some python code like:
import datetime
print datetime.datetime.fromtimestamp(11185551928)
Result: 2007-07-27 11:58:48
duration - all of the values in my duration column are multiples of 60, making it seem like its the length of the call in seconds, but that the accounting is only accurate to the minute.
Note that a duration of 0 seems to imply a missed call, where as all other calls have a duration of at least 60. This is the only way it seems to record that a call was a missed call.
flags - this seems to represent who made the call. If I made the call, it is 5. If I received the call, it is 4. All my values in this column are either 4 or 5.
id - the id of the contact who was involved in the call. Note that for all calls I received, the value is always -1 instead of the actual contact. The contact id is only saved if I made the call.
Getting the exact same error as Andy. Macbook Pro running 10.4.10. Thanks for the script!
I am getting the same error as Andy- Running OSX 10.4.9.1 and python 2.3.5