From e427a6d9efdd7252cc40497e4ec66dd320ee8ed6 Mon Sep 17 00:00:00 2001 From: Ragnt Date: Wed, 31 Jan 2024 17:05:07 -0500 Subject: [PATCH] Fix Compiler Warnings + Channel arg updated --- Cargo.lock | 2 +- Cargo.toml | 2 +- libs/libwifi/src/frame/components/mac_address.rs | 1 - .../libwifi/src/parsers/components/station_info.rs | 3 +++ libs/pcap-file/Cargo.toml | 7 ------- src/advancedtable/advtable.rs | 2 +- src/attack.rs | 6 ++---- src/auth.rs | 13 +++++-------- src/database.rs | 11 ++--------- src/devices.rs | 5 +++-- src/eventhandler.rs | 14 ++++++-------- src/gps.rs | 9 +++------ src/main.rs | 8 ++++---- src/oui.rs | 1 - src/pcapng.rs | 7 +++---- src/status.rs | 2 +- src/tabbedblock/tabbedblock.rs | 4 ++-- src/tx.rs | 2 +- src/ui.rs | 3 --- 19 files changed, 38 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1e11c82..7d2d125 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -69,7 +69,7 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "angry_oxide" -version = "0.8.0" +version = "0.8.2" dependencies = [ "anyhow", "byteorder", diff --git a/Cargo.toml b/Cargo.toml index 6c0acae..95f6c37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ members = ["libs/libwifi", "libs/libwifi_macros", "libs/pcap-file"] [workspace.package] -version = "0.8.0" +version = "0.8.2" authors = ["Ryan Butler"] description = "80211 Attack Tool" license = "MIT" diff --git a/libs/libwifi/src/frame/components/mac_address.rs b/libs/libwifi/src/frame/components/mac_address.rs index 0e5902d..c63a543 100644 --- a/libs/libwifi/src/frame/components/mac_address.rs +++ b/libs/libwifi/src/frame/components/mac_address.rs @@ -1,7 +1,6 @@ use std::fmt; use std::hash::{Hash, Hasher}; -use nom::AsBytes; use rand::{thread_rng, Rng, RngCore}; /// This is our representation of a MAC-address diff --git a/libs/libwifi/src/parsers/components/station_info.rs b/libs/libwifi/src/parsers/components/station_info.rs index 2479db2..8dd4630 100644 --- a/libs/libwifi/src/parsers/components/station_info.rs +++ b/libs/libwifi/src/parsers/components/station_info.rs @@ -1,3 +1,4 @@ +#![allow(dead_code)] use nom::bytes::complete::take; use nom::number::complete::u8 as get_u8; use nom::sequence::tuple; @@ -10,6 +11,8 @@ use crate::frame::components::{ WpaAkmSuite, WpaCipherSuite, WpaInformation, WpsInformation, WpsSetupState, }; + + /// Parse variable length and variable field information. /// The general structure of the data looks like this: /// diff --git a/libs/pcap-file/Cargo.toml b/libs/pcap-file/Cargo.toml index 7a3ed8a..d3758b4 100644 --- a/libs/pcap-file/Cargo.toml +++ b/libs/pcap-file/Cargo.toml @@ -24,10 +24,3 @@ thiserror = "1.0.35" criterion = "0.4.0" glob = "0.3.0" hex = "0.4.3" - -[[bench]] -name = "benches" -harness = false - -[profile.bench] -lto = "fat" diff --git a/src/advancedtable/advtable.rs b/src/advancedtable/advtable.rs index a8b9f4b..74bce24 100644 --- a/src/advancedtable/advtable.rs +++ b/src/advancedtable/advtable.rs @@ -2,7 +2,7 @@ use std::iter; use itertools::Itertools; -use ratatui::{layout::Constraint, style::Style, text::Text, widgets::Paragraph}; +use ratatui::{layout::Constraint, style::Style, text::Text}; use strum::{Display, EnumString}; use unicode_width::UnicodeWidthStr; diff --git a/src/attack.rs b/src/attack.rs index aa524f9..5c04eab 100644 --- a/src/attack.rs +++ b/src/attack.rs @@ -2,7 +2,6 @@ use std::{ os::fd::AsRawFd, - sync::mpsc::channel, time::{Duration, SystemTime}, }; @@ -13,8 +12,7 @@ use libwifi::{ }, parse_frame, Addresses, Frame, }; -use nl80211_ng::channels::{WiFiBand, WiFiChannel}; -use rand::seq::SliceRandom; +use nl80211_ng::channels::WiFiBand; use crate::{ status::{MessageType, StatusMessage}, @@ -22,7 +20,7 @@ use crate::{ build_association_request_rg, build_authentication_frame_noack, build_csa_beacon, build_deauthentication_fm_ap, build_deauthentication_fm_client, build_disassocation_from_ap, build_disassocation_from_client, - build_probe_request_undirected, build_probe_response, build_reassociation_request, + build_probe_response, build_reassociation_request, }, write_packet, OxideRuntime, }; diff --git a/src/auth.rs b/src/auth.rs index a0b0673..88a043d 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -1,20 +1,17 @@ use std::{ collections::HashMap, fmt, - time::{Duration, SystemTime, UNIX_EPOCH}, + time::{Duration, SystemTime}, }; use chrono::{DateTime, Local}; -use libwifi::frame::{components::MacAddress, EapolKey, KeyInformation, MessageType, Pmkid}; +use libwifi::frame::{components::MacAddress, EapolKey, MessageType, Pmkid}; -use crate::{ - util::{ - eapol_to_json_str, epoch_to_iso_string, epoch_to_string, key_info_to_json_str, +use crate::util::{ + eapol_to_json_str, slice_to_hex_string, system_time_to_iso8601, - }, - OxideRuntime, -}; + }; #[derive(Clone, Debug, Default)] pub struct FourWayHandshake { diff --git a/src/database.rs b/src/database.rs index 9405621..f8205cf 100644 --- a/src/database.rs +++ b/src/database.rs @@ -1,11 +1,7 @@ -use byteorder::{ByteOrder, LE}; -use libwifi::frame::components::MacAddress; use nl80211_ng::Interface; use rusqlite::{params, Connection, Result}; -use std::borrow::Cow; -use std::fs::File; -use std::time::{Duration, UNIX_EPOCH}; +use std::time::Duration; use std::{ sync::{ self, @@ -14,11 +10,8 @@ use std::{ Arc, Mutex, }, thread, - time::SystemTime, }; -use uuid::{uuid, Uuid}; -use crate::gps::{self, GpsData}; use crate::pcapng::FrameData; pub struct DatabaseWriter { @@ -156,7 +149,7 @@ pub fn setup_database(conn: &Connection, datasource: String, interface: Interfac fn add_frame(conn: &Connection, frx: &FrameData) { let packet_data = PacketData::new(frx); - let result = conn.execute( + let _result = conn.execute( "INSERT INTO packets (ts_sec, ts_usec, phyname, sourcemac, destmac, transmac, frequency, devkey, lat, lon, alt, speed, heading, packet_len, signal, datasource, dlt, packet, error, tags, datarate, hash, packetid) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16, ?17, ?18, ?19, ?20, ?21, ?22, ?23)", params![ packet_data.ts_sec, diff --git a/src/devices.rs b/src/devices.rs index 2b25921..1c35fb9 100644 --- a/src/devices.rs +++ b/src/devices.rs @@ -16,6 +16,7 @@ const CONST_T1_TIMEOUT: Duration = Duration::from_secs(5); // Do not change stat const CONST_T2_TIMEOUT: Duration = Duration::from_millis(200); // Still need a purpose for this. ////////////////////////////////////////////////////////////////////// +/// #[derive(Clone, Debug)] pub struct AuthSequence { pub t1: SystemTime, @@ -76,7 +77,7 @@ impl AuthSequence { // Trait to restrict WiFiDeviceList pub trait WiFiDeviceType {} -trait HasSSID { +pub trait HasSSID { fn ssid(&self) -> &Option; } @@ -767,7 +768,7 @@ impl WiFiDeviceList { let mut rows: Vec<(Vec, u16)> = Vec::new(); for (idx, ap) in access_points.iter().enumerate() { - let mut ap_row = vec![ + let ap_row = vec![ format!( "{}", if ap.is_target() { diff --git a/src/eventhandler.rs b/src/eventhandler.rs index bb8a3e6..2dd2d0f 100644 --- a/src/eventhandler.rs +++ b/src/eventhandler.rs @@ -1,18 +1,16 @@ -use byteorder::{ByteOrder, LE}; + use crossterm::event::{poll, Event, KeyCode, KeyEventKind, MouseEventKind}; -use std::time::{Duration, UNIX_EPOCH}; +use std::time::Duration; use std::{ sync::{ self, atomic::{AtomicBool, Ordering}, mpsc::{self, Receiver, Sender}, - Arc, Mutex, + Arc, }, thread, - time::SystemTime, }; -use uuid::Uuid; pub enum EventType { Key(Event), @@ -60,7 +58,7 @@ impl EventHandler { let event = crossterm::event::read().unwrap(); if let Event::Key(key) = event { if key.kind == KeyEventKind::Press { - match key.code { + let _ = match key.code { KeyCode::Char('d') => tx.send(EventType::Key(event)), KeyCode::Char('a') => tx.send(EventType::Key(event)), KeyCode::Char('W') => tx.send(EventType::Key(event)), @@ -88,14 +86,14 @@ impl EventHandler { }; } } else if let Event::Mouse(mouse) = event { - match mouse.kind { + let _ = match mouse.kind { MouseEventKind::ScrollDown => tx.send(EventType::Key(event)), MouseEventKind::ScrollUp => tx.send(EventType::Key(event)), _ => Ok({}), }; } } - tx.send(EventType::Tick); + let _ = tx.send(EventType::Tick); } })); } diff --git a/src/gps.rs b/src/gps.rs index 2c886fe..d75e300 100644 --- a/src/gps.rs +++ b/src/gps.rs @@ -1,10 +1,7 @@ use chrono::prelude::*; -use gpsd_proto::{get_data, handshake, GpsdError, ResponseData}; -use itertools::Itertools; - -use std::io::{self, BufReader, BufWriter}; +use gpsd_proto::{get_data, handshake, ResponseData}; +use std::io::{self, BufReader}; use std::net::TcpStream; -use std::os::unix::thread::JoinHandleExt; use std::time::{Duration, UNIX_EPOCH}; use std::{ @@ -383,7 +380,7 @@ impl Fixed3_7 { if self.value > 3600000000 { panic!("Value too much"); } - let remapped = (self.value as i64 - (180 * 10000000)); + let remapped = self.value as i64 - (180 * 10000000); remapped as f64 / 10000000.0 } } diff --git a/src/main.rs b/src/main.rs index c40fa68..86eaafb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +#![allow(dead_code)] mod advancedtable; mod ascii; mod attack; @@ -109,8 +110,8 @@ struct Arguments { #[arg(short, long)] /// Interface to use. interface: String, - #[arg(short, long)] - /// Optional - Channel to scan. Will use "-c 1 -c 6 -c 11" if none specified. + #[arg(short, long, use_value_delimiter = true, value_parser, num_args = 1, action = clap::ArgAction::Append)] + /// Optional - Channel to scan. Will use "-c 1,6,11" if none specified. channel: Vec, #[arg(short, long)] /// Optional - Entire band to scan - will include all channels interface can support. @@ -335,7 +336,7 @@ impl OxideRuntime { let mut netlink = Nl80211::new().expect("Cannot open Nl80211"); - let mut iface = if let Some(interface) = netlink + let iface = if let Some(interface) = netlink .get_interfaces() .iter() .find(|&(_, iface)| iface.name_as_string() == interface_name) @@ -985,7 +986,6 @@ fn process_frame(oxide: &mut OxideRuntime, packet: &[u8]) -> Result<(), String> .unwrap(); oxide.if_hardware.current_channel = current_channel.clone(); let band: WiFiBand = current_channel.get_band(); - let channel_u8: u8 = current_channel.get_channel_number(); let payload = &packet[radiotap.header.length..]; diff --git a/src/oui.rs b/src/oui.rs index 25582b2..e382421 100644 --- a/src/oui.rs +++ b/src/oui.rs @@ -1,4 +1,3 @@ -use std::collections::HashMap; use libwifi::frame::components::MacAddress; diff --git a/src/pcapng.rs b/src/pcapng.rs index 4f85c3b..7960062 100644 --- a/src/pcapng.rs +++ b/src/pcapng.rs @@ -1,4 +1,4 @@ -use byteorder::{ByteOrder, LE}; +use byteorder::LE; use crc32fast::Hasher; use libwifi::frame::components::MacAddress; use nl80211_ng::Interface; @@ -8,7 +8,7 @@ use pcap_file::pcapng::blocks::interface_description::{ }; use pcap_file::pcapng::blocks::opt_common::CustomBinaryOption; use pcap_file::pcapng::blocks::section_header::{SectionHeaderBlock, SectionHeaderOption}; -use pcap_file::pcapng::{PcapNgBlock, PcapNgWriter}; +use pcap_file::pcapng::PcapNgWriter; use pcap_file::{DataLink, Endianness}; use std::borrow::Cow; use std::fs::File; @@ -26,8 +26,7 @@ use std::{ use uname::uname; use uuid::Uuid; -use crate::gps::{self, GpsData}; -use crate::status::{self, MessageType, StatusMessage}; +use crate::gps::GpsData; #[derive(Clone, Debug)] pub struct FrameData { diff --git a/src/status.rs b/src/status.rs index 330cc6d..c468aa7 100644 --- a/src/status.rs +++ b/src/status.rs @@ -1,5 +1,5 @@ use chrono::{DateTime, Utc}; -use std::{collections::VecDeque, fmt}; +use std::fmt; // Define an enum for message types diff --git a/src/tabbedblock/tabbedblock.rs b/src/tabbedblock/tabbedblock.rs index 45a4f10..f9786e3 100644 --- a/src/tabbedblock/tabbedblock.rs +++ b/src/tabbedblock/tabbedblock.rs @@ -13,9 +13,9 @@ use super::tab::{Position, Tab}; use ratatui::{ buffer::Buffer, layout::{Alignment, Rect}, - style::{Color, Style, Styled}, + style::{Style, Styled}, symbols::line, - text::{Line, Span}, + text::Line, widgets::{Borders, Clear, Widget}, }; diff --git a/src/tx.rs b/src/tx.rs index b5c6a35..d35fa1f 100644 --- a/src/tx.rs +++ b/src/tx.rs @@ -354,7 +354,7 @@ pub fn build_disassocation_from_ap( ap_mac: &MacAddress, client_mac: &MacAddress, sequence: u16, - reason_code: DeauthenticationReason, + _reason_code: DeauthenticationReason, ) -> Vec { let mut rth: Vec = RTH_NO_ACK.to_vec(); diff --git a/src/ui.rs b/src/ui.rs index 6a69f30..6d93fe4 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -2,9 +2,7 @@ use copypasta_ext::osc52::Osc52ClipboardContext; use copypasta_ext::prelude::*; use copypasta_ext::x11_bin::X11BinClipboardContext; use derive_setters::Setters; -use gpsd_proto::Mode; use libwifi::frame::components::MacAddress; -use rand::Rng; use std::{io::Result, time::Instant}; use crate::{ @@ -23,7 +21,6 @@ use crate::{ OxideRuntime, }; -use nl80211_ng::get_interface_info_idx; // Ratatui imports: use ratatui::{