Skip to content

A WiFi security auditing software

feat: third beta version of the application (#4)

Martin Olivier7704f3225cb7
diff --git a/.github/assets/illustration.png b/.github/assets/illustration.png
old mode 100755
new mode 100644
index 7b0bc42..da62655
Binary files a/.github/assets/illustration.png and b/.github/assets/illustration.png differ
diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
index 5f6a648..b32fc37 100644
--- a/.github/workflows/CI.yml
+++ b/.github/workflows/CI.yml
@@ -25,7 +25,7 @@ jobs:
name: conventional commits
runs-on: ubuntu-22.04
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- uses: webiny/[email protected]
linter:
@@ -33,7 +33,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- name: Install dependencies
run: sudo apt update && sudo apt install -y libgtk-4-dev libglib2.0-dev
@@ -60,7 +60,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- name: Install dependencies
run: sudo apt update && sudo apt install -y libgtk-4-dev libglib2.0-dev
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..aa81faa
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,31 @@
+name: "Release"
+
+on:
+ push:
+ tags:
+ - "v*"
+
+jobs:
+ release:
+ name: "Deploy"
+ runs-on: "ubuntu-22.04"
+ permissions: write-all
+
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Install dependencies
+ run: sudo apt update && sudo apt install -y libgtk-4-dev libglib2.0-dev
+
+ - name: Install cargo-deb
+ run: cargo install cargo-deb
+
+ - name: Build project
+ run: cargo deb
+
+ - name: Deploy release
+ uses: softprops/action-gh-release@v1
+ with:
+ files: ./target/debian/*.deb
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/Cargo.lock b/Cargo.lock
index 5974707..b204795 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -19,7 +19,7 @@ dependencies = [
[[package]]
name = "airgorah"
-version = "0.2.0"
+version = "0.3.0"
dependencies = [
"csv",
"ctrlc",
@@ -30,6 +30,7 @@ dependencies = [
"serde",
"serde_json",
"sudo",
+ "toml 0.7.3",
"ureq",
"which",
]
@@ -697,7 +698,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66618389e4ec1c7afe67d51a9bf34ff9236480f8d51e7489b7d5ab0303c13f34"
dependencies = [
"once_cell",
- "toml_edit",
+ "toml_edit 0.18.1",
]
[[package]]
@@ -744,9 +745,9 @@ dependencies = [
[[package]]
name = "regex"
-version = "1.7.2"
+version = "1.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cce168fea28d3e05f158bda4576cf0c844d5045bc2cc3620fa0292ed5bb5814c"
+checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d"
dependencies = [
"aho-corasick",
"memchr",
@@ -860,6 +861,15 @@ dependencies = [
"serde",
]
+[[package]]
+name = "serde_spanned"
+version = "0.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0efd8caf556a6cebd3b285caf480045fcc1ac04f6bd786b09a6f11af30c4fcf4"
+dependencies = [
+ "serde",
+]
+
[[package]]
name = "slab"
version = "0.4.8"
@@ -928,7 +938,7 @@ dependencies = [
"cfg-expr",
"heck",
"pkg-config",
- "toml",
+ "toml 0.5.11",
"version-compare",
]
@@ -976,12 +986,33 @@ dependencies = [
"serde",
]
+[[package]]
+name = "toml"
+version = "0.7.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b403acf6f2bb0859c93c7f0d967cb4a75a7ac552100f9322faf64dc047669b21"
+dependencies = [
+ "serde",
+ "serde_spanned",
+ "toml_datetime 0.6.1",
+ "toml_edit 0.19.8",
+]
+
[[package]]
name = "toml_datetime"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4553f467ac8e3d374bc9a177a26801e5d0f9b211aa1673fb137a403afd1c9cf5"
+[[package]]
+name = "toml_datetime"
+version = "0.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622"
+dependencies = [
+ "serde",
+]
+
[[package]]
name = "toml_edit"
version = "0.18.1"
@@ -990,7 +1021,20 @@ checksum = "56c59d8dd7d0dcbc6428bf7aa2f0e823e26e43b3c9aca15bbc9475d23e5fa12b"
dependencies = [
"indexmap",
"nom8",
- "toml_datetime",
+ "toml_datetime 0.5.1",
+]
+
+[[package]]
+name = "toml_edit"
+version = "0.19.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13"
+dependencies = [
+ "indexmap",
+ "serde",
+ "serde_spanned",
+ "toml_datetime 0.6.1",
+ "winnow",
]
[[package]]
@@ -1248,3 +1292,12 @@ name = "windows_x86_64_msvc"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd"
+
+[[package]]
+name = "winnow"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ae8970b36c66498d8ff1d66685dc86b91b29db0c7739899012f63a63814b4b28"
+dependencies = [
+ "memchr",
+]
diff --git a/Cargo.toml b/Cargo.toml
index 893967b..6887644 100755
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,13 +1,13 @@
[package]
name = "airgorah"
-version = "0.2.0"
+version = "0.3.0"
edition = "2021"
license = "MIT"
+description = "A WiFi auditing software that can perform deauth attacks and passwords cracking"
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 cracking"
keywords = ["networking", "pentest", "aircrack-ng", "gui", "linux"]
readme = "README.md"
exclude = ["/.github", "/package", "/docs"]
@@ -17,26 +17,28 @@ gtk4 = { version = "0.6.4", features = ["v4_6"] }
glib = "0.17.5"
serde = { version = "1.0.158", features = ["derive"] }
serde_json = "1.0.94"
+toml = "0.7.3"
csv = "1.2.1"
sudo = "0.6.0"
ctrlc = "3.2.5"
-regex = "1.7.2"
+regex = "1.7.3"
lazy_static = "1.4.0"
ureq = { version = "2.6.2", features = ["json"] }
which = "4.4.0"
[package.metadata.deb]
-copyright = "2022, Martin Olivier"
+copyright = "2023, Martin Olivier"
maintainer = "Martin Olivier <[email protected]>"
-license-file = [ "LICENSE" ]
+license-file = ["LICENSE"]
extended-description = "A WiFi auditing software that can perform deauth attacks and passwords cracking"
-depends = "gnome-terminal, pkexec, libgtk-4-1 (>= 4.6.0), dbus-x11, wireless-tools, aircrack-ng (>= 1.6), wireshark-common"
+depends = "gnome-terminal, pkexec, libgtk-4-1 (>= 4.6.0), dbus-x11, net-tools, wireless-tools, aircrack-ng (>= 1.6), wireshark-common, macchanger"
priority = "optional"
section = "utility"
assets = [
["target/release/airgorah", "/usr/bin/airgorah", "755"],
["README.md", "/usr/share/doc/airgorah/README", "644"],
["icons/app_icon.png", "/usr/share/app-install/icons/airgorah.png", "644"],
+ ["package/config.toml", "/etc/airgorah/config.toml", "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"],
]
diff --git a/LICENSE b/LICENSE
index 1cc14c8..6000446 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2022 Martin Olivier
+Copyright (c) 2023 Martin Olivier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index dcbe2ca..2674565 100644
--- a/README.md
+++ b/README.md
@@ -7,8 +7,8 @@
<h4 align="center">A WiFi auditing software that can perform deauth attacks and passwords cracking</h4>
<p align="center">
- <a href="https://github.com/martin-olivier/airgorah/releases/tag/v0.2.0">
- <img src="https://img.shields.io/badge/Version-0.2.0_(beta)-blue.svg" alt="version"/>
+ <a href="https://github.com/martin-olivier/airgorah/releases/tag/v0.3.0">
+ <img src="https://img.shields.io/badge/Version-0.3.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"/>
@@ -44,9 +44,7 @@ You will also need a wireless network card that supports `monitor mode` and `pac
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 debian package and install it with the following command:
```
-wget https://github.com/martin-olivier/airgorah/releases/download/v0.2.0/airgorah_0.2.0_amd64.deb
-sudo apt update
-sudo apt install ./airgorah_0.2.0_amd64.deb
+sudo apt install ~/Downloads/airgorah_0.3.0_amd64.deb
```
Otherwise, if you'd like to compile from source, you can follow this [guide](docs/build_from_source.md).
@@ -61,9 +59,7 @@ Pull requests are welcome. For major changes, please open an issue first to disc
## Future
-- [ ] Implement the setting page
- [ ] Provide usage documentation
- [ ] Improve the code quality and the documentation
-- [ ] Improve the UI
- [ ] Provide releases for other linux distributions (Arch, Fedora, ...)
- [ ] Provide releases for other architectures (arm, ...)
diff --git a/docs/build_from_source.md b/docs/build_from_source.md
index 97d4418..3a1e0d5 100644
--- a/docs/build_from_source.md
+++ b/docs/build_from_source.md
@@ -15,13 +15,13 @@ 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 gnome-terminal wireshark-common
+sudo apt install dbus-x11 libgtk-4-dev libglib2.0-dev aircrack-ng net-tools wireless-tools gnome-terminal wireshark-common macchanger
```
### Fedora
```sh
-sudo dnf install dbus-x11 gtk4-devel glib2-devel aircrack-ng wireless-tools-1 gnome-terminal wireshark-cli
+sudo dnf install dbus-x11 gtk4-devel glib2-devel aircrack-ng net-tools wireless-tools-1 gnome-terminal wireshark-cli macchanger
```
## 3. Install Airgorah
diff --git a/package/.desktop b/package/.desktop
index d399046..7e0b424 100644
--- a/package/.desktop
+++ b/package/.desktop
@@ -1,6 +1,6 @@
[Desktop Entry]
Encoding=UTF-8
-Version=0.2.0
+Version=0.3.0
Type=Application
Terminal=false
Exec=pkexec airgorah
diff --git a/package/config.toml b/package/config.toml
new file mode 100644
index 0000000..44471bb
--- /dev/null
+++ b/package/config.toml
@@ -0,0 +1,3 @@
+mac_address = "random"
+display_hidden_ap = true
+kill_network_manager = true
\ No newline at end of file
diff --git a/src/backend/app.rs b/src/backend/app.rs
index af6ea34..ddf06b3 100755
--- a/src/backend/app.rs
+++ b/src/backend/app.rs
@@ -1,9 +1,11 @@
+use super::*;
use crate::error::Error;
use crate::globals::*;
use crate::types::*;
use std::thread::JoinHandle;
+/// Check if the user is root, and if all the dependencies are installed
pub fn app_setup() -> Result<(), Error> {
app_cleanup();
@@ -17,6 +19,8 @@ pub fn app_setup() -> Result<(), Error> {
return Err(Error::new("Airgorah need root privilege to run"));
}
+ load_settings();
+
check_dependencies(&[
"sh",
"service",
@@ -29,30 +33,32 @@ pub fn app_setup() -> Result<(), Error> {
"aircrack-ng",
"gnome-terminal",
"mergecap",
+ "macchanger",
])
}
+/// Stop the scan process, kill all the attack process, and remove all the files created by the app
pub fn app_cleanup() {
- super::stop_scan_process();
+ stop_scan_process().ok();
- for attacked_ap in super::get_attack_pool().iter_mut() {
+ for attacked_ap in get_attack_pool().iter_mut() {
match &mut attacked_ap.1 .1 {
AttackedClients::All(child) => {
- child.kill().unwrap();
- child.wait().unwrap();
+ child.kill().ok();
+ child.wait().ok();
}
AttackedClients::Selection(child_list) => {
for (_, child) in child_list {
- child.kill().unwrap();
- child.wait().unwrap();
+ child.kill().ok();
+ child.wait().ok();
}
}
}
}
if let Some(iface) = IFACE.lock().unwrap().as_ref() {
- super::disable_monitor_mode(iface).ok();
- super::restore_network_manager().ok();
+ disable_monitor_mode(iface).ok();
+ restore_network_manager().ok();
}
std::fs::remove_file(LIVE_SCAN_PATH.to_string() + "-01.csv").ok();
@@ -60,6 +66,7 @@ pub fn app_cleanup() {
std::fs::remove_file(OLD_SCAN_PATH.to_string() + "-01.cap").ok();
}
+/// Check if all the dependencies are installed
pub fn check_dependencies(deps: &[&str]) -> Result<(), Error> {
for dep in deps {
if which::which(dep).is_err() {
@@ -72,13 +79,18 @@ pub fn check_dependencies(deps: &[&str]) -> Result<(), Error> {
Ok(())
}
+/// Spawn a thread that will check if a new version is available
pub fn spawn_update_checker() -> JoinHandle<bool> {
std::thread::spawn(|| {
let url = "https://api.github.com/repos/martin-olivier/airgorah/releases/latest";
if let Ok(response) = ureq::get(url).call() {
if let Ok(json) = response.into_json::<serde_json::Value>() {
- return json["tag_name"] != VERSION;
+ if json["tag_name"] != VERSION {
+ let new_version = json["tag_name"].as_str().unwrap_or("unknown");
+ *NEW_VERSION.lock().unwrap() = Some(new_version.to_string());
+ return true;
+ }
}
}
false
diff --git a/src/backend/capture.rs b/src/backend/capture.rs
index 11d7a2a..e544c25 100755
--- a/src/backend/capture.rs
+++ b/src/backend/capture.rs
@@ -1,21 +1,21 @@
+use super::*;
+use crate::error::Error;
use crate::globals::*;
-pub fn update_handshakes() {
- let live_scan_output = std::process::Command::new("aircrack-ng")
- .args([&(LIVE_SCAN_PATH.to_string() + "-01.cap")])
- .output()
- .unwrap();
+use std::process::Command;
- let old_scan_output = std::process::Command::new("aircrack-ng")
- .args([&(OLD_SCAN_PATH.to_string() + "-01.cap")])
- .output()
- .unwrap();
-
- let mut stdout = String::from_utf8_lossy(&live_scan_output.stdout).to_string();
- stdout.push_str(&String::from_utf8_lossy(&old_scan_output.stdout));
+/// Update the handshake capture status of all APs
+pub fn update_handshakes() -> Result<(), Error> {
+ let capture_output = Command::new("aircrack-ng")
+ .args([
+ &(LIVE_SCAN_PATH.to_string() + "-01.cap"),
+ &(OLD_SCAN_PATH.to_string() + "-01.cap"),
+ ])
+ .output()?;
+ let stdout = String::from_utf8_lossy(&capture_output.stdout).to_string();
let lines = stdout.lines();
- let mut aps = super::get_aps();
+ let mut aps = get_aps();
for data in lines {
for (bssid, ap) in aps.iter_mut() {
@@ -25,8 +25,11 @@ pub fn update_handshakes() {
}
}
}
+ Ok(())
}
-pub fn save_capture(path: &str) {
- std::fs::copy(OLD_SCAN_PATH.to_string() + "-01.cap", path).ok();
+/// Save the current capture to a file
+pub fn save_capture(path: &str) -> Result<(), Error> {
+ std::fs::copy(OLD_SCAN_PATH.to_string() + "-01.cap", path)?;
+ Ok(())
}
diff --git a/src/backend/deauth.rs b/src/backend/deauth.rs
index 3ec628c..29ba171 100755
--- a/src/backend/deauth.rs
+++ b/src/backend/deauth.rs
@@ -1,16 +1,18 @@
+use super::*;
use crate::error::Error;
use crate::globals::*;
use crate::types::*;
-use std::process::Command;
+use std::process::{Command, Stdio};
use std::sync::MutexGuard;
+/// Launch a deauth attack on a specific AP
pub fn launch_deauth_attack(ap: AP, specific_clients: Option<Vec<String>>) -> Result<(), Error> {
- let iface = match super::get_iface() {
+ let iface = match get_iface() {
Some(res) => res,
None => return Err(Error::new("No interface set")),
};
- let mut attack_pool = super::get_attack_pool();
+ let mut attack_pool = get_attack_pool();
let attack_targets = match specific_clients {
Some(specific_clients) => {
@@ -20,7 +22,7 @@ pub fn launch_deauth_attack(ap: AP, specific_clients: Option<Vec<String>>) -> Re
cli.to_owned(),
Command::new("aireplay-ng")
.args(["-0", "0", "-D", "-a", &ap.bssid, "-c", &cli, &iface])
- .stdout(std::process::Stdio::null())
+ .stdout(Stdio::null())
.spawn()?,
));
}
@@ -29,7 +31,7 @@ pub fn launch_deauth_attack(ap: AP, specific_clients: Option<Vec<String>>) -> Re
None => AttackedClients::All(
Command::new("aireplay-ng")
.args(["-0", "0", "-D", "-a", &ap.bssid, &iface])
- .stdout(std::process::Stdio::null())
+ .stdout(Stdio::null())
.spawn()?,
),
};
@@ -39,19 +41,20 @@ pub fn launch_deauth_attack(ap: AP, specific_clients: Option<Vec<String>>) -> Re
Ok(())
}
+/// Stop a deauth attack on a specific AP
pub fn stop_deauth_attack(ap_bssid: &str) {
- let mut attack_pool = super::get_attack_pool();
+ let mut attack_pool = 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();
+ child.kill().ok();
+ child.wait().ok();
}
AttackedClients::Selection(child_list) => {
for (_cli, child) in child_list {
- child.kill().unwrap();
- child.wait().unwrap();
+ child.kill().ok();
+ child.wait().ok();
}
}
}
@@ -59,6 +62,7 @@ pub fn stop_deauth_attack(ap_bssid: &str) {
attack_pool.remove(ap_bssid);
}
+/// Get the attack pool
pub fn get_attack_pool() -> MutexGuard<'static, AttackPool> {
ATTACK_POOL.lock().unwrap()
}
diff --git a/src/backend/decrypt.rs b/src/backend/decrypt.rs
index 59e5ba2..eb52de4 100755
--- a/src/backend/decrypt.rs
+++ b/src/backend/decrypt.rs
@@ -1,15 +1,23 @@
+use crate::error::Error;
+
use std::process::{Command, Stdio};
-pub fn run_decrypt_process(handshake: &str, wordlist: &str) {
- let cmd = format!(
- "gnome-terminal --hide-menubar --title \"Handshake Decryption\" -- sh -c \"aircrack-ng '{}' -w '{}' ; exec sh\"",
- handshake,
- wordlist
- );
+/// Launch a new terminal window to run aircrack-ng to decrypt a handshake with the specified wordlist
+pub fn run_decrypt_process(handshake: &str, wordlist: &str) -> Result<(), Error> {
+ let cmd = format!("aircrack-ng '{}' -w '{}' ; exec sh", handshake, wordlist);
- Command::new("sh")
+ Command::new("gnome-terminal")
.stdin(Stdio::piped())
- .args(["-c", &cmd])
- .output()
- .ok();
+ .args([
+ "--hide-menubar",
+ "--title",
+ "Handshake Decryption",
+ "--",
+ "sh",
+ "-c",
+ &cmd,
+ ])
+ .output()?;
+
+ Ok(())
}
diff --git a/src/backend/interface.rs b/src/backend/interface.rs
index c479d12..3480e71 100644
--- a/src/backend/interface.rs
+++ b/src/backend/interface.rs
@@ -1,7 +1,9 @@
+use super::*;
use crate::error::Error;
use crate::globals::*;
use std::process::Command;
+/// Get the available interfaces
pub fn get_interfaces() -> Result<Vec<String>, Error> {
let cmd = Command::new("sh")
.args(["-c", "iw dev | awk \'$1==\"Interface\"{print $2}\'"])
@@ -16,6 +18,7 @@ pub fn get_interfaces() -> Result<Vec<String>, Error> {
Ok(out.split_terminator('\n').map(String::from).collect())
}
+/// Check if an interface supports 5GHz
pub fn is_5ghz_supported(iface: &str) -> Result<bool, Error> {
let check_band_cmd = Command::new("iwlist").args([iface, "freq"]).output()?;
@@ -32,6 +35,7 @@ pub fn is_5ghz_supported(iface: &str) -> Result<bool, Error> {
Ok(false)
}
+/// Check if an interface is in monitor mode
pub fn is_monitor_mode(iface: &str) -> Result<bool, Error> {
let check_monitor_cmd = Command::new("iw").args(["dev", iface, "info"]).output()?;
@@ -48,8 +52,46 @@ pub fn is_monitor_mode(iface: &str) -> Result<bool, Error> {
Ok(false)
}
+// Set the MAC address of an interface
+pub fn set_mac_address(iface: &str) -> Result<(), Error> {
+ if !is_monitor_mode(iface)? {
+ return Err(Error::new(
+ "Can't change MAC address, interface is not in monitor mode",
+ ));
+ }
+
+ Command::new("ifconfig").args([iface, "down"]).output()?;
+
+ let success = match get_settings().mac_address.as_str() {
+ "random" => {
+ Command::new("macchanger").args(["-A", iface]).output()?;
+ true
+ }
+ "default" => {
+ Command::new("macchanger").args(["-p", iface]).output()?;
+ true
+ }
+ mac => Command::new("macchanger")
+ .args(["-m", mac, iface])
+ .output()?
+ .status
+ .success(),
+ };
+
+ Command::new("ifconfig").args([iface, "up"]).output()?;
+
+ if !success {
+ return Err(Error::new(
+ "The MAC address is invalid. Change the value in the settings page.",
+ ));
+ }
+
+ Ok(())
+}
+
+/// enable monitor mode on an interface
pub fn enable_monitor_mode(iface: &str) -> Result<String, Error> {
- kill_network_manager().ok();
+ kill_network_manager()?;
if is_monitor_mode(iface)? {
return Ok(iface.to_string());
@@ -83,6 +125,7 @@ pub fn enable_monitor_mode(iface: &str) -> Result<String, Error> {
}
}
+/// disable monitor mode on an interface
pub fn disable_monitor_mode(iface: &str) -> Result<(), Error> {
let check_monitor_cmd = Command::new("iw").args(["dev", iface, "info"]).output()?;
@@ -90,7 +133,7 @@ pub fn disable_monitor_mode(iface: &str) -> Result<(), Error> {
return Err(Error::new("Failed to get current interface"));
}
- let check_monitor_output = String::from_utf8(check_monitor_cmd.stdout).unwrap();
+ let check_monitor_output = String::from_utf8(check_monitor_cmd.stdout)?;
if !check_monitor_output.contains("type monitor") {
return Ok(());
@@ -106,21 +149,31 @@ pub fn disable_monitor_mode(iface: &str) -> Result<(), Error> {
}
}
+/// Get the current interface
pub fn get_iface() -> Option<String> {
IFACE.lock().unwrap().clone()
}
+/// Set the current interface
pub fn set_iface(iface: String) {
IFACE.lock().unwrap().replace(iface);
}
+/// Kill the network manager to avoid channel hopping conflicts
pub fn kill_network_manager() -> Result<(), Error> {
- Command::new("airmon-ng").args(["check", "kill"]).output()?;
+ if get_settings().kill_network_manager {
+ Command::new("airmon-ng").args(["check", "kill"]).output()?;
+ }
Ok(())
}
+/// Restore the network manager
pub fn restore_network_manager() -> Result<(), Error> {
+ if !get_settings().kill_network_manager {
+ return Ok(());
+ }
+
Command::new("service")
.args(["NetworkManager", "restart"])
.output()?;
diff --git a/src/backend/mod.rs b/src/backend/mod.rs
index 60a25ab..9f9efeb 100755
--- a/src/backend/mod.rs
+++ b/src/backend/mod.rs
@@ -4,6 +4,7 @@ pub mod deauth;
pub mod decrypt;
pub mod interface;
pub mod scan;
+pub mod settings;
pub use app::*;
pub use capture::*;
@@ -11,3 +12,4 @@ pub use deauth::*;
pub use decrypt::*;
pub use interface::*;
pub use scan::*;
+pub use settings::*;
diff --git a/src/backend/scan.rs b/src/backend/scan.rs
index 1ffe894..0e42f98 100644
--- a/src/backend/scan.rs
+++ b/src/backend/scan.rs
@@ -1,13 +1,17 @@
use regex::Regex;
use std::collections::HashMap;
+use std::path::Path;
+use std::process::{Command, Stdio};
use std::sync::MutexGuard;
+use super::*;
use crate::error::Error;
use crate::globals::*;
use crate::types::*;
use serde::Deserialize;
+/// Represents the AP section of the csv file generated by airodump
#[derive(Debug, Deserialize)]
struct RawAP {
#[serde(rename = "BSSID")]
@@ -42,6 +46,7 @@ struct RawAP {
_key: String,
}
+/// Represents the Client section of the csv file generated by airodump
#[derive(Debug, Deserialize)]
struct RawClient {
#[serde(rename = "Station MAC")]
@@ -60,10 +65,12 @@ struct RawClient {
_probed_essids: String,
}
+/// Check if a scan is currently running
pub fn is_scan_process() -> bool {
- SCAN_PROC.lock().unwrap().as_ref().is_some()
+ SCAN_PROC.lock().unwrap().is_some()
}
+/// Check if the content of the channel filter is valid
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
@@ -80,13 +87,14 @@ pub fn is_valid_channel_filter(channel_filter: &str) -> bool {
true
}
+/// Set the scan process
pub fn set_scan_process(args: &[&str]) -> Result<(), Error> {
- let iface = match super::get_iface().as_ref() {
+ let iface = match get_iface().as_ref() {
Some(res) => res.to_string(),
None => return Err(Error::new("No interface set")),
};
- stop_scan_process();
+ stop_scan_process().ok();
let mut proc_args = vec![
iface.as_str(),
@@ -100,9 +108,9 @@ pub fn set_scan_process(args: &[&str]) -> Result<(), Error> {
];
proc_args.append(&mut args.to_vec());
- let child = std::process::Command::new("airodump-ng")
+ let child = Command::new("airodump-ng")
.args(proc_args)
- .stdout(std::process::Stdio::null())
+ .stdout(Stdio::null())
.spawn()?;
SCAN_PROC.lock().unwrap().replace(child);
@@ -110,24 +118,23 @@ pub fn set_scan_process(args: &[&str]) -> Result<(), Error> {
Ok(())
}
-pub fn stop_scan_process() {
+/// Stop the scan process
+pub fn stop_scan_process() -> Result<(), Error> {
if let Some(child) = SCAN_PROC.lock().unwrap().as_mut() {
- std::process::Command::new("kill")
- .arg(child.id().to_string())
- .status()
- .unwrap();
+ Command::new("kill").arg(child.id().to_string()).status()?;
+
child.wait().ok();
}
SCAN_PROC.lock().unwrap().take();
- let old_path_exists = std::path::Path::new(&(OLD_SCAN_PATH.to_string() + "-01.cap")).exists();
- let live_path_exists = std::path::Path::new(&(LIVE_SCAN_PATH.to_string() + "-01.cap")).exists();
+ let old_path_exists = Path::new(&(OLD_SCAN_PATH.to_string() + "-01.cap")).exists();
+ let live_path_exists = Path::new(&(LIVE_SCAN_PATH.to_string() + "-01.cap")).exists();
std::fs::remove_file(LIVE_SCAN_PATH.to_string() + "-01.csv").ok();
if !live_path_exists {
- return;
+ return Ok(());
}
if !old_path_exists {
@@ -136,7 +143,7 @@ pub fn stop_scan_process() {
OLD_SCAN_PATH.to_string() + "-01.cap",
)
.ok();
- return;
+ return Ok(());
}
std::process::Command::new("mergecap")
@@ -149,8 +156,7 @@ pub fn stop_scan_process() {
&(OLD_SCAN_PATH.to_string() + "-01.cap"),
&(LIVE_SCAN_PATH.to_string() + "-01.cap"),
])
- .status()
- .unwrap();
+ .status()?;
std::fs::remove_file(LIVE_SCAN_PATH.to_string() + "-01.cap").ok();
std::fs::remove_file(OLD_SCAN_PATH.to_string() + "-01.cap").ok();
@@ -159,16 +165,19 @@ pub fn stop_scan_process() {
OLD_SCAN_PATH.to_string() + "-01.cap",
)
.ok();
+
+ Ok(())
}
+/// Get the data captured from airodump
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() {
+ for attacked_ap in get_attack_pool().iter() {
aps.insert(attacked_ap.0.clone(), attacked_ap.1 .0.clone());
}
- let mut glob_aps = super::get_aps();
+ let mut glob_aps = get_aps();
for ap in glob_aps.iter() {
aps.insert(ap.0.clone(), ap.1.clone());
@@ -202,12 +211,12 @@ pub fn get_airodump_data() -> HashMap<String, AP> {
} else {
"2.4 GHz".to_string()
};
-
let bssid = result.bssid.trim_start().to_string();
-
let mut essid = result.essid.trim_start().to_string();
+ let mut hidden = false;
if essid.is_empty() {
+ hidden = true;
essid = format!("[Hidden] (length: {})", result.id_length.trim_start());
}
@@ -221,6 +230,7 @@ pub fn get_airodump_data() -> HashMap<String, AP> {
speed: result.speed.trim_start().to_string(),
power: result.power.trim_start().to_string(),
privacy: result.privacy.trim_start().to_string(),
+ hidden,
handshake: {
match glob_aps.get(&bssid) {
Some(ap) => ap.handshake,
@@ -258,13 +268,14 @@ pub fn get_airodump_data() -> HashMap<String, AP> {
}
}
- for ap in aps.iter() {
- glob_aps.insert(ap.0.clone(), ap.1.clone());
+ for (bssid, ap) in aps.iter() {
+ glob_aps.insert(bssid.clone(), ap.clone());
}
aps
}
+/// Get the APs data collected
pub fn get_aps() -> MutexGuard<'static, HashMap<String, AP>> {
APS.lock().unwrap()
}
diff --git a/src/backend/settings.rs b/src/backend/settings.rs
new file mode 100644
index 0000000..5a21af8
--- /dev/null
+++ b/src/backend/settings.rs
@@ -0,0 +1,28 @@
+use crate::globals::*;
+use crate::types::*;
+
+use std::path::Path;
+
+/// Load settings from the config file, otherwise use default settings
+pub fn load_settings() {
+ if Path::new(CONFIG_PATH).exists() {
+ let config = std::fs::read_to_string(CONFIG_PATH).unwrap_or_default();
+ let settings: Settings = toml::from_str(&config).unwrap_or_default();
+ *SETTINGS.lock().unwrap() = settings;
+ }
+}
+
+/// Save settings to the config file
+pub fn save_settings(settings: Settings) {
+ if Path::new(CONFIG_PATH).exists() {
+ if let Ok(toml_settings) = toml::to_string(&settings) {
+ std::fs::write(CONFIG_PATH, toml_settings).ok();
+ }
+ }
+ *SETTINGS.lock().unwrap() = settings;
+}
+
+/// Get the current settings
+pub fn get_settings() -> Settings {
+ SETTINGS.lock().unwrap().clone()
+}
diff --git a/src/frontend/connections/app.rs b/src/frontend/connections/app.rs
index 7d74f31..42bf492 100755
--- a/src/frontend/connections/app.rs
+++ b/src/frontend/connections/app.rs
@@ -9,6 +9,7 @@ use glib::clone;
use gtk4::gdk_pixbuf::Pixbuf;
use gtk4::prelude::*;
use gtk4::*;
+use std::io::BufReader;
use std::rc::Rc;
use std::time::Duration;
@@ -36,7 +37,7 @@ fn connect_about_button(app_data: Rc<AppData>) {
.app_gui
.about_button
.connect_clicked(clone!(@strong app_data => move |_| {
- let ico = Pixbuf::from_read(std::io::BufReader::new(globals::APP_ICON)).unwrap();
+ let ico = Pixbuf::from_read(BufReader::new(globals::APP_ICON)).unwrap();
let des = "A WiFi auditing software that can perform deauth attacks and passwords cracking";
AboutDialog::builder()
@@ -68,8 +69,8 @@ fn connect_update_button(app_data: Rc<AppData>) {
if let Some(proc) = updater.as_mut() {
if proc.is_finished() && updater.take().unwrap().join().unwrap_or(false) {
- app_data.app_gui.update_button.show();
- return glib::Continue(false);
+ app_data.app_gui.update_button.show();
+ return glib::Continue(false);
}
}
glib::Continue(true)
@@ -80,7 +81,15 @@ fn connect_update_button(app_data: Rc<AppData>) {
.app_gui
.update_button
.connect_clicked(clone!(@strong app_data => move |_| {
- InfoDialog::spawn(&app_data.app_gui.window, "Update available", "An update is available, you can download it on the following page:\n\nhttps://github.com/martin-olivier/airgorah/releases/latest");
+ let version = globals::VERSION;
+ let new_version = globals::NEW_VERSION.lock().unwrap();
+
+ let new_version = match new_version.as_ref() {
+ Some(result) => result.clone(),
+ None => "unknown".to_string(),
+ };
+
+ UpdateDialog::spawn(&app_data.app_gui.window, version, &new_version);
}));
}
@@ -98,7 +107,7 @@ fn connect_settings_button(app_data: Rc<AppData>) {
.app_gui
.settings_button
.connect_clicked(clone!(@strong app_data => move |_| {
- InfoDialog::spawn(&app_data.app_gui.window, "Coming Soon", "The settings page will be available in a future release");
+ app_data.settings_gui.show();
}));
}
@@ -145,6 +154,15 @@ fn connect_app_refresh(app_data: Rc<AppData>) {
let aps = backend::get_airodump_data();
for (bssid, ap) in aps.iter() {
+ if !backend::get_settings().display_hidden_ap && ap.hidden {
+ if let Some(iter) =
+ list_store_find(app_data.app_gui.aps_model.as_ref(), 1, bssid.as_str())
+ {
+ app_data.app_gui.aps_model.remove(&iter);
+ }
+ continue;
+ }
+
let it = match list_store_find(app_data.app_gui.aps_model.as_ref(), 1, bssid.as_str()) {
Some(it) => it,
None => app_data.app_gui.aps_model.append(),
@@ -155,6 +173,11 @@ fn connect_app_refresh(app_data: Rc<AppData>) {
false => gdk::RGBA::new(0.0, 0.0, 0.0, 0.0),
};
+ let handshake_status = match ap.handshake {
+ true => "Captured",
+ false => "",
+ };
+
app_data.app_gui.aps_model.set(
&it,
&[
@@ -166,15 +189,9 @@ fn connect_app_refresh(app_data: Rc<AppData>) {
(5, &ap.power.parse::<i32>().unwrap_or(-1)),
(6, &ap.privacy),
(7, &(ap.clients.len() as i32)),
- (
- 8,
- &match ap.handshake {
- true => "Captured",
- false => "",
- },
- ),
- (9, &ap.first_time_seen),
- (10, &ap.last_time_seen),
+ (8, &ap.first_time_seen),
+ (9, &ap.last_time_seen),
+ (10, &handshake_status),
(11, &background_color.to_str()),
],
);
@@ -223,7 +240,11 @@ fn connect_app_refresh(app_data: Rc<AppData>) {
}
}
- backend::update_handshakes();
+ glib::Continue(true)
+ });
+
+ glib::timeout_add_local(Duration::from_millis(1500), || {
+ backend::update_handshakes().ok();
glib::Continue(true)
});
@@ -294,13 +315,17 @@ fn connect_capture_button(app_data: Rc<AppData>) {
file_chooser_dialog.set_current_name("capture.cap");
file_chooser_dialog.run_async(clone!(@strong app_data => move |this, response| {
if response == ResponseType::Accept {
+ this.close();
+
let gio_file = match this.file() {
Some(file) => file,
None => return,
};
let path = gio_file.path().unwrap().to_str().unwrap().to_string();
- backend::save_capture(&path);
+ backend::save_capture(&path).unwrap_or_else(|e| {
+ ErrorDialog::spawn(&app_data.app_gui.window, "Save failed", &e.to_string(), false)
+ });
for (_, ap) in backend::get_aps().iter_mut() {
if ap.handshake {
@@ -311,13 +336,10 @@ fn connect_capture_button(app_data: Rc<AppData>) {
app_data.decrypt_gui.show(Some(path))
}
- this.close();
-
if was_scanning {
app_data.app_gui.scan_but.emit_clicked();
}
}));
- //
}));
}
diff --git a/src/frontend/connections/deauth.rs b/src/frontend/connections/deauth.rs
index 5759617..9c94d4f 100755
--- a/src/frontend/connections/deauth.rs
+++ b/src/frontend/connections/deauth.rs
@@ -9,16 +9,16 @@ use gtk4::prelude::*;
use gtk4::*;
use std::rc::Rc;
-fn get_selected_clis(storage: &ListStore) -> Vec<String> {
+fn get_selected_clients(storage: &ListStore) -> Vec<String> {
let mut iter = storage.iter_first();
- let mut selected_clis = vec![];
+ let mut selected_clients = 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);
+ selected_clients.push(mac_val);
}
iter = match storage.iter_next(&it) {
@@ -27,7 +27,7 @@ fn get_selected_clis(storage: &ListStore) -> Vec<String> {
}
}
- selected_clis
+ selected_clients
}
fn connect_all_cli_button(app_data: Rc<AppData>) {
@@ -48,7 +48,7 @@ fn connect_sel_cli_button(app_data: Rc<AppData>) {
.connect_toggled(clone!(@strong app_data => move |_| {
app_data.deauth_gui.view.set_sensitive(true);
- if get_selected_clis(&app_data.deauth_gui.store).is_empty() {
+ if get_selected_clients(&app_data.deauth_gui.store).is_empty() {
app_data.deauth_gui.attack_but.set_sensitive(false);
}
}));
@@ -64,7 +64,7 @@ fn connect_toggle(app_data: Rc<AppData>) {
app_data.deauth_gui.store.set_value(&iter, 0, &Value::from(&(!old_val)));
- match get_selected_clis(&app_data.deauth_gui.store).is_empty() {
+ match get_selected_clients(&app_data.deauth_gui.store).is_empty() {
true => app_data.deauth_gui.attack_but.set_sensitive(false),
false => app_data.deauth_gui.attack_but.set_sensitive(true),
};
@@ -74,7 +74,7 @@ fn connect_toggle(app_data: Rc<AppData>) {
fn connect_attack_but(app_data: Rc<AppData>) {
app_data.deauth_gui.attack_but.connect_clicked(clone!(@strong app_data => move |_| {
let params = match app_data.deauth_gui.sel_cli_but.is_active() {
- true => Some(get_selected_clis(&app_data.deauth_gui.store)),
+ true => Some(get_selected_clients(&app_data.deauth_gui.store)),
false => None,
};
@@ -89,7 +89,7 @@ fn connect_attack_but(app_data: Rc<AppData>) {
ErrorDialog::spawn(
&app_data.app_gui.window,
"Error",
- &format!("Could not start deauth process: {}", e),
+ &format!("Could not start deauth process:\n\n{}", e),
false,
);
});
diff --git a/src/frontend/connections/decrypt.rs b/src/frontend/connections/decrypt.rs
index 6bdf520..745207f 100755
--- a/src/frontend/connections/decrypt.rs
+++ b/src/frontend/connections/decrypt.rs
@@ -1,5 +1,6 @@
use crate::backend;
use crate::frontend::interfaces::*;
+use crate::frontend::widgets::ErrorDialog;
use glib::clone;
use gtk4::prelude::*;
@@ -62,10 +63,19 @@ fn connect_wordlist_button(app_data: Rc<AppData>) {
}
fn connect_decrypt_button(app_data: Rc<AppData>) {
- app_data.decrypt_gui.decrypt_but.connect_clicked(clone!(@strong app_data => move |_| {
- backend::run_decrypt_process(app_data.decrypt_gui.handshake_entry.text().as_str(), app_data.decrypt_gui.wordlist_entry.text().as_str());
- app_data.decrypt_gui.window.close();
- }));
+ app_data
+ .decrypt_gui
+ .decrypt_but
+ .connect_clicked(clone!(@strong app_data => move |_| {
+ let handshake_entry = app_data.decrypt_gui.handshake_entry.text();
+ let wordlist_entry = app_data.decrypt_gui.wordlist_entry.text();
+
+ app_data.decrypt_gui.window.close();
+
+ backend::run_decrypt_process(&handshake_entry, &wordlist_entry).unwrap_or_else(|e| {
+ ErrorDialog::spawn(&app_data.app_gui.window, "Failed to run decryption", &e.to_string(), false);
+ });
+ }));
}
pub fn connect(app_data: Rc<AppData>) {
diff --git a/src/frontend/connections/interface.rs b/src/frontend/connections/interface.rs
index 7160617..9eb9965 100644
--- a/src/frontend/connections/interface.rs
+++ b/src/frontend/connections/interface.rs
@@ -31,6 +31,7 @@ fn connect_interface_refresh(app_data: Rc<AppData>) {
}
app_data.interface_gui.interface_view.set_active(if !ifaces.is_empty() { Some(0) } else { None });
+ app_data.interface_gui.select_but.set_sensitive(!ifaces.is_empty());
}));
app_data.interface_gui.refresh_but.emit_clicked();
}
@@ -46,8 +47,21 @@ fn connect_interface_select(app_data: Rc<AppData>) {
};
let iface = list_store_get!(app_data.interface_gui.interface_model, &iter, 0, String);
- match crate::backend::enable_monitor_mode(&iface) {
+ match backend::enable_monitor_mode(&iface) {
Ok(res) => {
+ if let Err(e) = backend::set_mac_address(&res) {
+ backend::disable_monitor_mode(&iface).ok();
+ backend::restore_network_manager().ok();
+
+ app_data.interface_gui.refresh_but.emit_clicked();
+
+ return ErrorDialog::spawn(
+ &app_data.interface_gui.window,
+ "Failed to set MAC address",
+ &e.to_string(),
+ false,
+ );
+ }
backend::set_iface(res.clone());
app_data.app_gui.iface_label.set_text(&res);
@@ -55,13 +69,14 @@ fn connect_interface_select(app_data: Rc<AppData>) {
app_data.app_gui.scan_but.emit_clicked();
}
Err(e) => {
+ app_data.interface_gui.refresh_but.emit_clicked();
+
ErrorDialog::spawn(
&app_data.interface_gui.window,
"Monitor mode failed",
&format!("Could not enable monitor mode on \"{}\":\n{}", iface, e),
false,
);
- app_data.interface_gui.refresh_but.emit_clicked();
}
};
}));
diff --git a/src/frontend/connections/mod.rs b/src/frontend/connections/mod.rs
index 34073c3..6672468 100644
--- a/src/frontend/connections/mod.rs
+++ b/src/frontend/connections/mod.rs
@@ -3,6 +3,7 @@ mod deauth;
mod decrypt;
mod interface;
mod scan;
+mod settings;
use crate::frontend::interfaces::AppData;
use std::rc::Rc;
@@ -12,5 +13,6 @@ pub fn connect(app_data: Rc<AppData>) {
scan::connect(app_data.clone());
interface::connect(app_data.clone());
deauth::connect(app_data.clone());
- decrypt::connect(app_data);
+ decrypt::connect(app_data.clone());
+ settings::connect(app_data);
}
diff --git a/src/frontend/connections/scan.rs b/src/frontend/connections/scan.rs
index 33cfcdb..ed82bf1 100644
--- a/src/frontend/connections/scan.rs
+++ b/src/frontend/connections/scan.rs
@@ -68,14 +68,14 @@ fn run_scan(app_data: &AppData) {
}
}
- backend::set_scan_process(&args).unwrap_or_else(|e| {
- ErrorDialog::spawn(
+ if let Err(e) = backend::set_scan_process(&args) {
+ return ErrorDialog::spawn(
&app_data.app_gui.window,
"Error",
- &format!("Could not start scan process: {}", e),
+ &format!("Could not start scan process:\n\n{}", e),
false,
- )
- });
+ );
+ }
app_data
.app_gui
@@ -87,7 +87,7 @@ fn connect_scan_button(app_data: Rc<AppData>) {
app_data.app_gui.scan_but.connect_clicked(
clone!(@strong app_data => move |this| match backend::is_scan_process() {
true => {
- backend::stop_scan_process();
+ backend::stop_scan_process().ok();
this.set_icon_name("media-playback-start-symbolic");
}
false => {
@@ -102,7 +102,7 @@ fn connect_clear_button(app_data: Rc<AppData>) {
.app_gui
.clear_but
.connect_clicked(clone!(@strong app_data => move |this| {
- backend::stop_scan_process();
+ backend::stop_scan_process().ok();
backend::get_aps().clear();
app_data.app_gui.aps_model.clear();
@@ -141,13 +141,20 @@ fn connect_save_button(app_data: Rc<AppData>) {
file_chooser_dialog.set_current_name("capture.cap");
file_chooser_dialog.run_async(clone!(@strong app_data => move |this, response| {
if response == ResponseType::Accept {
+ this.close();
+
let gio_file = match this.file() {
Some(file) => file,
None => return,
};
let path = gio_file.path().unwrap().to_str().unwrap().to_string();
- backend::save_capture(&path);
+ if let Err(e) = backend::save_capture(&path) {
+ if was_scanning {
+ app_data.app_gui.scan_but.emit_clicked();
+ }
+ return ErrorDialog::spawn(&app_data.app_gui.window, "Save failed", &e.to_string(), false);
+ }
for (_, ap) in backend::get_aps().iter_mut() {
if ap.handshake {
@@ -156,8 +163,6 @@ fn connect_save_button(app_data: Rc<AppData>) {
}
}
- this.close();
-
if was_scanning {
app_data.app_gui.scan_but.emit_clicked();
}
@@ -225,8 +230,14 @@ fn connect_channel_entry(app_data: Rc<AppData>) {
clone!(@strong app_data => move |this| {
let channel_filter = this
.text()
- .as_str()
- .replace(' ', "");
+ .replace(' ', "")
+ .chars()
+ .filter(|c| c.is_numeric() || *c == ',')
+ .collect::<String>();
+
+ if channel_filter != this.text() {
+ return this.set_text(&channel_filter);
+ }
if !channel_filter.is_empty() && !backend::is_valid_channel_filter(&channel_filter) {
return;
diff --git a/src/frontend/connections/settings.rs b/src/frontend/connections/settings.rs
new file mode 100644
index 0000000..d7f0461
--- /dev/null
+++ b/src/frontend/connections/settings.rs
@@ -0,0 +1,90 @@
+use crate::backend;
+use crate::frontend::interfaces::*;
+
+use glib::clone;
+use gtk4::prelude::*;
+use gtk4::*;
+use regex::Regex;
+use std::rc::Rc;
+
+fn connect_random_mac_button(app_data: Rc<AppData>) {
+ app_data
+ .settings_gui
+ .random_mac
+ .connect_toggled(clone!(@strong app_data => move |_| {
+ app_data.settings_gui.mac_entry.set_sensitive(false);
+ app_data.settings_gui.save_but.set_sensitive(true);
+ }));
+}
+
+fn connect_default_mac_button(app_data: Rc<AppData>) {
+ app_data
+ .settings_gui
+ .default_mac
+ .connect_toggled(clone!(@strong app_data => move |_| {
+ app_data.settings_gui.mac_entry.set_sensitive(false);
+ app_data.settings_gui.save_but.set_sensitive(true);
+ }));
+}
+
+fn connect_specific_mac_button(app_data: Rc<AppData>) {
+ app_data
+ .settings_gui
+ .specific_mac
+ .connect_toggled(clone!(@strong app_data => move |_| {
+ app_data.settings_gui.mac_entry.set_sensitive(true);
+ app_data.settings_gui.mac_entry.notify("text");
+ }));
+}
+
+fn connect_mac_entry(app_data: Rc<AppData>) {
+ app_data.settings_gui.mac_entry.connect_text_notify(
+ clone!(@strong app_data => move |this| {
+ let mac_regex = Regex::new(r"^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})|([0-9a-fA-F]{4}\\.[0-9a-fA-F]{4}\\.[0-9a-fA-F]{4})$").unwrap();
+ let entry = this.text().to_string();
+
+ match mac_regex.is_match(&entry) {
+ true => app_data.settings_gui.save_but.set_sensitive(true),
+ false => app_data.settings_gui.save_but.set_sensitive(false),
+ }
+ }),
+ );
+}
+
+fn connect_save_but(app_data: Rc<AppData>) {
+ app_data
+ .settings_gui
+ .save_but
+ .connect_clicked(clone!(@strong app_data => move |_| {
+ let mut mac_address = crate::types::Settings::default().mac_address;
+
+ if app_data.settings_gui.random_mac.is_active() {
+ mac_address = "random".to_string()
+ } else if app_data.settings_gui.default_mac.is_active() {
+ mac_address = "default".to_string()
+ } else if app_data.settings_gui.specific_mac.is_active() {
+ mac_address = app_data.settings_gui.mac_entry.text().to_string()
+ }
+
+ let display_hidden_ap = app_data.settings_gui.display_hidden_ap.is_active();
+ let kill_network_manager = app_data.settings_gui.kill_network_manager.is_active();
+
+ let settings = crate::types::Settings {
+ mac_address,
+ display_hidden_ap,
+ kill_network_manager,
+ };
+
+ backend::save_settings(settings);
+
+ app_data.settings_gui.window.hide();
+ }));
+}
+
+pub fn connect(app_data: Rc<AppData>) {
+ connect_random_mac_button(app_data.clone());
+ connect_default_mac_button(app_data.clone());
+ connect_specific_mac_button(app_data.clone());
+ connect_mac_entry(app_data.clone());
+ connect_save_but(app_data);
+}
diff --git a/src/frontend/interfaces/app.rs b/src/frontend/interfaces/app.rs
index 0072f7a..318d487 100755
--- a/src/frontend/interfaces/app.rs
+++ b/src/frontend/interfaces/app.rs
@@ -1,6 +1,7 @@
use crate::backend;
use crate::frontend::widgets::*;
use crate::globals;
+
use gtk4::prelude::*;
use gtk4::*;
@@ -21,14 +22,14 @@ fn build_update_button() -> Button {
fn build_decrypt_button() -> Button {
Button::builder()
.icon_name("utilities-terminal")
- .tooltip_text("Open the handshake decryption pannel")
+ .tooltip_text("Open the handshake decryption panel")
.build()
}
fn build_settings_button() -> Button {
Button::builder()
.icon_name("preferences-system")
- .tooltip_text("Open the settings pannel")
+ .tooltip_text("Open the settings panel")
.build()
}
@@ -40,7 +41,7 @@ fn build_window(app: &Application) -> ApplicationWindow {
let window = ApplicationWindow::builder()
.application(app)
.title("Airgorah")
- .default_width(1280)
+ .default_width(1320)
.default_height(620)
.build();
@@ -62,43 +63,46 @@ fn build_aps_model() -> ListStore {
glib::Type::I32, // Power
glib::Type::STRING, // Encryption
glib::Type::I32, // Clients
- glib::Type::STRING, // Handshake
glib::Type::STRING, // First time seen
glib::Type::STRING, // First time seen
+ glib::Type::STRING, // Handshake
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",
- "Handshake",
- "First time seen",
- "Last time seen",
+ let columns = [
+ ("ESSID", 68),
+ ("BSSID", 130),
+ ("Band", 62),
+ ("Channel", 80),
+ ("Speed", 68),
+ ("Power", 68),
+ ("Encryption", 94),
+ ("Clients", 72),
+ ("First time seen", 140),
+ ("Last time seen", 140),
+ ("Handshake", 96),
];
- for (pos, colomn_name) in colomn_names.into_iter().enumerate() {
+ for (pos, (column_name, column_size)) in columns.into_iter().enumerate() {
let column = TreeViewColumn::builder()
- .title(colomn_name)
- .resizable(true)
- .min_width(50)
+ .title(column_name)
+ .resizable(false)
+ .fixed_width(column_size)
.sort_indicator(true)
.sort_column_id(pos as i32)
- .expand(true)
+ .expand(false)
.build();
if pos == 0 {
let icon_renderer = CellRendererPixbuf::new();
icon_renderer.set_property("icon-name", "network-wireless");
+
column.pack_start(&icon_renderer, false);
+ column.set_expand(true);
+ column.set_min_width(column_size);
}
let text_renderer = CellRendererText::new();
@@ -132,7 +136,7 @@ fn build_cli_model() -> ListStore {
fn build_cli_view() -> TreeView {
let view = TreeView::builder().vexpand(true).hexpand(true).build();
- let colomn_names = [
+ let column_names = [
"Station MAC",
"Packets",
"Power",
@@ -140,10 +144,10 @@ fn build_cli_view() -> TreeView {
"Last time seen",
];
- for (pos, colomn_name) in colomn_names.into_iter().enumerate() {
+ for (pos, column_name) in column_names.into_iter().enumerate() {
let column = TreeViewColumn::builder()
- .title(colomn_name)
- .resizable(true)
+ .title(column_name)
+ .resizable(false)
.min_width(50)
.sort_indicator(true)
.sort_column_id(pos as i32)
@@ -210,9 +214,9 @@ impl AppGui {
let settings_button = build_settings_button();
header_bar.pack_start(&about_button);
+ header_bar.pack_start(&decrypt_button);
+ header_bar.pack_start(&settings_button);
header_bar.pack_start(&update_button);
- header_bar.pack_end(&settings_button);
- header_bar.pack_end(&decrypt_button);
update_button.hide();
@@ -333,7 +337,7 @@ impl AppGui {
scan_box.set_margin_top(10);
scan_box.set_margin_end(10);
- // Set main window childs
+ // Set main window child
let panned = Paned::new(Orientation::Vertical);
panned.set_wide_handle(true);
diff --git a/src/frontend/interfaces/deauth.rs b/src/frontend/interfaces/deauth.rs
index b39a142..bd5fac1 100755
--- a/src/frontend/interfaces/deauth.rs
+++ b/src/frontend/interfaces/deauth.rs
@@ -1,4 +1,5 @@
use crate::types::*;
+
use gtk4::prelude::*;
use gtk4::*;
@@ -37,15 +38,8 @@ impl DeauthGui {
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 = ListStore::new(&[glib::Type::BOOL, glib::Type::STRING]);
- let frame = Frame::new(None);
- frame.set_child(Some(&but_box));
-
let column = TreeViewColumn::new();
column.set_title("Clients");
@@ -67,11 +61,18 @@ impl DeauthGui {
scroll.set_policy(PolicyType::Never, PolicyType::Automatic);
scroll.set_child(Some(&view));
+ let deauth_box = Box::new(Orientation::Vertical, 2);
+ deauth_box.append(&all_cli_but);
+ deauth_box.append(&sel_cli_but);
+ deauth_box.append(&scroll);
+
+ let frame = Frame::new(None);
+ frame.set_child(Some(&deauth_box));
+
let attack_but = 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);
diff --git a/src/frontend/interfaces/mod.rs b/src/frontend/interfaces/mod.rs
index d0fd494..4d34148 100644
--- a/src/frontend/interfaces/mod.rs
+++ b/src/frontend/interfaces/mod.rs
@@ -2,17 +2,20 @@ pub mod app;
pub mod deauth;
pub mod decrypt;
pub mod interface;
+pub mod settings;
pub use app::AppGui;
pub use deauth::DeauthGui;
pub use decrypt::DecryptGui;
pub use interface::InterfaceGui;
+pub use settings::SettingsGui;
pub struct AppData {
pub app_gui: AppGui,
pub interface_gui: InterfaceGui,
pub deauth_gui: DeauthGui,
pub decrypt_gui: DecryptGui,
+ pub settings_gui: SettingsGui,
}
impl AppData {
@@ -21,12 +24,14 @@ impl AppData {
let interface_gui = InterfaceGui::new(&app_gui.window);
let deauth_gui = DeauthGui::new(&app_gui.window);
let decrypt_gui = DecryptGui::new(&app_gui.window);
+ let settings_gui = SettingsGui::new(&app_gui.window);
Self {
app_gui,
interface_gui,
deauth_gui,
decrypt_gui,
+ settings_gui,
}
}
}
diff --git a/src/frontend/interfaces/settings.rs b/src/frontend/interfaces/settings.rs
new file mode 100644
index 0000000..fd48d24
--- /dev/null
+++ b/src/frontend/interfaces/settings.rs
@@ -0,0 +1,116 @@
+use crate::backend;
+
+use gtk4::prelude::*;
+use gtk4::*;
+
+pub struct SettingsGui {
+ pub window: Window,
+ pub random_mac: CheckButton,
+ pub default_mac: CheckButton,
+ pub specific_mac: CheckButton,
+ pub mac_entry: Entry,
+ pub display_hidden_ap: CheckButton,
+ pub kill_network_manager: CheckButton,
+ pub save_but: Button,
+}
+
+impl SettingsGui {
+ pub fn new(parent: &impl IsA<Window>) -> Self {
+ let window = Window::builder()
+ .title("Settings")
+ .hide_on_close(true)
+ .default_width(250)
+ .default_height(200)
+ .resizable(false)
+ .transient_for(parent)
+ .modal(true)
+ .build();
+
+ let random_mac = CheckButton::with_label("Random MAC address");
+ let default_mac = CheckButton::with_label("Default MAC address");
+ let specific_mac = CheckButton::with_label("Specific MAC address");
+ let mac_entry = Entry::builder()
+ .placeholder_text("ex: 00:00:01:02:03:04")
+ .hexpand(true)
+ .editable(true)
+ .sensitive(false)
+ .build();
+
+ random_mac.set_active(true);
+ default_mac.set_group(Some(&random_mac));
+ specific_mac.set_group(Some(&random_mac));
+
+ let mac_box = Box::new(Orientation::Vertical, 4);
+ mac_box.set_margin_start(4);
+ mac_box.set_margin_end(4);
+ mac_box.set_margin_bottom(4);
+ mac_box.append(&random_mac);
+ mac_box.append(&default_mac);
+ mac_box.append(&specific_mac);
+ mac_box.append(&mac_entry);
+
+ let mac_frame = Frame::new(Some("MAC"));
+ mac_frame.set_child(Some(&mac_box));
+
+ let display_hidden_ap = CheckButton::with_label("Display hidden APs");
+ display_hidden_ap.set_active(true);
+
+ let display_frame = Frame::new(Some("Display"));
+ display_frame.set_child(Some(&display_hidden_ap));
+
+ let kill_network_manager = CheckButton::with_label("Kill NetworkManager");
+ kill_network_manager.set_active(true);
+
+ let process_frame = Frame::new(Some("Process"));
+ process_frame.set_child(Some(&kill_network_manager));
+
+ let save_but = Button::with_label("Save");
+
+ let vbox = Box::new(Orientation::Vertical, 10);
+ vbox.set_margin_top(10);
+ vbox.set_margin_end(10);
+ vbox.set_margin_start(10);
+ vbox.set_margin_bottom(10);
+
+ vbox.append(&mac_frame);
+ vbox.append(&display_frame);
+ vbox.append(&process_frame);
+ vbox.append(&save_but);
+
+ window.set_child(Some(&vbox));
+
+ Self {
+ window,
+ random_mac,
+ default_mac,
+ specific_mac,
+ mac_entry,
+ display_hidden_ap,
+ kill_network_manager,
+ save_but,
+ }
+ }
+
+ pub fn show(&self) {
+ let settings = backend::get_settings();
+
+ self.mac_entry.set_text("");
+ self.save_but.set_sensitive(true);
+
+ match settings.mac_address.as_str() {
+ "random" => self.random_mac.set_active(true),
+ "default" => self.default_mac.set_active(true),
+ mac => {
+ self.specific_mac.set_active(true);
+ self.mac_entry.set_text(mac);
+ }
+ };
+
+ self.display_hidden_ap
+ .set_active(settings.display_hidden_ap);
+ self.kill_network_manager
+ .set_active(settings.kill_network_manager);
+
+ self.window.show();
+ }
+}
diff --git a/src/frontend/widgets/dialog.rs b/src/frontend/widgets/dialog.rs
index bb5188d..0087c56 100644
--- a/src/frontend/widgets/dialog.rs
+++ b/src/frontend/widgets/dialog.rs
@@ -1,3 +1,5 @@
+#![allow(unused)]
+
use gtk4::prelude::*;
use gtk4::*;
@@ -50,3 +52,35 @@ impl InfoDialog {
dialog.show();
}
}
+
+pub struct UpdateDialog;
+
+impl UpdateDialog {
+ pub fn spawn(parent: &impl IsA<Window>, version: &str, new_version: &str) {
+ let link = "https://github.com/martin-olivier/airgorah/releases/latest";
+ let title = format!("Update available ({} -> {})", version, new_version);
+ let body = format!("\nYou can download it from the following page:\n\n{}", link);
+
+ let dialog = MessageDialog::builder()
+ .text(title)
+ .secondary_text(body)
+ .decorated(true)
+ .message_type(MessageType::Info)
+ .modal(true)
+ .transient_for(parent)
+ .build();
+
+ dialog.add_button("Close", ResponseType::Close);
+ dialog.add_button("Copy Link", ResponseType::Other(42));
+
+ dialog.connect_response(|this, response| {
+ if response == ResponseType::Other(42) {
+ if let Some(display) = gdk::Display::default() {
+ display.clipboard().set_text(link);
+ }
+ }
+ this.close();
+ });
+ dialog.show();
+ }
+}
diff --git a/src/frontend/widgets/icon_button.rs b/src/frontend/widgets/icon_button.rs
index 3b20215..9fca153 100644
--- a/src/frontend/widgets/icon_button.rs
+++ b/src/frontend/widgets/icon_button.rs
@@ -3,6 +3,7 @@
use gtk4::gdk_pixbuf::Pixbuf;
use gtk4::prelude::*;
use gtk4::*;
+use std::io::BufReader;
pub struct IconButton {
pub handle: Button,
@@ -11,7 +12,7 @@ pub struct IconButton {
impl IconButton {
pub fn new(icon: &'static [u8]) -> Self {
- let pixbuf = Pixbuf::from_read(std::io::BufReader::new(icon)).unwrap();
+ let pixbuf = Pixbuf::from_read(BufReader::new(icon)).unwrap();
let image = Image::from_pixbuf(Some(&pixbuf));
let handle = Button::builder().child(&image).build();
@@ -27,7 +28,7 @@ impl IconButton {
}
pub fn set_icon(&self, icon: &'static [u8]) {
- let pixbuf = Pixbuf::from_read(std::io::BufReader::new(icon)).unwrap();
+ let pixbuf = Pixbuf::from_read(BufReader::new(icon)).unwrap();
self.image.set_from_pixbuf(Some(&pixbuf))
}
diff --git a/src/frontend/widgets/icon_text_button.rs b/src/frontend/widgets/icon_text_button.rs
index 8a4c64b..3a1982c 100644
--- a/src/frontend/widgets/icon_text_button.rs
+++ b/src/frontend/widgets/icon_text_button.rs
@@ -3,6 +3,7 @@
use gtk4::gdk_pixbuf::Pixbuf;
use gtk4::prelude::*;
use gtk4::*;
+use std::io::BufReader;
pub struct IconTextButton {
pub handle: Button,
@@ -15,7 +16,7 @@ impl IconTextButton {
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 pixbuf = Pixbuf::from_read(BufReader::new(icon)).unwrap();
let image = Image::from_pixbuf(Some(&pixbuf));
let label = Label::with_mnemonic(text);
@@ -44,7 +45,7 @@ impl IconTextButton {
}
pub fn set_icon(&self, icon: &'static [u8]) {
- let pixbuf = Pixbuf::from_read(std::io::BufReader::new(icon)).unwrap();
+ let pixbuf = Pixbuf::from_read(BufReader::new(icon)).unwrap();
self.image.set_from_pixbuf(Some(&pixbuf))
}
diff --git a/src/globals.rs b/src/globals.rs
index b0aacb6..7e9b920 100644
--- a/src/globals.rs
+++ b/src/globals.rs
@@ -1,4 +1,5 @@
use crate::types::*;
+
use lazy_static::lazy_static;
use std::collections::HashMap;
use std::process::Child;
@@ -6,12 +7,14 @@ use std::sync::Mutex;
use std::thread::JoinHandle;
pub static APP_ID: &str = "com.martin-olivier.airgorah";
-pub static VERSION: &str = "v0.2.0";
+pub static VERSION: &str = "v0.3.0";
pub static LIVE_SCAN_PATH: &str = "/tmp/airgorah_live_scan";
pub static OLD_SCAN_PATH: &str = "/tmp/airgorah_old_scan";
pub static MERGE_SCAN_PATH: &str = "/tmp/airgorah_merge_scan";
+pub static CONFIG_PATH: &str = "/etc/airgorah/config.toml";
+
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");
@@ -25,4 +28,6 @@ lazy_static! {
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<AttackPool> = Mutex::new(HashMap::new());
+ pub static ref SETTINGS: Mutex<Settings> = Mutex::new(Settings::default());
+ pub static ref NEW_VERSION: Mutex<Option<String>> = Mutex::new(None);
}
diff --git a/src/types.rs b/src/types.rs
index 15e84cc..4dd1736 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -16,6 +16,7 @@ pub struct AP {
pub speed: String,
pub power: String,
pub privacy: String,
+ pub hidden: bool,
pub handshake: bool,
pub saved_handshake: Option<String>,
pub first_time_seen: String,
@@ -31,3 +32,20 @@ pub struct Client {
pub first_time_seen: String,
pub last_time_seen: String,
}
+
+#[derive(Clone, Debug, Serialize, Deserialize)]
+pub struct Settings {
+ pub mac_address: String,
+ pub display_hidden_ap: bool,
+ pub kill_network_manager: bool,
+}
+
+impl Default for Settings {
+ fn default() -> Self {
+ Self {
+ mac_address: "random".to_string(),
+ display_hidden_ap: true,
+ kill_network_manager: true,
+ }
+ }
+}