Very much based on Facebook Message Parser (facebook_message_parser
), which is itself based on CopOnTheRun/FB-Message-Parser. This code is written to allow the facebook_message_parser.fb_analysis
module to run on the output, to produce similar graphs and stats.
On iOS6 and later, the iPhone stores texts and iMessages in a file called sms.db, an SQLite database. If the iPhone is backed up (unencrypted) to a computer, a program like iphonebackupbrowser (for Windows) can be used to locate the sms.db file in the backup. See below.
Before any code can be run: Lines 21 and 22 in ios_parser.py
will need to be updated to the name and mobile number of the owner of the database being parsed. The code will attempt to open sms.db
by default.
Run "python sms.py [optional_filename]
" with the sms.db
or [sms_db_hashed_name]
file in the same directory to export to CSV. This sample code can easily be adapted.
####iphonebackupbrowser
When browsing the backup with iphonebackupbrowser; the sms.db file is stored in the System
folder, as Library/SMS/sms.db
. On disk however, the file names are hashed and so once the file is located (click and drag, or double click in iphonebackupbrowser) it needs to be renamed to sms.db
. The raw file is commonly named 3d0d7e5fb2ce288813306e4d4636395e047a3d28
, in a location like %APPDATA%\Apple Computer\MobileSync\Backup\[Backup_Name_Hash]
on Windows machines.
The code is written in Python 2.7.
The code needs the sqlite3
Python library, version 3.8 or higher. Try:
import sqlite3
print sqlite3.sqlite_version
to check version number.
Anaconda Python for scientific computing is a simple and easy way to install all the dependencies for the code, alongside many other useful libraries. It can be downloaded here.