Skip to content

Commit aec2d0c

Browse files
committed
bugfixes
1 parent 98a631f commit aec2d0c

8 files changed

Lines changed: 194 additions & 85 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
members = ["libs/libwifi", "libs/libwifi_macros", "libs/pcap-file"]
33

44
[workspace.package]
5-
version = "0.7.2"
5+
version = "0.7.3"
66
authors = ["Ryan Butler"]
77
description = "80211 Attack Platform"
88
license = "MIT"

libs/libwifi/src/lib.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ const CRC_32: Crc<u32> = Crc::<u32>::new(&CRC_32_ISO_HDLC);
2727
pub fn parse_frame(input: &[u8], fcs_included: bool) -> Result<Frame, Error> {
2828
if fcs_included {
2929
if input.len() < 4 {
30-
return Err(Error::Failure(
31-
"Input frame is too short to contain an FCS".to_string(),
32-
input.to_vec(),
33-
));
30+
return Err(Error::Incomplete("Incomplete".to_string()));
3431
}
3532

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

4542
// Verify the FCS
4643
if crc != fcs {
47-
return Err(Error::Failure(
48-
format!(
49-
"Frame Check Sequence (FCS) mismatch {:02x} {:02x}",
50-
crc, fcs
51-
),
52-
input.to_vec(),
53-
));
44+
return Err(Error::Incomplete(format!(
45+
"(FCS) mismatch {:02x} {:02x}",
46+
crc, fcs
47+
)));
5448
}
5549
}
5650

src/attack.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ pub fn rogue_m2_attack_directed(
425425
if probe.station_info.ssid.is_none() {
426426
return Ok(());
427427
}
428+
428429
let ssid = probe.station_info.ssid.unwrap();
429430

430431
if station.timer_interact.elapsed().unwrap() < Duration::from_secs(3) {
@@ -526,20 +527,24 @@ pub fn rogue_m2_attack_undirected(
526527
if oxide.target_data.targets.has_ssid() {
527528
// Pick a random SSID from our targets and respond.
528529
let target = oxide.target_data.targets.get_random_ssid().unwrap();
529-
if let Some(ap) = oxide.access_points.get_device_by_ssid(&target) {
530+
let ap = if let Some(ap) = oxide.access_points.get_device_by_ssid_glob(&target) {
530531
// Make sure this AP is a target and that this AP is
531532
if oxide
532533
.handshake_storage
533534
.has_complete_handshake_for_ap(&ap.mac_address)
534535
{
535536
return Ok(());
537+
} else {
538+
ap
536539
}
537-
}
540+
} else {
541+
return Ok(());
542+
};
538543

539544
let frx = build_probe_response(
540545
&probe.header.address_2,
541546
&oxide.target_data.rogue_client,
542-
&target,
547+
&ap.ssid.clone().unwrap(),
543548
oxide.counters.sequence3(),
544549
oxide.if_hardware.current_channel.get_channel_number(),
545550
);
@@ -551,7 +556,8 @@ pub fn rogue_m2_attack_undirected(
551556
MessageType::Info,
552557
format!(
553558
"Anonymous Rogue AP Attempt: {} ({})",
554-
station.mac_address, target
559+
station.mac_address,
560+
ap.ssid.clone().unwrap()
555561
),
556562
));
557563
}

src/devices.rs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use globset::Glob;
12
use libwifi::frame::components::MacAddress;
23
use libwifi::{Addresses, Frame};
34
use nl80211_ng::channels::{WiFiBand, WiFiChannel};
@@ -433,15 +434,35 @@ impl<T: WiFiDeviceType> WiFiDeviceList<T> {
433434
where
434435
T: HasSSID,
435436
{
436-
self.devices
437-
.values_mut() // Get a mutable iterator over the values
438-
.find_map(|x: &mut T| {
439-
if x.ssid().as_ref().map_or(false, |f| f == ssid) {
437+
self.devices.values_mut().find_map(|x: &mut T| {
438+
if x.ssid().as_ref().map_or(false, |f| f == ssid) {
439+
Some(x)
440+
} else {
441+
None
442+
}
443+
})
444+
}
445+
446+
// Retrieve a device by MAC address GLOB
447+
pub fn get_device_by_ssid_glob(&mut self, ssid: &str) -> Option<&mut T>
448+
where
449+
T: HasSSID,
450+
{
451+
self.devices.values_mut().find_map(|x: &mut T| {
452+
if let Some(device_ssid) = x.ssid() {
453+
if Glob::new(ssid)
454+
.unwrap()
455+
.compile_matcher()
456+
.is_match(device_ssid)
457+
{
440458
Some(x)
441459
} else {
442460
None
443461
}
444-
})
462+
} else {
463+
None
464+
}
465+
})
445466
}
446467

447468
// Retrieve all devices

0 commit comments

Comments
 (0)