forked from cheeky4n6monkey/iOS_sysdiagnose_forensic_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsysdiagnose-wifi-plist.py
114 lines (92 loc) · 4.51 KB
/
sysdiagnose-wifi-plist.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#! /usr/bin/env python
# For Python3
# Script to print the values from WiFi/com.apple.wifi.plist or WiFi/preferences.plist
# Author: cheeky4n6monkey@gmail.com
import sys
from optparse import OptionParser
import plistlib
#import pprint
version_string = "sysdiagnose-wifi-plist.py v2019-10-24 Version 1.0"
if sys.version_info[0] < 3:
print("Must be using Python 3! Exiting ...")
exit(-1)
usage = "\n%prog -i inputfile\n"
parser = OptionParser(usage=usage)
parser.add_option("-i", dest="inputfile",
action="store", type="string",
help="WiFi/com.apple.wifi.plist or WiFi/preferences.plist To Be Searched")
parser.add_option("-t", dest="outputtsv",
action="store_true", default=False,
help="Write TSV output file called sysdiagnose-wifi-plist-output.TSV")
(options, args) = parser.parse_args()
#no arguments given by user, print help and exit
if len(sys.argv) == 1:
parser.print_help()
exit(-1)
print("Running " + version_string + "\n")
outputlist = []
with open(options.inputfile, 'rb', ) as fp:
pl = plistlib.load(fp)
#pprint.pprint(pl)
#print(pl.keys())
if 'List of known networks' in pl.keys():
for dic in pl['List of known networks']: # list of dicts
#print(item)
print("=============================")
print("SSID_STR = " + dic['SSID_STR'])
ssid = dic['SSID_STR']
bssid = ""
if 'BSSID' in dic.keys():
print("BSSID = " + dic['BSSID'])
bssid = dic['BSSID']
netusage = ""
if 'networkUsage' in dic.keys():
print("networkUsage = " + str(dic['networkUsage']))
netusage = str(dic['networkUsage'])
countrycode = ""
if '80211D_IE' in dic.keys():
#print(type(dic['80211D_IE'])) # dict
for key2, val2 in dic['80211D_IE'].items():
if key2 == 'IE_KEY_80211D_COUNTRY_CODE':
print("IE_KEY_80211D_COUNTRY_CODE = " + val2)
countrycode = val2
devname = ""
mfr = ""
serialnum = ""
modelname = ""
if 'WPS_PROB_RESP_IE' in dic.keys():
for key3, val3 in dic['WPS_PROB_RESP_IE'].items():
if key3 == 'IE_KEY_WPS_DEV_NAME':
print("IE_KEY_WPS_DEV_NAME = " + val3)
devname = val3
if key3 == 'IE_KEY_WPS_MANUFACTURER':
print("IE_KEY_WPS_MANUFACTURER = " + val3)
mfr = val3
if key3 == 'IE_KEY_WPS_SERIAL_NUM':
print("IE_KEY_WPS_SERIAL_NUM = " + val3)
serialnum = val3
#serialnum = "testserial"
if key3 == 'IE_KEY_WPS_MODEL_NAME':
print("IE_KEY_WPS_MODEL_NAME = " + val3)
modelname = val3
#modelname = "testmodel"
lastjoined = ""
if 'lastJoined' in dic.keys():
print("lastJoined = " + str(dic['lastJoined']))
lastjoined = str(dic['lastJoined'])
lastautojoined = ""
if 'lastAutoJoined' in dic.keys():
print("lastAutoJoined = " + str(dic['lastAutoJoined']))
lastautojoined = str(dic['lastAutoJoined'])
enabled = ""
if 'enabled' in dic.keys():
enabled = str(dic['enabled'])
print("enabled = " + str(dic['enabled']))
print("=============================\n")
outputlist.append((ssid, bssid, netusage, countrycode, devname, mfr, serialnum, modelname, lastjoined, lastautojoined, enabled))
if (options.outputtsv):
with open("sysdiagnose-wifi-plist-output.TSV", 'w') as wp:
wp.write("SSID\tBSSID\tNETUSAGE\tCOUNTRYCODE\tDEVICENAME\tMANUFACTURER\tSERIALNUM\tMODELNAME\tLASTJOINED\tLASTAUTOJOINED\tENABLED\n") # header
for ssid, bssid, netusage, countrycode, devname, mfr, serialnum, modelname, lastjoined, lastautojoined, enabled in outputlist:
wp.write(ssid+"\t"+bssid+"\t"+netusage+"\t"+countrycode+"\t"+devname+"\t"+mfr+"\t"+serialnum+"\t"+modelname+"\t"+lastjoined+"\t"+lastautojoined+"\t"+enabled+"\n")
print("Also outputted to sysdiagnose-wifi-plist-output.TSV\n")