forked from itsdarklikehell/pwnagotchi-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenable_assoc.py
81 lines (68 loc) · 2.48 KB
/
enable_assoc.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
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
class Do_Assoc(plugins.Plugin):
__GitHub__ = ""
__author__ = "(edited by: itsdarklikehell [email protected]), [email protected]"
__version__ = "1.0.0"
__license__ = "GPL3"
__description__ = "Enable and disable ASSOC on the fly. Enabled when plugin loads, disabled when plugin unloads."
__name__ = "Do_Assoc"
__help__ = "Enable and disable ASSOC on the fly. Enabled when plugin loads, disabled when plugin unloads."
__dependencies__ = {
"apt": ["none"],
"pip": ["scapy"],
}
__defaults__ = {
"enabled": False,
}
def __init__(self):
self.ready = False
logging.debug(f"[{self.__class__.__name__}] plugin init")
self.title = ""
self._agent = None
self._count = 0
def on_webhook(self, path, request):
pass
# called when the plugin is loaded
def on_loaded(self):
self._count = 0
logging.info(f"[{self.__class__.__name__}] plugin loaded")
# called before the plugin is unloaded
def on_unload(self, ui):
if self._agent:
self._agent._config["personality"]["associate"] = False
ui.remove_element("assoc_count")
logging.info(f"[{self.__class__.__name__}] plugin unloaded")
# called when everything is ready and the main loop is about to start
def on_ready(self, agent):
agent._config["personality"]["associate"] = True
self._agent = agent
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):
# 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)
ui.add_element(
"assoc_count",
LabeledValue(
color=BLACK,
label="A",
value="0",
position=pos,
label_font=fonts.BoldSmall,
text_font=fonts.Small,
),
)
# called when the ui is updated
def on_ui_update(self, ui):
# update those elements
ui.set("assoc_count", "%d" % (self._count))