Nutzen Sie Crowdsec in KeyHelp – IT-Praxis in Oberschwaben
17 mins read

Nutzen Sie Crowdsec in KeyHelp – IT-Praxis in Oberschwaben


Zuletzt aktualisiert am 10. Dezember 2025, 11:12:13

In der Vergangenheit habe ich Artikel über verschiedene Probleme bei der Verwendung von KeyHelp geschrieben. KeyHelp ist ein kostenloses Control Panel zur Verwaltung von Servern im Bereich Web- und Mailhosting.

Einige von Ihnen haben bereits etwas zu Crowdsec zu sagen, vielleicht setzen einige von Ihnen das Tool bereits erfolgreich auf Ihrem Server ein. Es handelt sich um eine Open-Source- und partizipative Sicherheitslösung. Dies ist in der Lage, Protokolldateien zu analysieren und den Schutz vor schädlichen IPs zu gewährleisten. Hier wird ein kollaboratives Vorgehen praktiziert. Mit anderen Worten: Es werden vermeidbare Angriffsinformationen zwischen allen Benutzern des Tools ausgetauscht.

Derzeit bietet der Hersteller Crowdsec drei verschiedene Pläne für sein Produkt an. In den meisten Fällen (so wie bei mir) wird der „Free“-Plan verwendet.

Rahmenbedingungen

Dieses Mal geht es in diesem Artikel um die Integration von Crowdsec zusammen mit KeyHelp. In meinem Fall läuft KeyHelp 23.2.1 (Build 3125) auf einem Server mit Ubuntu 22.04 LTS. Dementsprechend können sich Pfade und Dateinamen auf Debian-Servern unterscheiden.

Die Installation von Crowdsec und Firewall Bouncer ist im Online-Handbuch sehr gut beschrieben. Daher werde ich nicht näher darauf eingehen.

Erstkonfiguration

Bei erfolgreicher Installation können die benötigten Sammlungen installiert werden. Da KeyHelp wichtige Produkte (z. B. Apache, MariaDB, ProFTPD, Postfix usw.) vereint, gibt es im Crowdsec Hub auch vorgefertigte Sammlungen:

Dienstname Name der Crowdsec-Sammlungen
Betriebssystem Crowdsecurity/Linux
Apache2 crowdsecurity/apache2, crowdsecurity/base-http-scenarios, crowdsecurity/http-cve
Postfix Crowdsecurity/Postfix
die Taube Massensicherheit/Taube
MariaDB crowdsecurity/mariadb
ProFTPD crowdsecurity/proftpd
SSH crowdsecurity/sshd
Crowdsecurity/Whitelist-gute-Schauspieler
BIND9 mstilkerich/bind9

Die Installation einer Sammlung muss über eine SSH-Sitzung mit dem Befehl erfolgen cscli Machen Sie es möglich. Nachfolgend finden Sie ein Beispiel für die Installation von Postfix.

cscli collections install crowdsecurity/dovecot

Eine Übersicht über installierte Sammlungen kann auch mit cscli erstellt werden:

cscli collections list

COLLECTIONS
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 Name                                   Status   Version   Local Path
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 crowdsecurity/apache2                 ✔️ enabled   0.1       /etc/crowdsec/collections/apache2.yaml
 crowdsecurity/base-http-scenarios     ✔️ enabled   0.6       /etc/crowdsec/collections/base-http-scenarios.yaml
 crowdsecurity/dovecot                 ✔️ enabled   0.1       /etc/crowdsec/collections/dovecot.yaml
 crowdsecurity/http-cve                ✔️ enabled   2.5       /etc/crowdsec/collections/http-cve.yaml
 crowdsecurity/linux                   ✔️ enabled   0.2       /etc/crowdsec/collections/linux.yaml
 crowdsecurity/mariadb                 ✔️ enabled   0.1       /etc/crowdsec/collections/mariadb.yaml
 crowdsecurity/postfix                 ✔️ enabled   0.2       /etc/crowdsec/collections/postfix.yaml
 crowdsecurity/proftpd                 ✔️ enabled   0.1       /etc/crowdsec/collections/proftpd.yaml
 crowdsecurity/sshd                    ✔️ enabled   0.2       /etc/crowdsec/collections/sshd.yaml
 crowdsecurity/whitelist-good-actors   ✔️ enabled   0.1       /etc/crowdsec/collections/whitelist-good-actors.yaml
 mstilkerich/bind9                     ✔️ enabled   0.1       /etc/crowdsec/collections/bind9.yaml

