Skip to content

Commit

Permalink
Version 2.3:
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jayofelony committed Sep 6, 2023
1 parent 7a7b700 commit 0be91b6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 28 deletions.
2 changes: 1 addition & 1 deletion pwnagotchi/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.2.9'
__version__ = '2.3'
4 changes: 3 additions & 1 deletion pwnagotchi/ai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
9 changes: 2 additions & 7 deletions pwnagotchi/plugins/default/auto-update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 1 addition & 19 deletions pwnagotchi/plugins/default/fix_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")

Expand Down

0 comments on commit 0be91b6

Please sign in to comment.