Commit Graph

4089 Commits

Author SHA1 Message Date
Jeroen Oudshoorn
4ee52614cf Revert "fix(fix_services): remove dead code in on_ui_setup"
This reverts commit bbf1d95bfc.
2026-03-25 18:19:47 +01:00
Jeroen Oudshoorn
b42d01ddc2 Revert "fix(fix_services): remove unused Popen in on_ready (resource leak)"
This reverts commit 283be16549.
2026-03-25 18:19:45 +01:00
Jeroen Oudshoorn
9080a4c768 Revert "feat(pisugarx): implement all stub methods for PiSugar3"
This reverts commit 73f8524af4.
2026-03-25 18:19:41 +01:00
Jeroen Oudshoorn
17bb0c3c53 Revert "fix(pisugarx): improve I2C thread safety, error recovery, and write protection"
This reverts commit 380d05cca9.
2026-03-25 18:19:40 +01:00
Jeroen Oudshoorn
b927aff704 Revert "fix(pisugarx): prevent double voltage append with charge protection"
This reverts commit 1fbfe4bc86.
2026-03-25 18:19:38 +01:00
Jeroen Oudshoorn
71c704047a Revert "fix(pisugarx): guard against None self.ps in on_loaded and on_ui_update"
This reverts commit 2246a91590.
2026-03-25 18:19:37 +01:00
Jeroen Oudshoorn
add1f51b91 Revert "fix(pisugarx): correct model name mismatch in web UI"
This reverts commit 55f294ec77.
2026-03-25 18:19:36 +01:00
Jeroen Oudshoorn
b2e24a8e48 Revert "Add PiSugar 3 shutdown/startup scripts and watchdog"
This reverts commit dff77e105d.
2026-03-25 18:19:29 +01:00
Jeroen Oudshoorn
b661286545 Revert "Fix whitelist not filtering passively captured handshakes"
This reverts commit f2c73f5bbe.
2026-03-25 18:19:18 +01:00
Jeroen Oudshoorn
249cac0420 Revert "Fix auto-tune plugin: history compat, XSS, channel dedup, defaults"
This reverts commit 3c8aa55a57.
2026-03-25 18:19:17 +01:00
Jeroen Oudshoorn
52c1306719 Revert "Optimize handshake capture: fix bugs and improve attack efficiency"
This reverts commit 8c1c51f158.
2026-03-25 18:19:15 +01:00
Jeroen Oudshoorn
103f473376 Revert log changes
Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com>
2026-03-24 21:44:45 +01:00
Jayofelony
7cfc0cc9c9 Merge pull request #370
support syslog or console logging instead of files. disable session s…
2026-03-24 21:37:53 +01:00
Jayofelony
2d8f61dddd Merge pull request #306
added ui.faces.scale = # to png faces
2026-03-24 21:37:08 +01:00
Jayofelony
77555bb594 Merge pull request #553
Add handshakes-dl plugin with network map
2026-03-24 21:31:52 +01:00
Jayofelony
2fabaa301b Merge pull request #550
feat(fix_services): add interface name validation helper
2026-03-24 21:31:03 +01:00
Jayofelony
9f099d3664 Merge pull request #544
fix(fix_services): add threading lock for LASTTRY race condition
2026-03-24 21:30:16 +01:00
Jayofelony
e9257b2520 Merge pull request #526
fix(fix_services): merge duplicate pattern handlers 5 and 6
2026-03-24 21:29:02 +01:00
Jeroen Oudshoorn
581d038925 Merge remote-tracking branch 'origin/noai' into noai 2026-03-24 21:11:46 +01:00
Jeroen Oudshoorn
a5a2027cef Add PiSugar Whisplay to supported displays.
Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com>
2026-03-24 21:11:05 +01:00
CoderFX
0d5a0ccb01 Add handshakes-dl plugin with network map and handshake tracking
Adds a new default plugin that provides a web UI for browsing,
downloading, and analyzing captured WiFi handshakes and network data.

