-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathextract-wifi.py
43 lines (29 loc) · 988 Bytes
/
extract-wifi.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
from collections import deque
## Create a buffer to hold the key chain lines
buffer = deque('a', 23)
def extractAccountAndPassword():
account="Error: No Account Found"
password="Error: No Password Found"
for index, item in enumerate(buffer):
if "acct" in item:
account=item.replace('"', '').replace('acct<blob>=', '')
if "data:" == item:
password = buffer[index+1].strip('"')
print("%s\t%s" % (account, password))
def checkBuffer():
isWifi = False;
for item in buffer:
if "AirPort network password" in item:
isWifi = True;
if isWifi:
extractAccountAndPassword()
def main():
with open('keychain_all.txt', 'r') as inf:
for line in inf:
line = line.strip()
buffer.append(line)
if "keychain:" in line:
checkBuffer()
checkBuffer() # Check one last time
if __name__ == '__main__':
main()