Wenn alle oben aufgeführten Sammlungen installiert sind, muss natürlich die Crowdsec-Konfiguration überprüft werden.

Erstellen Sie zunächst eine Sicherungskopie der Datei /etc/crowdsec/acquis.yaml.

cp /etc/crowdsec/acquis.yaml /etc/crowdsec/acquis.yaml.bak

Öffnen Sie die Datei in einem Editor Ihrer Wahl und ersetzen Sie den Inhalt durch diese Konfiguration:

# Apache
filenames:
  - /var/log/apache2/keyhelp/access.log
  - /var/log/apache2/keyhelp/error.log
  - /var/log/apache2/keyhelp/autoconfig.access.log
  - /var/log/apache2/keyhelp/other_vhosts_access.log
  - /var/log/apache2/keyhelp/autoconfig.error.log
  - /var/log/apache2/error.log
  - /home/users/*/logs/*/access.log
  - /home/users/*/logs/*/error.log
labels:
  type: apache2
---
# SSH
journalctl_filter:
 - _SYSTEMD_UNIT=ssh.service
labels:
  type: syslog
---
# Dovecot
journalctl_filter:
 - _SYSTEMD_UNIT=dovecot.service
labels:
  type: syslog
---
# Postfix
journalctl_filter:
  - "[email protected]"
labels:
  type: syslog
---
# BIND9
journalctl_filter:
 - _SYSTEMD_UNIT=named.service
labels:
 type: syslog
---
# ProFTPD
filenames:
  - /var/log/proftpd/proftpd.log
labels:
  type: proftpd
---
# MariaDB
filenames:
  - /var/log/mysql/error.log
labels:
  type: mysql
---

Speichern Sie Ihre Änderungen und schließen Sie die Datei erneut. Der Dienst muss neu gestartet werden, damit die Änderungen wirksam werden.

sudo systemctl reload crowdsec

Lassen Sie Crowdsec dann 2-3-4 Stunden lang auf dem Server laufen, um Informationen aus den Journal- und Protokolldateien zu sammeln. Es kommt natürlich darauf an, wie fragmentiert der Server ist.

Die Eingabe der Details kann jederzeit über den Befehl „cscli-Metrik | mehr” extrahiert werden. So können Sie beispielsweise erkennen, aus welcher Quelle die Informationen stammen.

