mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
@ -1 +1 @@
|
|||||||
__version__ = '2.3.9b'
|
__version__ = '2.4.x'
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
main.name = ""
|
main.name = "pwnagotchi"
|
||||||
main.lang = "en"
|
main.lang = "en"
|
||||||
main.confd = "/etc/pwnagotchi/conf.d/"
|
main.confd = "/etc/pwnagotchi/conf.d/"
|
||||||
main.custom_plugin_repos = [
|
main.custom_plugin_repos = [
|
||||||
|
@ -60,14 +60,13 @@ class BluetoothSniffer(plugins.Plugin):
|
|||||||
ui.remove_element('BtS')
|
ui.remove_element('BtS')
|
||||||
|
|
||||||
def on_ui_update(self, ui):
|
def on_ui_update(self, ui):
|
||||||
with ui._lock:
|
current_time = time.time()
|
||||||
current_time = time.time()
|
# Checking the time elapsed since last scan
|
||||||
# Checking the time elapsed since last scan
|
if current_time - self.last_scan_time >= self.options['timer']:
|
||||||
if current_time - self.last_scan_time >= self.options['timer']:
|
self.last_scan_time = current_time
|
||||||
self.last_scan_time = current_time
|
# logging.info("[BtS] Bluetooth sniffed: %s", str(self.bt_sniff_info()))
|
||||||
# logging.info("[BtS] Bluetooth sniffed: %s", str(self.bt_sniff_info()))
|
ui.set('BtS', str(self.bt_sniff_info()))
|
||||||
ui.set('BtS', str(self.bt_sniff_info()))
|
self.scan(ui)
|
||||||
self.scan(ui)
|
|
||||||
|
|
||||||
# Method for scanning the nearby bluetooth devices
|
# Method for scanning the nearby bluetooth devices
|
||||||
def scan(self, display):
|
def scan(self, display):
|
||||||
|
@ -583,5 +583,4 @@ class BTTether(plugins.Plugin):
|
|||||||
label_font=fonts.Bold, text_font=fonts.Medium))
|
label_font=fonts.Bold, text_font=fonts.Medium))
|
||||||
|
|
||||||
def on_ui_update(self, ui):
|
def on_ui_update(self, ui):
|
||||||
with ui._lock:
|
ui.set('bluetooth', self.status)
|
||||||
ui.set('bluetooth', self.status)
|
|
||||||
|
@ -17,8 +17,8 @@ import pwnagotchi.ui.fonts as fonts
|
|||||||
|
|
||||||
|
|
||||||
class FixServices(plugins.Plugin):
|
class FixServices(plugins.Plugin):
|
||||||
__author__ = 'xBits'
|
__author__ = 'jayofelony'
|
||||||
__version__ = '0.1.1'
|
__version__ = '1.0'
|
||||||
__license__ = 'GPL3'
|
__license__ = 'GPL3'
|
||||||
__description__ = 'Fix blindness, firmware crashes and brain not being loaded'
|
__description__ = 'Fix blindness, firmware crashes and brain not being loaded'
|
||||||
__name__ = 'Fix_Services'
|
__name__ = 'Fix_Services'
|
||||||
@ -38,6 +38,7 @@ class FixServices(plugins.Plugin):
|
|||||||
self.pattern2 = re.compile(r'wifi error while hopping to channel')
|
self.pattern2 = re.compile(r'wifi error while hopping to channel')
|
||||||
self.pattern3 = re.compile(r'Firmware has halted or crashed')
|
self.pattern3 = re.compile(r'Firmware has halted or crashed')
|
||||||
self.pattern4 = re.compile(r'error 400: could not find interface wlan0mon')
|
self.pattern4 = re.compile(r'error 400: could not find interface wlan0mon')
|
||||||
|
self.pattern5 = re.compile(r'connection to the bettercap endpoint failed')
|
||||||
self.isReloadingMon = False
|
self.isReloadingMon = False
|
||||||
self.connection = None
|
self.connection = None
|
||||||
self.LASTTRY = 0
|
self.LASTTRY = 0
|
||||||
@ -98,7 +99,8 @@ class FixServices(plugins.Plugin):
|
|||||||
logging.info("[Fix_Services] wifi.recon flip: success!")
|
logging.info("[Fix_Services] wifi.recon flip: success!")
|
||||||
if hasattr(agent, 'view'):
|
if hasattr(agent, 'view'):
|
||||||
display = agent.view()
|
display = agent.view()
|
||||||
if display: display.update(force=True, new_data={"status": "Wifi recon flipped!",
|
if display:
|
||||||
|
display.update(force=True, new_data={"status": "Wifi recon flipped!",
|
||||||
"face": faces.COOL})
|
"face": faces.COOL})
|
||||||
else:
|
else:
|
||||||
print("Wifi recon flipped")
|
print("Wifi recon flipped")
|
||||||
@ -189,6 +191,20 @@ class FixServices(plugins.Plugin):
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
logging.error("[Fix_Services monstart]: %s" % repr(err))
|
logging.error("[Fix_Services monstart]: %s" % repr(err))
|
||||||
|
|
||||||
|
# Look for pattern 5
|
||||||
|
elif len(self.pattern5.findall(other_other_last_lines)) >= 3:
|
||||||
|
logging.info("[Fix_Services] bettercap is down!")
|
||||||
|
if hasattr(agent, 'view'):
|
||||||
|
display = agent.view()
|
||||||
|
display.set('status', 'Restarting wlan0 now!')
|
||||||
|
display.update(force=True)
|
||||||
|
try:
|
||||||
|
# Restart bettercap/pwnagotchi
|
||||||
|
logging.info("[Fix_Services restarting]")
|
||||||
|
pwnagotchi.restart("AUTO")
|
||||||
|
except Exception as err:
|
||||||
|
logging.error("[Fix_Services restarting]: %s" % repr(err))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("logs look good")
|
print("logs look good")
|
||||||
|
|
||||||
@ -224,7 +240,8 @@ class FixServices(plugins.Plugin):
|
|||||||
self._status = "BL"
|
self._status = "BL"
|
||||||
if hasattr(connection, 'view'):
|
if hasattr(connection, 'view'):
|
||||||
display = connection.view()
|
display = connection.view()
|
||||||
if display: display.update(force=True, new_data={"status": "I'm blind! Try turning it off and on again",
|
if display:
|
||||||
|
display.update(force=True, new_data={"status": "I'm blind! Try turning it off and on again",
|
||||||
"brcmfmac_status": self._status,
|
"brcmfmac_status": self._status,
|
||||||
"face": faces.BORED})
|
"face": faces.BORED})
|
||||||
else:
|
else:
|
||||||
@ -312,7 +329,7 @@ class FixServices(plugins.Plugin):
|
|||||||
# try accessing mon0 in bettercap
|
# try accessing mon0 in bettercap
|
||||||
result = connection.run("set wifi.interface wlan0mon")
|
result = connection.run("set wifi.interface wlan0mon")
|
||||||
if "success" in result:
|
if "success" in result:
|
||||||
logging.info("[Fix_Services set wifi.interface wlan0mon] worked: %s" % repr(result))
|
logging.info("[Fix_Services set wifi.interface wlan0mon] worked!")
|
||||||
self._status = ""
|
self._status = ""
|
||||||
self._count = self._count + 1
|
self._count = self._count + 1
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
@ -325,21 +342,25 @@ class FixServices(plugins.Plugin):
|
|||||||
logging.info(
|
logging.info(
|
||||||
"[Fix_Services set wifi.interface wlan0mon] except: %s" % repr(err))
|
"[Fix_Services set wifi.interface wlan0mon] except: %s" % repr(err))
|
||||||
except Exception as cerr: #
|
except Exception as cerr: #
|
||||||
if not display: print("failed loading wlan0mon attempt #%s: %s" % (tries, repr(cerr)))
|
if not display:
|
||||||
|
print("failed loading wlan0mon attempt #%s: %s" % (tries, repr(cerr)))
|
||||||
except Exception as err: # from modprobe
|
except Exception as err: # from modprobe
|
||||||
if not display: print("Failed reloading brcmfmac")
|
if not display:
|
||||||
|
print("Failed reloading brcmfmac")
|
||||||
logging.error("[Fix_Services] Failed reloading brcmfmac %s" % repr(err))
|
logging.error("[Fix_Services] Failed reloading brcmfmac %s" % repr(err))
|
||||||
|
|
||||||
except Exception as nope: # from modprobe -r
|
except Exception as nope: # from modprobe -r
|
||||||
# fails if already unloaded, so probably fine
|
# fails if already unloaded, so probably fine
|
||||||
logging.error("[Fix_Services #%s modprobe -r] %s" % (tries, repr(nope)))
|
logging.error("[Fix_Services #%s modprobe -r] %s" % (tries, repr(nope)))
|
||||||
if not display: print("[Fix_Services #%s modprobe -r] %s" % (tries, repr(nope)))
|
if not display:
|
||||||
|
print("[Fix_Services #%s modprobe -r] %s" % (tries, repr(nope)))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
tries = tries + 1
|
tries = tries + 1
|
||||||
if tries < 3:
|
if tries < 3:
|
||||||
logging.info("[Fix_Services] wlan0mon didn't make it. trying again")
|
logging.info("[Fix_Services] wlan0mon didn't make it. trying again")
|
||||||
if not display: print(" wlan0mon didn't make it. trying again")
|
if not display:
|
||||||
|
print(" wlan0mon didn't make it. trying again")
|
||||||
|
|
||||||
# exited the loop, so hopefully it loaded
|
# exited the loop, so hopefully it loaded
|
||||||
if tries < 3:
|
if tries < 3:
|
||||||
@ -363,15 +384,15 @@ class FixServices(plugins.Plugin):
|
|||||||
if "success" in result: # and result["success"] is True:
|
if "success" in result: # and result["success"] is True:
|
||||||
self._status = ""
|
self._status = ""
|
||||||
if display:
|
if display:
|
||||||
display.update(force=True, new_data={"status": "I can see again! (probably): %s" % repr(result),
|
display.update(force=True, new_data={"status": "I can see again! (probably)",
|
||||||
"brcmfmac_status": self._status,
|
"brcmfmac_status": self._status,
|
||||||
"face": faces.HAPPY})
|
"face": faces.HAPPY})
|
||||||
else:
|
else:
|
||||||
print("I can see again")
|
print("I can see again")
|
||||||
logging.info("[Fix_Services] wifi.recon on %s" % repr(result))
|
logging.info("[Fix_Services] wifi.recon on")
|
||||||
self.LASTTRY = time.time() + 120 # 2-minute pause until next time.
|
self.LASTTRY = time.time() + 120 # 2-minute pause until next time.
|
||||||
else:
|
else:
|
||||||
logging.error("[Fix_Services] wifi.recon did not start up: %s" % repr(result))
|
logging.error("[Fix_Services] wifi.recon did not start up")
|
||||||
self.LASTTRY = time.time() - 300 # failed, so try again ASAP
|
self.LASTTRY = time.time() - 300 # failed, so try again ASAP
|
||||||
self.isReloadingMon = False
|
self.isReloadingMon = False
|
||||||
|
|
||||||
@ -393,12 +414,11 @@ class FixServices(plugins.Plugin):
|
|||||||
|
|
||||||
# called when the ui is updated
|
# called when the ui is updated
|
||||||
def on_ui_update(self, ui):
|
def on_ui_update(self, ui):
|
||||||
with ui._lock:
|
# update those elements
|
||||||
# update those elements
|
if self._status:
|
||||||
if self._status:
|
ui.set('brcmfmac_status', "wlan0mon %s" % self._status)
|
||||||
ui.set('brcmfmac_status', "wlan0mon %s" % self._status)
|
else:
|
||||||
else:
|
ui.set('brcmfmac_status', "rst#%s" % self._count)
|
||||||
ui.set('brcmfmac_status', "rst#%s" % self._count)
|
|
||||||
|
|
||||||
def on_unload(self, ui):
|
def on_unload(self, ui):
|
||||||
with ui._lock:
|
with ui._lock:
|
||||||
|
@ -103,91 +103,90 @@ class MemTemp(plugins.Plugin):
|
|||||||
return " " * (self.FIELD_WIDTH - len(data)) + data
|
return " " * (self.FIELD_WIDTH - len(data)) + data
|
||||||
|
|
||||||
def on_ui_setup(self, ui):
|
def on_ui_setup(self, ui):
|
||||||
with ui._lock:
|
try:
|
||||||
try:
|
# Configure field list
|
||||||
# Configure field list
|
self.fields = self.options['fields'].split(',')
|
||||||
self.fields = self.options['fields'].split(',')
|
self.fields = [x.strip() for x in self.fields if x.strip() in self.ALLOWED_FIELDS.keys()]
|
||||||
self.fields = [x.strip() for x in self.fields if x.strip() in self.ALLOWED_FIELDS.keys()]
|
self.fields = self.fields[:3] # limit to the first 3 fields
|
||||||
self.fields = self.fields[:3] # limit to the first 3 fields
|
except Exception:
|
||||||
except Exception:
|
# Set default value
|
||||||
# Set default value
|
self.fields = self.DEFAULT_FIELDS
|
||||||
self.fields = self.DEFAULT_FIELDS
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Configure line_spacing
|
# Configure line_spacing
|
||||||
line_spacing = int(self.options['linespacing'])
|
line_spacing = int(self.options['linespacing'])
|
||||||
except Exception:
|
except Exception:
|
||||||
# Set default value
|
# Set default value
|
||||||
line_spacing = self.LINE_SPACING
|
line_spacing = self.LINE_SPACING
|
||||||
|
|
||||||
try:
|
|
||||||
# Configure position
|
|
||||||
pos = self.options['position'].split(',')
|
|
||||||
pos = [int(x.strip()) for x in pos]
|
|
||||||
if self.options['orientation'] == "vertical":
|
|
||||||
v_pos = (pos[0], pos[1])
|
|
||||||
else:
|
|
||||||
h_pos = (pos[0], pos[1])
|
|
||||||
except Exception:
|
|
||||||
# Set default position based on screen type
|
|
||||||
if ui.is_waveshare_v2():
|
|
||||||
h_pos = (178, 84)
|
|
||||||
v_pos = (197, 74)
|
|
||||||
elif ui.is_waveshare_v1():
|
|
||||||
h_pos = (170, 80)
|
|
||||||
v_pos = (165, 61)
|
|
||||||
elif ui.is_waveshare144lcd():
|
|
||||||
h_pos = (53, 77)
|
|
||||||
v_pos = (73, 67)
|
|
||||||
elif ui.is_inky():
|
|
||||||
h_pos = (140, 68)
|
|
||||||
v_pos = (160, 54)
|
|
||||||
elif ui.is_waveshare27inch():
|
|
||||||
h_pos = (192, 138)
|
|
||||||
v_pos = (211, 122)
|
|
||||||
else:
|
|
||||||
h_pos = (155, 76)
|
|
||||||
v_pos = (175, 61)
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Configure position
|
||||||
|
pos = self.options['position'].split(',')
|
||||||
|
pos = [int(x.strip()) for x in pos]
|
||||||
if self.options['orientation'] == "vertical":
|
if self.options['orientation'] == "vertical":
|
||||||
# Dynamically create the required LabeledValue objects
|
v_pos = (pos[0], pos[1])
|
||||||
for idx, field in enumerate(self.fields):
|
|
||||||
v_pos_x = v_pos[0]
|
|
||||||
v_pos_y = v_pos[1] + ((len(self.fields) - 3) * -1 * line_spacing)
|
|
||||||
ui.add_element(
|
|
||||||
f"memtemp_{field}",
|
|
||||||
LabeledValue(
|
|
||||||
color=BLACK,
|
|
||||||
label=f"{self.pad_text(field)}:",
|
|
||||||
value="-",
|
|
||||||
position=(v_pos_x, v_pos_y + (idx * line_spacing)),
|
|
||||||
label_font=fonts.Small,
|
|
||||||
text_font=fonts.Small,
|
|
||||||
label_spacing=self.LABEL_SPACING,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
# default to horizontal
|
h_pos = (pos[0], pos[1])
|
||||||
h_pos_x = h_pos[0] + ((len(self.fields) - 3) * -1 * 25)
|
except Exception:
|
||||||
h_pos_y = h_pos[1]
|
# Set default position based on screen type
|
||||||
|
if ui.is_waveshare_v2():
|
||||||
|
h_pos = (178, 84)
|
||||||
|
v_pos = (197, 74)
|
||||||
|
elif ui.is_waveshare_v1():
|
||||||
|
h_pos = (170, 80)
|
||||||
|
v_pos = (165, 61)
|
||||||
|
elif ui.is_waveshare144lcd():
|
||||||
|
h_pos = (53, 77)
|
||||||
|
v_pos = (73, 67)
|
||||||
|
elif ui.is_inky():
|
||||||
|
h_pos = (140, 68)
|
||||||
|
v_pos = (160, 54)
|
||||||
|
elif ui.is_waveshare27inch():
|
||||||
|
h_pos = (192, 138)
|
||||||
|
v_pos = (211, 122)
|
||||||
|
else:
|
||||||
|
h_pos = (155, 76)
|
||||||
|
v_pos = (175, 61)
|
||||||
|
|
||||||
|
if self.options['orientation'] == "vertical":
|
||||||
|
# Dynamically create the required LabeledValue objects
|
||||||
|
for idx, field in enumerate(self.fields):
|
||||||
|
v_pos_x = v_pos[0]
|
||||||
|
v_pos_y = v_pos[1] + ((len(self.fields) - 3) * -1 * line_spacing)
|
||||||
ui.add_element(
|
ui.add_element(
|
||||||
'memtemp_header',
|
f"memtemp_{field}",
|
||||||
Text(
|
LabeledValue(
|
||||||
color=BLACK,
|
color=BLACK,
|
||||||
value=" ".join([self.pad_text(x) for x in self.fields]),
|
label=f"{self.pad_text(field)}:",
|
||||||
position=(h_pos_x, h_pos_y),
|
value="-",
|
||||||
font=fonts.Small,
|
position=(v_pos_x, v_pos_y + (idx * line_spacing)),
|
||||||
|
label_font=fonts.Small,
|
||||||
|
text_font=fonts.Small,
|
||||||
|
label_spacing=self.LABEL_SPACING,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
ui.add_element(
|
else:
|
||||||
'memtemp_data',
|
# default to horizontal
|
||||||
Text(
|
h_pos_x = h_pos[0] + ((len(self.fields) - 3) * -1 * 25)
|
||||||
color=BLACK,
|
h_pos_y = h_pos[1]
|
||||||
value=" ".join([self.pad_text("-") for x in self.fields]),
|
ui.add_element(
|
||||||
position=(h_pos_x, h_pos_y + line_spacing),
|
'memtemp_header',
|
||||||
font=fonts.Small,
|
Text(
|
||||||
)
|
color=BLACK,
|
||||||
|
value=" ".join([self.pad_text(x) for x in self.fields]),
|
||||||
|
position=(h_pos_x, h_pos_y),
|
||||||
|
font=fonts.Small,
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
ui.add_element(
|
||||||
|
'memtemp_data',
|
||||||
|
Text(
|
||||||
|
color=BLACK,
|
||||||
|
value=" ".join([self.pad_text("-") for x in self.fields]),
|
||||||
|
position=(h_pos_x, h_pos_y + line_spacing),
|
||||||
|
font=fonts.Small,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def on_unload(self, ui):
|
def on_unload(self, ui):
|
||||||
with ui._lock:
|
with ui._lock:
|
||||||
|
Reference in New Issue
Block a user