From 3773f96901a5b2f398f098e530023290c66d2bc9 Mon Sep 17 00:00:00 2001 From: Casey Diemel Date: Sat, 12 Oct 2019 16:49:52 -0400 Subject: [PATCH 1/6] Updated on() to allow return values modified line 21 added line 22-23 Signed-off-by: Casey Diemel --- pwnagotchi/plugins/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pwnagotchi/plugins/__init__.py b/pwnagotchi/plugins/__init__.py index 6dd7b648..7faa5531 100644 --- a/pwnagotchi/plugins/__init__.py +++ b/pwnagotchi/plugins/__init__.py @@ -18,7 +18,9 @@ def on(event_name, *args, **kwargs): if cb_name in plugin.__dict__: # print("calling %s %s(%s)" %(cb_name, args, kwargs)) try: - plugin.__dict__[cb_name](*args, **kwargs) + ret_val = plugin.__dict__[cb_name](*args, **kwargs) + if ret_val is not None: + return ret_val except Exception as e: logging.error("error while running %s.%s : %s" % (plugin_name, cb_name, e)) From 308746a7de4038a7d1363e89188bc9d452b591b5 Mon Sep 17 00:00:00 2001 From: Casey Diemel Date: Sun, 13 Oct 2019 13:54:22 -0400 Subject: [PATCH 2/6] removed plugin.on() return value as is not needed Signed-off-by: Casey Diemel --- pwnagotchi/plugins/__init__.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pwnagotchi/plugins/__init__.py b/pwnagotchi/plugins/__init__.py index 7faa5531..6dd7b648 100644 --- a/pwnagotchi/plugins/__init__.py +++ b/pwnagotchi/plugins/__init__.py @@ -18,9 +18,7 @@ def on(event_name, *args, **kwargs): if cb_name in plugin.__dict__: # print("calling %s %s(%s)" %(cb_name, args, kwargs)) try: - ret_val = plugin.__dict__[cb_name](*args, **kwargs) - if ret_val is not None: - return ret_val + plugin.__dict__[cb_name](*args, **kwargs) except Exception as e: logging.error("error while running %s.%s : %s" % (plugin_name, cb_name, e)) From 2bbcc36f2aea0cc427e23ccc968d7dff492c18e6 Mon Sep 17 00:00:00 2001 From: Casey Diemel Date: Sun, 13 Oct 2019 13:57:45 -0400 Subject: [PATCH 3/6] added unfiltered ap list call back Signed-off-by: Casey Diemel --- pwnagotchi/agent.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pwnagotchi/agent.py b/pwnagotchi/agent.py index 41680df7..f8c8ff9a 100644 --- a/pwnagotchi/agent.py +++ b/pwnagotchi/agent.py @@ -190,6 +190,7 @@ class Agent(Client, AsyncAdvertiser, AsyncTrainer): aps = [] try: s = self.session() + plugins.on("unfiltered_ap_list", s['wifi']['aps']) for ap in s['wifi']['aps']: if ap['hostname'] not in whitelist: if self._filter_included(ap): From d15f8c18b51c1c794f45800aa6ccbb5da1836e0a Mon Sep 17 00:00:00 2001 From: Casey Diemel Date: Sun, 13 Oct 2019 17:52:41 -0400 Subject: [PATCH 4/6] updated function call Signed-off-by: Casey Diemel --- pwnagotchi/agent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pwnagotchi/agent.py b/pwnagotchi/agent.py index f8c8ff9a..497c91ed 100644 --- a/pwnagotchi/agent.py +++ b/pwnagotchi/agent.py @@ -190,7 +190,7 @@ class Agent(Client, AsyncAdvertiser, AsyncTrainer): aps = [] try: s = self.session() - plugins.on("unfiltered_ap_list", s['wifi']['aps']) + plugins.on("unfiltered_ap_list", self, s['wifi']['aps']) for ap in s['wifi']['aps']: if ap['hostname'] not in whitelist: if self._filter_included(ap): From 9aca3a3a5b0af6d8fa0788065f0991ca0bcfa197 Mon Sep 17 00:00:00 2001 From: Casey Diemel Date: Sun, 13 Oct 2019 17:53:18 -0400 Subject: [PATCH 5/6] added example for testing Signed-off-by: Casey Diemel --- .../plugins/default/unfiltered_example.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 pwnagotchi/plugins/default/unfiltered_example.py diff --git a/pwnagotchi/plugins/default/unfiltered_example.py b/pwnagotchi/plugins/default/unfiltered_example.py new file mode 100644 index 00000000..c4f9fba3 --- /dev/null +++ b/pwnagotchi/plugins/default/unfiltered_example.py @@ -0,0 +1,18 @@ +__author__ = 'diemelcw@gmail.com' +__version__ = '1.0.0' +__name__ = 'unfiltered_example' +__license__ = 'GPL3' +__description__ = 'An example plugin for pwnagotchi that implements on_unfiltered_ap_list(agent,aps)' + +import logging + +# Will be set with the options in config.yml config['main']['plugins'][__name__] +OPTIONS = dict() + +# called when AP list is ready, before whitelist filtering has occured +def on_unfiltered_ap_list(agent,aps): + logging.info("Unfiltered AP list to follow") + for ap in aps: + logging.info(ap['hostname']) + + ## Additional logic here ## From dfb4bcaf21f1c41acbebb9f692973d7bda28e8af Mon Sep 17 00:00:00 2001 From: Casey Diemel Date: Sun, 13 Oct 2019 18:13:25 -0400 Subject: [PATCH 6/6] added on_loaded function Signed-off-by: Casey Diemel --- pwnagotchi/plugins/default/unfiltered_example.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pwnagotchi/plugins/default/unfiltered_example.py b/pwnagotchi/plugins/default/unfiltered_example.py index c4f9fba3..c883b7c0 100644 --- a/pwnagotchi/plugins/default/unfiltered_example.py +++ b/pwnagotchi/plugins/default/unfiltered_example.py @@ -9,6 +9,10 @@ import logging # Will be set with the options in config.yml config['main']['plugins'][__name__] OPTIONS = dict() +# called when the plugin is loaded +def on_loaded(): + logging.warning("%s plugin loaded" % __name__) + # called when AP list is ready, before whitelist filtering has occured def on_unfiltered_ap_list(agent,aps): logging.info("Unfiltered AP list to follow")