Acquisition Metrics:
+--------------------------------------------------------------+------------+--------------+----------------+------------------------+
|                            Source                            | Lines read | Lines parsed | Lines unparsed | Lines poured to bucket |
+--------------------------------------------------------------+------------+--------------+----------------+------------------------+
| file:/home/users/ahlm/logs/mta-sts.blog.daniel.wydler.eu/ac- | 8          | 8            | -              | 10                     |
| cess.log                                                     |            |              |                |                        |
| file:/home/users/ahlm/logs/mta-sts.blog.daniel.wydler.eu/er- | 2          | 2            | -              | -                      |
| ror.log                                                      |            |              |                |                        |
| file:/home/users/ahlm/logs/mta-sts.xxxxxxx.de/access.log     | 3          | 3            | -              | 6                      |
| file:/home/users/ahlm/logs/mta-sts.xxxxxxx.de/error.log      | 1          | 1            | -              | -                      |
| file:/home/users/ahlm/logs/mta-sts.xxxxxxxx-xxxxxx.de/acces- | 14         | 14           | -              | 23                     |
| s.log                                                        |            |              |                |                        |
| file:/home/users/ahlm/logs/mta-sts.xxxxxxxx-xxxxxx.de/error- | 5          | 5            | -              | -                      |
| .log                                                         |            |              |                |                        |
| file:/home/users/ahlm/logs/mta-sts.wydler.eu/access.log      | 15         | 15           | -              | 17                     |
| file:/home/users/ahlm/logs/mta-sts.wydler.eu/error.log       | 1          | 1            | -              | -                      |
| file:/home/users/apnk/logs/www.xxxxxxx.de/access.log         | 248        | 248          | -              | 256                    |
| file:/home/users/apnk/logs/www.xxxxxxx.de/error.log          | 1          | 1            | -              | -                      |
| file:/home/users/ccvv/logs/blog.daniel.wydler.eu/access.log  | 36.54k     | 36.54k       | 2              | 5.35k                  |
| file:/home/users/ccvv/logs/blog.daniel.wydler.eu/error.log   | 1          | 1            | -              | -                      |
| file:/home/users/ccvv/logs/blog.wydler.eu/access.log         | 4.88k      | 4.88k        | -              | 2.65k                  |
| file:/home/users/ccvv/logs/blog.wydler.eu/error.log          | 1          | 1            | -              | -                      |
| file:/home/users/djth/logs/www.wydler.eu/access.log          | 409        | 409          | -              | 310                    |
| file:/home/users/djth/logs/www.wydler.eu/error.log           | 1          | 1            | -              | -                      |
| file:/home/users/epvm/logs/xxx.wydler.eu/access.log          | 316        | 316          | -              | 314                    |
| file:/home/users/idkc/logs/xxxxxxx.daniel.wydler.eu/access.- | 133        | 133          | -              | 40                     |
| log                                                          |            |              |                |                        |
| file:/home/users/kxmf/logs/xxxxxx.daniel.wydler.eu/access.l- | 767        | 767          | -              | 41                     |
| og                                                           |            |              |                |                        |
| file:/home/users/kxmf/logs/xxxxxx.xxxxxxx.de/access.log      | 15         | 15           | -              | 13                     |
| file:/home/users/vcfa/logs/ipv4.lg.daniel.wydler.eu/access.- | 3          | 3            | -              | 3                      |
| log                                                          |            |              |                |                        |
| file:/home/users/vcfa/logs/lg.daniel.wydler.eu/access.log    | 20         | 20           | -              | 13                     |
| file:/home/users/wihn/logs/yy.daniel.wydler.eu/access.log    | 64         | 64           | -              | 23                     |
| file:/home/users/xldr/logs/yyyyyyy.daniel.wydler.eu/access.- | 54         | 54           | -              | 10                     |
| log                                                          |            |              |                |                        |
| file:/home/users/zaco/logs/yyyyyyy.server03.daniel.wydler.e- | 4          | 4            | -              | 5                      |
| u/access.log                                                 |            |              |                |                        |
| file:/var/log/apache2/error.log                              | 46         | 46           | -              | -                      |
| file:/var/log/apache2/keyhelp/access.log                     | 1.08k      | 1.08k        | -              | 479                    |
| file:/var/log/apache2/keyhelp/error.log                      | 15         | 15           | -              | -                      |
| file:/var/log/apache2/keyhelp/other_vhosts_access.log        | 4.89k      | 4.89k        | -              | 3.89k                  |
| file:/var/log/proftpd/proftpd.log                            | 4          | 2            | 2              | 4                      |
| journalctl:journalctl-_SYSTEMD_UNIT=dovecot.service          | 735        | 385          | 350            | -                      |
| journalctl:[email protected]        | 4.10k      | 576          | 3.52k          | 576                    |
| journalctl:journalctl-_SYSTEMD_UNIT=ssh.service              | 2.91k      | 1.81k        | 1.10k          | 4.73k                  |
+--------------------------------------------------------------+------------+--------------+----------------+------------------------+

In diesem Fall wird beispielsweise BIND9 nicht aufgeführt. Das liegt daran, dass ich nicht den DNS-Dienst von KeyHelp verwende, sondern einen externen. Da im Journal keine Einträge erstellt werden, erscheinen diese nicht in der Gesamtliste.

Natürlich gibt es auch eine Übersicht über die jeweiligen Analysatoren und deren Statistiken:

