From 70bffe52001cc951814219a3f791008428ac707e Mon Sep 17 00:00:00 2001 From: Sniffleupagus Date: Tue, 4 Apr 2023 14:11:23 -0700 Subject: [PATCH] changes to support plugins requesting parts of session, and get notice of events --- pwnagotchi/agent.py | 6 ++++++ pwnagotchi/bettercap.py | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pwnagotchi/agent.py b/pwnagotchi/agent.py index 7fe6a76d..429b0ab1 100644 --- a/pwnagotchi/agent.py +++ b/pwnagotchi/agent.py @@ -324,6 +324,12 @@ class Agent(Client, Automata, AsyncAdvertiser, AsyncTrainer): found_handshake = False jmsg = json.loads(msg) + # give plugins access to the events + try: + plugins.on('bcap_%s' % re.sub(r"[^a-z0-9_]+", "_", jmsg['tag'].lower()), self, jmsg) + except Exception as err: + logging.error("Processing event: %s" % err) + if jmsg['tag'] == 'wifi.client.handshake': filename = jmsg['data']['file'] sta_mac = jmsg['data']['station'] diff --git a/pwnagotchi/bettercap.py b/pwnagotchi/bettercap.py index 1f9217d0..592ac5c2 100644 --- a/pwnagotchi/bettercap.py +++ b/pwnagotchi/bettercap.py @@ -31,8 +31,10 @@ class Client(object): self.websocket = "ws://%s:%s@%s:%d/api" % (username, password, hostname, port) self.auth = HTTPBasicAuth(username, password) - def session(self): - r = requests.get("%s/session" % self.url, auth=self.auth) + # session takes optional argument to pull a sub-dictionary + # ex.: "session/wifi", "session/ble" + def session(self, sess="session"): + r = requests.get("%s/%s" % (self.url, sess), auth=self.auth) return decode(r) async def start_websocket(self, consumer):