-
Notifications
You must be signed in to change notification settings - Fork 9
/
airodump.py
89 lines (69 loc) · 2.19 KB
/
airodump.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
#!/usr/bin/python
#
# Copyright (C), Attila Sukosd, BIT BLUEPRINT ApS ([email protected])
#
# The following is a wrapper around airodump-ng to collect information about wireless APs/clients
# http://www.aircrack-ng.org/doku.php?id=airodump-ng
#
import os,sys,time, traceback, subprocess
DEBUG=True
class AirodumpProcessor:
# Command to laucnh airodump-ng with:
CMD="airodump-ng --update 1 --berlin 20 mon0 2>&1"
# String that resets the terminal
#REFRESH_STR='\x1b[J\x1b[1;1H\n'
# String used to identify the list of clients
#CLIENT_LIST_STR=' BSSID STATION'
#AP_LIST_STR=' BSSID PWR'
###############################################
fd = None
ap_list_on = 0
client_list_on = 0
ap_list = {}
client_list = {}
def __init__(self):
pass
def start(self):
self.fd = subprocess.Popen(['airodump-ng', '--update', '1', '--berlin', '20', 'mon0'], bufsize=1, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
print "FD:",self.fd
if DEBUG: self.logger = sys.stdout #open("/logs/dump.log", "a")
def process(self):
if not self.fd:
self.start()
line = self.fd.stdout.readline()
if DEBUG: self.logger.write("Line:"+line.encode('ascii', errors='ignore')+"\n")
if not line:
return [None,None]
line = line.replace("\r", "").replace("\n", "").strip()
if line.startswith("CH "):
if DEBUG: self.logger.write("Got start!\n")
self.client_list_on = 0
self.ap_list_on = 0
cl = self.client_list
self.client_list = {}
aps = self.ap_list
self.ap_list = {}
return [aps, cl]
if len(line) < 1:
return [None,None]
try:
v = line.replace("(not associated)", "(not_associated)").split()
if len(v) < 6:
return [None, None]
if v[1].find(":") < 0:
return [None, None]
CLIENT = v[1]
if not self.client_list.has_key(CLIENT):
self.client_list[CLIENT] = {}
self.client_list[CLIENT]["ap"] = CLIENT
self.client_list[CLIENT]["client"] = v[1]
self.client_list[CLIENT]["pwr"] = v[2]
self.client_list[CLIENT]["rate"] = v[3]
self.client_list[CLIENT]["lost"] = v[4]
self.client_list[CLIENT]["packets"] = v[5]
except:
print "Failed,",line
traceback.print_exc()
return [None, None]
def stop(self):
self.fd.close()