wifi_lab
Clone
https://git.tahinli.com/Tahinli/wifi_lab.git
0 watching·0 forks·Rust·2.1 MiB·b265998·Tahinli·1 month ago·27 commits
| 1 | mod attack; |
| 2 | mod cli; |
| 3 | mod common; |
| 4 | mod crypto; |
| 5 | mod deauth; |
| 6 | mod dot11; |
| 7 | mod gpu; |
| 8 | mod handshake; |
| 9 | mod iface; |
| 10 | mod oui; |
| 11 | mod pcapin; |
| 12 | mod pcapout; |
| 13 | mod pmkid; |
| 14 | mod radiotap; |
| 15 | mod rainbow; |
| 16 | mod rawsock; |
| 17 | mod scanner; |
| 18 | mod service; |
| 19 | mod store; |
| 20 | mod ui; |
| 21 | mod wordlist; |
| 22 | |
| 23 | use clap::Parser; |
| 24 | |
| 25 | #[derive(Parser)] |
| 26 | #[command( |
| 27 | name = "wifi_lab", |
| 28 | about = "WPA/WPA2 lab: scan, capture handshakes/PMKIDs, deauth, crack (GPU/CPU)" |
| 29 | )] |
| 30 | struct Cli { |
| 31 | /// Wireless interface to use (default: first detected, else wlp14s0). |
| 32 | #[arg(long)] |
| 33 | iface: Option<String>, |
| 34 | /// Dev mode: fabricated events, no device access. Same as WIFI_LAB_MOCK=1. |
| 35 | #[arg(long)] |
| 36 | mock: bool, |
| 37 | /// Internal: run as the privileged radio service (spawned by the UI, |
| 38 | /// directly or via pkexec). Never returns; JSON lines on stdin/stdout. |
| 39 | #[arg(long, hide = true)] |
| 40 | privileged_worker: bool, |
| 41 | #[command(subcommand)] |
| 42 | command: Option<Commands>, |
| 43 | } |
| 44 | |
| 45 | #[derive(clap::Subcommand)] |
| 46 | enum Commands { |
| 47 | /// Headless crack of a capture file; no UI, no radio, no root. |
| 48 | Crack(CrackArgs), |
| 49 | } |
| 50 | |
| 51 | #[derive(clap::Args)] |
| 52 | struct CrackArgs { |
| 53 | /// Path to a .hc22000 file (first crackable WPA*01/02 line is used). |
| 54 | #[arg(long)] |
| 55 | capture: String, |
| 56 | #[arg(long, value_enum, default_value_t = CliMode::Wordlist)] |
| 57 | mode: CliMode, |
| 58 | /// Wordlist path (wordlist/rules/hybrid modes). |
| 59 | #[arg(long)] |
| 60 | wordlist: Option<String>, |
| 61 | /// Rules file path (rules mode). |
| 62 | #[arg(long)] |
| 63 | rules: Option<String>, |
| 64 | /// Bruteforce-ish minimum length. |
| 65 | #[arg(long, default_value_t = 8)] |
| 66 | min: usize, |
| 67 | /// Bruteforce-ish maximum length. |
| 68 | #[arg(long, default_value_t = 12)] |
| 69 | max: usize, |
| 70 | /// Wordlist × append-charset sweep (requires --wordlist). |
| 71 | #[arg(long)] |
| 72 | hybrid: bool, |
| 73 | #[arg(long)] |
| 74 | lower: bool, |
| 75 | #[arg(long)] |
| 76 | upper: bool, |
| 77 | #[arg(long)] |
| 78 | digits: bool, |
| 79 | #[arg(long)] |
| 80 | special: bool, |
| 81 | /// Force the CPU backend (also keeps the run side-effect-free: |
| 82 | /// no per-SSID PMK-cache appends). |
| 83 | #[arg(long)] |
| 84 | cpu: bool, |
| 85 | } |
| 86 | |
| 87 | #[derive(clap::ValueEnum, Clone)] |
| 88 | enum CliMode { |
| 89 | Wordlist, |
| 90 | Rules, |
| 91 | Bruteforce, |
| 92 | } |
| 93 | |
| 94 | fn main() { |
| 95 | let cli = Cli::parse(); |
| 96 | // Privileged service path: no GUI, no extra args needed (pkexec strips |
| 97 | // the environment; everything the service needs comes over the pipe). |
| 98 | if cli.privileged_worker { |
| 99 | service::run_service(); // never returns |
| 100 | } |
| 101 | // Headless crack path: no UI startup, no radio, no root. |
| 102 | if let Some(Commands::Crack(args)) = cli.command { |
| 103 | let mode = match args.mode { |
| 104 | CliMode::Wordlist => "wordlist", |
| 105 | CliMode::Rules => "rules", |
| 106 | CliMode::Bruteforce => "bruteforce", |
| 107 | }; |
| 108 | let owned = cli::CliCrack { |
| 109 | capture: args.capture, |
| 110 | mode: mode.to_string(), |
| 111 | wordlist: args.wordlist, |
| 112 | rules: args.rules, |
| 113 | min: args.min, |
| 114 | max: args.max, |
| 115 | hybrid: args.hybrid, |
| 116 | lower: args.lower, |
| 117 | upper: args.upper, |
| 118 | digits: args.digits, |
| 119 | special: args.special, |
| 120 | cpu: args.cpu, |
| 121 | }; |
| 122 | let mut out = std::io::stdout().lock(); |
| 123 | let code = cli::run_crack_cli(owned, &mut out); |
| 124 | std::process::exit(code); |
| 125 | } |
| 126 | let mock = cli.mock |
| 127 | || matches!( |
| 128 | std::env::var_os("WIFI_LAB_MOCK"), |
| 129 | Some(v) if v != "0" && v != "false" |
| 130 | ); |
| 131 | // Significantly loud one-liner: mode + iface + root status. |
| 132 | let iface = cli |
| 133 | .iface |
| 134 | .clone() |
| 135 | .unwrap_or_else(|| "(auto-detect at window open)".to_string()); |
| 136 | println!( |
| 137 | "wifi_lab: mode={} iface={} root={} — {}", |
| 138 | if mock { "MOCK" } else { "real" }, |
| 139 | iface, |
| 140 | iface::is_root(), |
| 141 | if mock { |
| 142 | "fabricated events only" |
| 143 | } else if iface::is_root() { |
| 144 | "monitor mode + injection available (service runs as child)" |
| 145 | } else { |
| 146 | "not root — polkit will ask for authentication when you start capture" |
| 147 | } |
| 148 | ); |
| 149 | ui::run_app(cli.iface, cli.mock); |
| 150 | } |