Crates.io | simple_wifi |
lib.rs | simple_wifi |
version | 0.1.6 |
source | src |
created_at | 2024-01-20 21:22:15.058227 |
updated_at | 2024-05-11 00:55:31.732911 |
description | Simple 802.11 Wi-Fi packet parser. |
homepage | |
repository | |
max_upload_size | |
id | 1106818 |
size | 37,947 |
simple_wifi
is a module for a quick decoding of 802.11 Wi-Fi Packets
simple_wifi
takes the raw packet and provides the Name of the packet,
packet type, packet subtype, toDS, FromDS, signal, channel, address1,
address2, address3, address4, SSID. It also gives you the ability to
write the packet to a pcap file as well.
Now you have the ability to write packets that have errored while decoding to a pcap file. More RadioTap Header Lengths have been added for decoding. Added the decoding for a DMG Beacon. Packet Type: 3 Subtype: 0. Added another ssid to see if all the characters are null. If so then the ssid will be "U_n_k_n_o_w_n".
simple_wifi
was tested on Linux Debian Distro using Alpha Wi-Fi card.
Using the module pnet
to open the socket and sniff the packets from the
Wi-Fi card.
# extern crate pnet;
# extern crate simple_wifi;
use pnet::datalink::{ self, NetworkInterface, Channel::Ethernet};
use simple_wifi::*;
use std::process;
fn main() {
// Wi-Fi card to sniff packets with.//!
let wifi_card: &str = "wlo1";
// Finding the interface that matches the wifi_card. So it can be used for sniffing.
let interface: NetworkInterface = datalink::interfaces()
.into_iter()
.filter(|iface: &NetworkInterface| iface.name == wifi_card)
.next()
.unwrap();
// Setting up the channel to the interface so you can sniff Wi-Fi packets.
let (_, mut rx) = match datalink::channel(&interface, Default::default()) {
Ok(Ethernet(tx, rx)) => (tx, rx),
Ok(_) => {
println!("\x1b[38;5;9mUnhandled channel type\x1b[0m");
process::exit(0);
},
Err(e) => {
println!("\x1b[38;5;9mAn error occurred when creating the datalink channel: {e}\x1b[0m");
process::exit(0);
}
};
loop {
let pkt: &[u8] = match rx.next() {
Ok(pkt) => pkt,
Err(_) => continue
};
let pkt_info: Packet = match Packet::new(pkt) {
Ok(t) => t,
Err(e) => {
println!("\x1b[38;5;9m{e}\x1b[0m");
let _ = write_pcap(&pkt.to_vec(), "/home/user/error.pcap");
continue;
}
};
println!("{pkt_info:#?}");
println!(
"Address1: {}, Address2: {}\nAddress3: {}, Address4: {}",
pkt_info.addr1, pkt_info.addr2, pkt_info.addr3, pkt_info.addr4
)
}
}