Copyright (C) 2017 Heather Mahalik (heather@smarterforensics.com)
You can view the GNU General Public License at http://www.gnu.org/licenses/
#v2018-04-25
usage = "Usage: iOS_sms_parser.py -d sms.db -o sms_output.tsv"
import sys import sqlite3 from optparse import OptionParser from os import path
version_string = "iOS_sms_parser v2017-10-28" print "Running " + version_string
usage = "Usage: %prog -d sms.db -o sms_output.tsv"
parser = OptionParser(usage=usage) parser.add_option("-d", dest="smsdb", action="store", type="string", help="sms database input file") parser.add_option("-o", dest="outputtsv", action="store", type="string", help="Message output in Tab Separated format")
(options, args) = parser.parse_args()
#no arguments given by user, print help and exit if len(sys.argv) == 1: parser.print_help() exit(-1)
if (options.smsdb == None): parser.print_help() print "\SMS database filename not specified!" exit(-1)
if (options.outputtsv == None): parser.print_help() print "\nOutput filename not specified!" exit(-1)
if path.isfile(options.smsdb): chatscon = sqlite3.connect(options.smsdb) else: print "Specified SMS Database does not exist!" exit(-1)
if (options.outputtsv != None): try: import codecs outputfile = codecs.open(options.outputtsv, "w", "utf-8") except: print ("Trouble Opening SMS Output File For Writing") exit(-1)