136 lines
4.4 KiB
Rust
136 lines
4.4 KiB
Rust
//! Renders the audit report from a realistic synthetic capture (7 networks,
|
|
//! 9 clients, 1 handshake). Set `SABIA_REPORT_OUT=<file.html>` to save the
|
|
//! HTML for visual inspection (e.g. `verificar-paginacao.mjs`).
|
|
|
|
mod common;
|
|
|
|
use sabia_core::analysis::analyze;
|
|
use sabia_core::audit::AuditEntry;
|
|
use sabia_core::report::{render, ReportModel, ReportOptions};
|
|
use sabia_core::scan::ScanTable;
|
|
|
|
const NETS: &[(&str, u8, &str, i8)] = &[
|
|
("Ciberfauna-Lab", 6, "WPA2", -38),
|
|
("Cafe-Livre", 1, "Open", -52),
|
|
("Vizinho-Antigo", 11, "WEP", -71),
|
|
("Ciberfauna-6E", 36, "WPA3", -47),
|
|
("Corp-Radius", 44, "WPA2-EAP", -63),
|
|
("", 6, "WPA2", -79),
|
|
("IoT-Casa", 1, "WPA2", -58),
|
|
];
|
|
|
|
fn synthetic_model() -> ReportModel {
|
|
let mut table = ScanTable::new();
|
|
for (i, (ssid, ch, _, sig)) in NETS.iter().enumerate() {
|
|
let mut mac = common::ap();
|
|
mac[5] = mac[5].wrapping_add(i as u8 + 1);
|
|
let freq = if *ch > 14 {
|
|
5000 + 5 * *ch as u16
|
|
} else {
|
|
2407 + 5 * *ch as u16
|
|
};
|
|
let b = common::beacon_frame(mac, ssid, *ch, &[2]);
|
|
table.ingest(&common::radiotap_wrap(&b, freq, *sig));
|
|
}
|
|
let probes = [
|
|
"Ciberfauna-Lab",
|
|
"Cafe-Livre",
|
|
"Aeroporto-WiFi",
|
|
"IoT-Casa",
|
|
"Hotel-Guest",
|
|
"Corp-Radius",
|
|
"Ciberfauna-Lab",
|
|
"Casa-Mae",
|
|
"Cafe-Livre",
|
|
];
|
|
for (i, p) in probes.iter().enumerate() {
|
|
let mut mac = common::sta();
|
|
mac[5] = mac[5].wrapping_add(i as u8 + 1);
|
|
let pr = common::probe_request(mac, p);
|
|
table.ingest(&common::radiotap_wrap(&pr, 2437, -45 - 4 * i as i8));
|
|
}
|
|
let (f1, f2) = common::handshake_radiotap_frames("Ciberfauna-Lab", "senha-correta", 2, false);
|
|
table.ingest_at(&f1, 10);
|
|
table.ingest_at(&f2, 11);
|
|
|
|
let mut aps = table.access_points();
|
|
aps.retain(|a| a.bssid != sabia_core::dot11::mac_to_string(&common::ap()));
|
|
for ap in aps.iter_mut() {
|
|
if let Some((_, _, sec, sig)) = NETS
|
|
.iter()
|
|
.find(|n| ap.ssid.as_deref().unwrap_or("") == n.0)
|
|
{
|
|
ap.security = Some(sec.to_string());
|
|
ap.signal_dbm = Some(*sig);
|
|
ap.cipher = Some(
|
|
match *sec {
|
|
"Open" => "—",
|
|
"WEP" => "WEP-104",
|
|
_ => "CCMP",
|
|
}
|
|
.into(),
|
|
);
|
|
ap.pmf = *sec == "WPA3";
|
|
ap.pmf_required = *sec == "WPA3";
|
|
ap.wps = ap.ssid.as_deref() == Some("IoT-Casa");
|
|
}
|
|
}
|
|
let mut clients = table.clients();
|
|
for (i, c) in clients.iter_mut().enumerate() {
|
|
c.packets = 900 - 80 * i as u64;
|
|
c.vendor = Some(["Apple", "Samsung", "Intel", "Espressif", "Xiaomi"][i % 5].into());
|
|
}
|
|
let mut handshakes = table.handshakes();
|
|
handshakes.truncate(1);
|
|
let now = 1_793_700_000;
|
|
let analysis = analyze(&aps, 14, now);
|
|
let mut stats = table.stats();
|
|
stats.aps = aps.len();
|
|
stats.frames = 48_213;
|
|
stats.deauth_frames = 14;
|
|
let audit = (0..6)
|
|
.map(|i| AuditEntry {
|
|
timestamp: format!("2026-11-03T14:{:02}:10Z", 10 + i * 3),
|
|
action: [
|
|
"scan.start",
|
|
"channel.hop",
|
|
"deauth",
|
|
"handshake.capture",
|
|
"crack.verify",
|
|
"report.export",
|
|
][i]
|
|
.into(),
|
|
target: "Ciberfauna-Lab".into(),
|
|
detail: "ação confirmada na interface pelo operador".into(),
|
|
prev_hash: "0".repeat(64),
|
|
hash: format!("{:064x}", 0x9a3f_11c2_u64 * (i as u64 + 7)),
|
|
})
|
|
.collect();
|
|
ReportModel {
|
|
title: "Auditoria Wi-Fi do laboratório".into(),
|
|
version: "1.0.7".into(),
|
|
iface: "wlan0mon".into(),
|
|
running: false,
|
|
generated_unix: now,
|
|
stats,
|
|
access_points: aps,
|
|
clients,
|
|
handshakes,
|
|
analysis,
|
|
audit,
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn renders_synthetic_capture_report() {
|
|
let model = synthetic_model();
|
|
assert_eq!(model.access_points.len(), 7);
|
|
let html = render(&model, ReportOptions::default());
|
|
assert!(html.contains("Ciberfauna-Lab"));
|
|
assert!(html.contains("TLP:AMBER"));
|
|
assert!(html.contains("class=\"cover-motif\""));
|
|
if let Ok(out) = std::env::var("SABIA_REPORT_OUT") {
|
|
std::fs::write(out, html).unwrap();
|
|
}
|
|
}
|