Skip to content

A WiFi security auditing software

feat: first beta version of the application (#1)

Martin Olivier73aeb502170d
diff --git a/.github/assets/illustration.png b/.github/assets/illustration.png
new file mode 100755
index 0000000..a47429b
Binary files /dev/null and b/.github/assets/illustration.png differ
diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
new file mode 100644
index 0000000..5f6a648
--- /dev/null
+++ b/.github/workflows/CI.yml
@@ -0,0 +1,69 @@
+name: CI
+
+on:
+ push:
+ branches:
+ - main
+ paths:
+ - src/*
+ - .github/workflows/CI.yml
+ - Cargo.toml
+ pull_request:
+ branches:
+ - main
+ paths:
+ - src/*
+ - .github/workflows/CI.yml
+ - Cargo.toml
+
+defaults:
+ run:
+ shell: bash
+
+jobs:
+ conventional_commits:
+ name: conventional commits
+ runs-on: ubuntu-22.04
+ steps:
+ - uses: actions/checkout@v2
+ - uses: webiny/[email protected]
+
+ linter:
+ name: linter
+ runs-on: ubuntu-22.04
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Install dependencies
+ run: sudo apt update && sudo apt install -y libgtk-4-dev libglib2.0-dev
+
+ - name: Clippy
+ run: cargo clippy --all --all-features -- -D warnings
+
+ - name: Format
+ run: cargo fmt --all -- --check
+
+ ci:
+ needs: linter
+ strategy:
+ fail-fast: false
+ matrix:
+ build: ['', --release]
+ include:
+ - build: ''
+ profile: debug
+ - build: --release
+ profile: release
+
+ name: ${{ matrix.profile }} build
+ runs-on: ubuntu-22.04
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Install dependencies
+ run: sudo apt update && sudo apt install -y libgtk-4-dev libglib2.0-dev
+
+ - name: Build project
+ run: cargo build ${{ matrix.build }}
diff --git a/.gitignore b/.gitignore
index 96ef6c0..45378bd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,12 @@
+# Editor Files and Folders
+
+.idea/
+.vscode/
+.DS_Store
+*~
+\#*#
+
+# Build Folder
+
/target
-Cargo.lock
+Cargo.lock
\ No newline at end of file
diff --git a/Cargo.toml b/Cargo.toml
index bb1c796..25dd73d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,6 +2,44 @@
name = "airgorah"
version = "0.1.0"
edition = "2021"
+license = "MIT"
+authors = ["Martin Olivier <[email protected]>"]
+homepage = "https://github.com/martin-olivier/airgorah"
+repository = "https://github.com/martin-olivier/airgorah"
+documentation = "https://github.com/martin-olivier/airgorah"
+description = "A WiFi auditing software that can perform deauth attacks and passwords recovery"
+keywords = ["networking", "pentest", "aircrack-ng", "gui", "linux"]
+readme = "README.md"
+exclude = ["/.github"]
[dependencies]
+serde = { version = "1.0.104", features = ["derive"] }
+serde_json = "1.0.86"
+csv = "1.1.6"
+glib = "0.15.12"
+sudo = "0.6.0"
+ctrlc = "3.2.3"
+regex = "1.6.0"
+lazy_static = "1.4.0"
+which = "4.3.0"
+[dependencies.gtk4]
+version = "0.4.8"
+default-features = false
+features = ["v4_6"]
+
+[package.metadata.deb]
+copyright = "2022, Martin Olivier"
+maintainer = "Martin Olivier <[email protected]>"
+license-file = [ "LICENSE" ]
+extended-description = "A WiFi auditing software that can perform deauth attacks and passwords recovery"
+depends = "pkexec, libgtk-4-1, dbus-x11, wireless-tools, aircrack-ng (>= 1.6)"
+priority = "optional"
+section = "utility"
+assets = [
+ ["target/release/airgorah", "/usr/bin/", "755"],
+ ["README.md", "/usr/share/doc/airgorah/README", "644"],
+ ["icons/app_icon.png", "/usr/share/app-install/icons/airgorah.png", "644"],
+ ["package/.desktop", "/usr/share/applications/com.martin-olivier.airgorah.desktop", "644"],
+ ["package/.policy", "/usr/share/polkit-1/actions/org.freedesktop.policykit.airgorah.policy", "755"],
+]
\ No newline at end of file
diff --git a/README.md b/README.md
index 77f7e87..41112ec 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,69 @@
-# airgorah
\ No newline at end of file
+<h1 align="center">
+ <img src="icons/app_icon.png" width=100 height=100/><br>
+ Airgorah
+ </a>
+</h1>
+
+<h4 align="center">A WiFi auditing software that can perform deauth attacks and passwords recovery</h4>
+
+<p align="center">
+ <a href="https://github.com/martin-olivier/airgorah/releases/tag/v0.1.0">
+ <img src="https://img.shields.io/badge/Version-0.1.0_(beta)-blue.svg" alt="version"/>
+ </a>
+ <a href="https://github.com/martin-olivier/airgorah/blob/main/LICENSE">
+ <img src="https://img.shields.io/badge/License-MIT-darkgreen.svg" alt="license"/>
+ </a>
+ <a href="https://www.rust-lang.org/">
+ <img src="https://img.shields.io/badge/Language-Rust-orange.svg" alt="cppversion"/>
+ </a>
+ <a href="https://github.com/martin-olivier/airgorah/actions/workflows/CI.yml">
+ <img src="https://github.com/martin-olivier/airgorah/actions/workflows/CI.yml/badge.svg" alt="ci"/>
+ </a>
+</p>
+
+![illustration](.github/assets/illustration.png)
+
+`Airgorah` can be used to audit a WiFi network by discovering the clients connected to it, performing deauth attacks against specific clients or all the clients connected to the network, or by recovering the password of the access point.
+
+It is written in Rust and uses [GTK4 bindings](https://github.com/gtk-rs/gtk4-rs) for the graphical part. The software is based on [aircrack-ng](https://github.com/aircrack-ng/aircrack-ng) tools suite.
+
+`⭐ Don't forget to put a star if you like the project!`
+
+## Legal
+
+⚠️ Airgorah is designed to be used in testing and discovering flaws in networks you are owner of. Performing attacks on WiFi networks you are not owner of is illegal in almost all countries. I am not responsible for whatever damage you may cause by using this software.
+
+## Requirements
+
+This software only works on `linux` and requires `root` privileges to run.
+
+You will also need a wireless network card that supports `monitor mode` and `packet injection`.
+
+## Installation
+
+You can find pre-built releases for `Debian` based distributions [here](https://github.com/martin-olivier/airgorah/releases/latest) (Ubuntu, PopOS, Mint, Kali). You will just need to download the package and install it with the following command:
+
+```sh
+sudo apt install <path_to_deb_package>
+```
+
+Otherwise, if you'd like to compile from source, you can follow this [guide](docs/build_from_source.md).
+
+## License
+
+This project is released under [MIT](LICENSE) license.
+
+## Contributing
+
+Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
+
+## Future
+
+- [ ] WPA handshake capture
+- [ ] WPA handshake decryption (dictionary / bruteforce)
+- [ ] WPS attack feature
+- [ ] WEP attack feature
+- [ ] Provide releases for other linux distributions (Arch, Fedora, ...)
+- [ ] Provide releases for other architectures (amd, arm, ...)
+- [ ] Improve the code quality and the documentation
+- [ ] Improve the UI
diff --git a/docs/build_from_source.md b/docs/build_from_source.md
new file mode 100644
index 0000000..607a7c5
--- /dev/null
+++ b/docs/build_from_source.md
@@ -0,0 +1,32 @@
+# Build from source
+
+## 1. Install Cargo
+
+To build the project, you will need to install [cargo](https://www.rust-lang.org/tools/install), the rust compiler:
+
+```sh
+curl https://sh.rustup.rs -sSf | sh
+```
+
+## 2. Install Dependencies
+
+Then, you will need to install `airgorah` dependencies:
+
+### Debian (Ubuntu, PopOS, Mint, Kali)
+
+```sh
+sudo apt install dbus-x11 libgtk-4-dev libglib2.0-dev aircrack-ng wireless-tools
+```
+
+### Fedora
+
+```sh
+sudo dnf install dbus-x11 gtk4-devel glib2-devel aircrack-ng wireless-tools-1
+```
+
+## 3. Install Airgorah
+
+After those steps, you will be able to:
+
+- [Create a package and install it](packaging.md) (recommended)
+- [Build and install from crates.io](installation.md)
diff --git a/docs/installation.md b/docs/installation.md
new file mode 100644
index 0000000..a608915
--- /dev/null
+++ b/docs/installation.md
@@ -0,0 +1,19 @@
+# Build and install Airgorah - crates.io
+
+To build and install `airgorah` from crates.io, you can use the following command:
+
+```sh
+cargo install airgorah
+```
+
+Then, you will be able to run `airgorah` on your computer by typing the following command:
+
+```sh
+sudo airgorah
+```
+
+If you want to uninstall `airgorah` from your computer, enter the following command:
+
+```sh
+cargo uninstall airgorah
+```
diff --git a/docs/packaging.md b/docs/packaging.md
new file mode 100644
index 0000000..e1f47ef
--- /dev/null
+++ b/docs/packaging.md
@@ -0,0 +1,27 @@
+# Build and install Airgorah - debian package
+
+First, you will need to clone the project using the following command:
+
+```sh
+git clone https://github.com/martin-olivier/airgorah.git
+cd airgorah
+```
+
+Then, you will be able to create a `debian` package by running the following commands:
+
+```sh
+cargo install cargo-deb
+cargo deb
+```
+
+After those commands, a `.deb` package will be created in the `target/debian` folder. You can install it with the following command:
+
+```sh
+sudo apt install <path_to_deb_package>
+```
+
+If you want to uninstall `airgorah` from your computer, enter the following command:
+
+```sh
+sudo apt remove airgorah
+```
diff --git a/icons/app_icon.png b/icons/app_icon.png
new file mode 100644
index 0000000..07177ed
Binary files /dev/null and b/icons/app_icon.png differ
diff --git a/icons/capture.png b/icons/capture.png
new file mode 100644
index 0000000..235a594
Binary files /dev/null and b/icons/capture.png differ
diff --git a/icons/deauth.png b/icons/deauth.png
new file mode 100644
index 0000000..d86f8eb
Binary files /dev/null and b/icons/deauth.png differ
diff --git a/icons/stop.png b/icons/stop.png
new file mode 100644
index 0000000..4cfb160
Binary files /dev/null and b/icons/stop.png differ
diff --git a/package/.desktop b/package/.desktop
new file mode 100644
index 0000000..da4be26
--- /dev/null
+++ b/package/.desktop
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Encoding=UTF-8
+Version=0.1.0
+Type=Application
+Terminal=false
+Exec=pkexec airgorah
+Name=Airgorah
+Icon=/usr/share/app-install/icons/airgorah.png
\ No newline at end of file
diff --git a/package/.policy b/package/.policy
new file mode 100644
index 0000000..d4d2fd1
--- /dev/null
+++ b/package/.policy
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE policyconfig PUBLIC
+ "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
+<policyconfig>
+ <action id="org.freedesktop.policykit.pkexec.airgorah">
+ <description>Run Airgorah</description>
+ <message>Authentication is required to run Airgorah</message>
+ <icon_name>accessories-text-editor</icon_name>
+ <defaults>
+ <allow_any>auth_admin</allow_any>
+ <allow_inactive>auth_admin</allow_inactive>
+ <allow_active>auth_admin</allow_active>
+ </defaults>
+ <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/airgorah</annotate>
+ <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
+ </action>
+</policyconfig>
\ No newline at end of file
diff --git a/src/backend/app.rs b/src/backend/app.rs
new file mode 100644
index 0000000..977d826
--- /dev/null
+++ b/src/backend/app.rs
@@ -0,0 +1,69 @@
+use crate::error::Error;
+use crate::globals::*;
+use crate::types::*;
+
+pub fn app_setup() -> Result<(), Error> {
+ app_cleanup();
+
+ ctrlc::set_handler(move || {
+ app_cleanup();
+ std::process::exit(1);
+ })
+ .expect("Error setting Ctrl-C handler");
+
+ if sudo::check() != sudo::RunningAs::Root {
+ return Err(Error::new("Airgorah need root privilege to run"));
+ }
+
+ check_dependencies(&[
+ "sh",
+ "service",
+ "iw",
+ "iwlist",
+ "awk",
+ "airmon-ng",
+ "airodump-ng",
+ "aireplay-ng",
+ ])
+}
+
+pub fn app_cleanup() {
+ if let Some(child) = SCAN_PROC.lock().unwrap().as_mut() {
+ child.kill().unwrap();
+ child.wait().unwrap();
+ }
+
+ for attacked_ap in ATTACK_POOL.lock().unwrap().iter_mut() {
+ match &mut attacked_ap.1 .1 {
+ AttackedClients::All(child) => {
+ child.kill().unwrap();
+ child.wait().unwrap();
+ }
+ AttackedClients::Selection(child_list) => {
+ for (_, child) in child_list {
+ child.kill().unwrap();
+ child.wait().unwrap();
+ }
+ }
+ }
+ }
+
+ if let Some(iface) = IFACE.lock().unwrap().as_ref() {
+ super::disable_monitor_mode(iface).ok();
+ super::restore_network_manager().ok();
+ }
+
+ std::fs::remove_file(SCAN_PATH.to_string() + "-01.csv").ok();
+}
+
+pub fn check_dependencies(deps: &[&str]) -> Result<(), Error> {
+ for dep in deps {
+ if which::which(dep).is_err() {
+ return Err(Error::new(&format!(
+ "Missing dependency: \"{}\"\n{}",
+ dep, "Please install it using your package manager"
+ )));
+ }
+ }
+ Ok(())
+}
diff --git a/src/backend/deauth.rs b/src/backend/deauth.rs
new file mode 100644
index 0000000..cfd82d4
--- /dev/null
+++ b/src/backend/deauth.rs
@@ -0,0 +1,79 @@
+use crate::error::Error;
+use crate::globals::*;
+use crate::types::*;
+use std::collections::HashMap;
+use std::process::Command;
+use std::sync::MutexGuard;
+
+pub fn launch_deauth_attack(ap: AP, specific_clients: Option<Vec<String>>) -> Result<(), Error> {
+ let iface = match super::get_iface() {
+ Some(res) => res,
+ None => return Err(Error::new("No interface set")),
+ };
+
+ // Set channel focus
+
+ let mut channel_select = Command::new("airodump-ng")
+ .args(["-c", &ap.channel, "--bssid", &ap.bssid, &iface])
+ .stdout(std::process::Stdio::null())
+ .spawn()?;
+
+ std::thread::sleep(std::time::Duration::from_millis(100));
+
+ channel_select.kill()?;
+ channel_select.wait()?;
+
+ // Start deauth process
+
+ let mut attack_pool = super::get_attack_pool();
+
+ let attack_targets = match specific_clients {
+ Some(specific_clients) => {
+ let mut cli_attack_targets = vec![];
+ for cli in specific_clients {
+ cli_attack_targets.push((
+ cli.to_owned(),
+ Command::new("aireplay-ng")
+ .args(["-0", "0", "-D", "-a", &ap.bssid, "-c", &cli, &iface])
+ .stdout(std::process::Stdio::null())
+ .spawn()?,
+ ));
+ }
+ AttackedClients::Selection(cli_attack_targets)
+ }
+ None => AttackedClients::All(
+ Command::new("aireplay-ng")
+ .args(["-0", "0", "-D", "-a", &ap.bssid, &iface])
+ .stdout(std::process::Stdio::null())
+ .spawn()?,
+ ),
+ };
+
+ attack_pool.insert(ap.bssid.to_string(), (ap, attack_targets));
+
+ Ok(())
+}
+
+pub fn stop_deauth_attack(ap_bssid: &str) {
+ let mut attack_pool = super::get_attack_pool();
+
+ if let Some(attack_target) = attack_pool.get_mut(ap_bssid) {
+ match &mut attack_target.1 {
+ AttackedClients::All(child) => {
+ child.kill().unwrap();
+ child.wait().unwrap();
+ }
+ AttackedClients::Selection(child_list) => {
+ for (_cli, child) in child_list {
+ child.kill().unwrap();
+ child.wait().unwrap();
+ }
+ }
+ }
+ }
+ attack_pool.remove(ap_bssid);
+}
+
+pub fn get_attack_pool() -> MutexGuard<'static, HashMap<String, (AP, AttackedClients)>> {
+ ATTACK_POOL.lock().unwrap()
+}
diff --git a/src/backend/interface.rs b/src/backend/interface.rs
new file mode 100644
index 0000000..c479d12
--- /dev/null
+++ b/src/backend/interface.rs
@@ -0,0 +1,135 @@
+use crate::error::Error;
+use crate::globals::*;
+use std::process::Command;
+
+pub fn get_interfaces() -> Result<Vec<String>, Error> {
+ let cmd = Command::new("sh")
+ .args(["-c", "iw dev | awk \'$1==\"Interface\"{print $2}\'"])
+ .output()?;
+
+ if !cmd.status.success() {
+ return Err(Error::new("Failed to get interfaces"));
+ }
+
+ let out = String::from_utf8(cmd.stdout)?;
+
+ Ok(out.split_terminator('\n').map(String::from).collect())
+}
+
+pub fn is_5ghz_supported(iface: &str) -> Result<bool, Error> {
+ let check_band_cmd = Command::new("iwlist").args([iface, "freq"]).output()?;
+
+ if !check_band_cmd.status.success() {
+ return Err(Error::new("No such interface"));
+ }
+
+ let check_band_output = String::from_utf8(check_band_cmd.stdout)?;
+
+ if check_band_output.contains("Channel 36 : 5.18 GHz") {
+ return Ok(true);
+ }
+
+ Ok(false)
+}
+
+pub fn is_monitor_mode(iface: &str) -> Result<bool, Error> {
+ let check_monitor_cmd = Command::new("iw").args(["dev", iface, "info"]).output()?;
+
+ if !check_monitor_cmd.status.success() {
+ return Err(Error::new("No such interface"));
+ }
+
+ let check_monitor_output = String::from_utf8(check_monitor_cmd.stdout)?;
+
+ if check_monitor_output.contains("type monitor") {
+ return Ok(true);
+ }
+
+ Ok(false)
+}
+
+pub fn enable_monitor_mode(iface: &str) -> Result<String, Error> {
+ kill_network_manager().ok();
+
+ if is_monitor_mode(iface)? {
+ return Ok(iface.to_string());
+ }
+
+ let old_interface_list = get_interfaces()?;
+ let enable_monitor_cmd = Command::new("airmon-ng").args(["start", iface]).output()?;
+
+ if !enable_monitor_cmd.status.success() {
+ return Err(Error::new("Failed to enable monitor mode"));
+ }
+
+ match is_monitor_mode(&(iface.to_string() + "mon")) {
+ Ok(res) => match res {
+ true => Ok(iface.to_string() + "mon"),
+ false => Err(Error::new("Failed to enable monitor mode")),
+ },
+ Err(_) => {
+ let new_interface_list = get_interfaces()?;
+
+ for iface_it in new_interface_list {
+ if !old_interface_list.contains(&iface_it) && is_monitor_mode(&iface_it)? {
+ return Ok(iface_it);
+ }
+ }
+
+ Err(Error::new(
+ "Monitor mode has been enabled but the new interface has not been found",
+ ))
+ }
+ }
+}
+
+pub fn disable_monitor_mode(iface: &str) -> Result<(), Error> {
+ let check_monitor_cmd = Command::new("iw").args(["dev", iface, "info"]).output()?;
+
+ if !check_monitor_cmd.status.success() {
+ return Err(Error::new("Failed to get current interface"));
+ }
+
+ let check_monitor_output = String::from_utf8(check_monitor_cmd.stdout).unwrap();
+
+ if !check_monitor_output.contains("type monitor") {
+ return Ok(());
+ }
+
+ let disable_monitor_cmd = Command::new("airmon-ng").args(["stop", iface]).output()?;
+
+ match disable_monitor_cmd.status.success() {
+ true => Ok(()),
+ false => Err(Error::new(
+ "Failed to disable monitor mode on current interface",
+ )),
+ }
+}
+
+pub fn get_iface() -> Option<String> {
+ IFACE.lock().unwrap().clone()
+}
+
+pub fn set_iface(iface: String) {
+ IFACE.lock().unwrap().replace(iface);
+}
+
+pub fn kill_network_manager() -> Result<(), Error> {
+ Command::new("airmon-ng").args(["check", "kill"]).output()?;
+
+ Ok(())
+}
+
+pub fn restore_network_manager() -> Result<(), Error> {
+ Command::new("service")
+ .args(["NetworkManager", "restart"])
+ .output()?;
+ Command::new("service")
+ .args(["network-manager", "restart"])
+ .output()?;
+ Command::new("service")
+ .args(["wpa-supplicant", "restart"])
+ .output()?;
+
+ Ok(())
+}
diff --git a/src/backend/mod.rs b/src/backend/mod.rs
new file mode 100644
index 0000000..94077f3
--- /dev/null
+++ b/src/backend/mod.rs
@@ -0,0 +1,9 @@
+pub mod app;
+pub mod deauth;
+pub mod interface;
+pub mod scan;
+
+pub use app::*;
+pub use deauth::*;
+pub use interface::*;
+pub use scan::*;
diff --git a/src/backend/scan.rs b/src/backend/scan.rs
new file mode 100644
index 0000000..2280270
--- /dev/null
+++ b/src/backend/scan.rs
@@ -0,0 +1,225 @@
+use regex::Regex;
+use std::collections::HashMap;
+use std::sync::MutexGuard;
+
+use crate::error::Error;
+use crate::globals::*;
+use crate::types::*;
+
+use serde::Deserialize;
+
+#[derive(Debug, Deserialize)]
+struct RawAP {
+ #[serde(rename = "BSSID")]
+ bssid: String,
+ #[serde(rename = " First time seen")]
+ first_time_seen: String,
+ #[serde(rename = " Last time seen")]
+ last_time_seen: String,
+ #[serde(rename = " channel")]
+ channel: String,
+ #[serde(rename = " Speed")]
+ speed: String,
+ #[serde(rename = " Privacy")]
+ privacy: String,
+ #[serde(rename = " Cipher")]
+ _cipher: String,
+ #[serde(rename = " Authentication")]
+ _authentication: String,
+ #[serde(rename = " Power")]
+ power: String,
+ #[serde(rename = " # beacons")]
+ _beacons: String,
+ #[serde(rename = " # IV")]
+ _iv: String,
+ #[serde(rename = " LAN IP")]
+ _lan_ip: String,
+ #[serde(rename = " ID-length")]
+ id_length: String,
+ #[serde(rename = " ESSID")]
+ essid: String,
+ #[serde(rename = " Key")]
+ _key: String,
+}
+
+#[derive(Debug, Deserialize)]
+struct RawClient {
+ #[serde(rename = "Station MAC")]
+ station_mac: String,
+ #[serde(rename = " First time seen")]
+ first_time_seen: String,
+ #[serde(rename = " Last time seen")]
+ last_time_seen: String,
+ #[serde(rename = " Power")]
+ power: String,
+ #[serde(rename = " # packets")]
+ packets: String,
+ #[serde(rename = " BSSID")]
+ bssid: String,
+ #[serde(rename = " Probed ESSIDs")]
+ _probed_essids: String,
+}
+
+pub fn is_scan_process() -> bool {
+ SCAN_PROC.lock().unwrap().as_ref().is_some()
+}
+
+pub fn is_valid_channel_filter(channel_filter: &str) -> bool {
+ let channel_regex = Regex::new(r"^[1-9]+[0-9]*$").unwrap();
+ let channel_list: Vec<String> = channel_filter
+ .split_terminator(',')
+ .map(String::from)
+ .collect();
+
+ for chan in channel_list {
+ if !channel_regex.is_match(&chan) {
+ return false;
+ }
+ }
+
+ true
+}
+
+pub fn set_scan_process(args: &[&str]) -> Result<(), Error> {
+ let iface = match super::get_iface().as_ref() {
+ Some(res) => res.to_string(),
+ None => return Err(Error::new("No interface set")),
+ };
+
+ if let Some(child) = SCAN_PROC.lock().unwrap().as_mut() {
+ child.kill().unwrap();
+ child.wait().unwrap();
+ }
+
+ std::fs::remove_file(SCAN_PATH.to_string() + "-01.csv").ok();
+
+ let mut proc_args = vec![
+ iface.as_str(),
+ "-a",
+ "--output-format",
+ "csv",
+ "-w",
+ SCAN_PATH,
+ "--write-interval",
+ "1",
+ ];
+ proc_args.append(&mut args.to_vec());
+
+ let child = std::process::Command::new("airodump-ng")
+ .args(proc_args)
+ .stdout(std::process::Stdio::null())
+ .spawn()?;
+
+ SCAN_PROC.lock().unwrap().replace(child);
+
+ Ok(())
+}
+
+pub fn stop_scan_process() {
+ if let Some(child) = SCAN_PROC.lock().unwrap().as_mut() {
+ child.kill().unwrap();
+ child.wait().unwrap();
+ }
+
+ SCAN_PROC.lock().unwrap().take();
+
+ std::fs::remove_file(SCAN_PATH.to_string() + "-01.csv").ok();
+}
+
+pub fn get_airodump_data() -> HashMap<String, AP> {
+ let mut aps: HashMap<String, AP> = HashMap::new();
+
+ for attacked_ap in super::get_attack_pool().iter() {
+ aps.insert(attacked_ap.0.clone(), attacked_ap.1 .0.clone());
+ }
+
+ let mut glob_aps = super::get_aps();
+
+ for ap in glob_aps.iter() {
+ aps.insert(ap.0.clone(), ap.1.clone());
+ }
+
+ let full_path = SCAN_PATH.to_string() + "-01.csv";
+ let csv_file = match std::fs::read_to_string(full_path) {
+ Ok(file) => file,
+ Err(_) => return aps,
+ };
+
+ let file_parts: Vec<&str> = csv_file.split("\r\n\r\n").collect();
+ let ap_part = if !file_parts.is_empty() {
+ file_parts[0]
+ } else {
+ ""
+ };
+ let cli_part = if file_parts.len() >= 2 {
+ file_parts[1]
+ } else {
+ ""
+ };
+
+ let mut ap_reader = csv::Reader::from_reader(ap_part.as_bytes());
+ let mut cli_reader = csv::Reader::from_reader(cli_part.as_bytes());
+
+ for result in ap_reader.deserialize::<RawAP>().flatten() {
+ let channel_nb = result.channel.trim_start().parse::<i32>().unwrap_or(-1);
+ let band = if channel_nb > 14 {
+ "5 GHz".to_string()
+ } else {
+ "2.4 GHz".to_string()
+ };
+
+ let bssid = result.bssid.trim_start().to_string();
+
+ let mut essid = result.essid.trim_start().to_string();
+
+ if essid.is_empty() {
+ essid = format!("[Hidden ESSID] (length: {})", result.id_length.trim_start());
+ }
+
+ let old_data = aps.insert(
+ bssid.clone(),
+ AP {
+ essid,
+ bssid: bssid.clone(),
+ band,
+ channel: result.channel.trim_start().to_string(),
+ speed: result.speed.trim_start().to_string(),
+ power: result.power.trim_start().to_string(),
+ privacy: result.privacy.trim_start().to_string(),
+ first_time_seen: result.first_time_seen.trim_start().to_string(),
+ last_time_seen: result.last_time_seen.trim_start().to_string(),
+ clients: HashMap::new(),
+ },
+ );
+
+ if let Some(ap) = old_data {
+ aps.get_mut(&bssid).unwrap().clients = ap.clients;
+ }
+ }
+
+ for result in cli_reader.deserialize::<RawClient>().flatten() {
+ if let Some(ap) = aps.get_mut(result.bssid.trim_start()) {
+ let mac = result.station_mac.trim_start().to_string();
+ ap.clients.insert(
+ mac.clone(),
+ Client {
+ mac,
+ packets: result.packets.trim_start().to_string(),
+ power: result.power.trim_start().to_string(),
+ first_time_seen: result.first_time_seen.trim_start().to_string(),
+ last_time_seen: result.last_time_seen.trim_start().to_string(),
+ },
+ );
+ }
+ }
+
+ for ap in aps.iter() {
+ glob_aps.insert(ap.0.clone(), ap.1.clone());
+ }
+
+ aps
+}
+
+pub fn get_aps() -> MutexGuard<'static, HashMap<String, AP>> {
+ APS.lock().unwrap()
+}
diff --git a/src/error.rs b/src/error.rs
new file mode 100644
index 0000000..52f044d
--- /dev/null
+++ b/src/error.rs
@@ -0,0 +1,40 @@
+#[derive(Debug)]
+pub struct Error {
+ pub error_message: String,
+}
+
+impl Error {
+ pub fn new(error_message: &str) -> Self {
+ Self {
+ error_message: error_message.to_string(),
+ }
+ }
+}
+
+impl std::error::Error for Error {
+ fn description(&self) -> &str {
+ &self.error_message
+ }
+}
+
+impl std::fmt::Display for Error {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ write!(f, "{}", self.error_message)
+ }
+}
+
+impl From<std::io::Error> for Error {
+ fn from(error: std::io::Error) -> Error {
+ Error {
+ error_message: error.to_string(),
+ }
+ }
+}
+
+impl From<std::string::FromUtf8Error> for Error {
+ fn from(error: std::string::FromUtf8Error) -> Error {
+ Error {
+ error_message: error.to_string(),
+ }
+ }
+}
diff --git a/src/frontend/connections/deauth.rs b/src/frontend/connections/deauth.rs
new file mode 100644
index 0000000..bca86b6
--- /dev/null
+++ b/src/frontend/connections/deauth.rs
@@ -0,0 +1,34 @@
+use crate::backend;
+use crate::frontend::interfaces::*;
+use crate::list_store_get;
+use glib::clone;
+use gtk4::prelude::*;
+use gtk4::*;
+use std::rc::Rc;
+
+pub fn connect_deauth_button(app_data: Rc<AppData>) {
+ app_data
+ .deauth_but
+ .connect_clicked(clone!(@strong app_data => move |_| {
+ let (_model, iter) = match app_data.aps_view.selection().selected() {
+ Some((selection, iter)) => (selection, iter),
+ None => return,
+ };
+
+ let bssid = list_store_get!(app_data.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 => {
+ if backend::is_scan_process() {
+ app_data.scan_but.emit_clicked();
+ }
+ DeauthWindow::spawn(
+ &app_data.main_window,
+ backend::get_aps()[&bssid].clone(),
+ );
+ }
+ }
+ }));
+}
diff --git a/src/frontend/connections/handshake.rs b/src/frontend/connections/handshake.rs
new file mode 100644
index 0000000..6cf0de4
--- /dev/null
+++ b/src/frontend/connections/handshake.rs
@@ -0,0 +1,15 @@
+use crate::frontend::interfaces::*;
+use glib::clone;
+use std::rc::Rc;
+
+pub fn connect_capture_button(app_data: Rc<AppData>) {
+ app_data
+ .capture_but
+ .connect_clicked(clone!(@strong app_data => move |_| {
+ InfoDialog::spawn(
+ &app_data.main_window,
+ "Comming Soon",
+ "This feature will be available in a future version",
+ );
+ }));
+}
diff --git a/src/frontend/connections/interface.rs b/src/frontend/connections/interface.rs
new file mode 100644
index 0000000..a912831
--- /dev/null
+++ b/src/frontend/connections/interface.rs
@@ -0,0 +1,62 @@
+use crate::backend;
+use crate::frontend::interfaces::*;
+use crate::list_store_get;
+use glib::clone;
+use gtk4::prelude::*;
+use std::rc::Rc;
+
+pub fn connect_interface_refresh(app_data: Rc<AppData>) {
+ app_data
+ .refresh_but
+ .connect_clicked(clone!(@strong app_data => move |_| {
+ app_data.interface_model.clear();
+
+ let ifaces = match backend::get_interfaces() {
+ Ok(ifaces) => ifaces,
+ Err(e) => {
+ return ErrorDialog::spawn(
+ &app_data.interface_window,
+ "Failed to get interfaces",
+ &e.to_string(),
+ false,
+ );
+ }
+ };
+
+ for iface in ifaces.iter() {
+ app_data.interface_model.insert_with_values(None, &[(0, &iface)]);
+ }
+
+ app_data.interface_view.set_active(if !ifaces.is_empty() { Some(0) } else { None });
+ }));
+ app_data.refresh_but.emit_clicked();
+}
+
+pub fn connect_interface_select(app_data: Rc<AppData>) {
+ app_data
+ .select_but
+ .connect_clicked(clone!(@strong app_data => move |_| {
+ let iter = match app_data.interface_view.active_iter() {
+ Some(iter) => iter,
+ None => return,
+ };
+ let iface = list_store_get!(app_data.interface_model, &iter, 0, String);
+
+ match crate::backend::enable_monitor_mode(&iface) {
+ Ok(res) => {
+ backend::set_iface(res);
+ app_data.interface_window.hide();
+ app_data.scan_but.emit_clicked();
+ }
+ Err(e) => {
+ ErrorDialog::spawn(
+ &app_data.interface_window,
+ "Monitor mode failed",
+ &format!("Could not enable monitor mode on \"{}\":\n{}", iface, e),
+ false,
+ );
+ app_data.refresh_but.emit_clicked();
+ }
+ };
+ }));
+}
diff --git a/src/frontend/connections/mod.rs b/src/frontend/connections/mod.rs
new file mode 100644
index 0000000..5cbe261
--- /dev/null
+++ b/src/frontend/connections/mod.rs
@@ -0,0 +1,11 @@
+pub mod deauth;
+pub mod handshake;
+pub mod interface;
+pub mod refresh;
+pub mod scan;
+
+pub use deauth::*;
+pub use handshake::*;
+pub use interface::*;
+pub use refresh::*;
+pub use scan::*;
diff --git a/src/frontend/connections/refresh.rs b/src/frontend/connections/refresh.rs
new file mode 100644
index 0000000..0dd6c08
--- /dev/null
+++ b/src/frontend/connections/refresh.rs
@@ -0,0 +1,132 @@
+use crate::backend;
+use crate::frontend::interfaces::*;
+use crate::globals;
+use crate::list_store_get;
+use crate::types::*;
+use gtk4::prelude::*;
+use gtk4::*;
+use std::rc::Rc;
+use std::time::Duration;
+
+pub fn list_store_find(storage: &ListStore, pos: i32, to_match: &str) -> Option<TreeIter> {
+ let mut iter = storage.iter_first();
+
+ while let Some(it) = iter {
+ let value = list_store_get!(storage, &it, pos, String);
+
+ if value == to_match {
+ return Some(it);
+ }
+
+ iter = match storage.iter_next(&it) {
+ true => Some(it),
+ false => None,
+ }
+ }
+
+ None
+}
+
+pub fn connect_app_refresh(app_data: Rc<AppData>) {
+ glib::timeout_add_local(Duration::from_millis(100), move || {
+ match app_data.aps_view.selection().selected() {
+ Some((_, iter)) => {
+ let bssid = list_store_get!(app_data.aps_model, &iter, 1, String);
+ let attack_pool = backend::get_attack_pool();
+
+ match attack_pool.contains_key(&bssid) {
+ true => {
+ app_data.deauth_but.set_label("Stop Attack");
+ app_data.deauth_but.set_icon(globals::STOP_ICON);
+ }
+ false => {
+ app_data.deauth_but.set_label("Deauth Attack");
+ app_data.deauth_but.set_icon(globals::DEAUTH_ICON);
+ }
+ }
+ }
+ None => {
+ app_data.deauth_but.set_label("Deauth Attack");
+ app_data.deauth_but.set_icon(globals::DEAUTH_ICON);
+ }
+ };
+
+ match backend::get_aps().is_empty() {
+ true => app_data.clear_but.set_sensitive(false),
+ false => app_data.clear_but.set_sensitive(true),
+ }
+
+ let aps = backend::get_airodump_data();
+
+ for (bssid, ap) in aps.iter() {
+ let it = match list_store_find(app_data.aps_model.as_ref(), 1, bssid.as_str()) {
+ Some(it) => it,
+ None => app_data.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),
+ };
+
+ app_data.aps_model.set(
+ &it,
+ &[
+ (0, &ap.essid),
+ (1, &ap.bssid),
+ (2, &ap.band),
+ (3, &ap.channel.parse::<i32>().unwrap_or(-1)),
+ (4, &ap.speed.parse::<i32>().unwrap_or(-1)),
+ (5, &ap.power.parse::<i32>().unwrap_or(-1)),
+ (6, &ap.privacy),
+ (7, &(ap.clients.len() as i32)),
+ (8, &ap.first_time_seen),
+ (9, &ap.last_time_seen),
+ (10, &background_color.to_str()),
+ ],
+ );
+ }
+
+ if let Some((_, iter)) = app_data.aps_view.selection().selected() {
+ let bssid = list_store_get!(app_data.aps_model, &iter, 1, String);
+ let clients = &aps[&bssid].clients;
+
+ for (_, cli) in clients.iter() {
+ let it = match list_store_find(app_data.cli_model.as_ref(), 0, cli.mac.as_str()) {
+ Some(it) => it,
+ None => app_data.cli_model.append(),
+ };
+
+ let background_color = match backend::get_attack_pool().get(&bssid) {
+ Some(attack_target) => match &attack_target.1 {
+ AttackedClients::All(_) => gdk::RGBA::RED,
+ AttackedClients::Selection(selection) => {
+ let mut color = gdk::RGBA::new(0.0, 0.0, 0.0, 0.0);
+
+ for sel in selection.iter() {
+ if sel.0 == cli.mac.as_str() {
+ color = gdk::RGBA::RED;
+ }
+ }
+ color
+ }
+ },
+ None => gdk::RGBA::new(0.0, 0.0, 0.0, 0.0),
+ };
+
+ app_data.cli_model.set(
+ &it,
+ &[
+ (0, &cli.mac),
+ (1, &cli.packets.parse::<i32>().unwrap_or(-1)),
+ (2, &cli.power.parse::<i32>().unwrap_or(-1)),
+ (3, &cli.first_time_seen),
+ (4, &cli.last_time_seen),
+ (5, &background_color.to_str()),
+ ],
+ );
+ }
+ }
+ glib::Continue(true)
+ });
+}
diff --git a/src/frontend/connections/scan.rs b/src/frontend/connections/scan.rs
new file mode 100644
index 0000000..dbf86ac
--- /dev/null
+++ b/src/frontend/connections/scan.rs
@@ -0,0 +1,244 @@
+use crate::backend;
+use crate::frontend::interfaces::*;
+use crate::types::*;
+use glib::clone;
+use gtk4::prelude::*;
+use gtk4::*;
+use std::fs::File;
+use std::io::Write;
+use std::rc::Rc;
+
+fn run_scan(app_data: &AppData) {
+ let mut args = vec![];
+
+ let iface = match backend::get_iface() {
+ Some(iface) => iface,
+ None => return app_data.interface_window.show(),
+ };
+
+ if !app_data.ghz_2_4_but.is_active() && !app_data.ghz_5_but.is_active() {
+ return ErrorDialog::spawn(
+ &app_data.main_window,
+ "Error",
+ "You need to select at least one frequency band",
+ false,
+ );
+ }
+
+ let mut bands = "".to_string();
+
+ if app_data.ghz_5_but.is_active() {
+ if !backend::is_5ghz_supported(&iface).unwrap() {
+ ErrorDialog::spawn(
+ &app_data.main_window,
+ "Error",
+ "Your network card doesn't support 5GHz",
+ false,
+ );
+ return app_data.ghz_5_but.set_active(false);
+ }
+ bands.push('a');
+ }
+ if app_data.ghz_2_4_but.is_active() {
+ bands.push_str("bg");
+ }
+ args.push("--band");
+ args.push(&bands);
+
+ let channel_filter = app_data
+ .channel_filter_entry
+ .text()
+ .as_str()
+ .replace(' ', "");
+
+ if !channel_filter.is_empty() {
+ match backend::is_valid_channel_filter(&channel_filter) {
+ true => {
+ args.push("--channel");
+ args.push(&channel_filter);
+ }
+ false => {
+ return ErrorDialog::spawn(
+ &app_data.main_window,
+ "Error",
+ "You need to put a valid channel filter",
+ false,
+ );
+ }
+ }
+ }
+
+ backend::set_scan_process(&args).unwrap_or_else(|e| {
+ ErrorDialog::spawn(
+ &app_data.main_window,
+ "Error",
+ &format!("Could not start scan process: {}", e),
+ false,
+ )
+ });
+
+ app_data
+ .scan_but
+ .set_icon_name("media-playback-pause-symbolic");
+}
+
+pub fn connect_scan_button(app_data: Rc<AppData>) {
+ app_data.scan_but.connect_clicked(
+ clone!(@strong app_data => move |this| match backend::is_scan_process() {
+ true => {
+ backend::stop_scan_process();
+ this.set_icon_name("media-playback-start-symbolic");
+ }
+ false => {
+ run_scan(&app_data);
+ }
+ }),
+ );
+}
+
+pub fn connect_clear_button(app_data: Rc<AppData>) {
+ app_data
+ .clear_but
+ .connect_clicked(clone!(@strong app_data => move |this| {
+ backend::stop_scan_process();
+ backend::get_aps().clear();
+
+ app_data.aps_model.clear();
+ app_data.cli_model.clear();
+
+ this.set_sensitive(false);
+ app_data
+ .scan_but
+ .set_icon_name("media-playback-start-symbolic");
+ }));
+}
+
+pub fn connect_save_button(app_data: Rc<AppData>) {
+ app_data
+ .export_but
+ .connect_clicked(clone!(@strong app_data => move |_| {
+ let aps = backend::get_aps();
+
+ if aps.is_empty() {
+ return ErrorDialog::spawn(
+ &app_data.main_window,
+ "Error",
+ "There is no data to export",
+ false,
+ );
+ }
+
+ let aps = aps.values().cloned().collect::<Vec<AP>>();
+ let json_data = serde_json::to_string::<Vec<AP>>(&aps).unwrap();
+
+ let file_chooser_dialog = Rc::new(FileChooserDialog::new(
+ Some("Save Capture"),
+ Some(&app_data.main_window),
+ FileChooserAction::Save,
+ &[("Save", ResponseType::Accept)],
+ ));
+
+ file_chooser_dialog.set_current_name("capture.json");
+ file_chooser_dialog.run_async(move |this, response| {
+ if response == ResponseType::Accept {
+ let gio_file = match this.file() {
+ Some(file) => file,
+ None => return,
+ };
+ let mut file = File::create(gio_file.path().unwrap()).unwrap();
+ file.write_all(json_data.as_bytes()).unwrap();
+ }
+ this.close();
+ });
+ }));
+}
+
+pub fn connect_ghz_2_4_button(app_data: Rc<AppData>) {
+ app_data
+ .ghz_2_4_but
+ .connect_toggled(clone!(@strong app_data => move |this| {
+ if backend::is_scan_process() {
+ if !this.is_active() && !app_data.ghz_5_but.is_active() {
+ ErrorDialog::spawn(
+ &app_data.main_window,
+ "Error",
+ "You need to select at least one frequency band",
+ false,
+ );
+ return this.set_active(true);
+ }
+ run_scan(&app_data);
+ }
+ }));
+}
+
+pub fn connect_ghz_5_button(app_data: Rc<AppData>) {
+ app_data
+ .ghz_5_but
+ .connect_toggled(clone!(@strong app_data => move |this| {
+ let iface = match backend::get_iface() {
+ Some(iface) => iface,
+ None => return,
+ };
+
+ if !backend::is_5ghz_supported(&iface).unwrap() && this.is_active() {
+ ErrorDialog::spawn(
+ &app_data.main_window,
+ "Error",
+ "Your network card doesn't support 5GHz",
+ false,
+ );
+ return this.set_active(false);
+ }
+
+ if backend::is_scan_process() {
+ if !this.is_active() && !app_data.ghz_2_4_but.is_active() {
+ ErrorDialog::spawn(
+ &app_data.main_window,
+ "Error",
+ "You need to select at least one frequency band",
+ false,
+ );
+ return this.set_active(true);
+ }
+ run_scan(&app_data);
+ }
+ }));
+}
+
+pub fn connect_channel_entry(app_data: Rc<AppData>) {
+ app_data
+ .channel_filter_entry
+ .connect_text_notify(clone!(@strong app_data => move |this| {
+ let channel_filter = this
+ .text()
+ .as_str()
+ .replace(' ', "");
+
+ if !channel_filter.is_empty() && !backend::is_valid_channel_filter(&channel_filter) {
+ return;
+ }
+
+ if backend::is_scan_process() {
+ run_scan(&app_data);
+ }
+ }));
+}
+
+pub fn connect_cursor_changed(app_data: Rc<AppData>) {
+ app_data
+ .aps_view
+ .connect_cursor_changed(clone!(@strong app_data => move |this| {
+ match this.selection().selected().is_some() {
+ true => {
+ app_data.deauth_but.set_sensitive(true);
+ app_data.capture_but.set_sensitive(true);
+ }
+ false => {
+ app_data.deauth_but.set_sensitive(false);
+ app_data.capture_but.set_sensitive(false);
+ }
+ };
+ app_data.cli_model.clear();
+ }));
+}
diff --git a/src/frontend/interfaces/app.rs b/src/frontend/interfaces/app.rs
new file mode 100644
index 0000000..392a3d2
--- /dev/null
+++ b/src/frontend/interfaces/app.rs
@@ -0,0 +1,401 @@
+use crate::backend;
+use crate::frontend::widgets::*;
+use crate::globals;
+use gtk4::gdk_pixbuf::Pixbuf;
+use gtk4::prelude::*;
+use gtk4::*;
+
+fn build_about_button() -> Button {
+ let about_button = Button::builder().icon_name("dialog-information").build();
+
+ about_button.connect_clicked(|_| {
+ let ico = Pixbuf::from_read(std::io::BufReader::new(globals::APP_ICON)).unwrap();
+ let des = "A WiFi auditing software that can perform deauth attacks and passwords recovery";
+
+ AboutDialog::builder()
+ .program_name("Airgorah")
+ .version(globals::VERSION)
+ .authors(vec!["Martin OLIVIER ([email protected])".to_string()])
+ .copyright("Copyright (c) Martin OLIVIER")
+ .license_type(License::MitX11)
+ .logo(&Picture::for_pixbuf(&ico).paintable().unwrap())
+ .comments(des)
+ .website_label("https://github.com/martin-olivier/airgorah")
+ .modal(true)
+ .build()
+ .show();
+ });
+
+ about_button
+}
+
+pub fn build_header_bar() -> HeaderBar {
+ let header_bar = HeaderBar::builder().show_title_buttons(true).build();
+
+ header_bar.pack_start(&build_about_button());
+
+ header_bar
+}
+
+fn build_main_window(app: &Application) -> ApplicationWindow {
+ let window = ApplicationWindow::builder()
+ .application(app)
+ .title("Airgorah")
+ .default_width(1280)
+ .default_height(540)
+ .build();
+
+ window.connect_close_request(|_| {
+ backend::app_cleanup();
+ glib::signal::Inhibit(false)
+ });
+
+ window
+}
+
+fn build_interface_window(app: &Application) -> Window {
+ Window::builder()
+ .title("Select a wireless interface")
+ .hide_on_close(true)
+ .default_width(280)
+ .default_height(70)
+ .resizable(false)
+ .modal(true)
+ .transient_for(&app.active_window().unwrap())
+ .build()
+}
+
+fn build_interface_model() -> ListStore {
+ ListStore::new(&[glib::Type::STRING])
+}
+
+fn build_interface_view(model: &ListStore) -> ComboBox {
+ let text_renderer = CellRendererText::new();
+
+ let icon_renderer = CellRendererPixbuf::new();
+ icon_renderer.set_property("icon-name", "network-wired");
+
+ let combo = ComboBox::with_model(model);
+ combo.set_hexpand(true);
+ combo.pack_start(&icon_renderer, false);
+ combo.pack_start(&text_renderer, false);
+ combo.add_attribute(&text_renderer, "text", 0);
+
+ combo
+}
+
+fn build_aps_model() -> ListStore {
+ ListStore::new(&[
+ glib::Type::STRING,
+ glib::Type::STRING,
+ glib::Type::STRING,
+ glib::Type::I32,
+ glib::Type::I32,
+ glib::Type::I32,
+ glib::Type::STRING,
+ glib::Type::I32,
+ glib::Type::STRING,
+ glib::Type::STRING,
+ glib::Type::STRING, // color
+ ])
+}
+
+fn build_aps_view() -> TreeView {
+ let view = TreeView::builder().vexpand(true).hexpand(true).build();
+ let colomn_names = [
+ "ESSID",
+ "BSSID",
+ "Band",
+ "Channel",
+ "Speed",
+ "Power",
+ "Encryption",
+ "Clients",
+ "First time seen",
+ "Last time seen",
+ ];
+
+ for (pos, colomn_name) in colomn_names.into_iter().enumerate() {
+ let column = TreeViewColumn::builder()
+ .title(colomn_name)
+ .resizable(true)
+ .min_width(50)
+ .sort_indicator(true)
+ .sort_column_id(pos as i32)
+ .expand(true)
+ .build();
+
+ if pos == 0 {
+ let icon_renderer = CellRendererPixbuf::new();
+ icon_renderer.set_property("icon-name", "network-wireless");
+ column.pack_start(&icon_renderer, false);
+ }
+
+ let text_renderer = CellRendererText::new();
+ column.pack_start(&text_renderer, true);
+ column.add_attribute(&text_renderer, "text", pos as i32);
+ column.add_attribute(&text_renderer, "background", 10);
+
+ view.append_column(&column);
+ }
+ view
+}
+
+fn build_aps_scroll() -> ScrolledWindow {
+ let aps_scroll = ScrolledWindow::new();
+ aps_scroll.set_policy(PolicyType::Never, PolicyType::Automatic);
+ aps_scroll.set_height_request(140);
+
+ aps_scroll
+}
+
+fn build_cli_model() -> ListStore {
+ ListStore::new(&[
+ glib::Type::STRING,
+ glib::Type::I32,
+ glib::Type::I32,
+ glib::Type::STRING,
+ glib::Type::STRING,
+ glib::Type::STRING,
+ ])
+}
+
+fn build_cli_view() -> TreeView {
+ let view = TreeView::builder().vexpand(true).hexpand(true).build();
+ let colomn_names = [
+ "Station MAC",
+ "Packets",
+ "Power",
+ "First time seen",
+ "Last time seen",
+ ];
+
+ for (pos, colomn_name) in colomn_names.into_iter().enumerate() {
+ let column = TreeViewColumn::builder()
+ .title(colomn_name)
+ .resizable(true)
+ .min_width(50)
+ .sort_indicator(true)
+ .sort_column_id(pos as i32)
+ .expand(true)
+ .build();
+
+ if pos == 0 {
+ let icon_renderer = CellRendererPixbuf::new();
+ icon_renderer.set_property("icon-name", "computer");
+ column.pack_start(&icon_renderer, false);
+ }
+
+ let text_renderer = CellRendererText::new();
+ column.pack_start(&text_renderer, true);
+ column.add_attribute(&text_renderer, "text", pos as i32);
+ column.add_attribute(&text_renderer, "background", 5);
+
+ view.append_column(&column);
+ }
+ view
+}
+
+fn build_cli_scroll() -> ScrolledWindow {
+ let aps_scroll = ScrolledWindow::new();
+ aps_scroll.set_policy(PolicyType::Never, PolicyType::Automatic);
+
+ aps_scroll
+}
+
+pub struct AppData {
+ // Main window
+ pub main_window: ApplicationWindow,
+ pub aps_model: ListStore,
+ pub aps_view: TreeView,
+ pub cli_model: ListStore,
+ pub cli_view: TreeView,
+ pub ghz_2_4_but: CheckButton,
+ pub ghz_5_but: CheckButton,
+ pub channel_filter_entry: Entry,
+ pub scan_but: Button,
+ pub clear_but: Button,
+ pub export_but: Button,
+ pub deauth_but: IconTextButton,
+ pub capture_but: IconTextButton,
+
+ // Interface window
+ pub interface_window: Window,
+ pub select_but: Button,
+ pub refresh_but: Button,
+ pub interface_model: ListStore,
+ pub interface_view: ComboBox,
+}
+
+impl AppData {
+ pub fn new(app: &Application) -> Self {
+ // --- MAIN WINDOW ---
+
+ let main_window = build_main_window(app);
+ main_window.set_titlebar(Some(&build_header_bar()));
+
+ // Left Views (APs and Clients)
+
+ let aps_model = build_aps_model();
+ let aps_view = build_aps_view();
+ let aps_scroll = build_aps_scroll();
+
+ aps_scroll.set_child(Some(&aps_view));
+ aps_view.set_model(Some(&aps_model));
+
+ let cli_model = build_cli_model();
+ let cli_view = build_cli_view();
+ let cli_scroll = build_cli_scroll();
+
+ cli_scroll.set_child(Some(&cli_view));
+ cli_view.set_model(Some(&cli_model));
+
+ // Scan, Stop and Save Buttons
+
+ let scan_but = Button::builder()
+ .icon_name("media-playback-start-symbolic")
+ .tooltip_text("Start / Pause the scan")
+ .build();
+
+ let clear_but = Button::builder()
+ .icon_name("edit-delete-symbolic")
+ .sensitive(false)
+ .tooltip_text("Stop the scan and clear results")
+ .build();
+
+ let export_but = Button::builder()
+ .icon_name("media-floppy-symbolic")
+ .tooltip_text("Export the scan results to a JSON file")
+ .build();
+
+ let top_but_box = CenterBox::new();
+ top_but_box.set_margin_start(10);
+ top_but_box.set_margin_end(10);
+ top_but_box.set_margin_top(10);
+ top_but_box.set_start_widget(Some(&scan_but));
+ top_but_box.set_center_widget(Some(&clear_but));
+ top_but_box.set_end_widget(Some(&export_but));
+
+ // Scan filters
+
+ let scan_box = Box::new(Orientation::Vertical, 10);
+
+ let ghz_2_4_but = CheckButton::builder().active(true).label("2.4 GHz").build();
+ let ghz_5_but = CheckButton::builder().active(false).label("5 GHz").build();
+
+ ghz_2_4_but.set_margin_start(6);
+ ghz_5_but.set_margin_end(6);
+
+ let but_box = Box::new(Orientation::Horizontal, 10);
+ but_box.append(&ghz_2_4_but);
+ but_box.append(&ghz_5_but);
+ but_box.set_margin_bottom(4);
+
+ let band_frame = Frame::new(Some("Band"));
+ band_frame.set_child(Some(&but_box));
+
+ let channel_filter_entry = Entry::builder()
+ .placeholder_text("ex: 1,6,11")
+ .margin_start(4)
+ .margin_end(4)
+ .margin_bottom(4)
+ .build();
+
+ let channel_frame = Frame::new(Some("Channel"));
+ channel_frame.set_child(Some(&channel_filter_entry));
+
+ let separator = Separator::new(Orientation::Vertical);
+ separator.set_vexpand(true);
+ separator.set_opacity(0.0);
+
+ let deauth_but = IconTextButton::new(globals::DEAUTH_ICON, "Deauth Attack");
+ deauth_but.set_tooltip_text(Some("Perform (or stop) a deauth attack on the selected AP"));
+ deauth_but.set_sensitive(false);
+
+ let capture_but = IconTextButton::new(globals::CAPTURE_ICON, "Handshake Capture");
+ capture_but.set_tooltip_text(Some("Capture a WPA handshake from the selected AP"));
+ capture_but.set_sensitive(false);
+ capture_but.set_margin_bottom(10);
+
+ scan_box.append(&band_frame);
+ scan_box.append(&channel_frame);
+ scan_box.append(&top_but_box);
+ scan_box.append(&separator);
+ scan_box.append(&deauth_but.handle);
+ scan_box.append(&capture_but.handle);
+
+ scan_box.set_hexpand(false);
+
+ scan_box.set_margin_top(10);
+ scan_box.set_margin_end(10);
+
+ // Set main window childs
+
+ let main_box = Box::new(Orientation::Horizontal, 10);
+
+ let panned = Paned::new(Orientation::Vertical);
+ panned.set_wide_handle(true);
+ panned.set_start_child(Some(&aps_scroll));
+ panned.set_end_child(Some(&cli_scroll));
+
+ main_box.append(&panned);
+ main_box.append(&scan_box);
+
+ main_window.set_child(Some(&main_box));
+ main_window.show();
+
+ // --- INTERFACE WINDOW ---
+
+ let interface_window = build_interface_window(app);
+
+ let interface_model = build_interface_model();
+
+ let interface_view = build_interface_view(&interface_model);
+
+ let refresh_but = Button::builder()
+ .icon_name("object-rotate-right-symbolic")
+ .build();
+
+ let select_but = Button::with_label("Select");
+
+ let hbox = Box::new(Orientation::Horizontal, 10);
+ let vbox = Box::new(Orientation::Vertical, 10);
+
+ hbox.append(&interface_view);
+ hbox.append(&refresh_but);
+
+ hbox.set_margin_top(10);
+ hbox.set_margin_start(10);
+ hbox.set_margin_end(10);
+
+ vbox.append(&hbox);
+ vbox.append(&select_but);
+
+ vbox.set_margin_top(0);
+
+ interface_window.set_child(Some(&vbox));
+
+ Self {
+ // MAIN WINDOW
+ main_window,
+ aps_model,
+ aps_view,
+ cli_model,
+ cli_view,
+ ghz_2_4_but,
+ ghz_5_but,
+ channel_filter_entry,
+ scan_but,
+ clear_but,
+ export_but,
+ deauth_but,
+ capture_but,
+ // INTERFACE WINDOW
+ interface_window,
+ select_but,
+ refresh_but,
+ interface_model,
+ interface_view,
+ }
+ }
+}
diff --git a/src/frontend/interfaces/deauth.rs b/src/frontend/interfaces/deauth.rs
new file mode 100644
index 0000000..80aca82
--- /dev/null
+++ b/src/frontend/interfaces/deauth.rs
@@ -0,0 +1,166 @@
+use glib::Value;
+use gtk4::prelude::*;
+use gtk4::*;
+use std::rc::Rc;
+
+use super::dialog::*;
+use crate::backend;
+use crate::list_store_get;
+use crate::types::*;
+
+pub struct DeauthWindow;
+
+impl DeauthWindow {
+ pub fn spawn(parent: &impl IsA<Window>, ap: AP) {
+ let window = Rc::new(
+ Window::builder()
+ .title(&format!("Deauth \"{}\"", ap.essid))
+ .default_width(300)
+ .default_height(140)
+ .resizable(false)
+ .modal(true)
+ .build(),
+ );
+
+ window.set_transient_for(Some(parent));
+
+ let all_cli_but = CheckButton::with_label("Deauth all clients");
+ let sel_cli_but = CheckButton::with_label("Deauth selected clients");
+
+ all_cli_but.set_active(true);
+ sel_cli_but.set_group(Some(&all_cli_but));
+
+ all_cli_but.set_margin_start(15);
+ all_cli_but.set_margin_top(15);
+
+ sel_cli_but.set_margin_start(15);
+ sel_cli_but.set_margin_bottom(15);
+
+ let but_box = Box::new(Orientation::Vertical, 10);
+ but_box.append(&all_cli_but);
+ but_box.append(&sel_cli_but);
+
+ let store = Rc::new(ListStore::new(&[glib::Type::BOOL, glib::Type::STRING]));
+
+ let frame = Frame::new(None);
+ frame.set_child(Some(&but_box));
+
+ let view = Rc::new(TreeView::new());
+ view.set_model(Some(store.as_ref()));
+
+ for (_, cli) in ap.clients.iter() {
+ store.set(&store.append(), &[(0, &false), (1, &cli.mac)]);
+ }
+
+ let column = TreeViewColumn::new();
+ column.set_title("Clients");
+ view.append_column(&column);
+ view.set_vexpand(true);
+
+ let toggle = CellRendererToggle::new();
+ column.pack_start(&toggle, false);
+ column.add_attribute(&toggle, "active", 0);
+
+ let text_ren = CellRendererText::new();
+ column.pack_start(&text_ren, true);
+ column.add_attribute(&text_ren, "text", 1);
+
+ let scroll = Rc::new(ScrolledWindow::new());
+ scroll.set_policy(PolicyType::Never, PolicyType::Automatic);
+ scroll.set_child(Some(view.as_ref()));
+ scroll.hide();
+
+ let attack_but = Rc::new(Button::with_label("Attack"));
+
+ let main_box = Box::new(Orientation::Vertical, 10);
+ main_box.append(&frame);
+ main_box.append(&*scroll);
+ main_box.append(&*attack_but);
+
+ main_box.set_margin_bottom(10);
+ main_box.set_margin_end(10);
+ main_box.set_margin_start(10);
+ main_box.set_margin_top(10);
+
+ window.set_child(Some(&main_box));
+ window.show();
+
+ // Callbacks
+
+ let window_ref = window.clone();
+ let scroll_ref = scroll.clone();
+ let attack_but_ref = attack_but.clone();
+
+ all_cli_but.connect_toggled(move |_| {
+ scroll_ref.hide();
+ window_ref.set_height_request(140);
+ attack_but_ref.set_sensitive(true);
+ });
+
+ let window_ref = window.clone();
+ let store_ref = store.clone();
+ let attack_but_ref = attack_but.clone();
+
+ sel_cli_but.connect_toggled(move |_| {
+ scroll.show();
+ window_ref.set_height_request(300);
+ if get_selected_clis(&store_ref).is_empty() {
+ attack_but_ref.set_sensitive(false);
+ }
+ });
+
+ let store_ref = store.clone();
+ let attack_but_ref = attack_but.clone();
+
+ toggle.connect_toggled(move |_, path| {
+ let iter = store_ref.iter(&path).unwrap();
+ let old_val = list_store_get!(store_ref, &iter, 0, bool);
+
+ store_ref.set_value(&iter, 0, &Value::from(&(!old_val)));
+
+ match get_selected_clis(&store_ref).is_empty() {
+ true => attack_but_ref.set_sensitive(false),
+ false => attack_but_ref.set_sensitive(true),
+ };
+ });
+
+ attack_but.connect_clicked(move |_| {
+ let params = match sel_cli_but.is_active() {
+ true => Some(get_selected_clis(store.as_ref())),
+ false => None,
+ };
+
+ backend::launch_deauth_attack(ap.clone(), params).unwrap_or_else(|e| {
+ return ErrorDialog::spawn(
+ window.as_ref(),
+ "Error",
+ &format!("Could not start deauth process: {}", e),
+ false,
+ );
+ });
+
+ window.close();
+ });
+ }
+}
+
+fn get_selected_clis(storage: &ListStore) -> Vec<String> {
+ let mut iter = storage.iter_first();
+ let mut selected_clis = vec![];
+
+ while let Some(it) = iter {
+ let check_val = list_store_get!(storage, &it, 0, bool);
+ let mac_val = list_store_get!(storage, &it, 1, String);
+
+ if check_val {
+ selected_clis.push(mac_val);
+ }
+
+ iter = match storage.iter_next(&it) {
+ true => Some(it),
+ false => None,
+ }
+ }
+
+ selected_clis
+}
diff --git a/src/frontend/interfaces/dialog.rs b/src/frontend/interfaces/dialog.rs
new file mode 100644
index 0000000..bb5188d
--- /dev/null
+++ b/src/frontend/interfaces/dialog.rs
@@ -0,0 +1,52 @@
+use gtk4::prelude::*;
+use gtk4::*;
+
+pub struct ErrorDialog;
+
+impl ErrorDialog {
+ pub fn spawn(parent: &impl IsA<Window>, title: &str, content: &str, terminate: bool) {
+ let dialog = MessageDialog::builder()
+ .text(title)
+ .secondary_text(content)
+ .decorated(true)
+ .message_type(MessageType::Error)
+ .buttons(ButtonsType::Close)
+ .modal(true)
+ .transient_for(parent)
+ .build();
+
+ dialog.connect_response(move |this, _| {
+ this.close();
+ if terminate {
+ std::process::exit(1);
+ }
+ });
+ dialog.connect_close(move |_| {
+ if terminate {
+ std::process::exit(1);
+ }
+ });
+ dialog.show();
+ }
+}
+
+pub struct InfoDialog;
+
+impl InfoDialog {
+ pub fn spawn(parent: &impl IsA<Window>, title: &str, content: &str) {
+ let dialog = MessageDialog::builder()
+ .text(title)
+ .secondary_text(content)
+ .decorated(true)
+ .message_type(MessageType::Info)
+ .buttons(ButtonsType::Ok)
+ .modal(true)
+ .transient_for(parent)
+ .build();
+
+ dialog.connect_response(|this, _| {
+ this.close();
+ });
+ dialog.show();
+ }
+}
diff --git a/src/frontend/interfaces/mod.rs b/src/frontend/interfaces/mod.rs
new file mode 100644
index 0000000..240bd8c
--- /dev/null
+++ b/src/frontend/interfaces/mod.rs
@@ -0,0 +1,7 @@
+pub mod app;
+pub mod deauth;
+pub mod dialog;
+
+pub use app::AppData;
+pub use deauth::DeauthWindow;
+pub use dialog::{ErrorDialog, InfoDialog};
diff --git a/src/frontend/mod.rs b/src/frontend/mod.rs
new file mode 100644
index 0000000..0bfb9a2
--- /dev/null
+++ b/src/frontend/mod.rs
@@ -0,0 +1,43 @@
+mod connections;
+mod interfaces;
+mod widgets;
+
+use crate::backend;
+use connections::*;
+use interfaces::*;
+
+use gtk4::prelude::*;
+use gtk4::*;
+use std::rc::Rc;
+
+pub fn build_ui(app: &Application) {
+ let gui_data = Rc::new(AppData::new(app));
+
+ if let Err(e) = backend::app_setup() {
+ return ErrorDialog::spawn(&app.active_window().unwrap(), "Error", &e.to_string(), true);
+ }
+
+ connect_app_refresh(gui_data.clone());
+ connect_cursor_changed(gui_data.clone());
+
+ connect_interface_refresh(gui_data.clone());
+ connect_interface_select(gui_data.clone());
+
+ connect_scan_button(gui_data.clone());
+ connect_clear_button(gui_data.clone());
+ connect_save_button(gui_data.clone());
+
+ connect_ghz_2_4_button(gui_data.clone());
+ connect_ghz_5_button(gui_data.clone());
+ connect_channel_entry(gui_data.clone());
+
+ connect_deauth_button(gui_data.clone());
+ connect_capture_button(gui_data);
+}
+
+#[macro_export]
+macro_rules! list_store_get {
+ ($storage:expr,$iter:expr,$pos:expr,$typ:ty) => {
+ $storage.get_value($iter, $pos).get::<$typ>().unwrap()
+ };
+}
diff --git a/src/frontend/widgets/icon_button.rs b/src/frontend/widgets/icon_button.rs
new file mode 100644
index 0000000..95dd543
--- /dev/null
+++ b/src/frontend/widgets/icon_button.rs
@@ -0,0 +1,55 @@
+#![allow(unused)]
+
+use gtk4::gdk_pixbuf::Pixbuf;
+use gtk4::prelude::*;
+use gtk4::*;
+
+pub struct IconButton {
+ pub handle: Button,
+ image: Image,
+}
+
+impl IconButton {
+ pub fn new(icon: &'static [u8]) -> Self {
+ let pixbuf = Pixbuf::from_read(std::io::BufReader::new(icon)).unwrap();
+
+ let image = Image::from_pixbuf(Some(&pixbuf));
+
+ let handle = Button::builder().child(&image).build();
+
+ Self { handle, image }
+ }
+
+ pub fn set_tooltip_text(&self, text: Option<&str>) {
+ self.handle.set_tooltip_text(text)
+ }
+
+ pub fn set_sensitive(&self, sensitive: bool) {
+ self.handle.set_sensitive(sensitive)
+ }
+
+ pub fn set_icon(&self, icon: &'static [u8]) {
+ let pixbuf = Pixbuf::from_read(std::io::BufReader::new(icon)).unwrap();
+ self.image.set_from_pixbuf(Some(&pixbuf))
+ }
+
+ pub fn connect_clicked<F: Fn(&Button) + 'static>(&self, f: F) -> glib::SignalHandlerId {
+ self.handle.connect_clicked(f)
+ }
+
+ pub fn set_margin_bottom(&self, margin_bottom: i32) {
+ self.handle.set_margin_bottom(margin_bottom)
+ }
+
+ pub fn set_margin_end(&self, margin_end: i32) {
+ self.handle.set_margin_end(margin_end)
+ }
+
+ pub fn set_margin_start(&self, margin_start: i32) {
+ self.handle.set_margin_start(margin_start)
+ }
+
+ pub fn set_margin_top(&self, margin_top: i32) {
+ self.handle.set_margin_top(margin_top)
+ }
+}
diff --git a/src/frontend/widgets/icon_text_button.rs b/src/frontend/widgets/icon_text_button.rs
new file mode 100644
index 0000000..db30d3d
--- /dev/null
+++ b/src/frontend/widgets/icon_text_button.rs
@@ -0,0 +1,72 @@
+#![allow(unused)]
+
+use gtk4::gdk_pixbuf::Pixbuf;
+use gtk4::prelude::*;
+use gtk4::*;
+
+pub struct IconTextButton {
+ pub handle: Button,
+ image: Image,
+ label: Label,
+}
+
+impl IconTextButton {
+ pub fn new(icon: &'static [u8], text: &str) -> Self {
+ let but_box = Box::new(Orientation::Horizontal, 6);
+ but_box.set_halign(Align::Center);
+
+ let pixbuf = Pixbuf::from_read(std::io::BufReader::new(icon)).unwrap();
+
+ let image = Image::from_pixbuf(Some(&pixbuf));
+
+ let label = Label::with_mnemonic(text);
+
+ but_box.append(&image);
+ but_box.append(&label);
+
+ let handle = Button::builder().child(&but_box).build();
+
+ Self {
+ handle,
+ image,
+ label,
+ }
+ }
+
+ pub fn set_tooltip_text(&self, text: Option<&str>) {
+ self.handle.set_tooltip_text(text)
+ }
+
+ pub fn set_sensitive(&self, sensitive: bool) {
+ self.handle.set_sensitive(sensitive)
+ }
+
+ pub fn set_label(&self, label: &str) {
+ self.label.set_label(label)
+ }
+
+ pub fn set_icon(&self, icon: &'static [u8]) {
+ let pixbuf = Pixbuf::from_read(std::io::BufReader::new(icon)).unwrap();
+ self.image.set_from_pixbuf(Some(&pixbuf))
+ }
+
+ pub fn connect_clicked<F: Fn(&Button) + 'static>(&self, f: F) -> glib::SignalHandlerId {
+ self.handle.connect_clicked(f)
+ }
+
+ pub fn set_margin_bottom(&self, margin_bottom: i32) {
+ self.handle.set_margin_bottom(margin_bottom)
+ }
+
+ pub fn set_margin_end(&self, margin_end: i32) {
+ self.handle.set_margin_end(margin_end)
+ }
+
+ pub fn set_margin_start(&self, margin_start: i32) {
+ self.handle.set_margin_start(margin_start)
+ }
+
+ pub fn set_margin_top(&self, margin_top: i32) {
+ self.handle.set_margin_top(margin_top)
+ }
+}
diff --git a/src/frontend/widgets/mod.rs b/src/frontend/widgets/mod.rs
new file mode 100644
index 0000000..809793e
--- /dev/null
+++ b/src/frontend/widgets/mod.rs
@@ -0,0 +1,5 @@
+mod icon_button;
+mod icon_text_button;
+
+pub use icon_button::IconButton;
+pub use icon_text_button::IconTextButton;
diff --git a/src/globals.rs b/src/globals.rs
new file mode 100644
index 0000000..eea0600
--- /dev/null
+++ b/src/globals.rs
@@ -0,0 +1,22 @@
+use crate::types::*;
+use lazy_static::lazy_static;
+use std::collections::HashMap;
+use std::process::Child;
+use std::sync::Mutex;
+
+pub static APP_ID: &str = "com.martin-olivier.airgorah";
+pub static VERSION: &str = "v0.1.0";
+pub static SCAN_PATH: &str = "/tmp/airgorah_scan";
+
+pub static APP_ICON: &[u8] = include_bytes!("../icons/app_icon.png");
+pub static DEAUTH_ICON: &[u8] = include_bytes!("../icons/deauth.png");
+pub static STOP_ICON: &[u8] = include_bytes!("../icons/stop.png");
+pub static CAPTURE_ICON: &[u8] = include_bytes!("../icons/capture.png");
+
+lazy_static! {
+ pub static ref IFACE: Mutex<Option<String>> = Mutex::new(None);
+ pub static ref SCAN_PROC: Mutex<Option<Child>> = Mutex::new(None);
+ pub static ref APS: Mutex<HashMap<String, AP>> = Mutex::new(HashMap::new());
+ pub static ref ATTACK_POOL: Mutex<HashMap<String, (AP, AttackedClients)>> =
+ Mutex::new(HashMap::new());
+}
diff --git a/src/main.rs b/src/main.rs
index e7a11a9..4a20716 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,3 +1,17 @@
+use gtk4::prelude::*;
+use gtk4::Application;
+
+mod backend;
+mod error;
+mod frontend;
+mod globals;
+mod types;
+
fn main() {
- println!("Hello, world!");
+ let application = Application::builder()
+ .application_id(globals::APP_ID)
+ .build();
+
+ application.connect_activate(frontend::build_ui);
+ application.run();
}
diff --git a/src/types.rs b/src/types.rs
new file mode 100644
index 0000000..dd0016d
--- /dev/null
+++ b/src/types.rs
@@ -0,0 +1,31 @@
+use serde::{Deserialize, Serialize};
+use std::collections::HashMap;
+use std::process::Child;
+
+pub enum AttackedClients {
+ All(Child),
+ Selection(Vec<(String, Child)>),
+}
+
+#[derive(Clone, Debug, Serialize, Deserialize)]
+pub struct AP {
+ pub essid: String,
+ pub bssid: String,
+ pub band: String,
+ pub channel: String,
+ pub speed: String,
+ pub power: String,
+ pub privacy: String,
+ pub first_time_seen: String,
+ pub last_time_seen: String,
+ pub clients: HashMap<String, Client>,
+}
+
+#[derive(Clone, Debug, Serialize, Deserialize)]
+pub struct Client {
+ pub mac: String,
+ pub packets: String,
+ pub power: String,
+ pub first_time_seen: String,
+ pub last_time_seen: String,
+}