Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
80 lines
5.7 KiB
JavaScript
80 lines
5.7 KiB
JavaScript
// Synthetic audit data served in place of `/api/*`, so the real interface can be photographed
|
|
// without Wi-Fi hardware. Shapes mirror the serde structs in crates/sabia-core (scan.rs,
|
|
// handshake.rs, iface.rs, wps.rs). Everything here is invented: no real network appears.
|
|
|
|
const now = Math.floor(Date.now() / 1000);
|
|
|
|
const ap = (o) => ({
|
|
bssid: '', ssid: null, hidden: false, channel: null, band: null, freq_mhz: null,
|
|
security: null, cipher: null, akm: [], pmf: false, pmf_required: false,
|
|
wps: false, wps_locked: null, wps_version: null, wps_manufacturer: null, wps_model: null,
|
|
wps_model_number: null, wps_device_name: null, wps_serial: null, vendor: null, country: 'BR',
|
|
phy: ['n'], width_mhz: 20, beacon_interval: 100, privacy: true,
|
|
signal_dbm: null, max_signal_dbm: null, beacons: 1200, data_frames: 340, clients: [],
|
|
first_seen_unix: now - 600, last_seen_unix: now, ...o,
|
|
});
|
|
|
|
const LAB = 'c0:25:e9:1a:2b:3c';
|
|
const C = (n) => `02:5a:${n}`;
|
|
|
|
const access_points = [
|
|
ap({ bssid: LAB, ssid: 'Ciberfauna-Lab', channel: 6, band: '2.4 GHz', freq_mhz: 2437, security: 'WPA2', cipher: 'CCMP', akm: ['PSK'], vendor: 'TP-Link', signal_dbm: -42, max_signal_dbm: -42, phy: ['n', 'ax'], clients: ['38:f9:d3:4a:5b:6c', '9c:b6:d0:11:22:33', 'a4:83:e7:44:55:66'] }),
|
|
ap({ bssid: '8c:3b:ad:20:00:01', ssid: 'Starlink-HighSpeed', channel: 36, band: '5 GHz', freq_mhz: 5180, security: 'WPA3', cipher: 'CCMP', akm: ['SAE'], pmf: true, pmf_required: true, vendor: 'Starlink', signal_dbm: -50, max_signal_dbm: -50, width_mhz: 80, phy: ['n', 'ac', 'ax'], clients: ['f0:18:98:77:88:99', 'dc:a6:32:aa:bb:cc'] }),
|
|
ap({ bssid: 'b0:4e:26:30:00:02', ssid: 'Campus-Guest', channel: 1, band: '2.4 GHz', freq_mhz: 2412, security: 'Open', cipher: null, akm: [], privacy: false, vendor: 'Ubiquiti', signal_dbm: -56, max_signal_dbm: -56, clients: ['3c:22:fb:12:34:56'] }),
|
|
ap({ bssid: 'e4:5f:01:40:00:03', ssid: 'Corp-Enterprise', channel: 149, band: '5 GHz', freq_mhz: 5745, security: 'WPA2-EAP', cipher: 'CCMP', akm: ['802.1X'], pmf: true, vendor: 'Cisco', signal_dbm: -60, max_signal_dbm: -60, width_mhz: 80, phy: ['n', 'ac'], clients: ['00:1b:63:84:45:e6', '28:cf:e9:21:43:65'] }),
|
|
ap({ bssid: 'fc:ec:da:50:00:04', ssid: 'SmartHome-IoT', channel: 11, band: '2.4 GHz', freq_mhz: 2462, security: 'WPA', cipher: 'TKIP', akm: ['PSK'], wps: true, wps_locked: false, wps_version: '2.0', wps_manufacturer: 'Genérico', wps_model: 'IoT-Hub', vendor: 'Espressif', signal_dbm: -67, max_signal_dbm: -67, phy: ['g', 'n'], clients: ['24:6f:28:99:00:11'] }),
|
|
ap({ bssid: '00:1f:33:60:00:05', ssid: 'Netgear-Legacy', channel: 3, band: '2.4 GHz', freq_mhz: 2422, security: 'WEP', cipher: 'WEP', akm: [], wps: true, wps_locked: false, wps_version: '1.0', vendor: 'Netgear', signal_dbm: -72, max_signal_dbm: -72, phy: ['b', 'g'], clients: [] }),
|
|
ap({ bssid: 'f8:1a:67:89:ab:cd', ssid: null, hidden: true, channel: 44, band: '5 GHz', freq_mhz: 5220, security: 'WPA2', cipher: 'CCMP', akm: ['PSK'], vendor: 'TP-Link', signal_dbm: -78, max_signal_dbm: -78, width_mhz: 40, phy: ['n', 'ac'], clients: [] }),
|
|
];
|
|
|
|
const client = (mac, bssid, name, vendor, dbm, extra = {}) => ({
|
|
mac, display_name: name, vendor, manufacturer: null, model: null, device_name: null,
|
|
hostname: name, ip: null, os: null, device: null, random_mac: false, bssid,
|
|
signal_dbm: dbm, max_signal_dbm: dbm, packets: 420, probes: [], associated: true,
|
|
first_seen_unix: now - 500, last_seen_unix: now,
|
|
signal_history: Array.from({ length: 24 }, (_, i) => ({ t: now - (24 - i) * 5, dbm: dbm + ((i * 7) % 5) - 2 })),
|
|
events: [{ t: now - 480, kind: 'associação', detail: null }], ...extra,
|
|
});
|
|
|
|
const clients = [
|
|
client('38:f9:d3:4a:5b:6c', LAB, 'notebook-lab', 'Apple', -48),
|
|
client('9c:b6:d0:11:22:33', LAB, 'estacao-02', 'Intel', -55),
|
|
client('a4:83:e7:44:55:66', LAB, 'celular-visita', 'Samsung', -61),
|
|
client('f0:18:98:77:88:99', '8c:3b:ad:20:00:01', 'tablet-sala', 'Apple', -58),
|
|
client('dc:a6:32:aa:bb:cc', '8c:3b:ad:20:00:01', 'raspberry-lab', 'Raspberry Pi', -63),
|
|
client('3c:22:fb:12:34:56', 'b0:4e:26:30:00:02', null, 'Apple', -66),
|
|
client('00:1b:63:84:45:e6', 'e4:5f:01:40:00:03', 'ws-financeiro', 'Dell', -64),
|
|
client('28:cf:e9:21:43:65', 'e4:5f:01:40:00:03', 'ws-rh', 'Dell', -70),
|
|
client('24:6f:28:99:00:11', 'fc:ec:da:50:00:04', 'sensor-estufa', 'Espressif', -69),
|
|
];
|
|
|
|
const handshakes = [{
|
|
bssid: LAB, station: '38:f9:d3:4a:5b:6c', ssid: 'Ciberfauna-Lab', kind: '4-way', messages: '1,2,3,4',
|
|
complete: true, crackable: true, pmkid: null, key_version: 2, password: null, raw_frames: 4,
|
|
first_seen_unix: now - 300, last_seen_unix: now - 300,
|
|
}];
|
|
|
|
const snapshot = {
|
|
iface: 'wlan0', running: true, channel: 6,
|
|
stats: { frames: 48213, eapol_frames: 4, deauth_frames: 0, aps: access_points.length, clients: clients.length, handshakes: 1 },
|
|
access_points, clients, handshakes,
|
|
analysis: { bands: [], findings: [], wpa3: [], deauth_60s: 0 },
|
|
error: null, warning: null,
|
|
};
|
|
|
|
export function mockFor(method, path, version) {
|
|
switch (`${method} ${path}`) {
|
|
case 'GET /api/version': return { version };
|
|
case 'GET /api/ifaces': return [{ name: 'wlan0', mac: '00:c0:ca:9b:12:34', phy: 'phy0', mode: 'Monitor', up: true }];
|
|
case 'POST /api/scan/start': return { ok: true };
|
|
case 'GET /api/scan/snapshot': return snapshot;
|
|
case 'GET /api/scan/clients': return clients;
|
|
case 'GET /api/handshakes': return handshakes;
|
|
case 'GET /api/wps/tools': return [{ name: 'reaver', path: 'embutido', bundled: true }, { name: 'bully', path: '/usr/bin/bully', bundled: false }];
|
|
case 'GET /api/update/check': return { current_version: version, latest_version: version, update_available: false };
|
|
default:
|
|
return path.endsWith('s') || path.endsWith('/jobs') ? [] : { ok: true };
|
|
}
|
|
}
|
|
export const LAB_BSSID = LAB;
|