Skip to content

Commit

Permalink
bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ragnt committed Jan 17, 2024
1 parent 98a631f commit aec2d0c
Show file tree
Hide file tree
Showing 8 changed files with 194 additions and 85 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
members = ["libs/libwifi", "libs/libwifi_macros", "libs/pcap-file"]

[workspace.package]
version = "0.7.2"
version = "0.7.3"
authors = ["Ryan Butler"]
description = "80211 Attack Platform"
license = "MIT"
Expand Down
16 changes: 5 additions & 11 deletions libs/libwifi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ const CRC_32: Crc<u32> = Crc::<u32>::new(&CRC_32_ISO_HDLC);
pub fn parse_frame(input: &[u8], fcs_included: bool) -> Result<Frame, Error> {
if fcs_included {
if input.len() < 4 {
return Err(Error::Failure(
"Input frame is too short to contain an FCS".to_string(),
input.to_vec(),
));
return Err(Error::Incomplete("Incomplete".to_string()));
}

// Split the input into frame data and FCS
Expand All @@ -44,13 +41,10 @@ pub fn parse_frame(input: &[u8], fcs_included: bool) -> Result<Frame, Error> {

// Verify the FCS
if crc != fcs {
return Err(Error::Failure(
format!(
"Frame Check Sequence (FCS) mismatch {:02x} {:02x}",
crc, fcs
),
input.to_vec(),
));
return Err(Error::Incomplete(format!(
"(FCS) mismatch {:02x} {:02x}",
crc, fcs
)));
}
}

Expand Down
14 changes: 10 additions & 4 deletions src/attack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ pub fn rogue_m2_attack_directed(
if probe.station_info.ssid.is_none() {
return Ok(());
}

let ssid = probe.station_info.ssid.unwrap();

if station.timer_interact.elapsed().unwrap() < Duration::from_secs(3) {
Expand Down Expand Up @@ -526,20 +527,24 @@ pub fn rogue_m2_attack_undirected(
if oxide.target_data.targets.has_ssid() {
// Pick a random SSID from our targets and respond.
let target = oxide.target_data.targets.get_random_ssid().unwrap();
if let Some(ap) = oxide.access_points.get_device_by_ssid(&target) {
let ap = if let Some(ap) = oxide.access_points.get_device_by_ssid_glob(&target) {
// Make sure this AP is a target and that this AP is
if oxide
.handshake_storage
.has_complete_handshake_for_ap(&ap.mac_address)
{
return Ok(());
} else {
ap
}
}
} else {
return Ok(());
};

let frx = build_probe_response(
&probe.header.address_2,
&oxide.target_data.rogue_client,
&target,
&ap.ssid.clone().unwrap(),
oxide.counters.sequence3(),
oxide.if_hardware.current_channel.get_channel_number(),
);
Expand All @@ -551,7 +556,8 @@ pub fn rogue_m2_attack_undirected(
MessageType::Info,
format!(
"Anonymous Rogue AP Attempt: {} ({})",
station.mac_address, target
station.mac_address,
ap.ssid.clone().unwrap()
),
));
}
Expand Down
31 changes: 26 additions & 5 deletions src/devices.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use globset::Glob;
use libwifi::frame::components::MacAddress;
use libwifi::{Addresses, Frame};
use nl80211_ng::channels::{WiFiBand, WiFiChannel};
Expand Down Expand Up @@ -433,15 +434,35 @@ impl<T: WiFiDeviceType> WiFiDeviceList<T> {
where
T: HasSSID,
{
self.devices
.values_mut() // Get a mutable iterator over the values
.find_map(|x: &mut T| {
if x.ssid().as_ref().map_or(false, |f| f == ssid) {
self.devices.values_mut().find_map(|x: &mut T| {
if x.ssid().as_ref().map_or(false, |f| f == ssid) {
Some(x)
} else {
None
}
})
}

// Retrieve a device by MAC address GLOB
pub fn get_device_by_ssid_glob(&mut self, ssid: &str) -> Option<&mut T>
where
T: HasSSID,
{
self.devices.values_mut().find_map(|x: &mut T| {
if let Some(device_ssid) = x.ssid() {
if Glob::new(ssid)
.unwrap()
.compile_matcher()
.is_match(device_ssid)
{
Some(x)
} else {
None
}
})
} else {
None
}
})
}

// Retrieve all devices
Expand Down
Loading

0 comments on commit aec2d0c

Please sign in to comment.