Features:
- Browse and search captured .pcap handshake files
- Download individual files or all as a zip archive
- Interactive network map with D3.js force-directed graph
  - Zoom, pan, drag nodes to rearrange
  - AP nodes colored by encryption type, sized by client count
  - Click AP to highlight its connected clients
  - Auto-fits to viewport after layout settles
- Sortable table view with expandable AP rows showing clients
- Handshake column with download links for captured .pcap files
- Historical AP import from existing pcap filenames
- Live data from bettercap session merged with persistent history
- Stats bar: AP count, unique clients, total data volume
- Persistent JSON storage surviving reboots
2026-03-11 21:56:26 +02:00
CoderFX
45d846c348 feat(fix_services): add interface name validation helper
Add _IFACE_RE regex and _validate_iface() classmethod that validates
Linux network interface names (max 15 chars, alphanumeric plus dash
and underscore). Provides a safety net against malformed names if
interface configuration is ever externalized.
2026-03-11 17:36:45 +02:00
CoderFX
f894649e51 fix(fix_services): add threading lock around LASTTRY and isReloadingMon
on_epoch and on_bcap_sys_log run from different threads (main loop vs
bettercap event handler). Both read and write self.LASTTRY without
synchronization, creating a race where two recovery actions fire
simultaneously. Similarly, isReloadingMon can be checked and set by
concurrent threads leading to overlapping restarts.

Add a threading.Lock to serialize cooldown checks and state mutations:
- on_bcap_sys_log: lock around LASTTRY cooldown check
- on_epoch: lock around LASTTRY cooldown check
- _tryTurningItOffAndOnAgain: lock around duplicate-attempt guard,
  early return instead of else-block to flatten indentation

Signed-off-by: PwnPacker <4704376+CoderFX@users.noreply.github.com>
2026-03-11 17:28:21 +02:00
CoderFX
3962c75730 fix(fix_services): merge duplicate pattern handlers 5 and 6
Patterns 5 (concurrent map iteration) and 6 (panic: runtime error) had
identical handlers — both log "Bettercap has crashed!", restart bettercap,
and restart pwnagotchi. Merge into a single elif with an or condition.

Closes #539

