This commit is contained in:
dadav 2020-04-18 00:02:25 +02:00
parent 0b5a63a3d8
commit 6038f555fa
2 changed files with 13 additions and 18 deletions
pwnagotchi

@ -47,6 +47,8 @@ class Client(object):
logging.debug("Error while parsing event (%s)", ex) logging.debug("Error while parsing event (%s)", ex)
except websockets.exceptions.ConnectionClosedError: except websockets.exceptions.ConnectionClosedError:
logging.debug("Lost websocket connection. Reconnecting...") logging.debug("Lost websocket connection. Reconnecting...")
except websockets.exceptions.WebSocketException as wex:
logging.debug("Websocket exception (%s)", wex)
def run(self, command, verbose_errors=True): def run(self, command, verbose_errors=True):
r = requests.post("%s/session" % self.url, auth=self.auth, json={'cmd': command}) r = requests.post("%s/session" % self.url, auth=self.auth, json={'cmd': command})

@ -3,8 +3,6 @@ import logging
import re import re
import subprocess import subprocess
from io import TextIOWrapper from io import TextIOWrapper
from time import sleep
from threading import Lock
from pwnagotchi import plugins from pwnagotchi import plugins
@ -16,7 +14,6 @@ class Watchdog(plugins.Plugin):
def __init__(self): def __init__(self):
self.options = dict() self.options = dict()
self.lock = Lock()
self.pattern = re.compile(r'brcmf_cfg80211_nexmon_set_channel.*?Set Channel failed') self.pattern = re.compile(r'brcmf_cfg80211_nexmon_set_channel.*?Set Channel failed')
def on_loaded(self): def on_loaded(self):
@ -26,9 +23,6 @@ class Watchdog(plugins.Plugin):
logging.info("Watchdog plugin loaded.") logging.info("Watchdog plugin loaded.")
def on_epoch(self, agent, epoch, epoch_data): def on_epoch(self, agent, epoch, epoch_data):
if self.lock.locked():
return
with self.lock:
# get last 10 lines # get last 10 lines
last_lines = ''.join(list(TextIOWrapper(subprocess.Popen(['journalctl','-n10','-k'], last_lines = ''.join(list(TextIOWrapper(subprocess.Popen(['journalctl','-n10','-k'],
stdout=subprocess.PIPE).stdout))[-10:]) stdout=subprocess.PIPE).stdout))[-10:])
@ -37,7 +31,6 @@ class Watchdog(plugins.Plugin):
display.set('status', 'Blind-Bug detected. Restarting bettercap.') display.set('status', 'Blind-Bug detected. Restarting bettercap.')
display.update(force=True) display.update(force=True)
logging.info('[WATCHDOG] Blind-Bug detected. Restarting.') logging.info('[WATCHDOG] Blind-Bug detected. Restarting.')
mode_file = '/root/.pwnagotchi-manual' if agent.mode == 'manual' else '/root/.pwnagotchi-auto' mode = 'MANU' if agent.mode == 'manual' else 'AUTO'
os.system(f"touch {mode_file}") import pwnagotchi
os.system('systemctl restart bettercap') pwnagotchi.restart(mode=mode)
sleep(10)