secubox-deb/packages/secubox-toolbox/menu.d
CyberMind 8701c8f989
feat(secubox-toolbox): Phase 1 ToolBoX — captive AP + MITM analyzer + CA distribution (ref #475) (#476)
* feat(secubox-toolbox): Phase 1 ToolBoX captive + MITM analyzer (ref #475)

Productionize le PoC captive portal (live sur gk2 depuis 2026-06-04) en
package Debian dédié `secubox-toolbox` 1.0.0 (parent #474).

Note rename: nom `secubox-portal` déjà pris par le portail d'auth JWT du
dashboard SecuBox → nomenclature `secubox-toolbox` cohérente avec la
framing user ("Module ToolBoX") + concept cabine numérique.

## Périmètre Phase 1

### Backend FastAPI (`secubox_toolbox/`)
- `models.py` — pydantic Config (ap/dhcp/portal/r2/addons/quarantine) + DTOs
- `config.py` — TOML loader + resolve_secret(file://)
- `mac.py` — IP→MAC via `ip neigh` + hash HMAC-SHA256 sel rotatif daily
- `nft.py` — wrappers nftables (add/del/is_validated/is_consented)
- `store.py` — SQLite (consents/clients/events/reports + purge auto)
- `reports.py` — HMAC token éphémère (Phase 4 = PDF complet)
- `ca.py` — gen self-signed CA + render iOS mobileconfig + Android DER
- `api.py` — 13 routes : splash, captive probes, /accept, /status,
  /ca/{mobileconfig,android.crt,install-help}, /report/{token},
  /admin/{config,clients}, /health
- `app.py` — Uvicorn entry + purge async loop

### Templates Jinja2 (`conf/`)
- `splash.html.j2` — page captive P31 light + bannière R2 consent
- `success.html.j2` — page post-validation
- `ca-help.html.j2` — tutoriel install par-OS (iOS/Android/Desktop)
- `ios.mobileconfig.j2` — Apple plist profile pour install CA
- `nft-toolbox.nft.j2` — règles nftables Jinja (table inet toolbox)
- `toolbox.toml` — config TOML par défaut

### mitmproxy addons (`mitmproxy_addons/`)
- `_common.py` — helpers fire-forget POST + MAC lookup
- `cookies.py` → POST /run/secubox/cookies.sock/inject
- `dpi.py` → POST /run/secubox/dpi.sock/classify
- `avatar.py` → POST /run/secubox/avatar.sock/fingerprint (UA + Client Hints)
- `ja4.py` → POST /run/secubox/threat-analyst.sock/ja4 (TLS ClientHello)
- `soc_relay.py` → POST /run/secubox/soc.sock/event (indicateurs basiques)

### Systemd / scripts
- `secubox-toolbox.service` — FastAPI portal (uvicorn 10.99.0.1:8088)
- `secubox-toolbox-mitm.service` — mitmdump transparent (10.99.0.1:8080)
  avec les 5 addons pré-chargés
- `scripts/toolbox-up` — render+apply nftables depuis TOML
- `scripts/ca-init` — gen CA self-signed 10y (idempotent)

### Packaging Debian
- `debian/control` — Architecture: all, deps complets (mitmproxy + nftables...)
- `debian/postinst` — crée user secubox-toolbox, sel rotatif daily, CA self-signed,
  enable services (sans start auto — opérateur doit configurer)
- `debian/conffiles` — /etc/secubox/toolbox.toml
- 2 services systemd installés (primary via dh_installsystemd, secondary manuellement)

### WebUI admin
- `/usr/share/secubox/www/toolbox/index.html` — dashboard P31 light avec
  carte Config (SSID, iface, DHCP, R2 toggle), Clients actifs, Liveness
  + auto-refresh 10s
- `menu.d/26-toolbox.json` — category=security, icône 📡

## Garde-fous respectés
- /etc/secubox parent 0755 (cf. #468) — ne touche QUE les sous-paths
- /run/secubox parent 1777 root:root (cf. #471) — ne touche jamais le parent
- secrets/toolbox-mac-salt chmod 0640 root:secubox-toolbox
- CA key chmod 0600
- SQLite store ([[feedback_prefer_sqlite]])
- R2 = opt-in explicite (CSPN), MAC hashing avec sel daily rotatif

## Build
- `dpkg-buildpackage -b` → secubox-toolbox_1.0.0-1~bookworm1_all.deb (~20 KB)
- 13 routes FastAPI valides
- syntax check Python OK pour 16 fichiers

## Hors périmètre Phase 1 (per #474 roadmap)
- SOC scoring/correlation → Phase 2
- OPAD auto-quarantine decision tree → Phase 3
- PDF report complet + ECH JA4 advanced → Phase 4
- Android APK CA profile signé → Phase 4

* fix(secubox-toolbox): menu category=wall + postinst CA perms (ref #475)

- menu.d/26-toolbox.json : category 'security' → 'wall' (per user feedback —
  use one of the 6 built-in CATEGORY_META standards : auth/wall/boot/mind/
  root/mesh ; ne pas générer de nouvelles catégories). ToolBoX fits in the
  Wall 🛡️ category alongside WAF/CrowdSec/IDS modules.

- debian/postinst : ajoute le fix de perms après le ca-init. Le script
  ca-init crée /etc/secubox/toolbox/ca/ en 0700 root:root par défaut
  (sécurité maximale) mais le service secubox-toolbox tourne sous l'user
  secubox-toolbox et ne peut donc pas lire le CA. On chown root:
  secubox-toolbox + chmod 0750 pour autoriser la lecture par le group.
  Sans ce fix : 500 sur /api/v1/toolbox/ca/mobileconfig (PermissionError).

---------

Co-authored-by: CyberMind-FR <gandalf@Gk2.net>
2026-06-04 07:55:24 +02:00
..
26-toolbox.json feat(secubox-toolbox): Phase 1 ToolBoX — captive AP + MITM analyzer + CA distribution (ref #475) (#476) 2026-06-04 07:55:24 +02:00