diff --git a/builder/data/usr/bin/pwnlib b/builder/data/usr/bin/pwnlib index fdfc4bdd..a7728f75 100755 --- a/builder/data/usr/bin/pwnlib +++ b/builder/data/usr/bin/pwnlib @@ -37,7 +37,9 @@ reload_brcm() { # starts mon0 start_monitor_interface() { rfkill unblock all - airmon-ng start wlan0 + ifconfig wlan0 up + iw phy `iw dev wlan0 info | gawk '/wiphy/ {printf "phy" $2}'` interface add wlan0mon type monitor + ifconfig wlan0 down && ifconfig wlan0mon up } # stops mon0 diff --git a/builder/pwnagotchi.yml b/builder/pwnagotchi.yml index f71c070c..d0bb5886 100644 --- a/builder/pwnagotchi.yml +++ b/builder/pwnagotchi.yml @@ -255,7 +255,6 @@ block: | export GOPATH=$HOME/go export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin - insertafter: EOF when: golang.changed - name: Install bettercap v2.32.1 diff --git a/pwnagotchi/plugins/__init__.py b/pwnagotchi/plugins/__init__.py index 2606b727..f43a4140 100644 --- a/pwnagotchi/plugins/__init__.py +++ b/pwnagotchi/plugins/__init__.py @@ -1,15 +1,17 @@ import os import glob -import _thread import threading import importlib, importlib.util import logging +from concurrent.futures import ThreadPoolExecutor default_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "default") loaded = {} database = {} locks = {} +THREAD_POOL_SIZE = 10 +executor = ThreadPoolExecutor(max_workers=THREAD_POOL_SIZE) class Plugin: @classmethod @@ -28,7 +30,6 @@ class Plugin: if cb is not None and callable(cb): locks["%s::%s" % (plugin_name, attr_name)] = threading.Lock() - def toggle_plugin(name, enable=True): """ Load or unload a plugin @@ -67,12 +68,10 @@ def toggle_plugin(name, enable=True): return False - def on(event_name, *args, **kwargs): for plugin_name in loaded.keys(): one(plugin_name, event_name, *args, **kwargs) - def locked_cb(lock_name, cb, *args, **kwargs): global locks @@ -82,7 +81,6 @@ def locked_cb(lock_name, cb, *args, **kwargs): with locks[lock_name]: cb(*args, *kwargs) - def one(plugin_name, event_name, *args, **kwargs): global loaded @@ -94,12 +92,11 @@ def one(plugin_name, event_name, *args, **kwargs): try: lock_name = "%s::%s" % (plugin_name, cb_name) locked_cb_args = (lock_name, callback, *args, *kwargs) - _thread.start_new_thread(locked_cb, locked_cb_args) + executor.submit(locked_cb, *locked_cb_args) except Exception as e: logging.error("error while running %s.%s : %s" % (plugin_name, cb_name, e)) logging.error(e, exc_info=True) - def load_from_file(filename): logging.debug("loading %s" % filename) plugin_name = os.path.basename(filename.replace(".py", "")) @@ -108,7 +105,6 @@ def load_from_file(filename): spec.loader.exec_module(instance) return plugin_name, instance - def load_from_path(path, enabled=()): global loaded, database logging.debug("loading plugins from %s - enabled: %s" % (path, enabled)) @@ -124,7 +120,6 @@ def load_from_path(path, enabled=()): return loaded - def load(config): enabled = [name for name, options in config['main']['plugins'].items() if 'enabled' in options and options['enabled']] @@ -142,4 +137,4 @@ def load(config): plugin.options = config['main']['plugins'][name] on('loaded') - on('config_changed', config) \ No newline at end of file + on('config_changed', config)