Fix fix_services.py

Signed-off-by: jayofelony <oudshoorn.jeroen@gmail.com>
This commit is contained in:
jayofelony
2024-03-25 23:29:10 +01:00
parent 9287283ee7
commit 697a7778b1

View File

@ -5,7 +5,6 @@ import time
import random import random
from io import TextIOWrapper from io import TextIOWrapper
import os import os
import platform
import pwnagotchi import pwnagotchi
from pwnagotchi import plugins from pwnagotchi import plugins
@ -117,43 +116,41 @@ class FixServices(plugins.Plugin):
logging.debug("[Fix_Services]**** checking") logging.debug("[Fix_Services]**** checking")
# Look for pattern 1 # Look for pattern 1
if platform.machine().startswith('arm'): if len(self.pattern.findall(last_lines)) >= 3:
if len(self.pattern.findall(last_lines)) >= 3: logging.debug("[Fix_Services]**** Should trigger a reload of the wlan0mon device:\n%s" % last_lines)
logging.debug("[Fix_Services]**** Should trigger a reload of the wlan0mon device:\n%s" % last_lines) if hasattr(agent, 'view'):
if hasattr(agent, 'view'): display = agent.view()
display = agent.view() display.set('status', 'Blind-Bug detected. Restarting.')
display.set('status', 'Blind-Bug detected. Restarting.') display.update(force=True)
display.update(force=True) logging.debug('[Fix_Services] Blind-Bug detected. Restarting.')
logging.debug('[Fix_Services] Blind-Bug detected. Restarting.') try:
try: self._tryTurningItOffAndOnAgain(agent)
self._tryTurningItOffAndOnAgain(agent) except Exception as err:
except Exception as err: logging.warning("[Fix_Services] TTOAOA: %s" % repr(err))
logging.warning("[Fix_Services] TTOAOA: %s" % repr(err))
# Look for pattern 2 # Look for pattern 2
elif len(self.pattern2.findall(other_last_lines)) >= 5: elif len(self.pattern2.findall(other_last_lines)) >= 5:
if platform.machine().startswith('arm'): logging.debug("[Fix_Services]**** Should trigger a reload of the wlan0mon device:\n%s" % last_lines)
logging.debug("[Fix_Services]**** Should trigger a reload of the wlan0mon device:\n%s" % last_lines) if hasattr(agent, 'view'):
if hasattr(agent, 'view'): display = agent.view()
display = agent.view() display.set('status', 'Wifi channel stuck. Restarting recon.')
display.set('status', 'Wifi channel stuck. Restarting recon.') display.update(force=True)
display.update(force=True) logging.debug('[Fix_Services] Wifi channel stuck. Restarting recon.')
logging.debug('[Fix_Services] Wifi channel stuck. Restarting recon.')
try: try:
result = agent.run("wifi.recon off; wifi.recon on") result = agent.run("wifi.recon off; wifi.recon on")
if result["success"]: if result["success"]:
logging.debug("[Fix_Services] wifi.recon flip: success!") logging.debug("[Fix_Services] wifi.recon flip: success!")
if display: if display:
display.update(force=True, new_data={"status": "Wifi recon flipped!", display.update(force=True, new_data={"status": "Wifi recon flipped!",
"face": faces.COOL}) "face": faces.COOL})
else:
print("Wifi recon flipped\nthat was easy!")
else: else:
logging.warning("[Fix_Services] wifi.recon flip: FAILED: %s" % repr(result)) print("Wifi recon flipped\nthat was easy!")
else:
logging.warning("[Fix_Services] wifi.recon flip: FAILED: %s" % repr(result))
except Exception as err: except Exception as err:
logging.error("[Fix_Services wifi.recon flip] %s" % repr(err)) logging.error("[Fix_Services wifi.recon flip] %s" % repr(err))
# Look for pattern 3 # Look for pattern 3
elif len(self.pattern3.findall(other_last_lines)) >= 1: elif len(self.pattern3.findall(other_last_lines)) >= 1: