From 4852b3f59edc662df0b27f74ba5a5e62df0d7a65 Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Mon, 4 Nov 2019 17:41:27 +0100 Subject: [PATCH 1/4] Make bt-tet lil bit more verbose --- pwnagotchi/plugins/default/bt-tether.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pwnagotchi/plugins/default/bt-tether.py b/pwnagotchi/plugins/default/bt-tether.py index 89d87de..7300cbc 100644 --- a/pwnagotchi/plugins/default/bt-tether.py +++ b/pwnagotchi/plugins/default/bt-tether.py @@ -461,6 +461,7 @@ class BTTether(plugins.Plugin): logging.error("BT-TET: Can't start bluetooth.service") return + logging.info("BT-TETHER: Sussessfully loaded ...") self.ready = True def on_ui_setup(self, ui): From 537519dea67cabb6737dd917bd737a2cb0431f37 Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Mon, 4 Nov 2019 17:44:53 +0100 Subject: [PATCH 2/4] Fix typo --- pwnagotchi/plugins/default/bt-tether.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pwnagotchi/plugins/default/bt-tether.py b/pwnagotchi/plugins/default/bt-tether.py index 7300cbc..9710194 100644 --- a/pwnagotchi/plugins/default/bt-tether.py +++ b/pwnagotchi/plugins/default/bt-tether.py @@ -434,7 +434,7 @@ class BTTether(plugins.Plugin): 'max_tries', 'share_internet', 'mac', 'ip', 'netmask', 'interval']: if device_opt not in options or (device_opt in options and options[device_opt] is None): - logging.error("BT-TET: Pleace specify the %s for device %s.", + logging.error("BT-TET: Please specify the %s for device %s.", device_opt, device) break else: From 806efa1fc2f3991e2b7cd2aab6eb21732a85cf67 Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Mon, 4 Nov 2019 17:45:53 +0100 Subject: [PATCH 3/4] More consistency --- pwnagotchi/plugins/default/bt-tether.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pwnagotchi/plugins/default/bt-tether.py b/pwnagotchi/plugins/default/bt-tether.py index 9710194..ba19072 100644 --- a/pwnagotchi/plugins/default/bt-tether.py +++ b/pwnagotchi/plugins/default/bt-tether.py @@ -434,7 +434,7 @@ class BTTether(plugins.Plugin): 'max_tries', 'share_internet', 'mac', 'ip', 'netmask', 'interval']: if device_opt not in options or (device_opt in options and options[device_opt] is None): - logging.error("BT-TET: Please specify the %s for device %s.", + logging.error("BT-TETHER: Please specify the %s for device %s.", device_opt, device) break else: @@ -445,20 +445,20 @@ class BTTether(plugins.Plugin): if 'mac' in self.options: for opt in ['share_internet', 'mac', 'ip', 'netmask', 'interval']: if opt not in self.options or (opt in self.options and self.options[opt] is None): - logging.error("BT-TET: Please specify the %s in your config.yml.", opt) + logging.error("BT-TETHER: Please specify the %s in your config.yml.", opt) return self.devices['legacy'] = Device(name='legacy', **self.options) if not self.devices: - logging.error("BT-TET: No valid devices found") + logging.error("BT-TETHER: No valid devices found") return # ensure bluetooth is running bt_unit = SystemdUnitWrapper('bluetooth.service') if not bt_unit.is_active(): if not bt_unit.start(): - logging.error("BT-TET: Can't start bluetooth.service") + logging.error("BT-TETHER: Can't start bluetooth.service") return logging.info("BT-TETHER: Sussessfully loaded ...") From 86a3443b8d47ffd60e9bd1cd33721baa047a0c93 Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Mon, 4 Nov 2019 17:55:16 +0100 Subject: [PATCH 4/4] Handle exception if no Interface found --- pwnagotchi/plugins/default/bt-tether.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pwnagotchi/plugins/default/bt-tether.py b/pwnagotchi/plugins/default/bt-tether.py index ba19072..50cdd0d 100644 --- a/pwnagotchi/plugins/default/bt-tether.py +++ b/pwnagotchi/plugins/default/bt-tether.py @@ -519,14 +519,21 @@ class BTTether(plugins.Plugin): logging.debug('BT-TETHER: Try to create nap connection with %s ...', device.name) device.network, success = BTNap.nap(dev_remote) + interface = None if success: - if device.interface() is None: + try: + interface = device.interface() + except Exception: + logging.debug('BT-TETHER: Could not establish nap connection with %s', device.name) + continue + + if interface is None: ui.set('bluetooth', 'BE') logging.debug('BT-TETHER: Could not establish nap connection with %s', device.name) continue - logging.debug('BT-TETHER: Created interface (%s)', device.interface()) + logging.debug('BT-TETHER: Created interface (%s)', interface) ui.set('bluetooth', 'C') any_device_connected = True device.tries = 0 # reset tries @@ -535,7 +542,6 @@ class BTTether(plugins.Plugin): ui.set('bluetooth', 'NF') continue - interface = device.interface() addr = f"{device.ip}/{device.netmask}" gateway = ".".join(device.ip.split('.')[:-1] + ['1'])