Crowdsec Hacker-Modus aktiviert: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
| Zeile 66: | Zeile 66: | ||
- Browser öffnen | - Browser öffnen | ||
- STRG + SHIFT + R drücken (Force Reload) | - STRG + SHIFT + R drücken (Force Reload) | ||
| − | =Auf der | + | =Auf der Controlplane Tests und Kontrollen= |
| + | == cscli alerts list == | ||
| + | Zeigt alle von CrowdSec erkannten Angriffsversuche. | ||
| + | Für jeden Alert werden IP-Adresse, erkannte Szenarien und getroffene Entscheidungen angezeigt. | ||
*cscli alerts list | *cscli alerts list | ||
<pre> | <pre> | ||
Version vom 7. April 2025, 11:13 Uhr
Angriffssimulation im Labor
Vorbereitung: Logbeobachtung aktivieren
- tail -f /var/log/crowdsec.log
Verbindung zum Angreifer herstellen
- ssh attacker
Notwendige Werkzeuge installieren (auf attacker)
- apt install -y nikto hydra
SSH-Angriff testen
Brute-Force-Angriff starten (auf attacker)
- hydra -l admin -x 1:1:a controlplane ssh
Logausgabe beobachten
Im ursprünglichen Terminal:
- tail -f /var/log/crowdsec.log
Aktive Entscheidungen anzeigen
- cscli decisions list
Vorbereitung für nächsten Test: Entscheidungen löschen
SSH-Entscheidungen zurücksetzen
- cscli decisions delete --scenario crowdsecurity/ssh-bf
- cscli decisions delete --scenario crowdsecurity/ssh-slow-bf
- tail -f /var/log/crowdsec.log
Web-Angriff mit nikto
NGINX-Access-Log zur Analyse einbinden
Die Datei /var/log/nginx/access.log muss in der Acquisition-Konfiguration aufgenommen werden, damit HTTP-Angriffe erkannt werden können.
acquis.yaml erweitern
- echo "
filename: /var/log/nginx/access.log labels: type: nginx " >> /etc/crowdsec/acquis.yaml
HTTP-Szenarien und Parser installieren
- cscli collections install crowdsecurity/nginx
CrowdSec neu starten
- systemctl restart crowdsec
Kontrolle: HTTP-Szenarien geladen
- cscli scenarios list | grep http
Erwartete Einträge: - crowdsecurity/http-probing - crowdsecurity/http-crawl-non-browser - crowdsecurity/generic-bad-user-agent
Nikto-Scan starten (auf attacker)
- nikto -h http://controlplane
Ergebnis prüfen
- apt install w3m
Im Browser auf attacker:
Hinweis: NGINX zeigt noch Standardseite
Durch die Verwendung des Stream-Modus im Bouncer wird die neue Entscheidung nur alle 10 Sekunden aktualisiert. Um die blockierte Seite zu sehen: - Browser öffnen - STRG + SHIFT + R drücken (Force Reload)
Auf der Controlplane Tests und Kontrollen
cscli alerts list
Zeigt alle von CrowdSec erkannten Angriffsversuche. Für jeden Alert werden IP-Adresse, erkannte Szenarien und getroffene Entscheidungen angezeigt.
- cscli alerts list
╭────┬───────────────────┬──────────────────────────────────────────────────────────────┬─────────┬────┬───────────┬─────────────────────────────────────────╮ │ ID │ value │ reason │ country │ as │ decisions │ created_at │ ├────┼───────────────────┼──────────────────────────────────────────────────────────────┼─────────┼────┼───────────┼─────────────────────────────────────────┤ │ 19 │ Ip:192.168.178.90 │ LePresidente/http-generic-403-bf │ │ │ captcha:1 │ 2025-04-07 10:49:52.793426307 +0000 UTC │ │ 18 │ Ip:192.168.178.90 │ crowdsecurity/http-cve-2021-41773 │ │ │ captcha:1 │ 2025-04-07 10:49:52.553615326 +0000 UTC │ │ 17 │ Ip:192.168.178.90 │ crowdsecurity/http-path-traversal-probing │ │ │ captcha:1 │ 2025-04-07 10:49:52.065041564 +0000 UTC │ │ 16 │ Ip:192.168.178.90 │ crowdsecurity/http-admin-interface-probing │ │ │ captcha:1 │ 2025-04-07 10:49:51.726351563 +0000 UTC │ │ 15 │ Ip:192.168.178.90 │ crowdsecurity/http-crawl-non_statics │ │ │ captcha:1 │ 2025-04-07 10:49:50.706075649 +0000 UTC │ │ 14 │ Ip:192.168.178.90 │ crowdsecurity/http-bad-user-agent │ │ │ captcha:1 │ 2025-04-07 10:49:50.706071295 +0000 UTC │ │ 13 │ Ip:192.168.178.90 │ crowdsecurity/http-xss-probbing │ │ │ captcha:1 │ 2025-04-07 10:47:26.783425774 +0000 UTC │ │ 12 │ Ip:192.168.178.90 │ crowdsecurity/http-cve-2021-41773 │ │ │ captcha:1 │ 2025-04-07 10:47:26.228992152 +0000 UTC │ │ 11 │ Ip:192.168.178.90 │ crowdsecurity/http-path-traversal-probing │ │ │ captcha:1 │ 2025-04-07 10:47:24.964628213 +0000 UTC │ │ 10 │ Ip:192.168.178.90 │ crowdsecurity/http-admin-interface-probing │ │ │ captcha:1 │ 2025-04-07 10:47:24.135101291 +0000 UTC │ │ 9 │ Ip:192.168.178.90 │ crowdsecurity/http-crawl-non_statics │ │ │ captcha:1 │ 2025-04-07 10:47:22.359760401 +0000 UTC │ │ 8 │ Ip:192.168.178.90 │ crowdsecurity/http-sensitive-files │ │ │ captcha:1 │ 2025-04-07 10:47:22.545143901 +0000 UTC │ │ 7 │ Ip:192.168.178.90 │ crowdsecurity/http-probing │ │ │ captcha:1 │ 2025-04-07 10:47:22.545076598 +0000 UTC │ │ 6 │ Ip:192.168.178.90 │ crowdsecurity/http-bad-user-agent │ │ │ captcha:1 │ 2025-04-07 10:47:22.359766995 +0000 UTC │ │ 4 │ Ip:192.168.178.90 │ crowdsecurity/ssh-slow-bf │ │ │ ban:1 │ 2025-04-07 10:10:36.680739028 +0000 UTC │ │ 3 │ Ip:192.168.178.90 │ crowdsecurity/ssh-bf │ │ │ ban:1 │ 2025-04-07 10:10:36.680724079 +0000 UTC │ │ 2 │ Ip:1.2.3.4 │ manual 'ban' from │ │ │ ban:1 │ 2025-04-07 09:33:23 +0000 UTC │ │ │ │ 'a736abd11f52406db0e02d7a3877059b33AmC8XqkH1c9aCq' │ │ │ │ │ ╰────┴───────────────────┴──────────────────────────────────────────────────────────────┴─────────┴────┴───────────┴─────────────────────────────────────────╯
- cscli decisions list
╭───────┬──────────┬───────────────────┬──────────────────────────────────┬─────────┬─────────┬────┬────────┬────────────┬──────────╮ │ ID │ Source │ Scope:Value │ Reason │ Action │ Country │ AS │ Events │ expiration │ Alert ID │ ├───────┼──────────┼───────────────────┼──────────────────────────────────┼─────────┼─────────┼────┼────────┼────────────┼──────────┤ │ 74578 │ crowdsec │ Ip:192.168.178.90 │ LePresidente/http-generic-403-bf │ captcha │ │ │ 6 │ 3h43m39s │ 19 │ ╰───────┴──────────┴───────────────────┴──────────────────────────────────┴─────────┴─────────┴────┴────────┴────────────┴──────────╯ 13 duplicated entries skipped
- cscli parsers list
────────────────────────────────────────────────────────────────────────────────────────────────────────────── PARSERS ────────────────────────────────────────────────────────────────────────────────────────────────────────────── Name 📦 Status Version Local Path ────────────────────────────────────────────────────────────────────────────────────────────────────────────── crowdsecurity/dateparse-enrich ✔️ enabled 0.2 /etc/crowdsec/parsers/s02-enrich/dateparse-enrich.yaml crowdsecurity/geoip-enrich ✔️ enabled 0.5 /etc/crowdsec/parsers/s02-enrich/geoip-enrich.yaml crowdsecurity/http-logs ✔️ enabled 1.3 /etc/crowdsec/parsers/s02-enrich/http-logs.yaml crowdsecurity/iptables-logs ✔️ enabled 0.5 /etc/crowdsec/parsers/s01-parse/iptables-logs.yaml crowdsecurity/nginx-logs ✔️ enabled 1.7 /etc/crowdsec/parsers/s01-parse/nginx-logs.yaml crowdsecurity/sshd-logs ✔️ enabled 2.9 /etc/crowdsec/parsers/s01-parse/sshd-logs.yaml crowdsecurity/syslog-logs ✔️ enabled 0.8 /etc/crowdsec/parsers/s00-raw/syslog-logs.yaml ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
- cscli metrics
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ Acquisition Metrics │ ├────────────────────────────────┬────────────┬──────────────┬────────────────┬────────────────────────┬───────────────────┤ │ Source │ Lines read │ Lines parsed │ Lines unparsed │ Lines poured to bucket │ Lines whitelisted │ ├────────────────────────────────┼────────────┼──────────────┼────────────────┼────────────────────────┼───────────────────┤ │ file:/var/log/nginx/access.log │ 7.54k │ 7.54k │ - │ 19.54k │ - │ ╰────────────────────────────────┴────────────┴──────────────┴────────────────┴────────────────────────┴───────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────╮ │ Local API Alerts │ ├──────────────────────────────────────────────────────────────────────┬───────┤ │ Reason │ Count │ ├──────────────────────────────────────────────────────────────────────┼───────┤ │ crowdsecurity/http-crawl-non_statics │ 2 │ │ crowdsecurity/ssh-slow-bf │ 1 │ │ crowdsecurity/http-admin-interface-probing │ 2 │ │ crowdsecurity/http-cve-2021-41773 │ 2 │ │ crowdsecurity/http-path-traversal-probing │ 2 │ │ crowdsecurity/http-probing │ 1 │ │ crowdsecurity/http-sensitive-files │ 1 │ │ crowdsecurity/http-xss-probbing │ 1 │ │ crowdsecurity/ssh-bf │ 1 │ │ manual 'ban' from 'a736abd11f52406db0e02d7a3877059b33AmC8XqkH1c9aCq' │ 1 │ │ LePresidente/http-generic-403-bf │ 1 │ │ crowdsecurity/http-bad-user-agent │ 2 │ ╰──────────────────────────────────────────────────────────────────────┴───────╯ ╭─────────────────────────────────────────────────────────────────────╮ │ Bouncer Metrics (crowdsec-nginx-bouncer-1744017363) since 2025-04-0 │ │ 7 10:26:37 +0000 UTC │ ├────────────────────────────┬──────────────────┬─────────┬───────────┤ │ Origin │ active_decisions │ dropped │ processed │ │ │ IPs │ request │ request │ ├────────────────────────────┼──────────────────┼─────────┼───────────┤ │ CAPI (community blocklist) │ 51.54k │ - │ - │ │ crowdsec (security engine) │ 1 │ 5.77k │ - │ ├────────────────────────────┼──────────────────┼─────────┼───────────┤ │ Total │ 51.54k │ 5.77k │ 51.11k │ ╰────────────────────────────┴──────────────────┴─────────┴───────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────╮ │ Bouncer Metrics (cs-firewall-bouncer-1744017348) since 2025-04-07 09:30:55 +0000 UTC │ ├────────────────────────────┬──────────────────┬───────────────────┬───────────────────────┤ │ Origin │ active_decisions │ dropped │ processed │ │ │ IPs │ bytes │ packets │ bytes │ packets │ ├────────────────────────────┼──────────────────┼─────────┼─────────┼───────────┼───────────┤ │ CAPI (community blocklist) │ 51.54k │ 0 │ 0 │ - │ - │ │ crowdsec (security engine) │ 0 │ 420 │ 7 │ - │ - │ │ cscli (manual decisions) │ 0 │ 0 │ 0 │ - │ - │ ├────────────────────────────┼──────────────────┼─────────┼─────────┼───────────┼───────────┤ │ Total │ 51.54k │ 420 │ 7 │ 34.44M │ 75.39k │ ╰────────────────────────────┴──────────────────┴─────────┴─────────┴───────────┴───────────╯ ╭─────────────────────────────────────────────────────────────────────────╮ │ Local API Decisions │ ├────────────────────────────────────────────┬──────────┬─────────┬───────┤ │ Reason │ Origin │ Action │ Count │ ├────────────────────────────────────────────┼──────────┼─────────┼───────┤ │ http:dos │ CAPI │ ban │ 4 │ │ LePresidente/http-generic-403-bf │ crowdsec │ captcha │ 1 │ │ crowdsecurity/http-admin-interface-probing │ crowdsec │ captcha │ 2 │ │ crowdsecurity/http-crawl-non_statics │ crowdsec │ captcha │ 2 │ │ crowdsecurity/http-probing │ crowdsec │ captcha │ 1 │ │ crowdsecurity/http-sensitive-files │ crowdsec │ captcha │ 1 │ │ http:crawl │ CAPI │ ban │ 45 │ │ http:exploit │ CAPI │ ban │ 46 │ │ http:scan │ CAPI │ ban │ 27176 │ │ crowdsecurity/http-bad-user-agent │ crowdsec │ captcha │ 2 │ │ tcp:scan │ CAPI │ ban │ 494 │ │ crowdsecurity/http-cve-2021-41773 │ crowdsec │ captcha │ 2 │ │ crowdsecurity/http-path-traversal-probing │ crowdsec │ captcha │ 2 │ │ http:bruteforce │ CAPI │ ban │ 797 │ │ ssh:bruteforce │ CAPI │ ban │ 22980 │ │ crowdsecurity/http-xss-probbing │ crowdsec │ captcha │ 1 │ ╰────────────────────────────────────────────┴──────────┴─────────┴───────╯ ╭──────────────────────────────────────╮ │ Local API Metrics │ ├──────────────────────┬────────┬──────┤ │ Route │ Method │ Hits │ ├──────────────────────┼────────┼──────┤ │ /v1/alerts │ GET │ 6 │ │ /v1/alerts │ POST │ 8 │ │ /v1/decisions/stream │ GET │ 283 │ │ /v1/heartbeat │ GET │ 22 │ │ /v1/usage-metrics │ POST │ 3 │ │ /v1/watchers/login │ POST │ 7 │ ╰──────────────────────┴────────┴──────╯ ╭──────────────────────────────────────────────────────────────────────────╮ │ Local API Bouncers Metrics │ ├───────────────────────────────────┬──────────────────────┬────────┬──────┤ │ Bouncer │ Route │ Method │ Hits │ ├───────────────────────────────────┼──────────────────────┼────────┼──────┤ │ crowdsec-nginx-bouncer-1744017363 │ /v1/decisions/stream │ GET │ 145 │ │ cs-firewall-bouncer-1744017348 │ /v1/decisions/stream │ GET │ 138 │ ╰───────────────────────────────────┴──────────────────────┴────────┴──────╯ ╭──────────────────────────────────────────────────────────────────────────────────╮ │ Local API Machines Metrics │ ├──────────────────────────────────────────────────┬───────────────┬────────┬──────┤ │ Machine │ Route │ Method │ Hits │ ├──────────────────────────────────────────────────┼───────────────┼────────┼──────┤ │ a736abd11f52406db0e02d7a3877059b33AmC8XqkH1c9aCq │ /v1/alerts │ GET │ 6 │ │ a736abd11f52406db0e02d7a3877059b33AmC8XqkH1c9aCq │ /v1/alerts │ POST │ 8 │ │ a736abd11f52406db0e02d7a3877059b33AmC8XqkH1c9aCq │ /v1/heartbeat │ GET │ 22 │ ╰──────────────────────────────────────────────────┴───────────────┴────────┴──────╯ ╭─────────────────────────────────────────────────────────────╮ │ Parser Metrics │ ├────────────────────────────────┬────────┬────────┬──────────┤ │ Parsers │ Hits │ Parsed │ Unparsed │ ├────────────────────────────────┼────────┼────────┼──────────┤ │ child-crowdsecurity/http-logs │ 22.63k │ 18.65k │ 3.98k │ │ child-crowdsecurity/nginx-logs │ 7.55k │ 7.54k │ 2 │ │ crowdsecurity/dateparse-enrich │ 7.54k │ 7.54k │ - │ │ crowdsecurity/http-logs │ 7.54k │ 7.54k │ 6 │ │ crowdsecurity/nginx-logs │ 7.54k │ 7.54k │ - │ │ crowdsecurity/non-syslog │ 7.54k │ 7.54k │ - │ ╰────────────────────────────────┴────────┴────────┴──────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ Scenario Metrics │ ├────────────────────────────────────────────┬───────────────┬───────────┬──────────────┬────────┬─────────┤ │ Scenario │ Current Count │ Overflows │ Instantiated │ Poured │ Expired │ ├────────────────────────────────────────────┼───────────────┼───────────┼──────────────┼────────┼─────────┤ │ LePresidente/http-generic-403-bf │ - │ 1 │ 3 │ 11 │ 2 │ │ crowdsecurity/http-admin-interface-probing │ - │ 120 │ 124 │ 607 │ 4 │ │ crowdsecurity/http-bad-user-agent │ - │ 3.64k │ 3.81k │ 7.45k │ 173 │ │ crowdsecurity/http-crawl-non_statics │ - │ 74 │ 87 │ 3.13k │ 13 │ │ crowdsecurity/http-cve-2021-41773 │ - │ 7 │ 7 │ - │ - │ │ crowdsecurity/http-path-traversal-probing │ - │ 93 │ 95 │ 376 │ 2 │ │ crowdsecurity/http-probing │ - │ 668 │ 689 │ 7.38k │ 21 │ │ crowdsecurity/http-sensitive-files │ - │ 39 │ 39 │ 197 │ - │ │ crowdsecurity/http-wordpress-scan │ - │ - │ 1 │ 1 │ 1 │ │ crowdsecurity/http-xss-probbing │ - │ 63 │ 67 │ 391 │ 4 │ ╰────────────────────────────────────────────┴───────────────┴───────────┴──────────────┴────────┴─────────╯
