forked from cheeky4n6monkey/iOS_sysdiagnose_forensic_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsysdiagnose-sys.py
84 lines (67 loc) · 2.41 KB
/
sysdiagnose-sys.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#! /usr/bin/env python
# For Python3
# Script to print the values from /logs/SystemVersion/SystemVersion.plist
# Author: [email protected]
#
# Change log: David DURVAUX - add function are more granular approach
import sys
from optparse import OptionParser
import plistlib
version_string = "sysdiagnose-sys.py v2019-05-10 Version 2.0"
# --------------------------------------------------------------------------- #
def getProductInfo(path="./logs/SystemVersion/SystemVersion.plist"):
"""
return an hash table with the following structure
{
"ProductName" : "",
"ProductionVersion" : "",
"ProductBuildVersion" : ""
}
Non populated field are filled with a None value
"""
result = {
"ProductName" : None,
"ProductionVersion" : None,
"ProductBuildVersion" : None
}
try:
fd = open(path, 'rb')
plist = plistlib.load(fd)
for key in ["ProductName", "ProductVersion", "ProductBuildVersion", "BuildID", "SystemImageID"]:
if key in plist.keys():
result[key] = plist[key]
else:
print("WARNING: %s not found in %s plist" % (key, path))
fd.close()
except Exception as e:
print("Impossible to parse %s: %s" % (path, str(e)))
return result
def main():
"""
Main function, to be called when used as CLI tool
"""
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/SystemVersion/SystemVersion.plist To Be Searched")
(options, args) = parser.parse_args()
if options.inputfile:
pl = getProductInfo(options.inputfile)
print("ProductName = %s" % pl["ProductName"])
print("ProductVersion = %s" % pl["ProductVersion"])
print("ProductBuildVersion = %s" % pl["ProductBuildVersion"])
else:
print("WARNING -i option is mandatory!")
# --------------------------------------------------------------------------- #
"""
Call main function
"""
if __name__ == "__main__":
# Create an instance of the Analysis class (called "base") and run main
main()
# That's all folk ;)