-
Notifications
You must be signed in to change notification settings - Fork 1
/
wifi_manager.py
61 lines (39 loc) · 1.31 KB
/
wifi_manager.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 os
import subprocess
import re
import time
from multiprocessing import Process, Manager
import pprint
import datetime
import copy
def dump_aps(interface, timeout):
table = ''
table_start = re.compile('\sCH')
line_start = re.compile('[A-Z0-9]{2}:[A-Z0-9]{2}:[A-Z0-9]{2}:[A-Z0-9]{2}:[A-Z0-9]{2}:[A-Z0-9]{2}')
start_time = time.time()
airodump = subprocess.Popen(['airodump-ng', interface, '-c', '1,11', '-N', 'eduroam'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, bufsize=1)
accumulator = {}
while time.time() - start_time < timeout:
line = airodump.stdout.readline().strip('\n')
line = [x for x in line.split(' ') if x != '']
if line != [] and line_start.match(line[0]):
if line[0] not in accumulator:
accumulator[line[0]] = []
accumulator[line[0]].append([line[1], line[-1], line[5]])
final = {}
for a in accumulator:
s = 0
for z in accumulator[a]:
try:
s += int(z[0])
except:
pass
final[a] = abs(s / len(accumulator[a]))
airodump.terminate()
return final
if __name__ == '__main__':
while True:
try:
pprint.pprint(dump_aps('wlp0s20f3mon'))
except:
pass