Signed-off-by: PwnPacker <4704376+CoderFX@users.noreply.github.com>
2026-03-11 17:12:37 +02:00
Jayofelony
3d9280a61a Merge pull request #533 from CoderFX/fix/fix-services-print-to-logging
fix(fix_services): replace print() calls with logging
2026-03-11 07:29:37 +01:00
Jayofelony
012efdbaf4 Merge pull request #535 from CoderFX/fix/fix-services-lasttry-update
fix(fix_services): update LASTTRY cooldown after pattern matches
2026-03-11 07:21:06 +01:00
Jayofelony
635f00f4e7 Merge pull request #531 from CoderFX/fix/fix-services-unused-imports
fix(fix_services): remove unused imports Text, BLACK, fonts
2026-03-11 07:20:46 +01:00
Jayofelony
50719285a7 Merge pull request #529 from CoderFX/fix/fix-services-os-system
fix(fix_services): replace os.system with subprocess.run
2026-03-11 07:20:30 +01:00
Jayofelony
bade01f515 Merge pull request #527 from CoderFX/fix/fix-services-success-check
fix(fix_services): fix bettercap result success checks
2026-03-11 07:20:15 +01:00
Jayofelony
cb5366a211 Merge pull request #523 from CoderFX/fix/fix-services-display-null-ref
fix(fix_services): fix display null reference in on_epoch
2026-03-11 07:19:59 +01:00
Jayofelony
c672430e2c Merge pull request #521 from CoderFX/fix/fix-services-dead-code-ui-setup
fix(fix_services): remove dead code in on_ui_setup
2026-03-11 07:19:45 +01:00
Jayofelony
1fe97e8680 Merge pull request #519 from CoderFX/fix/fix-services-dead-code-on-ready
fix(fix_services): remove unused Popen in on_ready
2026-03-11 07:19:30 +01:00
Jayofelony
3d7894cb4c Merge pull request #517 from CoderFX/fix/fix-services-typo
fix(fix_services): fix "interfaceface" typo in log message
2026-03-11 07:19:15 +01:00
Jayofelony
f10c01f2ab Merge pull request #513 from CoderFX/feature/pisugarx-implement-stubs
feat(pisugarx): implement all 17 stub methods for PiSugar3
2026-03-11 07:19:01 +01:00
Jayofelony
1b676ef707 Merge pull request #512 from CoderFX/fix/pisugarx-i2c-robustness
fix(pisugarx): improve I2C thread safety, error recovery, and write protection
2026-03-11 07:18:42 +01:00
Jayofelony
92c5526cca Merge pull request #510 from CoderFX/fix/pisugarx-double-voltage
fix(pisugarx): prevent double voltage append with charge protection
2026-03-11 07:18:25 +01:00
Jayofelony
5367acecad Merge pull request #508 from CoderFX/fix/pisugarx-null-safety
fix(pisugarx): guard against None self.ps in on_loaded and on_ui_update
2026-03-11 07:17:38 +01:00
Jayofelony
10216f854b Merge pull request #506 from CoderFX/fix/pisugarx-model-name-mismatch
fix(pisugarx): correct model name mismatch in web UI
2026-03-11 07:16:18 +01:00
CoderFX
c2e61a1517 fix(fix_services): update LASTTRY in all on_epoch pattern handlers
Signed-off-by: PwnPacker <4704376+CoderFX@users.noreply.github.com>
2026-03-11 03:15:28 +02:00
CoderFX
310a7d3930 fix(fix_services): replace print() calls with proper logging
Plugin code uses print() in several places instead of the logging
module. On a headless Pi Zero, print() output goes nowhere useful
while logging integrates with pwnagotchi's log system.

Signed-off-by: PwnPacker <4704376+CoderFX@users.noreply.github.com>
2026-03-11 03:15:26 +02:00
CoderFX
d85fd18932 fix(fix_services): replace os.system with subprocess.run
Signed-off-by: PwnPacker <4704376+CoderFX@users.noreply.github.com>
2026-03-11 03:12:59 +02:00
CoderFX
36647cb367 fix(fix_services): remove unused imports Text, BLACK, fonts
Signed-off-by: PwnPacker <4704376+CoderFX@users.noreply.github.com>
2026-03-11 03:10:56 +02:00
CoderFX
74e4743042 fix(fix_services): fix bettercap result success checks
'"success" in result' checks if the key exists in the dict (always
True for valid responses), not whether the operation succeeded.
result["success"] can KeyError if the key is missing.

Change all checks to result.get("success") which correctly returns
the boolean value or None if the key is absent.

Signed-off-by: PwnPacker <4704376+CoderFX@users.noreply.github.com>
2026-03-11 03:00:35 +02:00
CoderFX
0fd715b554 fix(fix_services): fix display null reference crash in on_epoch
on_epoch calls agent.view() directly without checking hasattr first,
unlike every other method in the plugin. This crashes if the agent
has no view attribute (e.g., during early startup or in headless mode).

Signed-off-by: PwnPacker <4704376+CoderFX@users.noreply.github.com>
2026-03-11 02:54:39 +02:00
CoderFX
bbf1d95bfc fix(fix_services): remove dead code in on_ui_setup
on_ui_setup computes a pos variable from options or defaults but
never uses it. The ui._lock context and logging.debug("Got here")
are leftover scaffolding with no effect.

Signed-off-by: PwnPacker <4704376+CoderFX@users.noreply.github.com>
2026-03-11 02:44:49 +02:00
CoderFX
283be16549 fix(fix_services): remove unused Popen in on_ready (resource leak)
on_ready opens a subprocess.Popen to read journalctl but never uses
the result. The Popen object is never closed, leaking a file descriptor
and zombie process on every startup.

