fix
This commit is contained in:
parent
0b5a63a3d8
commit
6038f555fa
@ -47,6 +47,8 @@ class Client(object):
|
||||
logging.debug("Error while parsing event (%s)", ex)
|
||||
except websockets.exceptions.ConnectionClosedError:
|
||||
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):
|
||||
r = requests.post("%s/session" % self.url, auth=self.auth, json={'cmd': command})
|
||||
|
@ -3,8 +3,6 @@ import logging
|
||||
import re
|
||||
import subprocess
|
||||
from io import TextIOWrapper
|
||||
from time import sleep
|
||||
from threading import Lock
|
||||
from pwnagotchi import plugins
|
||||
|
||||
|
||||
@ -16,7 +14,6 @@ class Watchdog(plugins.Plugin):
|
||||
|
||||
def __init__(self):
|
||||
self.options = dict()
|
||||
self.lock = Lock()
|
||||
self.pattern = re.compile(r'brcmf_cfg80211_nexmon_set_channel.*?Set Channel failed')
|
||||
|
||||
def on_loaded(self):
|
||||
@ -26,18 +23,14 @@ class Watchdog(plugins.Plugin):
|
||||
logging.info("Watchdog plugin loaded.")
|
||||
|
||||
def on_epoch(self, agent, epoch, epoch_data):
|
||||
if self.lock.locked():
|
||||
return
|
||||
with self.lock:
|
||||
# get last 10 lines
|
||||
last_lines = ''.join(list(TextIOWrapper(subprocess.Popen(['journalctl','-n10','-k'],
|
||||
stdout=subprocess.PIPE).stdout))[-10:])
|
||||
if len(self.pattern.findall(last_lines)) >= 3:
|
||||
display = agent.view()
|
||||
display.set('status', 'Blind-Bug detected. Restarting bettercap.')
|
||||
display.update(force=True)
|
||||
logging.info('[WATCHDOG] Blind-Bug detected. Restarting.')
|
||||
mode_file = '/root/.pwnagotchi-manual' if agent.mode == 'manual' else '/root/.pwnagotchi-auto'
|
||||
os.system(f"touch {mode_file}")
|
||||
os.system('systemctl restart bettercap')
|
||||
sleep(10)
|
||||
# get last 10 lines
|
||||
last_lines = ''.join(list(TextIOWrapper(subprocess.Popen(['journalctl','-n10','-k'],
|
||||
stdout=subprocess.PIPE).stdout))[-10:])
|
||||
if len(self.pattern.findall(last_lines)) >= 3:
|
||||
display = agent.view()
|
||||
display.set('status', 'Blind-Bug detected. Restarting bettercap.')
|
||||
display.update(force=True)
|
||||
logging.info('[WATCHDOG] Blind-Bug detected. Restarting.')
|
||||
mode = 'MANU' if agent.mode == 'manual' else 'AUTO'
|
||||
import pwnagotchi
|
||||
pwnagotchi.restart(mode=mode)
|
||||
|
Loading…
x
Reference in New Issue
Block a user