fix
This commit is contained in:
parent
0b5a63a3d8
commit
6038f555fa
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,18 +23,14 @@ 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():
|
# get last 10 lines
|
||||||
return
|
last_lines = ''.join(list(TextIOWrapper(subprocess.Popen(['journalctl','-n10','-k'],
|
||||||
with self.lock:
|
stdout=subprocess.PIPE).stdout))[-10:])
|
||||||
# get last 10 lines
|
if len(self.pattern.findall(last_lines)) >= 3:
|
||||||
last_lines = ''.join(list(TextIOWrapper(subprocess.Popen(['journalctl','-n10','-k'],
|
display = agent.view()
|
||||||
stdout=subprocess.PIPE).stdout))[-10:])
|
display.set('status', 'Blind-Bug detected. Restarting bettercap.')
|
||||||
if len(self.pattern.findall(last_lines)) >= 3:
|
display.update(force=True)
|
||||||
display = agent.view()
|
logging.info('[WATCHDOG] Blind-Bug detected. Restarting.')
|
||||||
display.set('status', 'Blind-Bug detected. Restarting bettercap.')
|
mode = 'MANU' if agent.mode == 'manual' else 'AUTO'
|
||||||
display.update(force=True)
|
import pwnagotchi
|
||||||
logging.info('[WATCHDOG] Blind-Bug detected. Restarting.')
|
pwnagotchi.restart(mode=mode)
|
||||||
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)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user