-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrecon.py
99 lines (71 loc) · 2.87 KB
/
recon.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
import json
import requests
class Recon:
def __init__(self, bearer, band, url):
self.bearer = bearer
self.band = band
self.url = url
self.headers = {
"Authorization": f"Bearer {self.bearer}"
}
self.securityMasks = {
"17845315": "WPA Mixed PSK (CCMP)",
"16811010": "WPA2 Enterprise (CCMP)",
"16794626": "WPA2 PSK (CCMP)",
"8932963": "WPA Mixed PSK (CCMP TKIP)",
"8422914": "WPA2 Enterprise (CCMP TKIP)",
"526433": "WPA PSK (CCMP TKIP)",
"0": "No Security"
}
self.scanData = []
def startScan(self):
payload = {
"live": False,
"scan_time": 0,
"band": str(self.band)
}
req = requests.post(f"{self.url}/api/recon/start", headers=self.headers, json=payload)
response = json.loads(req.text)
if "error" in response:
return False, response["error"]
return True, response["scanID"]
def stopScan(self):
req = requests.post(f"{self.url}/api/recon/stop", headers=self.headers)
response = json.loads(req.text)
if "success" in response and response["success"] == True:
return True
return False
def getResults(self, scanID):
req = requests.get(f"{self.url}/api/recon/scans/{scanID}", headers=self.headers)
response = json.loads(req.text)
return response
def newAPS(self, scanID):
results = self.getResults(scanID)
aps = []
newAps = []
if "APResults" in results and results["APResults"] != None:
for i in range(len(results["APResults"])):
ssid = results["APResults"][i]["ssid"]
bssid = results["APResults"][i]["bssid"]
if str(results["APResults"][i]["encryption"]) in self.securityMasks:
encryption = self.securityMasks[str(results["APResults"][i]["encryption"])]
else:
encryption = "Unknown"
isHidden = bool(results["APResults"][i]["hidden"])
isWPS = bool(results["APResults"][i]["wps"])
channel = results["APResults"][i]["channel"]
signal = results["APResults"][i]["signal"]
newData = [ssid, bssid, channel, signal, encryption, isHidden, isWPS]
aps.append(newData)
for i in range(len(aps)):
toAdd = True
for j in range(len(self.scanData)):
if self.scanData[j][1] == aps[i][1]:
toAdd = False
break
if toAdd:
newAps.append(aps[i])
self.scanData.append(aps[i])
if newAps:
return True, newAps
return False, None