commit beb83c2fffd9d27f495a6c1da1b1cbe24b13a50e Author: Torge Date: Fri May 9 12:07:31 2025 +0000 README.md hinzugefügt diff --git a/README.md b/README.md new file mode 100644 index 0000000..935f69d --- /dev/null +++ b/README.md @@ -0,0 +1,90 @@ +# 📡 Fail2Ban Discord Alert + +Ein Python-basiertes Monitoring-Tool, das automatisch IP-Sperren aus der `fail2ban.log` erkennt und sie mit Länderflagge und Geodaten in Echtzeit an einen Discord-Webhook sendet. + +--- + +## 🔧 Features + +- ✅ Überwachung von `/var/log/fail2ban.log` in Echtzeit +- 🛡️ Versand von Discord-Embed-Nachrichten bei neuen IP-Bans +- 🌍 Geo-IP-Lookup mit Ländererkennung via [ipapi.co](https://ipapi.co) +- 🇩🇪🇺🇸 Automatische Anzeige von Länderflaggen im Embed +- 🧠 SQLite-Datenbank zur Vermeidung doppelter Benachrichtigungen +- 📁 `.env`-Konfigurationsdatei für sicheren Webhook-Zugriff +- 🧰 Automatischer Systemd-Service für dauerhaftes Monitoring + +--- + +## 📦 Voraussetzungen + +- Linux mit systemd +- Python 3.6+ +- Zugriff auf `/var/log/fail2ban.log` +- Funktionierender Fail2Ban-Dienst +- Ein Discord-Webhook-Link + +--- + +## 🚀 Installation + +```bash +git clone https://github.com/dein-nutzername/fail2ban-discord-alert.git +cd fail2ban-discord-alert +chmod +x install_fail2ban_discord.sh +sudo ./install_fail2ban_discord.sh +``` + +> 📩 Während der Installation wirst du nach einem Discord Webhook gefragt. Es wird automatisch eine Testnachricht gesendet und alles eingerichtet. + +--- + +## ⚙️ Dateien im Projekt + +| Datei | Funktion | +|--------------------------------|-----------------------------------------------| +| `fail2ban_discord.py` | Hauptmonitor-Skript | +| `.env` | Webhook-Konfiguration (wird befüllt) | +| `requirements.txt` | Python-Abhängigkeiten | +| `install_fail2ban_discord.sh` | Installationsskript inkl. systemd-Anbindung | +| `bans.db` | SQLite-Datenbank für verarbeitete IPs | + +--- + +## 🔁 Service-Verwaltung + +```bash +# Status prüfen +systemctl status fail2ban_discord_alert.service + +# Dienst starten/stoppen +sudo systemctl start fail2ban_discord_alert.service +sudo systemctl stop fail2ban_discord_alert.service +``` + +--- + +## 🧪 Test-Webhook erneut senden + +```bash +curl -H "Content-Type: application/json" \ + -X POST \ + -d '{"content": "✅ Testnachricht vom Fail2Ban Discord Alert!"}' \ + "$(grep DISCORD_WEBHOOK_URL .env | cut -d '=' -f2)" +``` + +--- + +## 🧼 Uninstall (optional) + +Ein `uninstall.sh` Skript entfernt: +- den systemd-Dienst +- die Python-Umgebung +- die Datenbank +- die Konfigurationsdateien + +--- + +## 📄 Lizenz + +MIT License – frei verwendbar, auch in kommerziellen Umgebungen.