Parser Metrics:
+----------------------------------------+---------+---------+----------+
|                Parsers                 |  Hits   | Parsed  | Unparsed |
+----------------------------------------+---------+---------+----------+
| child-child-crowdsecurity/apache2-logs | 1       | 1       | -        |
| child-crowdsecurity/apache2-logs       | 49.62k  | 49.54k  | 78       |
| child-crowdsecurity/dovecot-logs       | 1.79k   | 385     | 1.40k    |
| child-crowdsecurity/http-logs          | 148.63k | 114.25k | 34.38k   |
| child-crowdsecurity/postfix-logs       | 6.08k   | 576     | 5.50k    |
| child-crowdsecurity/sshd-logs          | 23.27k  | 1.81k   | 21.45k   |
| child-crowdsecurity/syslog-logs        | 7.74k   | 7.74k   | -        |
| child-proftpd-logs                     | 10      | 2       | 8        |
| crowdsecurity/apache2-logs             | 49.55k  | 49.54k  | 2        |
| crowdsecurity/cdn-whitelist            | 95      | 95      | -        |
| crowdsecurity/dateparse-enrich         | 52.32k  | 52.32k  | -        |
| crowdsecurity/dovecot-logs             | 735     | 385     | 350      |
| crowdsecurity/geoip-enrich             | 52.27k  | 52.27k  | -        |
| crowdsecurity/http-logs                | 49.54k  | 49.37k  | 175      |
| crowdsecurity/non-syslog               | 49.55k  | 49.55k  | -        |
| crowdsecurity/postfix-logs             | 2.33k   | 576     | 1.76k    |
| crowdsecurity/rdns                     | 95      | 95      | -        |
| crowdsecurity/seo-bots-whitelist       | 95      | 95      | -        |
| crowdsecurity/sshd-logs                | 2.91k   | 1.81k   | 1.10k    |
| crowdsecurity/syslog-logs              | 7.74k   | 7.74k   | -        |
| crowdsecurity/whitelists               | 52.32k  | 52.32k  | -        |
| proftpd-logs                           | 4       | 2       | 2        |
+----------------------------------------+---------+---------+----------+

Übersicht über lokal gesteuerte Entscheidungen von Crowdsec:

Local API Decisions:
+--------------------------------------------+----------+--------+-------+
|                   Reason                   |  Origin  | Action | Count |
+--------------------------------------------+----------+--------+-------+
| crowdsecurity/http-path-traversal-probing  | CAPI     | ban    | 85    |
| crowdsecurity/CVE-2022-35914               | CAPI     | ban    | 57    |
| crowdsecurity/http-bf-wordpress_bf         | CAPI     | ban    | 962   |
| crowdsecurity/http-open-proxy              | CAPI     | ban    | 555   |
| crowdsecurity/CVE-2022-26134               | CAPI     | ban    | 180   |
| crowdsecurity/CVE-2022-37042               | CAPI     | ban    | 22    |
| crowdsecurity/http-crawl-non_statics       | CAPI     | ban    | 552   |
| crowdsecurity/http-bad-user-agent          | CAPI     | ban    | 7402  |
| crowdsecurity/http-bad-user-agent          | crowdsec | ban    | 14    |
| crowdsecurity/jira_cve-2021-26086          | CAPI     | ban    | 24    |
| crowdsecurity/thinkphp-cve-2018-20062      | CAPI     | ban    | 79    |
| crowdsecurity/dovecot-spam                 | CAPI     | ban    | 4162  |
| crowdsecurity/http-backdoors-attempts      | CAPI     | ban    | 982   |
| crowdsecurity/ssh-bf                       | CAPI     | ban    | 13852 |
| ltsich/http-w00tw00t                       | CAPI     | ban    | 3     |
| crowdsecurity/CVE-2022-41082               | CAPI     | ban    | 997   |
| crowdsecurity/http-cve-2021-41773          | CAPI     | ban    | 29    |
| crowdsecurity/http-probing                 | CAPI     | ban    | 2444  |
| crowdsecurity/http-wordpress_user-enum     | CAPI     | ban    | 653   |
| firehol_botscout_7d                        | lists    | ban    | 3808  |
| firehol_cybercrime                         | lists    | ban    | 469   |
| crowdsecurity/CVE-2022-42889               | CAPI     | ban    | 14    |
| crowdsecurity/http-generic-bf              | CAPI     | ban    | 19    |
| crowdsecurity/f5-big-ip-cve-2020-5902      | CAPI     | ban    | 25    |
| crowdsecurity/fortinet-cve-2018-13379      | CAPI     | ban    | 84    |
| crowdsecurity/http-sensitive-files         | CAPI     | ban    | 11    |
| crowdsecurity/postfix-spam                 | crowdsec | ban    | 1     |
| crowdsecurity/postfix-spam                 | CAPI     | ban    | 4407  |
| crowdsecurity/ssh-slow-bf                  | CAPI     | ban    | 25    |
| crowdsecurity/ssh-slow-bf                  | crowdsec | ban    | 6     |
| firehol_cruzit_web_attacks                 | lists    | ban    | 13252 |
| crowdsecurity/CVE-2019-18935               | CAPI     | ban    | 55    |
| crowdsecurity/apache_log4j2_cve-2021-44228 | CAPI     | ban    | 424   |
| crowdsecurity/netgear_rce                  | CAPI     | ban    | 41    |
| crowdsecurity/proftpd-bf                   | CAPI     | ban    | 50    |
| crowdsecurity/grafana-cve-2021-43798       | CAPI     | ban    | 65    |
| crowdsecurity/mariadb-bf                   | CAPI     | ban    | 17    |
+--------------------------------------------+----------+--------+-------+

