docs: refresh docs and screenshots, drop em dashes, add scripts/screenshots.sh

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Sonnet 5.5 committed 2026-11-03 20:44:47 -03:00
1 parent 1bbb5f934c
commit a7505f4ff3
32 files changed
+326 -121

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
# Regenerates every image in docs/img from the real interface, with synthetic audit data
# (no Wi-Fi hardware needed): `sabia ui` serves the page and the browser answers /api/* from
# scripts/screenshots/mock-api.mjs.
#
# scripts/screenshots.sh [out-dir] # default: docs/img (or $OUT)
#
# Env: CHROME (default ~/.claude/tools/chrome-claude), PUPPETEER_CORE (default the puppeteer-core
# in ~/.claude/tools/node_modules), SABIA (binary to use; default: build target/release/sabia).
set -euo pipefail
cd "$(dirname "$0")/.."
OUT=${1:-${OUT:-docs/img}}
CHROME=${CHROME:-$HOME/.claude/tools/chrome-claude}
PUPPETEER_CORE=${PUPPETEER_CORE:-$HOME/.claude/tools/node_modules/puppeteer-core/lib/esm/puppeteer/puppeteer-core.js}
[ -x "$CHROME" ] || { echo "screenshots: Chrome not found at $CHROME (set CHROME)" >&2; exit 1; }
[ -f "$PUPPETEER_CORE" ] || { echo "screenshots: puppeteer-core not found at $PUPPETEER_CORE (set PUPPETEER_CORE)" >&2; exit 1; }
# The UI is embedded in the binary at compile time, so rebuild (incremental) unless SABIA is given.
if [ -z "${SABIA:-}" ]; then cargo build --release -p sabia-cli; SABIA=target/release/sabia; fi
mkdir -p "$OUT"
OUT=$(cd "$OUT" && pwd)
work=$(mktemp -d)
pid=
cleanup() { [ -n "$pid" ] && kill "$pid" 2>/dev/null || true; rm -rf "$work"; }
trap cleanup EXIT
port=$(python3 -c 'import socket; s=socket.socket(); s.bind(("127.0.0.1",0)); print(s.getsockname()[1])')
# The audit log goes to the temp dir, never into the repo.
"$SABIA" ui --port "$port" --no-open --audit "$work/audit.log" >"$work/ui.log" 2>&1 &
pid=$!
token=
for _ in $(seq 1 50); do
token=$(grep -o 'token=[A-Za-z0-9]*' "$work/ui.log" | head -1 | cut -d= -f2 || true)
[ -n "$token" ] && break
sleep 0.2
done
[ -n "$token" ] || { echo "screenshots: could not read the UI token" >&2; cat "$work/ui.log" >&2; exit 1; }
version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)
BASE_URL="http://127.0.0.1:$port" TOKEN="$token" OUT="$OUT" VERSION="$version" CHROME="$CHROME" PUPPETEER_CORE="$PUPPETEER_CORE" \
node scripts/screenshots/capture.mjs
+66
View File
@@ -0,0 +1,66 @@
// Photographs the real Sabiá interface (served by `sabia ui`) with `/api/*` answered by
// mock-api.mjs. Called by scripts/screenshots.sh; env: BASE_URL, TOKEN, OUT, VERSION,
// CHROME, PUPPETEER_CORE.
import { mockFor, LAB_BSSID } from './mock-api.mjs';
const { BASE_URL, TOKEN, OUT, VERSION, CHROME, PUPPETEER_CORE } = process.env;
const puppeteer = (await import(PUPPETEER_CORE)).default;
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
const browser = await puppeteer.launch({ executablePath: CHROME, args: ['--no-sandbox'], defaultViewport: { width: 1600, height: 940, deviceScaleFactor: 1 } });
async function newPage(theme, lang) {
const page = await browser.newPage();
await page.evaluateOnNewDocument((t, l) => {
try {
localStorage.setItem('sabia-theme', t);
localStorage.setItem('sabia-lang', l);
localStorage.setItem('sabia-view', 'nets');
} catch { /* storage unavailable */ }
}, theme, lang);
await page.setRequestInterception(true);
page.on('request', (req) => {
const u = new URL(req.url());
if (!u.pathname.startsWith('/api/')) return req.continue();
const body = JSON.stringify(mockFor(req.method(), u.pathname, VERSION));
req.respond({ status: 200, contentType: 'application/json', body });
});
await page.goto(`${BASE_URL}/?token=${TOKEN}`, { waitUntil: 'networkidle0' });
await page.emulateMediaFeatures([{ name: 'prefers-color-scheme', value: theme }]);
return page;
}
async function startCapture(page) {
await page.click('#btnScan');
await page.waitForSelector('.net-row', { timeout: 15000 });
await sleep(1500);
}
for (const lang of ['pt', 'en']) {
for (const theme of ['dark', 'light']) {
const page = await newPage(theme, lang);
await startCapture(page);
await page.screenshot({ path: `${OUT}/networks-${theme}-${lang}.png` });
await page.click(`.ssid-btn[data-bssid="${LAB_BSSID}"]`);
await page.waitForSelector('#targetDlg[open]');
await page.click('#targetDlg .tabs [data-tab="attacks"]');
await sleep(600);
await page.click('#authChk');
await sleep(600);
await page.screenshot({ path: `${OUT}/attack-${theme}-${lang}.png` });
await page.close();
}
// Small dialog shot, light theme, as in the docs.
const page = await newPage('light', lang);
await startCapture(page);
await page.click('#settingsBtn');
await page.waitForSelector('#settingsDlg[open]');
await sleep(500);
const r = await page.$eval('#settingsDlg', (el) => { const b = el.getBoundingClientRect(); return { x: b.x, y: b.y, width: b.width, height: b.height }; });
const pad = 24;
await page.screenshot({ path: `${OUT}/settings-language-${lang}.png`, clip: { x: Math.round(r.x - pad), y: Math.round(r.y - pad), width: Math.floor(r.width + 2 * pad), height: Math.floor(r.height + 2 * pad) } });
await page.close();
}
await browser.close();
console.log('ok');
+79
View File
@@ -0,0 +1,79 @@
// 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;