-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecord.py
82 lines (62 loc) · 1.87 KB
/
record.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
#!/usr/bin/env python3
import subprocess
import xml.sax
import os
import time
import json
import traceback
client_list = []
class ClientInfo:
def __init__(self):
self.mac = ""
self.rssi = ""
self.mon = "0"
def __str__(self):
return self.mac
class ClientInfoHandler(xml.sax.ContentHandler):
def __init__(self):
self.CurrentData = ""
self.current_client = None
self.in_client = False
def startElement(self, tag, argument):
self.CurrentData = tag
if tag == "wireless-client":
self.in_client = True
self.current_client = ClientInfo()
def endElement(self, tag):
global client_list
if tag == "wireless-client":
self.in_client = False
client_list.append(self.current_client.__dict__)
self.CurrentData = ""
def characters(self, content):
if self.CurrentData == "client-mac":
self.current_client.mac = content
elif self.CurrentData == "last_signal_rssi":
self.current_client.rssi = content
def main():
storage = "export-01.kismet.netxml"
s = subprocess.Popen(
["airodump-ng", "--output-format", "netxml", "--bssid", "50:C7:BF:BA:F4:12", "-w" "export", "mon0"]
)
time.sleep(3)
os.system("kill -2 " + str(s.pid))
time.sleep(0.5)
parser = xml.sax.make_parser()
parser.setFeature(xml.sax.handler.feature_namespaces, 0)
handler = ClientInfoHandler()
parser.setContentHandler(handler)
try:
parser.parse(storage)
except xml.sax.SAXParseException:
traceback.print_exc()
if os.path.exists(storage):
os.system("rm -f " + storage)
with open("export.json", "w") as f:
json.dump(client_list, f)
if __name__ == "__main__":
c = 1
while True:
print(f"Starting round {c}...")
main()
c += 1