Eine Übersicht über aktive Verbote darf natürlich nicht fehlen:

 cscli decisions list
╭─────────┬──────────┬───────────────────────────────┬───────────────────────────────────┬────────┬─────────┬─────────────────────────────────────────────────────────┬────────┬─────────────────────┬──────────╮
│   ID    │  Source  │          Scope:Value          │              Reason               │ Action │ Country │                           AS                            │ Events │     expiration      │ Alert ID │
├─────────┼──────────┼───────────────────────────────┼───────────────────────────────────┼────────┼─────────┼─────────────────────────────────────────────────────────┼────────┼─────────────────────┼──────────┤
│ 5027445 │ crowdsec │ Ip:157.230.36.150             │ crowdsecurity/ssh-slow-bf         │ ban    │ SG      │ 14061 DIGITALOCEAN-ASN                                  │ 20     │ 20h11m47.844177743s │ 9556     │
│ 4995208 │ crowdsec │ Ip:45.84.138.184              │ crowdsecurity/ssh-slow-bf         │ ban    │ DE      │ 51167 Contabo GmbH                                      │ 20     │ 17h37m42.721598678s │ 9551     │
│ 4980207 │ crowdsec │ Ip:124.223.39.239             │ crowdsecurity/ssh-slow-bf         │ ban    │ CN      │ 45090 Shenzhen Tencent Computer Systems Company Limited │ 28     │ 16h56m24.471143094s │ 9549     │
│ 4980206 │ crowdsec │ Ip:178.34.151.144             │ crowdsecurity/ssh-slow-bf         │ ban    │ RU      │ 12389 Rostelecom                                        │ 27     │ 16h52m9.751517031s  │ 9548     │
│ 4980205 │ crowdsec │ Ip:43.155.129.185             │ crowdsecurity/ssh-slow-bf         │ ban    │ KR      │ 132203 Tencent Building, Kejizhongyi Avenue             │ 22     │ 16h48m55.219474518s │ 9547     │
│ 4980204 │ crowdsec │ Ip:169.47.92.197              │ crowdsecurity/ssh-slow-bf         │ ban    │ US      │ 36351 SOFTLAYER                                         │ 20     │ 16h41m37.969035856s │ 9546     │
│ 4980203 │ crowdsec │ Ip:167.94.145.57              │ crowdsecurity/http-bad-user-agent │ ban    │ US      │ 398705 CENSYS-ARIN-02                                   │ 2      │ 16h11m53.470598884s │ 9545     │
│ 4980202 │ crowdsec │ Ip:167.94.146.57              │ crowdsecurity/http-bad-user-agent │ ban    │ US      │ 398705 CENSYS-ARIN-02                                   │ 2      │ 15h49m14.543231614s │ 9544     │
│ 4980201 │ crowdsec │ Ip:64.227.146.163             │ crowdsecurity/http-bad-user-agent │ ban    │ IN      │ 14061 DIGITALOCEAN-ASN                                  │ 2      │ 15h38m20.551143417s │ 9543     │
│ 4965200 │ crowdsec │ Ip:195.191.219.132            │ crowdsecurity/http-bad-user-agent │ ban    │ GB      │ 3170 VeloxServ Communications Ltd                       │ 2      │ 14h4m1.41547488s    │ 9541     │
│ 4965199 │ crowdsec │ Ip:195.191.219.133            │ crowdsecurity/http-bad-user-agent │ ban    │ GB      │ 3170 VeloxServ Communications Ltd                       │ 2      │ 13h28m57.177967926s │ 9540     │
│ 4965198 │ crowdsec │ Ip:95.91.109.50               │ crowdsecurity/http-bad-user-agent │ ban    │ DE      │ 3209 Vodafone GmbH                                      │ 2      │ 13h16m16.672252187s │ 9539     │
│ 4902961 │ crowdsec │ Ip:157.90.209.81              │ crowdsecurity/http-bad-user-agent │ ban    │ DE      │ 24940 Hetzner Online GmbH                               │ 2      │ 8h40m25.911768882s  │ 9532     │
│ 4902960 │ crowdsec │ Ip:71.6.167.142               │ crowdsecurity/postfix-spam        │ ban    │ US      │ 10439 CARINET                                           │ 6      │ 8h1m47.678250094s   │ 9531     │
│ 4870842 │ crowdsec │ Ip:42.236.17.245              │ crowdsecurity/http-bad-user-agent │ ban    │ CN      │ 4837 CHINA UNICOM China169 Backbone                     │ 2      │ 5h36m22.112898982s  │ 9526     │
│ 4855841 │ crowdsec │ Ip:167.248.133.34             │ crowdsecurity/http-bad-user-agent │ ban    │ US      │ 398722 CENSYS-ARIN-03                                   │ 2      │ 3h48m7.771592182s   │ 9524     │
│ 4855840 │ crowdsec │ Ip:2602:80d:1000:b0cc:e:2:5:3 │ crowdsecurity/http-bad-user-agent │ ban    │ US      │ 398722 CENSYS-ARIN-03                                   │ 2      │ 3h48m1.397738097s   │ 9523     │
│ 4840839 │ crowdsec │ Ip:2620:96:e000:b0cc:e:2:1:7  │ crowdsecurity/http-bad-user-agent │ ban    │ US      │ 398324 CENSYS-ARIN-01                                   │ 2      │ 2h16m55.860071985s  │ 9521     │
│ 4808721 │ crowdsec │ Ip:167.114.159.183            │ crowdsecurity/http-bad-user-agent │ ban    │ CA      │ 16276 OVH SAS                                           │ 2      │ 45m3.605748551s     │ 9516     │
│ 4808720 │ crowdsec │ Ip:167.248.133.36             │ crowdsecurity/http-bad-user-agent │ ban    │ US      │ 398722 CENSYS-ARIN-03                                   │ 2      │ 30m9.525910948s     │ 9515     │
│ 4808719 │ crowdsec │ Ip:157.90.91.229              │ crowdsecurity/http-bad-user-agent │ ban    │ DE      │ 24940 Hetzner Online GmbH                               │ 2      │ 23m36.841475868s    │ 9514     │
╰─────────┴──────────┴───────────────────────────────┴───────────────────────────────────┴────────┴─────────┴─────────────────────────────────────────────────────────┴────────┴─────────────────────┴──────────╯

