-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenable_assocV2.py
More file actions
71 lines (58 loc) · 2.47 KB
/
enable_assocV2.py
File metadata and controls
71 lines (58 loc) · 2.47 KB
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
import os, sys
import logging
import pwnagotchi.plugins as plugins
from pwnagotchi.ui.components import LabeledValue
from pwnagotchi.ui.view import BLACK
import pwnagotchi.ui.fonts as fonts
#https://github.com/Sniffleupagus/pwnagotchi_plugins/pull/6
class enable_assocV2(plugins.Plugin):
__author__ = 'evilsocket@gmail.com'
__version__ = '1.0.2.2'
__editor__ = '(edited by Sniffleupagus then avipars)'
__license__ = 'GPL3'
__description__ = 'Enable and disable ASSOC on the fly. Enabled when plugin loads, disabled when plugin unloads. No Touch screen here'
def __init__(self):
self._agent = None
self._count = 0
# called when the plugin is loaded
def on_loaded(self):
self._count = 0
pass
# called before the plugin is unloaded
def on_unload(self, ui):
try:
if self._agent:
self._agent._config['personality']['associate'] = False
ui.remove_element('assoc_count')
logging.info(f"[{self.__class__.__name__}] unloading")
except Exception as e:
logging.warn(repr(e))
# called when everything is ready and the main loop is about to start
def on_ready(self, agent):
self._agent = agent
agent._config['personality']['associate'] = True
logging.info(f"[{self.__class__.__name__}] ready: enabled association")
def on_association(self, agent, access_point):
self._count += 1
# called to setup the ui elements
def on_ui_setup(self, ui):
self._ui = ui
# add custom UI elements
if "position" in self.options:
pos = self.options['position'].split(',')
pos = [int(x.strip()) for x in pos]
else:
pos = (0,29,30,59)
try:
ui.add_element('assoc_count', LabeledValue(color=BLACK, label='A', value='0', position=pos,
label_font=fonts.BoldSmall, text_font=fonts.Small))
except Exception as err:
logging.info(f"[{self.__class__.__name__}] ui error: {repr(err)}")
# called when the ui is updated
def on_ui_update(self, ui):
# update those elements
try:
ui.set('assoc_count', str(self._count)) # Update with current auth count
except Exception as err:
logging.info(
f"[{self.__class__.__name__}] ui error: %s" % repr(err))