2026-10-13 12:06:40 +00:00
|
|
|
# barbenoire
|
|
|
|
|
|
2026-10-13 14:12:14 +02:00
|
|
|
Telegram bot on top of the homelab's **CrowdSec** Local API.
|
|
|
|
|
CrowdSec itself still sends the ban notifications (same bot token, `http` plugin);
|
|
|
|
|
this bot only adds commands.
|
|
|
|
|
|
|
|
|
|
| Command | Reply |
|
|
|
|
|
|---|---|
|
|
|
|
|
| `/bans` | Active bans from the local CrowdSec (community blocklist not counted) |
|
|
|
|
|
| `/ip <address>` | Banned right now? Country, AS, alert history, CTI/Shodan links |
|
|
|
|
|
| `/unban <address>` | Lift a ban, after a ✅/❌ confirmation |
|
|
|
|
|
| `/stats` | Alerts over 24 h and 7 days, by scenario and country |
|
|
|
|
|
|
|
|
|
|
Optional: a heartbeat to a Kuma Push monitor (`KUMA_PUSH_URL`).
|
|
|
|
|
It only answers the chat IDs in `ALLOWED_CHAT_IDS`.
|
|
|
|
|
|
|
|
|
|
## CrowdSec credentials (on the CrowdSec host, LXC 101)
|
|
|
|
|
|
|
|
|
|
```bash
|
2026-10-13 14:16:22 +02:00
|
|
|
cscli bouncers add barbenoire # -> CROWDSEC_BOUNCER_KEY (required, read-only)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**Read-only mode (default):** with only the bouncer key, `/bans` and `/ip` work (no country,
|
|
|
|
|
no history); `/unban` and `/stats` reply that they are turned off.
|
|
|
|
|
|
|
|
|
|
**Full mode (optional):** a machine login adds alert history, countries, `/stats` and
|
|
|
|
|
`/unban`. A machine can also *create* alerts and bans, so its password is sensitive.
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
cscli machines add barbenoire --password '<long random>' -f /dev/null
|
|
|
|
|
# then set CROWDSEC_MACHINE_ID / CROWDSEC_MACHINE_PASSWORD in .env and restart
|
2026-10-13 14:12:14 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The bot talks to the LAPI at `http://10.0.0.11:8080` (reachable from VM 107).
|
|
|
|
|
|
|
|
|
|
## Run locally
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
python3 -m venv .venv && .venv/bin/pip install -r requirements.txt
|
|
|
|
|
cp .env.example .env # fill in token + CrowdSec credentials
|
|
|
|
|
.venv/bin/python app.py
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Deploy on Pterodactyl (python generic egg)
|
|
|
|
|
|
|
|
|
|
Server `barbenoire` on node `wings`. Same variables as barberousse, with
|
|
|
|
|
`GIT_ADDRESS=https://forgejo.un-oeil.fr/un-oeil/barbenoire.git`.
|
|
|
|
|
|
|
|
|
|
1. Set the variables, then **Reinstall** (clones the repo).
|
|
|
|
|
2. Files → create `.env` from `.env.example` (git-ignored).
|
|
|
|
|
3. Start. The console shows `Barbenoire starting (...)`.
|
|
|
|
|
|
|
|
|
|
To update: push to Forgejo, then Restart the server.
|