mirror of
https://github.com/eiskasten/wc-beacon.git
synced 2026-09-14 23:27:02 -05:00
Add first frame
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/target
|
||||
275
Cargo.lock
generated
Normal file
275
Cargo.lock
generated
Normal file
@@ -0,0 +1,275 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6748e8def348ed4d14996fa801f4122cd763fff530258cdc03f64b25f89d3a5a"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.82"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "305fe645edc1442a0fa8b6726ba61d422798d37a52e12eaecf4b022ebbb88f01"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "cipher"
|
||||
version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
|
||||
dependencies = [
|
||||
"crypto-common",
|
||||
"inout",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc"
|
||||
version = "3.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe"
|
||||
dependencies = [
|
||||
"crc-catalog",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc-catalog"
|
||||
version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484"
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "distribution-beacon"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"crc",
|
||||
"pcap",
|
||||
"rc4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1"
|
||||
dependencies = [
|
||||
"errno-dragonfly",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "errno-dragonfly"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "inout"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.147"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
version = "0.6.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||
|
||||
[[package]]
|
||||
name = "pcap"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cbaa01d616eb84eb35cd085fdeaa8671dc8d951bdc4a75bfc414466e76b039ce"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
"libc",
|
||||
"libloading",
|
||||
"pkg-config",
|
||||
"regex",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
|
||||
|
||||
[[package]]
|
||||
name = "rc4"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f1256e23efe6097f27aa82d6ca6889361c001586ae0f6917cbad072f05eb275"
|
||||
dependencies = [
|
||||
"cipher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2"
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2"
|
||||
dependencies = [
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"
|
||||
15
Cargo.toml
Normal file
15
Cargo.toml
Normal file
@@ -0,0 +1,15 @@
|
||||
[package]
|
||||
name = "distribution-beacon"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
pcap = "1.1.0"
|
||||
crc = "3.0.1"
|
||||
rc4 = "0.1.0"
|
||||
|
||||
[profile.release]
|
||||
opt-level = "s"
|
||||
lto = true
|
||||
8
scripts/unmanage.sh
Executable file
8
scripts/unmanage.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
DEV="$1"
|
||||
|
||||
nmcli device set "$DEV" managed no
|
||||
ip link set "$DEV" down
|
||||
iw "$DEV" set monitor none
|
||||
ip link set "$DEV" up
|
||||
112
src/main.rs
Normal file
112
src/main.rs
Normal file
@@ -0,0 +1,112 @@
|
||||
use std::error::Error;
|
||||
use std::ops::Add;
|
||||
use std::result::Result;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
use crc::{Crc, CRC_32_ISO_HDLC};
|
||||
|
||||
use crate::GGID::{English, French, German, Italian, Japanese, Korean, Spanish};
|
||||
|
||||
type MacAddress = [u8; 6];
|
||||
|
||||
const CRC_32: Crc<u32> = Crc::<u32>::new(&CRC_32_ISO_HDLC);
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let dev_name = "wlp0s20f3";
|
||||
let dev_addr: MacAddress = [0x94, 0xe6, 0xf7, 0x06, 0xcf, 0x6b];
|
||||
let broadcast_addr: MacAddress = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff];
|
||||
|
||||
eprintln!("Use device '{}' with ethernet address '{:02x?}' and broadcast address '{:02x?}'", dev_name, dev_addr, broadcast_addr);
|
||||
let mut cap = pcap::Capture::from_device(dev_name)?.open()?;
|
||||
let mut counter: u64 = 0;
|
||||
loop {
|
||||
let dumped_radio: &[u8] = &[
|
||||
0x00, 0x00, // rev, pad
|
||||
0x38, 0x00, // header length
|
||||
0x2f, 0x40, 0x40, 0xa0, 0x20, 0x08, 0x00, 0xa0, 0x20, 0x08, 0x00, 0x00, // present flags
|
||||
0x4d, 0x6c, 0xb8, 0x06, 0x00, 0x00, 0x00, 0x00, // MAC timestamp, update
|
||||
0x12, // flags
|
||||
0x04, // data rate
|
||||
0x8a, 0x09, // channel frequency
|
||||
0xa0, 0x00, // channel flags
|
||||
0xbd, // antenna signal
|
||||
0x00, // ?
|
||||
0x00, 0x00, // rx flags
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ?
|
||||
0xee, 0x6b, 0xb8, 0x06, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x11, 0x03, // timestamp information, update
|
||||
0xbc, // antenna signal
|
||||
0x00, // antenna
|
||||
0xbd, // antenna signal
|
||||
0x01 // antenna
|
||||
];
|
||||
let sequence = (counter << 4).to_le_bytes();
|
||||
let beacon_frame: &[u8] = &[
|
||||
0x80, 0x00, // frame control field (type, subtype)
|
||||
0x00, 0x00, // duration
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // destination address
|
||||
0xa4, 0xc0, 0xe1, 0x6e, 0x76, 0x80, // source address
|
||||
0xa4, 0xc0, 0xe1, 0x6e, 0x76, 0x80, // bssid
|
||||
0x40, 0xd0 // sequence number, fragment number, update increment by 0x10
|
||||
];
|
||||
let wireless_management: &[u8] = &[
|
||||
// fixed parameters
|
||||
0xcc, 0xc8, 0x08, 0x2f, 0x00, 0x00, 0x00, 0x00, // timestamp, update
|
||||
0x0a, 0x00, // beacon interval
|
||||
0x21, 0x00, // capabilities information
|
||||
// tagged parameters
|
||||
0x01, 0x02, 0x82, 0x84, // tag supported rates
|
||||
0x03, 0x01, 0x07, // ds parameter set, current channel
|
||||
0x05, 0x05, 0x01, 0x02, 0x00, 0x00, 0x00, // traffic indication map, update
|
||||
// vendor specific
|
||||
0xdd, // tag number
|
||||
0x88, // tag length
|
||||
0x00, 0x09, 0xbf, // OUI
|
||||
0x00, // OUI type
|
||||
0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x18, 0x03, 0x40, 0x00, 0x00, 0x00, 0x70, 0x00, 0x28, 0x00, 0x0c, 0x00, 0xc5, 0xbd, 0x00, 0x00, 0xa8, 0x03, 0x00, 0x00, 0x03, 0xfc, 0x9f, 0xa4, 0x77, 0xa3, 0x6f, 0x56, 0x7c, 0x17, 0xb7, 0x56, 0x0e, 0x87, 0x38, 0xd8, 0xbc, 0x37, 0x71, 0x29, 0x9c, 0x0c, 0x4c, 0xd1, 0xba, 0x4d, 0xc0, 0x01, 0xd4, 0xbc, 0x81, 0x5b, 0xdd, 0xe6, 0x46, 0xd1, 0x57, 0x66, 0x95, 0x58, 0x81, 0x08, 0x1e, 0x69, 0x06, 0xe4, 0x93, 0x9b, 0xa8, 0x5f, 0xb7, 0x3a, 0x4f, 0x9a, 0xaa, 0x9b, 0x76, 0x86, 0xa7, 0xe8, 0x7f, 0xfd, 0x48, 0x60, 0xdf, 0x45, 0x2a, 0x6d, 0x30, 0x85, 0xa1, 0x8f, 0x1d, 0x3c, 0xb0, 0x70, 0x1e, 0xe1, 0x22, 0x7e, 0x70, 0x8e, 0x64, 0x67, 0xa4, 0xfd, 0xbf, 0xb1, 0xdb, 0x5d, 0xd2, 0x51, 0x02, 0xb0, 0x12, 0x6f, 0x88, 0xb9, 0x72, 0xb0, 0x77, 0xec, 0x84, 0x5e,
|
||||
];
|
||||
let mut header_plus_body = [
|
||||
beacon_frame,
|
||||
wireless_management
|
||||
].concat();
|
||||
let recalc_crc = CRC_32.checksum(header_plus_body.as_slice());
|
||||
|
||||
let packet = [
|
||||
dumped_radio,
|
||||
header_plus_body.as_slice(),
|
||||
&recalc_crc.to_le_bytes()
|
||||
].concat();
|
||||
cap.sendpacket(packet.as_slice())?;
|
||||
|
||||
counter += 1;
|
||||
thread::sleep(Duration::from_secs(1));
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(u32)]
|
||||
enum GGID {
|
||||
Japanese = 0x345,
|
||||
English = 0x400318,
|
||||
French = 0x8000cd,
|
||||
German = 0x8000ce,
|
||||
Italian = 0x8000cf,
|
||||
Spanish = 0x8000d0,
|
||||
Korean = 0xc00018,
|
||||
}
|
||||
|
||||
impl TryFrom<&str> for GGID {
|
||||
type Error = String;
|
||||
|
||||
fn try_from(value: &str) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
"jp" => Ok(Japanese),
|
||||
"en" => Ok(English),
|
||||
"fr" => Ok(French),
|
||||
"de" => Ok(German),
|
||||
"it" => Ok(Italian),
|
||||
"es" => Ok(Spanish),
|
||||
"ko" => Ok(Korean),
|
||||
_ => Err(String::from("Unknown language code: ").add(value))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user