forked from cheeky4n6monkey/iOS_sysdiagnose_forensic_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsysdiagnose-appinstallation.py
57 lines (41 loc) · 1.53 KB
/
sysdiagnose-appinstallation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#! /usr/bin/env python
# For Python3
# Script to print connection info from logs/appinstallation/AppUpdates.sqlite.db
# Author: [email protected]
# PID: encoded in Litlle Endian??
import sys
from optparse import OptionParser
import time
import struct
import datetime
import sqlite3
version_string = "sysdiagnose-appinstallation.py v2019-08-09 Version 1.0"
if sys.version_info[0] < 3:
print("Must be using Python 3! Exiting ...")
exit(-1)
print("Running " + version_string + "\n")
usage = "\n%prog -i inputfile\n"
parser = OptionParser(usage=usage)
parser.add_option("-i", dest="inputfile",
action="store", type="string",
help="logs/appinstallation/AppUpdates.sqlite.db to be parsed")
(options, args) = parser.parse_args()
#no arguments given by user, print help and exit
if len(sys.argv) == 1:
parser.print_help()
exit(-1)
try:
appinstalldb = sqlite3.connect(options.inputfile)
cursor = appinstalldb.cursor()
for row in cursor.execute("SELECT pid, bundle_id, install_date FROM app_updates"):
[pid, bundle_id, install_date] = row
# convert install_date from Cocoa EPOCH -> UTC
epoch = install_date + 978307200 # difference between COCOA and UNIX epoch is 978307200 seconds
utctime = datetime.datetime.utcfromtimestamp(epoch)
# convert PID
#pid = struct.pack('>I', pid)
# print result
print("%s,%s,%s" % (pid, bundle_id, utctime))
except:
print("AN UNHANDLED ERRORS OCCURS AND THE DB WAS NOT PARSED")
# That's all folk ;)