-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpi_kismet.py
72 lines (66 loc) · 2.05 KB
/
pi_kismet.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
import sys, time
sys.path.append("/home/pi/Adafruit-Raspberry-Pi-Python-Code/Adafruit_CharLCDPlate")
sys.path.append("/home/pi/kismetclient")
from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate
from pi_kismet_display import KismetDisplay
from kismetclient import Client
from kismetclient import handlers
HOLD_TIME = 3.0
REFRESH_TIME = 5.0
display = KismetDisplay()
lcd = display.lcd
prevCol = -1
prev = -1
lastTime = time.time()
def shutdown():
lcd.clear()
exit(0)
total = wpa = wep = none = wps = 0
aps = []
k = Client()
def count_crypts(client, name, macaddr, cryptstring):
global aps, total, wpa, wep, none, wps
pairing = (name, macaddr)
if pairing not in aps:
aps.append(pairing)
if 'None' in cryptstring:
none += 1
elif 'WPA' in cryptstring:
wpa += 1
elif 'WEP' in cryptstring:
wep += 1
elif 'WPS' in cryptstring:
wpa += 1
wps += 1
elif cryptstring == '':
none += 1
total = len(aps)
k.register_handler('DEVICE', count_crypts)
# Listen for button presses
while True:
k.listen()
display.update_screens(wpa,wep,wps,none,total)
b = lcd.buttons()
if b is not prev:
if lcd.buttonPressed(lcd.SELECT):
tt = time.time() # Start time of button press
while lcd.buttonPressed(lcd.SELECT): # Wait for button release
if (time.time() - tt) >= HOLD_TIME: # Extended hold?
shutdown() # We're outta here
display.backlightStep()
elif lcd.buttonPressed(lcd.LEFT):
display.scrollRight()
elif lcd.buttonPressed(lcd.RIGHT):
display.scrollLeft()
elif lcd.buttonPressed(lcd.UP):
display.modeUp()
elif lcd.buttonPressed(lcd.DOWN):
display.modeDown()
prev = b
lastTime = time.time()
else:
now = time.time()
since = now - lastTime
if since > REFRESH_TIME or since < 0.0:
display.update()
lastTime = now