Um die vollständige Tabelle anzuzeigen, klicken Sie oben rechts auf die Option „Code in einem neuen Fenster öffnen“.

Löschen Sie ein Verbot

Selbstverständlich kann ein umgehbarer Fake-Verbot auch jederzeit manuell aufgehoben werden. Insbesondere beim Ausprobieren neuer Kollektionen kann es vorkommen, dass Ihre IP-Adresse eingetragen wird.

Es handelt sich um einen Befehl zum Löschen eines Eintrags cscli-Entscheidungen löschen.

Usage:

  cscli decisions delete [options] [flags]


Aliases:

  delete, remove


Examples:

cscli decisions delete -r 1.2.3.0/24
cscli decisions delete -i 1.2.3.4
cscli decisions delete --id 42
cscli decisions delete --type captcha



Flags:

  -i, --ip string         Source ip (shorthand for --scope ip --value <IP>)
  -r, --range string      Range source ip (shorthand for --scope range --value <RANGE>)
  -t, --type string       the decision type (ie. ban,captcha)
  -v, --value string      the value to match for in the specified scope
  -s, --scenario string   the scenario name (ie. crowdsecurity/ssh-bf)
      --origin string     the value to match for the specified origin (cscli,crowdsec,console,cscli-import,lists,CAPI ...)
      --id string         decision id
      --all               delete all decisions
      --contained         query decisions contained by range
  -h, --help              help for delete

