Zum Hauptinhalt springen
Zurück zur Kategorie

CrowdSec Einrichtung: Community-gestützte Sicherheits-Engine

CrowdSec-Installation, Bouncer-Konfiguration, Angriffserkennung, IP-Blockierung, Dashboard, Sammlungs- und Szenario-Verwaltung.

Lesezeit: 15 Min. Monitoring
crowdsecsicherheitidsangriffserkennungfirewalldockercommunity

Inhaltsverzeichnis

CrowdSec Einrichtung: Community-gestützte Sicherheits-Engine

CrowdSec ist eine community-gestützte Open-Source-Sicherheits-Engine. Sie erkennt Angriffe durch Log-Analyse und bietet proaktiven Schutz durch von der Community geteilte Bedrohungsinformationen. Sie kann als moderne und skalierbare Alternative zu Fail2ban betrachtet werden.

Was ist CrowdSec?

Wichtige Funktionen:

  • Log-Analyse: Echtzeit-Systemlog-Analyse
  • Community-Intelligence: Globale Bedrohungsdatenbank-Freigabe
  • Bouncer-System: Blockierung auf verschiedenen Ebenen (Firewall, Nginx, Cloudflare)
  • Szenario-basiert: YAML-basierte Angriffsszenarien
  • Sammlungen: Fertige Sicherheitsregelpakete
  • Dashboard: Webbasiertes Verwaltungspanel
  • API-basiert: REST-API-Integration

Installation

Installation mit Paketmanager

hljs bash
curl -s https://install.crowdsec.net | sudo sh
sudo apt install crowdsec -y
sudo apt install crowdsec-firewall-bouncer-iptables -y
sudo systemctl status crowdsec

Docker-Installation

hljs yaml
version: '3.8'
services:
  crowdsec:
    image: crowdsecurity/crowdsec:latest
    container_name: crowdsec
    restart: unless-stopped
    ports:
      - "8080:8080"
      - "6060:6060"
    volumes:
      - crowdsec_config:/etc/crowdsec
      - crowdsec_data:/var/lib/crowdsec/data
      - /var/log:/var/log:ro
    environment:
      - COLLECTIONS=crowdsecurity/linux crowdsecurity/nginx crowdsecurity/sshd

volumes:
  crowdsec_config:
  crowdsec_data:

Grundkonfiguration

Sammlungsverwaltung

hljs bash
sudo cscli collections list
sudo cscli collections install crowdsecurity/linux
sudo cscli collections install crowdsecurity/nginx
sudo cscli collections install crowdsecurity/sshd
sudo cscli hub update
sudo cscli hub upgrade

Szenario-Verwaltung

hljs bash
sudo cscli scenarios list
sudo cscli scenarios install crowdsecurity/ssh-bf
sudo cscli scenarios install crowdsecurity/http-bad-user-agent
sudo cscli scenarios install crowdsecurity/http-probing

Bouncer-Konfiguration

Firewall Bouncer

hljs bash
sudo apt install crowdsec-firewall-bouncer-iptables -y
hljs yaml
mode: iptables
update_frequency: 10s
api_url: http://localhost:8080/
api_key: IHR_API_KEY
deny_action: DROP
deny_log: true

Nginx Bouncer

hljs bash
sudo apt install crowdsec-nginx-bouncer -y
sudo cscli bouncers add nginx-bouncer

Entscheidungsverwaltung

hljs bash
sudo cscli decisions list
sudo cscli decisions add --ip 1.2.3.4 --reason "Manuelles Sperren" --type ban --duration 24h
sudo cscli decisions add --range 1.2.3.0/24 --reason "Subnetz-Sperre" --type ban
sudo cscli decisions delete --ip 1.2.3.4
sudo cscli decisions delete --all

CrowdSec Console (Dashboard)

hljs bash
sudo cscli console enroll IHR_ENROLLMENT_KEY
sudo systemctl restart crowdsec

Dashboard: https://app.crowdsec.net

Benutzerdefiniertes Szenario

hljs yaml
type: leaky
name: custom/brute-force
description: "Benutzerdefinierte Brute-Force-Erkennung"
filter: "evt.Meta.log_type == 'ssh_failed-auth'"
groupby: evt.Meta.source_ip
capacity: 5
leakspeed: 10m
blackholeduration: 4h
labels:
  service: ssh
  type: brute_force
  remediation: true

Whitelist-Konfiguration

hljs yaml
name: custom/whitelist
description: "Vertrauenswürdige IPs"
whitelist:
  reason: "Vertrauenswürdige IP-Adressen"
  ip:
    - "192.168.1.0/24"
    - "10.0.0.0/8"

Prometheus-Metriken

hljs bash
sudo cscli metrics
curl http://localhost:6060/metrics

Aktualisierung

hljs bash
sudo apt update
sudo apt upgrade crowdsec crowdsec-firewall-bouncer-iptables
sudo cscli hub update
sudo cscli hub upgrade

Logs und Debug

hljs bash
sudo tail -f /var/log/crowdsec.log
sudo tail -f /var/log/crowdsec-firewall-bouncer.log
sudo cscli explain --file /var/log/auth.log --type syslog

Durch die Installation von CrowdSec auf Ihren REXE-Servern profitieren Sie von community-gestütztem Sicherheitsschutz. Im Gegensatz zu Fail2ban kann CrowdSec dank globaler Bedrohungsintelligenz IPs proaktiv blockieren, die Ihren Server noch nicht angegriffen haben.