From 0be91b6e2fa5cb92db752495e8b19a43c61443d8 Mon Sep 17 00:00:00 2001 From: Jeroen Oudshoorn Date: Wed, 6 Sep 2023 10:20:43 +0200 Subject: [PATCH] Version 2.3: Edited auto-update fix_services removed brain part __init__.py remove brain.nn if error occurs and restart pwnagotchi service Signed-off-by: Jeroen Oudshoorn --- pwnagotchi/_version.py | 2 +- pwnagotchi/ai/__init__.py | 4 +++- pwnagotchi/plugins/default/auto-update.py | 9 ++------- pwnagotchi/plugins/default/fix_services.py | 20 +------------------- 4 files changed, 7 insertions(+), 28 deletions(-) diff --git a/pwnagotchi/_version.py b/pwnagotchi/_version.py index 00c3889f6..93bbb90e9 100644 --- a/pwnagotchi/_version.py +++ b/pwnagotchi/_version.py @@ -1 +1 @@ -__version__ = '2.2.9' +__version__ = '2.3' diff --git a/pwnagotchi/ai/__init__.py b/pwnagotchi/ai/__init__.py index fedcc80a0..bce147b2e 100644 --- a/pwnagotchi/ai/__init__.py +++ b/pwnagotchi/ai/__init__.py @@ -18,7 +18,7 @@ def load(config, agent, epoch, from_disk=True): logging.info("[ai] bootstrapping dependencies ...") start = time.time() - SB_BACKEND = "stable_baselines3"; + SB_BACKEND = "stable_baselines3" try: from stable_baselines3 import A2C @@ -78,6 +78,8 @@ def load(config, agent, epoch, from_disk=True): return a2c except Exception as e: logging.exception("error while starting AI (%s)", e) + logging.info("Deleting brain and restarting.") + os.system("rm /root/brain.nn && systemctl restart pwnagotchi") logging.warning("[ai] AI not loaded!") return False diff --git a/pwnagotchi/plugins/default/auto-update.py b/pwnagotchi/plugins/default/auto-update.py index cc229d824..eac48f550 100644 --- a/pwnagotchi/plugins/default/auto-update.py +++ b/pwnagotchi/plugins/default/auto-update.py @@ -123,13 +123,8 @@ def install(display, update): if not os.path.exists(source_path): source_path = "%s-%s" % (source_path, update['available']) - if "pwngrid" in source_path: - os.system("cd %s && make && make install" % source_path) - elif "bettercap" in source_path: - os.system("cd %s && make && make install" % source_path) - else: - # setup.py is going to install data files for us - os.system("cd %s && pip3 install ." % source_path) + # setup.py is going to install data files for us + os.system("cd %s && pip3 install ." % source_path) return True diff --git a/pwnagotchi/plugins/default/fix_services.py b/pwnagotchi/plugins/default/fix_services.py index 485e44035..520261363 100644 --- a/pwnagotchi/plugins/default/fix_services.py +++ b/pwnagotchi/plugins/default/fix_services.py @@ -35,8 +35,7 @@ def __init__(self): self.options = dict() self.pattern = re.compile(r'brcmf_cfg80211_nexmon_set_channel.*?Set Channel failed') self.pattern2 = re.compile(r'wifi error while hopping to channel') - self.pattern3 = re.compile(r'error 400: could not find interface wlan0mon') - self.pattern4 = re.compile(r'AI not loaded!') + self.pattern3 = re.compile(r'Firmware has halted or crashed') self.isReloadingMon = False self.connection = None self.LASTTRY = 0 @@ -174,23 +173,6 @@ def on_epoch(self, agent, epoch, epoch_data): except Exception as err: logging.error("[FixBRCMF monstart]: %s" % repr(err)) - # Look for pattern 4 - elif len(self.pattern4.findall(other_other_last_lines)) >= 1: - logging.info("[FixBRCMF] Having a brain meltdown. Deleting myself.") - if hasattr(agent, 'view'): - display = agent.view() - if display: display.update(force=True, - new_data={"status": "Having a brain meltdown. Deleting myself.", - "face": faces.SAD}) - try: - # Delete brain /root/brain.nn and restarting pwnagotchi service - cmd_output = subprocess.check_output("rm /root/brain.nn && systemctl restart pwnagotchi", - shell=True) - self._status = "up" - logging.info("[FixBRCMF brain]: %s" % repr(cmd_output)) - except Exception as err: - logging.error("[FixBRCMF brain]: %s" % repr(err)) - else: print("logs look good")