Natürlich gibt es viele Möglichkeiten, das Verbot zu umgehen. Bitte beachten Sie den Abschnitt „Beispiele“. Die Änderung wird sofort wirksam.

Erstellen Sie eine benutzerdefinierte Whitelist

Ich verwende gerne eine Whitelist für meine Überwachungssysteme. Denn früher oder später werden sie als Aggressoren erkannt, denen man ausweichen, sie verbieten und so Alarm schlagen kann.

Erstellen Sie eine neue YAML-Datei und fügen Sie die IPv4- und IPv6-Adressen/Subnetze hinzu.

cat << EOF > /etc/crowdsec/parsers/s02-enrich/wydler.eu-whitelist.yaml
name: crowdsecurity/whitelists
description: "Whitelist events from ipv4 addresses"
whitelist:
  reason: "ipv4/ipv6 ip/ranges"
  ip:
    - "46.223.45.56"
  cidr:
    - "46.223.0.0/17"
    - "2a02:8070::/31"
  expression:
    - evt.Overflow.Alert.Source.IP in LookupHost("wydler.eu")

EOF

Um die neue Konfigurationsdatei lesen zu können, muss der Dienst neu geladen werden.

systemctl reload crowdsec

Überprüfen Sie, ob die neue Konfiguration angewendet wird.

cscli parsers list

PARSERS
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Name  Status Version Local Path
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
crowdsecurity/apache2-logs ✔️ enabled 1.4 /etc/crowdsec/parsers/s01-parse/apache2-logs.yaml
...
wydler.eu-whitelist.yaml  enabled,local /etc/crowdsec/parsers/s02-enrich/wydler.eu-whitelist.yaml
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Schützen Sie WordPress

Eines der beliebtesten Content-Management-Systeme (CMS) ist wohl WordPress. Daher beschreibe ich an dieser Stelle den Einsatz von CrowdSec in Verbindung mit WordPress. Grundsätzlich handelt es sich bei der Einrichtung und Konfiguration um einen zweiteiligen Prozess.

Installation der CrowdSec-Sammlung:

cscli collections install crowdsecurity/wordpress

Bouncer für WordPress installieren:

cscli bouncers add cs-wordpress-bouncer

Bei der Installation wird außerdem ein API-Schlüssel generiert und an uns gesendet. Bewahren Sie diesen Schlüssel gut auf, da er später für das WordPress-Plugin benötigt wird.

Installation des Plugins für WordPress.

Abschließender Funktionstest des Rebounds.

Geolokalisierung einrichten

Dieses Modul basiert auf der MaxMind GeoIP-Datenbank. Einige Leute kennen möglicherweise die kostenlose Version der GeoIP-Datenbank. Diese existieren noch. Um dies nutzen zu können, müssen Sie auf der Website ein kostenloses Benutzerkonto erstellen.

Nachdem der Benutzer angelegt und aktiviert wurde, kann der Lizenzschlüssel generiert werden. Nach der Anmeldung befindet sich links ein Navigationsmenü. Im Feld Konto gibt es einen Eintrag „Lizenzschlüssel verwalten“. Klicken Sie anschließend auf die Schaltfläche „Neuen Lizenzschlüssel generieren“ und folgen Sie den Anweisungen.

