Crowdsec SSH Bruteforce Beispiel
Version vom 13. April 2025, 11:34 Uhr von Thomas.will (Diskussion | Beiträge)
Installation des CrowdSec SSH-Bruteforce-Schutzes
Installation der SSH-Collection
- sudo cscli collections install crowdsecurity/sshd
- sudo systemctl reload crowdsec
Installation des nftables Bouncers
- Wenn noch nicht geschehen
- apt install crowdsec-firewall-bouncer-nftables
Neustart des Bouncers
- sudo systemctl restart crowdsec-firewall-bouncer
- sudo systemctl status crowdsec-firewall-bouncer
Überprüfen, ob der Bouncer mit CrowdSec verbunden ist
- sudo cscli bouncers list
Überprüfung der installierten SSH-Szenarien
- sudo cscli scenarios list | grep ssh
Auf dem Attacker starten wir nun einen Angriff
- Passwortliste besorgen
- Hydra installieren
- apt install hydra -y
- Attacke
- hydra -l root -P bad-passwords ssh://10.0.10.132 -V
Die IP sollte hier erscheinen
- ipset list crowdsec-blacklists-1
Name: crowdsec-blacklists-1 Type: hash:net Revision: 7 Header: family inet hashsize 1024 maxelem 131072 timeout 300 bucketsize 12 initval 0xadaaeb46 Size in memory: 520 References: 1 Number of entries: 1 Members: 192.168.178.102 timeout 14298
Überprüfung der erkannten SSH-Angriffe
- sudo cscli alerts list
+----+-------------------+---------------------------+---------+----+-----------+-----------------------------------------+ | ID | value | reason | country | as | decisions | created_at | +----+-------------------+---------------------------+---------+----+-----------+-----------------------------------------+ | 3 | Ip:10.0.10.99 | crowdsecurity/ssh-slow-bf | | | ban:1 | 2025-03-08 10:07:24.268224992 +0000 UTC | | 2 | Ip:10.0.10.99 | crowdsecurity/ssh-bf | | | ban:1 | 2025-03-08 10:07:24.268879637 +0000 UTC | +----+-------------------+---------------------------+---------+----+-----------+-----------------------------------------+
Anzeige der gebannten IP-Adressen
- sudo cscli decisions list
╭───────┬──────────┬───────────────┬───────────────────────────┬────────┬─────────┬────┬────────┬────────────────────┬──────────╮ │ ID │ Source │ Scope:Value │ Reason │ Action │ Country │ AS │ Events │ expiration │ Alert ID │ ├───────┼──────────┼───────────────┼───────────────────────────┼────────┼─────────┼────┼────────┼────────────────────┼──────────┤ │ 15002 │ crowdsec │ Ip:10.0.10.99 │ crowdsecurity/ssh-slow-bf │ ban │ │ │ 13 │ 3h58m41.750831936s │ 3 │ ╰───────┴──────────┴───────────────┴───────────────────────────┴────────┴─────────┴────┴────────┴────────────────────┴──────────╯ 1 duplicated entries skipped
Live-Log der CrowdSec-Analyse anzeigen
- sudo journalctl -u crowdsec -f
Überprüfung der installierten Parser, Szenarien und Bouncer
- sudo cscli parsers list
- sudo cscli scenarios list
- sudo cscli bouncers list
Test: Anzeige der letzten SSH-Fehlversuche
- sudo journalctl -u ssh -g "Failed password" --no-pager | tail -n 20