Signed-off-by: PwnPacker <4704376+CoderFX@users.noreply.github.com>
2026-03-11 02:43:06 +02:00
CoderFX
7fc4bef0ab fix(fix_services): fix interfaceface typo in log message
Typo "wifi.interfaceface" should be "wifi.interface" in the debug
log for the bettercap set wifi.interface command result.

Signed-off-by: PwnPacker <4704376+CoderFX@users.noreply.github.com>
2026-03-11 02:42:04 +02:00
CoderFX
73f8524af4 feat(pisugarx): implement all stub methods for PiSugar3
All 17 stub methods now return real data by reading PiSugar3 I2C
registers directly or from pisugar-power-manager config.

Register reads (from cached i2creg, address 0x57):
- get_battery_current: registers 0x26-0x27
- get_anti_mistouch: CTR1 (0x02) bit 3
- get_battery_auto_power_on: CTR1 (0x02) bit 4
- get_battery_soft_poweroff: CTR2 (0x03) bit 4
- get_battery_charging: derived from power_plugged + allow_charging
- get_system_time: RTC registers 0x31-0x37 (BCD decoded)
- get_rtc_adjust_ppm: registers 0x3A-0x3B (frequency compensation)
- get_rtc_alarm_repeat: registers 0x40, 0x44-0x47

I2C writes:
- set_battery_allow_charging (PiSugar3): CTR1 bit 6 set
- set_battery_notallow_charging (PiSugar3): CTR1 bit 6 clear
- rtc_web: write system time as BCD to RTC registers 0x31-0x37

Config-derived:
- get_battery_safe_shutdown_level: from plugin config
- get_battery_safe_shutdown_delay: 10s (PiSugar3 hardware)
- get_battery_charging_range: from max_charge_voltage_protection
- get_battery_full_charge_duration: N/A (no hardware support)

Pisugar-power-manager config reads:
- get_tap_enable: reads {tap}_tap_enable from config.json
- get_tap_shell: reads {tap}_tap_shell from config.json

Also fixes model name mismatch in web UI ('Pisugar 3' -> 'PiSugar3')
so PiSugar3-specific fields display correctly.

Signed-off-by: PwnPacker <4704376+CoderFX@users.noreply.github.com>
2026-03-11 01:37:00 +02:00
CoderFX
380d05cca9 fix(pisugarx): improve I2C thread safety, error recovery, and write protection
Four robustness improvements to PiSugarServer I2C communication:

1. Race condition: build i2creg into temp list, swap atomically with
   threading lock so UI thread never reads partial register data.

2. Bus recovery: add error counter with exponential backoff (3s-30s),
   log suppression after 3 errors, and SMBus reconnect after 5
   consecutive failures to recover from MCU deep sleep.

3. Write protection: restructure as try/finally so register 0x0B is
   always re-enabled even if the middle write fails.

4. Shutdown safety: wrap I2C writes in try/except/finally so failures
   are logged but never prevent pwnagotchi.shutdown() from executing.

Fixes #511

Signed-off-by: PwnPacker <4704376+CoderFX@users.noreply.github.com>
2026-03-11 01:07:27 +02:00
CoderFX
1fbfe4bc86 fix(pisugarx): prevent double voltage append with charge protection
For PiSugar2/2Plus with max_charge_voltage_protection enabled,
battery_voltage was appended to voltage_history twice per cycle:
once inside the charge protection block and once unconditionally
at the end. This skews the trimmed-mean battery level calculation.

Make the final append conditional so each model appends exactly
once per cycle regardless of charge protection setting.

Fixes #509

Signed-off-by: PwnPacker <4704376+CoderFX@users.noreply.github.com>
2026-03-11 01:04:19 +02:00