GeoIP auf dem Server installieren.

apt install -y geoipupdate
geoipupdate -V

Nach der Installation müssen in der Konfiguration der zuvor generierte Lizenzschlüssel und die dazugehörige Account-ID eingetragen werden. Allerdings wird zuvor eine Kopie der Originalkonfiguration erstellt. Vergessen Sie nicht, Ihre Daten in den Zeilen 2 und 3 einzugeben!

cp /etc/GeoIP.conf /etc/GeoIP.conf.bak
sed -i 's/# AccountID YOUR_ACCOUNT_ID_HERE/AccountID 123456/g' /etc/GeoIP.conf
sed -i 's/# LicenseKey YOUR_LICENSE_KEY_HERE/LicenseKey abcdef_ghijklmnopqrstuvwxzabcdefgehi_jkl/g' /etc/GeoIP.conf

Manuelles Datenbank-Update.

geoipupdate -v

geoipupdate version 4.6.0
Using config file /etc/GeoIP.conf
Using database directory /var/lib/GeoIP
Performing get filename request to 
Acquired lock file lock (/var/lib/GeoIP/.geoipupdate.lock)
Calculated MD5 sum for /var/lib/GeoIP/GeoLite2-Country.mmdb: 32c6d31d54e21cb098c98e92872356f1
Performing update request to 
No new updates available for GeoLite2-Country
Performing get filename request to 
Acquired lock file lock (/var/lib/GeoIP/.geoipupdate.lock)
Calculated MD5 sum for /var/lib/GeoIP/GeoLite2-City.mmdb: 4ab99947c489155020040aaf82fe1038
Performing update request to 
No new updates available for GeoLite2-City

Die aktuellen Daten oder beide Dateien werden standardmäßig unter „/var/lib/GeoIP“ gespeichert.

ls -lisa /var/lib/GeoIP
total 74320
257122     4 drwxr-xr-x  2 root root     4096 Dec 25 12:14 ./
129257     4 drwxr-xr-x 38 root root     4096 Dec 25 12:20 ../
257109     0 -rw-------  1 root root        0 Dec 25 12:14 .geoipupdate.lock
257123 68140 -rw-r--r--  1 root root 69773675 Dec 25 12:14 GeoLite2-City.mmdb
257111  6172 -rw-r--r--  1 root root  6320117 Dec 25 12:14 GeoLite2-Country.mmdb

Automatisches Update mit Cron.

cat << EOF >> /etc/cron.daily/geoip-update-db
#!/bin/sh

/usr/bin/geoipupdate -v
EOF

chmod 755 /etc/cron.daily/geoip-update-db

Mithilfe von KeyHelp wird die Funktion „openbase.dir“ automatisch für jedes Benutzerkonto aktiviert und konfiguriert. Daher muss dem Parameter im betroffenen Benutzer der Pfad „/var/lib/GeoIP“ hinzugefügt werden.

Die GeoIP-Funktion kann dann im CrowdSec-Plugin von WordPress konfiguriert werden.

Abschließend darf natürlich auch die Funktionsprüfung nicht fehlen.

der Abschluss

Ich verwende Crowdsec nun seit über 3 Monaten auf meinen KeyHelp-Servern. Ich muss sagen, bisher handelt es sich noch nicht einmal um einen Fehlalarm. Vor allem bei Postfix hatte ich Angst, dass ein oder zwei gängige E-Mail-Server blockiert würden. Gott sei Dank war das bisher nicht so. Im Gegenteil, es ist überraschend, wie viele Hintergrundgeräusche Crowdsec definitiv ausblendet.

Viel Spaß beim Ausprobieren. 🙂



gadgets les plus récents 2024

Agen Togel Terpercaya

Bandar Togel

Sabung Ayam Online

Berita Terkini

Artikel Terbaru

Berita Terbaru

Penerbangan

Berita Politik

Berita Politik

Software

Software Download

Download Aplikasi

Berita Terkini

News

Jasa PBN

Jasa Artikel

Leave a Reply

Your email address will not be published. Required fields are marked *