Version 2.2.8

Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com>

Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com>
This commit is contained in:
Jeroen Oudshoorn
2023-09-05 13:22:06 +02:00
parent 78de8ff09c
commit 3c261a488c
2 changed files with 17 additions and 14 deletions

View File

@ -1 +1 @@
__version__ = '2.2.7' __version__ = '2.2.8'

View File

@ -43,10 +43,7 @@ class Fix_BRCMF(plugins.Plugin):
self.LASTTRY = 0 self.LASTTRY = 0
self._status = "--" self._status = "--"
self._count = 0 self._count = 0
self.last_lines = ''.join(list(TextIOWrapper(subprocess.Popen(['journalctl', '-n10', '-k'],
stdout=subprocess.PIPE).stdout))[-10:])
self.other_last_lines = ''.join(list(TextIOWrapper(subprocess.Popen(['journalctl', '-n10'],
stdout=subprocess.PIPE).stdout))[-10:])
def on_loaded(self): def on_loaded(self):
""" """
@ -56,6 +53,8 @@ class Fix_BRCMF(plugins.Plugin):
logging.info("[FixBRCMF] plugin loaded.") logging.info("[FixBRCMF] plugin loaded.")
def on_ready(self, agent): def on_ready(self, agent):
last_lines = ''.join(list(TextIOWrapper(subprocess.Popen(['journalctl', '-n10', '-k'],
stdout=subprocess.PIPE).stdout))[-10:])
try: try:
cmd_output = subprocess.check_output("ip link show wlan0mon", shell=True) cmd_output = subprocess.check_output("ip link show wlan0mon", shell=True)
logging.info("[FixBRCMF ip link show wlan0mon]: %s" % repr(cmd_output)) logging.info("[FixBRCMF ip link show wlan0mon]: %s" % repr(cmd_output))
@ -63,20 +62,20 @@ class Fix_BRCMF(plugins.Plugin):
logging.info("wlan0mon is up.") logging.info("wlan0mon is up.")
self._status = "up" self._status = "up"
if len(self.pattern.findall(self.last_lines)) >= 3: if len(self.pattern.findall(last_lines)) >= 3:
self._status = "XX" self._status = "XX"
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.info('[FixBRCMF] Blind-Bug detected. Restarting.\n%s' % repr(self.last_lines)) logging.info('[FixBRCMF] Blind-Bug detected. Restarting.\n%s' % repr(last_lines))
try: try:
self._tryTurningItOffAndOnAgain(agent) self._tryTurningItOffAndOnAgain(agent)
except Exception as err: except Exception as err:
logging.warning("[FixBRCMF turnOffAndOn] %s" % repr(err)) logging.warning("[FixBRCMF turnOffAndOn] %s" % repr(err))
else: else:
logging.info("[FixBRCMF] Logs look good, too:\n%s" % self.last_lines) logging.info("[FixBRCMF] Logs look good, too:\n%s" % last_lines)
self._status = "" self._status = ""
except Exception as err: except Exception as err:
@ -110,6 +109,10 @@ class Fix_BRCMF(plugins.Plugin):
logging.error("[FixBRCMF]SYSLOG wifi.recon flip fail: %s" % err) logging.error("[FixBRCMF]SYSLOG wifi.recon flip fail: %s" % err)
def on_epoch(self, agent, epoch, epoch_data): def on_epoch(self, agent, epoch, epoch_data):
last_lines = ''.join(list(TextIOWrapper(subprocess.Popen(['journalctl', '-n10', '-k'],
stdout=subprocess.PIPE).stdout))[-10:])
other_last_lines = ''.join(list(TextIOWrapper(subprocess.Popen(['journalctl', '-n10'],
stdout=subprocess.PIPE).stdout))[-10:])
# don't check if we ran a reset recently # don't check if we ran a reset recently
logging.debug("[FixBRCMF]**** epoch") logging.debug("[FixBRCMF]**** epoch")
if time.time() - self.LASTTRY > 180: if time.time() - self.LASTTRY > 180:
@ -119,8 +122,8 @@ class Fix_BRCMF(plugins.Plugin):
logging.debug("[FixBRCMF]**** checking") logging.debug("[FixBRCMF]**** checking")
# Look for pattern 1 # Look for pattern 1
if len(self.pattern.findall(self.last_lines)) >= 3: if len(self.pattern.findall(last_lines)) >= 3:
logging.info("[FixBRCMF]**** Should trigger a reload of the wlan0mon device:\n%s" % self.last_lines) logging.info("[FixBRCMF]**** 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.')
@ -132,7 +135,7 @@ class Fix_BRCMF(plugins.Plugin):
logging.warning("[FixBRCMF] TTOAOA: %s" % repr(err)) logging.warning("[FixBRCMF] TTOAOA: %s" % repr(err))
# Look for pattern 2 # Look for pattern 2
elif len(self.pattern2.findall(self.other_last_lines)) >= 5: elif len(self.pattern2.findall(other_last_lines)) >= 5:
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.')
@ -156,7 +159,7 @@ class Fix_BRCMF(plugins.Plugin):
logging.error("[FixBRCMF wifi.recon flip] %s" % repr(err)) logging.error("[FixBRCMF wifi.recon flip] %s" % repr(err))
# Look for pattern 3 # Look for pattern 3
elif len(self.pattern3.findall(self.other_last_lines)) >= 1: elif len(self.pattern3.findall(other_last_lines)) >= 1:
logging.info("[FixBRCMF] Firmware has halted or crashed. Restarting wlan0mon.") logging.info("[FixBRCMF] Firmware has halted or crashed. Restarting wlan0mon.")
if hasattr(agent, 'view'): if hasattr(agent, 'view'):
display = agent.view() display = agent.view()
@ -171,7 +174,7 @@ class Fix_BRCMF(plugins.Plugin):
logging.error("[FixBRCMF monstart]: %s" % repr(err)) logging.error("[FixBRCMF monstart]: %s" % repr(err))
# Look for pattern 4 # Look for pattern 4
elif len(self.pattern4.findall(self.other_last_lines)) >= 1: elif len(self.pattern4.findall(other_last_lines)) >= 1:
logging.info("[FixBRCMF] Having a brain meltdown. Deleting myself.") logging.info("[FixBRCMF] Having a brain meltdown. Deleting myself.")
if hasattr(agent, 'view'): if hasattr(agent, 'view'):
display = agent.view() display = agent.view()
@ -188,7 +191,7 @@ class Fix_BRCMF(plugins.Plugin):
logging.error("[FixBRCMF brain]: %s" % repr(err)) logging.error("[FixBRCMF brain]: %s" % repr(err))
# Look for pattern 5 # Look for pattern 5
elif len(self.pattern5.findall(self.other_last_lines)) >= 1: elif len(self.pattern5.findall(other_last_lines)) >= 1:
logging.info("[FixBRCMF] Bettercap connection failure. Restarting Bettercap.") logging.info("[FixBRCMF] Bettercap connection failure. Restarting Bettercap.")
if hasattr(agent, 'view'): if hasattr(agent, 'view'):
display = agent.view() display = agent.view()