PiGuard is a lightweight Wi‑Fi intrusion detection system (WIDS) designed for minimal hardware like the Raspberry Pi. It detects deauthentication attacks and rogue access points in real time, provides a web UI, and exposes a clean API for automation.
sudo ./install.sh --repo https://github.com/mardigiorgio/PiGuard.git --branch main --interactive
# Inside the cloned repo
env | grep -i piGuard || true
sudo ./install.sh --source "$PWD" --interactive
sudo ./install.sh --source "$PWD" --no-interactive --skip-ui
What the installer does:
/opt/piguard
, sets up venv and installs Python package (editable)--skip-ui
)piguard-api
, piguard-sensor
, piguard-sniffer
/etc/piguard/wids.yaml
(if missing) and offers an interactive setup to choose interface, API key, and defended SSIDAfter install:
http://<pi-ip>:8080/
piguard-api
— FastAPI server (serves UI and API)piguard-sniffer
— Capture loop (requires monitor mode)piguard-sensor
— Detection loop (reads DB and emits alerts)Common operations:
sudo systemctl status piguard-api piguard-sniffer piguard-sensor
sudo systemctl restart piguard-sniffer
The UI Logs tab includes “Restart Sniffer” and “Restart Sensor” buttons.
The primary config lives at /etc/piguard/wids.yaml
. A sample is in configs/wids.example.yaml
.
Key sections:
database.path
: SQLite file path (e.g., /var/lib/piguard/db.sqlite
)api.bind_host
/ api.bind_port
/ api.api_key
: API server and keythresholds.deauth
:window_sec
: sliding time window for counting deauth framesper_src_limit
: per‑MAC counter threshold (advisory)global_limit
: global threshold that actually triggers the alertcooldown_sec
: minimum interval between identical alertsthresholds.rogue
:pwr_window
, pwr_var_threshold
, pwr_cooldown_sec
: power variance anomaly tuningsniffer
: optional sniffer tuning (e.g., parse_rsn
, log_stats
)capture
: capture interface and channel hoppingiface
: monitor‑mode interface (e.g., wlan0mon
)hop.enabled
: enable/disable hoppinghop.mode
: lock
| list
| all
hop.lock_channel
: channel when mode=lock
hop.list_channels
: explicit sweep list when mode=list
hop.dwell_ms
: ms to spend per hophop.channels_24
/channels_5
/channels_6
: band channel lists when mode=all
defense
:ssid
: the single SSID to protect (arming the sensor)allowed_bssids
/ allowed_channels
/ allowed_bands
: allowlistsalerts
: optional Discord webhook and/or email SMTP settingsMost of these can be edited from the UI tabs (Defense, Device, Settings). The sensor and hopper observe config updates at runtime.
Sniffer (src/wids/capture/live.py
)
conf.use_pcap=True
) and BPF filter to limit to management frames (beacon/deauth/disassoc)Event
inserts and uses bulk operations for throughputSensor (src/wids/sensor/main.py
)
GROUP BY
for efficiency)Alert
rows and optional notifications (Discord/email)API (src/wids/service/api.py
)
Data model (src/wids/db.py
)
Event
, Alert
, Log
tables (SQLModel)PRAGMA
tuning for write‑heavy workloadsUI (/ui
)
?apikey=...
or stored in localStorageGET /api/health
, GET /api/overview
GET /api/alerts
, POST /api/alerts/test
, GET /api/stream
(SSE)GET /api/logs
, GET /api/events
GET /api/settings/deauth
, POST/PUT /api/settings/deauth
GET/POST /api/defense
GET/POST /api/capture
GET /api/ifaces
, GET /api/iface?dev=wlan0mon
, POST /api/iface/monitor
, POST /api/iface/monitor_clone
, POST /api/iface/channel
POST /api/admin/clear
, POST /api/admin/restart
All protected endpoints require X-Api-Key
header.
window_sec
, lower global_limit
and per_src_limit
, reduce cooldown_sec
.hop.dwell_ms
, reduce hopped channel set (e.g., [1,6,11]
), or switch to mode=lock
on a busy channel.sudo ./install.sh --source "$PWD" --no-interactive
sudo systemctl restart piguard-api
HTTP 401 Unauthorized
: wrong or missing X-Api-Key
; check /etc/piguard/wids.yaml
.HTTP 405 Method Not Allowed
on settings: API service is old; redeploy and restart.sniffer: interface DOWN
: bring the interface up or create a monitor interface in the UI.--skip-ui
or ensure npm/Node are present.# API + sensor (+ sniffer via sudo) using configs/wids.yaml
python -m wids dev --config configs/wids.yaml --ui
python -m wids iface-up --dev wlan0mon
python -m wids sniffer --config configs/wids.yaml
python -m wids sensor --config configs/wids.yaml
Raspberry Pi Wi‑Fi IDS (deauth/rogue AP) with FastAPI backend, Svelte UI, and a one‑command installer. Real‑time detection, channel hopping, and a clean web console for device control, logs, and settings.