Crowdsec SSH Bruteforce Beispiel: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
Zeile 4: Zeile 4:
 
*'''sudo cscli collections install crowdsecurity/sshd'''
 
*'''sudo cscli collections install crowdsecurity/sshd'''
 
*'''sudo systemctl reload crowdsec'''
 
*'''sudo systemctl reload crowdsec'''
 
+
==Installation des nftables Bouncers==
 
+
;Wenn noch nicht geschehen
 +
*apt install crowdsec-firewall-bouncer-nftables
 
== Neustart des Bouncers ==
 
== Neustart des Bouncers ==
 
*'''sudo systemctl restart crowdsec-firewall-bouncer'''
 
*'''sudo systemctl restart crowdsec-firewall-bouncer'''

Version vom 13. April 2025, 11:33 Uhr

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

Bevor wir einen Angriff simulieren, stellen wir sicher, dass CrowdSec überhaupt SSH-Angriffe erkennt.

  • sudo cscli scenarios list | grep ssh

Auf dem Attacker starten wir nun einen Angriff

Passwortliste besorgen
Hydra installieren
  • apt install hydra -y
Attacke

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