diff --git a/docs/USAGE.md b/docs/USAGE.md index 8bdab5f..e02e1c6 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -28,13 +28,14 @@ just logs a reminder; nothing fails mid-attack. Not root? The badge shows it and a toast warns once — the UI stays usable, but every attack will fail with errors in the Log page. -The tool does **not** kill or stop anything on your system. If -NetworkManager/wpa_supplicant grab the interface (channel changes fail, -no packets), stop them yourself, e.g.: - -```sh -sudo systemctl stop NetworkManager # optional, only if attacks misbehave -``` +**NetworkManager fight:** while NetworkManager is active it pins the card +to the connected network's channel — during a scan you will typically see +**only that one SSID** (e.g. your connected network) instead of every +neighbour. The app detects this at *Start capture*, shows a destructive +toast, logs a warning, and offers a **"Stop NM"** button in the header +(one click, uses the elevated session). Restore it afterwards with +`systemctl start NetworkManager`. Everything else on the system is left +untouched. ## Workflow diff --git a/src/iface.rs b/src/iface.rs index 1456f55..60a39dc 100644 --- a/src/iface.rs +++ b/src/iface.rs @@ -170,6 +170,27 @@ pub fn is_root() -> bool { (unsafe { libc::geteuid() }) == 0 } +/// True while NetworkManager is active — it will fight channel control and +/// pin the card to the connected network's channel (only *that* SSID's +/// beacons get seen). No root needed to check. +pub fn networkmanager_active() -> bool { + Command::new("systemctl") + .args(["is-active", "--quiet", "NetworkManager"]) + .status() + .map(|s| s.success()) + .unwrap_or(false) +} + +/// Stop NetworkManager (and with it wpa_supplicant's radio fighting). +/// Requires root. Restart later with `systemctl start NetworkManager`. +pub fn stop_networkmanager() -> Result<()> { + run( + "systemctl", + &["stop".into(), "NetworkManager".into()], + ) + .map(|_| ()) +} + /// True when `pkexec` (polkit) is available for GUI privilege elevation. pub fn pkexec_available() -> bool { Command::new("pkexec") diff --git a/src/ui/app.rs b/src/ui/app.rs index 3024f60..1143492 100644 --- a/src/ui/app.rs +++ b/src/ui/app.rs @@ -85,6 +85,8 @@ pub struct AppRoot { /// flight. 0 = waiting on the polkit dialog, 1 = elevated instance /// launched (quit this one), 2 = declined/failed (message was logged). pub elevation: Option>, + /// NetworkManager seen active when capture started (fights channels). + pub nm_active: bool, /// Used to invalidate stale cracker simulation ticks after Stop/re-Start. pub crack_epoch: u64, pub ap_sort: Option, @@ -158,6 +160,7 @@ impl AppRoot { crack_inflight: false, pending_toast: None, elevation: None, + nm_active: false, crack_epoch: 0, ap_sort: None, client_sort: None, @@ -247,11 +250,27 @@ impl AppRoot { } else { if !self.is_root { self.state.push_log( - "ui: capture needs root — click \"Elevate via polkit\" in the header first".to_string(), + "ui: capture REFUSED — no root privileges. Elevate via polkit first.".to_string(), + ); + self.pending_toast = Some( + "ELEVATION REQUIRED: click \"Elevate via polkit\" in the header before starting capture".into(), ); cx.notify(); return; } + // NetworkManager fight: pin-to-connected-channel makes ONLY the + // associated network (e.g. parafin) visible during the hop. + if crate::iface::networkmanager_active() { + self.nm_active = true; + self.state.push_log( + "ui: WARNING NetworkManager is active — it pins the card to the connected \ + network's channel; you will likely see ONLY that SSID. Use \"Stop NM\" in the header." + .to_string(), + ); + self.pending_toast = Some( + "NetworkManager is active — only your connected network may be visible; stop it from the header".into(), + ); + } let ifname = self.state.ifname.clone(); match Backend::start_scan(&ifname, self.tx.clone()) { Ok(be) => { @@ -269,6 +288,27 @@ impl AppRoot { } } + /// Stop NetworkManager (root) so it stops pinning the radio to the + /// connected network's channel. + pub fn stop_nm(&mut self, cx: &mut Context) { + match crate::iface::stop_networkmanager() { + Ok(()) => { + self.nm_active = false; + self.state.push_log( + "ui: NetworkManager stopped — channel hopping is now exclusive; restart it later with `systemctl start NetworkManager`" + .to_string(), + ); + self.pending_toast = + Some("NetworkManager stopped — all networks become visible as the hopper cycles".into()); + } + Err(e) => { + self.state + .push_log(format!("ERROR stopping NetworkManager: {e:#}")); + } + } + cx.notify(); + } + /// Re-exec this app as root via polkit (pkexec). The polkit dialog is /// fully OS-driven; on success the elevated instance opens its own /// window and this one closes itself. @@ -487,6 +527,17 @@ impl AppRoot { } }); + let nm_badge = (self.nm_active && !self.is_mock) + .then(|| badge("NM active — channels pinned").destructive()); + let nm_btn = (self.nm_active && self.is_root && !self.is_mock).then(|| { + button("stop-nm", "Stop NM").on_click({ + let view = view.clone(); + move |_, _window, cx| { + view.update(cx, |app, cx| app.stop_nm(cx)); + } + }) + }); + h_stack() .w_full() .px_4() @@ -500,6 +551,8 @@ impl AppRoot { .child(privilege) .children(elevate_btn) .child(div().w(px(220.)).child(self.iface_select.clone())) + .children(nm_badge) + .children(nm_btn) .child(toggle) .child(div().flex_1()) .child(