GNU/Linux >> LINUX-Kenntnisse >  >> Cent OS

So sichern Sie den CentOS 7-Server mit ModSecurity

ModSecurity ist eine Open-Source-Firewall für Webanwendungen, die es den Verteidigern von Webanwendungen ermöglicht, Einblick in den HTTP-Datenverkehr zu erhalten, und leistungsstarke Regelsätze zur Verbesserung der Sicherheit und des Schutzes bietet. Es bietet ein vollständiges Paket mit Echtzeit-Webüberwachung, Protokollierung und Zugriffskontrolle. Die Regelsätze können gemäß den Benutzereinstellungen angepasst und verwaltet werden. Die Freiheit zu wählen, was zu tun ist, ist ein wesentlicher Vorteil von ModSecurity und trägt wirklich zum Kontext einer Open Source bei. Mit vollem Zugriff auf den Quellcode haben wir die Möglichkeit, das Tool an unsere Bedürfnisse anzupassen und zu erweitern.

In diesem Artikel erkläre ich, wie man ModSecurity auf einem CentOS 7-Server installiert und konfiguriert. Lassen Sie uns die Installationsschritte durchgehen.

Zunächst möchte ich die Servereinstellungen überprüfen, hauptsächlich die aktuelle Apache-Version und die installierten Module.

[root@server1 ~]# httpd -V
Server version: Apache/2.4.6 (CentOS)
Server built: Nov 19 2015 21:43:13
Server's Module Magic Number: 20120211:24
Server loaded: APR 1.4.8, APR-UTIL 1.5.2
Compiled using: APR 1.4.8, APR-UTIL 1.5.2
Architecture: 64-bit
Server MPM: prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT="/etc/httpd"
-D SUEXEC_BIN="/usr/sbin/suexec"
-D DEFAULT_PIDLOG="/run/httpd/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"

Sie können diesen Befehl verwenden, um die mit Apache aktivierten dynamisch kompilierten Module zu identifizieren.

[root@server1 ~]# httpd -M
Loaded Modules:
core_module (static)
so_module (static)
http_module (static)
access_compat_module (shared)
actions_module (shared)
alias_module (shared)
allowmethods_module (shared)
auth_basic_module (shared)
auth_digest_module (shared)
authn_anon_module (shared)
authn_core_module (shared)
authn_dbd_module (shared)
authn_dbm_module (shared)
authn_file_module (shared)
authn_socache_module (shared)
authz_core_module (shared)
authz_dbd_module (shared)
authz_dbm_module (shared)
authz_groupfile_module (shared)
authz_host_module (shared)
authz_owner_module (shared)
authz_user_module (shared)
autoindex_module (shared)
cache_module (shared)
cache_disk_module (shared)
data_module (shared)
dbd_module (shared)
deflate_module (shared)
dir_module (shared)
dumpio_module (shared)
echo_module (shared)
env_module (shared)
expires_module (shared)
ext_filter_module (shared)
filter_module (shared)
headers_module (shared)
include_module (shared)
info_module (shared)
log_config_module (shared)
logio_module (shared)
mime_magic_module (shared)
mime_module (shared)
negotiation_module (shared)
remoteip_module (shared)
reqtimeout_module (shared)
rewrite_module (shared)
setenvif_module (shared)
slotmem_plain_module (shared)
slotmem_shm_module (shared)
socache_dbm_module (shared)
socache_memcache_module (shared)
socache_shmcb_module (shared)
status_module (shared)
substitute_module (shared)
suexec_module (shared)
unique_id_module (shared)
unixd_module (shared)
userdir_module (shared)
version_module (shared)
vhost_alias_module (shared)
dav_module (shared)
dav_fs_module (shared)
dav_lock_module (shared)
lua_module (shared)
mpm_prefork_module (shared)
proxy_module (shared)
lbmethod_bybusyness_module (shared)
lbmethod_byrequests_module (shared)
lbmethod_bytraffic_module (shared)
lbmethod_heartbeat_module (shared)
proxy_ajp_module (shared)
proxy_balancer_module (shared)
proxy_connect_module (shared)
proxy_express_module (shared)
proxy_fcgi_module (shared)
proxy_fdpass_module (shared)
proxy_ftp_module (shared)
proxy_http_module (shared)
proxy_scgi_module (shared)
proxy_wstunnel_module (shared)
systemd_module (shared)
cgi_module (shared)
php5_module (shared)

Installation

Nachdem Sie das Apache-Setup überprüft haben, können Sie das ModSecurity-Paket aus dem CentOS-Basisrepo installieren.

[root@server1 yum.repos.d]# yum install mod_security -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.metrocast.net
* extras: mirror.metrocast.net
* updates: mirror.metrocast.net
Resolving Dependencies
--> Running transaction check
---> Package mod_security.x86_64 0:2.7.3-5.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================================
Installing:
mod_security x86_64 2.7.3-5.el7 base 177 k

Transaction Summary
===============================================================================================================================================
Install 1 Package

Dadurch wird mod_security auf Ihrem Server installiert. Jetzt müssen wir es auf unserem Server konfigurieren.

Überprüfen und bestätigen Sie die Integration des Moduls in Apache

Suchen Sie nach der Konfigurationsdatei, die mit dem Standardregelsatz generiert wurde. Die Konfigurationsdatei befindet sich im Apache-Ordner für benutzerdefinierte Module "/etc/httpd/conf.d/".

[root@server1 conf.d]# pwd
/etc/httpd/conf.d
[root@server1 conf.d]# ll mod_security.conf
-rw-r--r-- 1 root root 2139 Jun 10 2014 mod_security.conf

[root@server1 conf.d]# httpd -M | grep security
security2_module (shared)

Starten Sie nun den Apache neu und überprüfen Sie, ob das Mod_security-Modul beim Neustart in den Apache-Protokollen geladen wird.

[root@server1 conf.d]# tail -f /etc/httpd/logs/error_log
Mon Apr 18 06:24:35.170359 2016] [suexec:notice] [pid 2819] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Apr 18 06:24:35.170461 2016] [:notice] [pid 2819] ModSecurity for Apache/2.7.3 (http://www.modsecurity.org/) configured.
[Mon Apr 18 06:24:35.170469 2016] [:notice] [pid 2819] ModSecurity: APR compiled version="1.4.8"; loaded version="1.4.8"
[Mon Apr 18 06:24:35.170476 2016] [:notice] [pid 2819] ModSecurity: PCRE compiled version="8.32 "; loaded version="8.32 2012-11-30"
[Mon Apr 18 06:24:35.170483 2016] [:notice] [pid 2819] ModSecurity: LUA compiled version="Lua 5.1"
[Mon Apr 18 06:24:35.170488 2016] [:notice] [pid 2819] ModSecurity: LIBXML compiled version="2.9.1"
[Mon Apr 18 06:24:35.451568 2016] [auth_digest:notice] [pid 2819] AH01757: generating secret for digest authentication ...
[Mon Apr 18 06:24:35.452305 2016] [lbmethod_heartbeat:notice] [pid 2819] AH02282: No slotmem from mod_heartmonitor
[Mon Apr 18 06:24:35.501101 2016] [mpm_prefork:notice] [pid 2819] AH00163: Apache/2.4.6 (CentOS) PHP/5.4.16 configured -- resuming normal operations

Aus den Protokollen können Sie die geladene ModSecurity-Version und andere Details erkennen.

Identifizierung der Natur

Wir müssen die ModSecurity-Konfigurationsdatei durchgehen, um den Include-Pfad für die benutzerdefinierten Regeln zu identifizieren, die wir zur Anpassung hinzufügen können, und auch den Protokolldateipfad für weitere Analysen identifizieren.

Wir können die benutzerdefinierten Regeln innerhalb dieses Pfads gemäß der Konfiguration hinzufügen.

# ModSecurity Core Rules Set configuration
IncludeOptional modsecurity.d/*.conf
IncludeOptional modsecurity.d/activated_rules/*.conf

[root@server1 modsecurity.d]# pwd
/etc/httpd/modsecurity.d
[root@server1 modsecurity.d]# ll
total 4
drwxr-xr-x 2 root root 4096 Jun 10 2014 activated_rules

Und wir können die Protokolldatei unter /var/log/httpd/modsec_audit.log einsehen

Anpassen von ModSecurity mit den Core-Regelsätzen

Wir können die benutzerdefinierten Regelsätze aus dem offiziellen Repo beziehen. Diese Regelsätze werden automatisch mit den aktivierten Regeln verknüpft und werden standardmäßig bei der Installation wirksam.

root@server1 conf.d]# yum -y install mod_security_crs
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.metrocast.net
* extras: mirror.metrocast.net
* updates: mirror.metrocast.net
Resolving Dependencies
--> Running transaction check
---> Package mod_security_crs.noarch 0:2.2.6-6.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================================
Installing:
mod_security_crs noarch 2.2.6-6.el7 base 90 k

Dies sind die allgemeinen Kernregelsätze, die aus der offiziellen Repo-Datei installiert wurden. Wir müssen bestimmte Regeln ändern, um zu verhindern, dass legitime Serveranfragen blockiert werden.

[root@server1 base_rules]# ll
total 332
-rw-r--r-- 1 root root 1980 Jun 9 2014 modsecurity_35_bad_robots.data
-rw-r--r-- 1 root root 386 Jun 9 2014 modsecurity_35_scanners.data
-rw-r--r-- 1 root root 3928 Jun 9 2014 modsecurity_40_generic_attacks.data
-rw-r--r-- 1 root root 2610 Jun 9 2014 modsecurity_41_sql_injection_attacks.data
-rw-r--r-- 1 root root 2224 Jun 9 2014 modsecurity_50_outbound.data
-rw-r--r-- 1 root root 56714 Jun 9 2014 modsecurity_50_outbound_malware.data
-rw-r--r-- 1 root root 22861 Jun 9 2014 modsecurity_crs_20_protocol_violations.conf
-rw-r--r-- 1 root root 6915 Jun 9 2014 modsecurity_crs_21_protocol_anomalies.conf
-rw-r--r-- 1 root root 3792 Jun 9 2014 modsecurity_crs_23_request_limits.conf
-rw-r--r-- 1 root root 6933 Jun 9 2014 modsecurity_crs_30_http_policy.conf
-rw-r--r-- 1 root root 5394 Jun 9 2014 modsecurity_crs_35_bad_robots.conf
-rw-r--r-- 1 root root 19157 Jun 9 2014 modsecurity_crs_40_generic_attacks.conf
-rw-r--r-- 1 root root 43961 Jun 9 2014 modsecurity_crs_41_sql_injection_attacks.conf
-rw-r--r-- 1 root root 87470 Jun 9 2014 modsecurity_crs_41_xss_attacks.conf
-rw-r--r-- 1 root root 1795 Jun 9 2014 modsecurity_crs_42_tight_security.conf
-rw-r--r-- 1 root root 3660 Jun 9 2014 modsecurity_crs_45_trojans.conf
-rw-r--r-- 1 root root 2253 Jun 9 2014 modsecurity_crs_47_common_exceptions.conf
-rw-r--r-- 1 root root 2787 Jun 9 2014 modsecurity_crs_48_local_exceptions.conf.example
-rw-r--r-- 1 root root 1835 Jun 9 2014 modsecurity_crs_49_inbound_blocking.conf
-rw-r--r-- 1 root root 22314 Jun 9 2014 modsecurity_crs_50_outbound.conf
-rw-r--r-- 1 root root 1448 Jun 9 2014 modsecurity_crs_59_outbound_blocking.conf
-rw-r--r-- 1 root root 2674 Jun 9 2014 modsecurity_crs_60_correlation.conf
[root@server1 base_rules]# pwd
/usr/lib/modsecurity.d/base_rules

Diese Regeln werden automatisch mit dem aktivierten Regelsatz verknüpft, um standardmäßig bei der Installation aktiviert zu werden.

[root@server1 activated_rules]# ls
modsecurity_35_bad_robots.data modsecurity_crs_23_request_limits.conf modsecurity_crs_47_common_exceptions.conf
modsecurity_35_scanners.data modsecurity_crs_30_http_policy.conf modsecurity_crs_48_local_exceptions.conf.example
modsecurity_40_generic_attacks.data modsecurity_crs_35_bad_robots.conf modsecurity_crs_49_inbound_blocking.conf
modsecurity_41_sql_injection_attacks.data modsecurity_crs_40_generic_attacks.conf modsecurity_crs_50_outbound.conf
modsecurity_50_outbound.data modsecurity_crs_41_sql_injection_attacks.conf modsecurity_crs_59_outbound_blocking.conf
modsecurity_50_outbound_malware.data modsecurity_crs_41_xss_attacks.conf modsecurity_crs_60_correlation.conf
modsecurity_crs_20_protocol_violations.conf modsecurity_crs_42_tight_security.conf
modsecurity_crs_21_protocol_anomalies.conf modsecurity_crs_45_trojans.conf
[root@server1 activated_rules]# pwd
/etc/httpd/modsecurity.d/activated_rules

Wir können sogar Ihre ModSecurity anpassen indem Sie den Regelsatz von OWASP CRS auswählen .

OWASP ModSecurity CRS stellt eine Reihe generischer Angriffserkennungsregeln bereit, um einen Basisschutz für die Webanwendungen sicherzustellen. Wir können es je nach unseren Sicherheitsanforderungen komplexer machen. OWASP CRS bietet ebenfalls Schutz in den folgenden Kategorien:

HTTP-Schutz
Blacklist-Lookups in Echtzeit
DDOS-Angriffe
Schutz vor häufigen Web-Angriffen
Automatisierungserkennung – Erkennung von Bots, Crawlern, Scannern und anderen schädlichen Oberflächenaktivitäten.
Erkennt das Hochladen bösartiger Dateien über das Internet mit AV-Scanning
Verfolgen sensibler Daten – Verfolgt die Verwendung von Kreditkarten und blockiert Datenlecks.
Trojaner-Schutz
Identifizierung von Anwendungsfehlern
Fehlererkennung und -ausblendung
Sie können sich auf diese Anleitung OWASP CRS-Anweisungen beziehen, um unsere eigenen Regelsätze zu konfigurieren.

So installieren Sie den OWASP CRS-Regelsatz anstelle der standardmäßigen generischen Regeln aus dem offiziellen Repo. Sie können das OWASP CRS herunterladen und die Konfigurationsdatei und die Regelsätze nach /etc/httpd/modsecurity.d/ kopieren Ordner.

Bevor Sie das OWASP Core Rule Set aktivieren, können Sie modsecurity_crs entfernen, das aus dem Repo aktiviert ist.

Wechseln Sie nun in den Ordner /usr/local/src und laden Sie die Repo-Datei von OWASP CRS download herunter.

[root@server1 src]# wget https://github.com/SpiderLabs/owasp-modsecurity-crs/zipball/master
--2016-04-18 08:28:01-- https://github.com/SpiderLabs/owasp-modsecurity-crs/zipball/master
Resolving github.com (github.com)... 192.30.252.131
Connecting to github.com (github.com)|192.30.252.131|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/SpiderLabs/owasp-modsecurity-crs/legacy.zip/master [following]
--2016-04-18 08:28:01-- https://codeload.github.com/SpiderLabs/owasp-modsecurity-crs/legacy.zip/master
Resolving codeload.github.com (codeload.github.com)... 192.30.252.161
Connecting to codeload.github.com (codeload.github.com)|192.30.252.161|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/zip]
Saving to: ‘master’

[ <=> ] 3,43,983 --.-K/s in 0.04s

2016-04-18 08:28:02 (7.68 MB/s) - ‘master’ saved [343983]

Da es sich bei der heruntergeladenen Datei um eine ZIP-Datei handelt, extrahieren Sie die Datei für den Inhalt.

[root@server1 src]# file master
master: Zip archive data, at least v1.0 to extract

root@server1 src]# unzip master

root@server1 src]# ls
master SpiderLabs-owasp-modsecurity-crs-f16e0b1

Kopieren Sie nach dem Herunterladen der Dateien die crs-Konfigurationsdatei und den Basisregelsatz an den Speicherort /etc/httpd/modsecurity.d/

[root@server1 modsecurity.d]# cp -rp /usr/local/src/SpiderLabs-owasp-modsecurity-crs-f16e0b1/modsecurity_crs_10_setup.conf.example .
[root@server1 modsecurity.d]# ls
activated_rules modsecurity_crs_10_setup.conf.example
[root@server1 modsecurity.d]# mv modsecurity_crs_10_setup.conf.example modsecurity_crs_10_setup.conf

Wechseln Sie nun in den Ordner enabled_rules und kopieren Sie die Basisregeln aus der Installation dorthin.

[root@server1 modsecurity.d]# cd activated_rules/

[root@server1 activated_rules]# cp -rp /usr/local/src/SpiderLabs-owasp-modsecurity-crs-f16e0b1/base_rules/* .
[root@server1 activated_rules]# ll
total 344
-rw-r--r-- 1 root root 1969 Apr 14 08:49 modsecurity_35_bad_robots.data
-rw-r--r-- 1 root root 386 Apr 14 08:49 modsecurity_35_scanners.data
-rw-r--r-- 1 root root 3928 Apr 14 08:49 modsecurity_40_generic_attacks.data
-rw-r--r-- 1 root root 2224 Apr 14 08:49 modsecurity_50_outbound.data
-rw-r--r-- 1 root root 56714 Apr 14 08:49 modsecurity_50_outbound_malware.data
-rw-r--r-- 1 root root 23038 Apr 14 08:49 modsecurity_crs_20_protocol_violations.conf
-rw-r--r-- 1 root root 8107 Apr 14 08:49 modsecurity_crs_21_protocol_anomalies.conf
-rw-r--r-- 1 root root 3792 Apr 14 08:49 modsecurity_crs_23_request_limits.conf
-rw-r--r-- 1 root root 6907 Apr 14 08:49 modsecurity_crs_30_http_policy.conf
-rw-r--r-- 1 root root 5410 Apr 14 08:49 modsecurity_crs_35_bad_robots.conf
-rw-r--r-- 1 root root 20881 Apr 14 08:49 modsecurity_crs_40_generic_attacks.conf
-rw-r--r-- 1 root root 44677 Apr 14 08:49 modsecurity_crs_41_sql_injection_attacks.conf
-rw-r--r-- 1 root root 99654 Apr 14 08:49 modsecurity_crs_41_xss_attacks.conf
-rw-r--r-- 1 root root 1795 Apr 14 08:49 modsecurity_crs_42_tight_security.conf
-rw-r--r-- 1 root root 3660 Apr 14 08:49 modsecurity_crs_45_trojans.conf
-rw-r--r-- 1 root root 2247 Apr 14 08:49 modsecurity_crs_47_common_exceptions.conf
-rw-r--r-- 1 root root 2787 Apr 14 08:49 modsecurity_crs_48_local_exceptions.conf.example
-rw-r--r-- 1 root root 1838 Apr 14 08:49 modsecurity_crs_49_inbound_blocking.conf
-rw-r--r-- 1 root root 22328 Apr 14 08:49 modsecurity_crs_50_outbound.conf
-rw-r--r-- 1 root root 1448 Apr 14 08:49 modsecurity_crs_59_outbound_blocking.conf
-rw-r--r-- 1 root root 2674 Apr 14 08:49 modsecurity_crs_60_correlation.conf

Sobald die Regeln kopiert sind, können Sie den Apache neu starten und seinen Status bestätigen, um sicherzustellen, dass alles richtig konfiguriert ist.

[root@server1 activated_rules]# systemctl status httpd
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled)
Active: active (running) since Mon 2016-04-18 08:35:13 UTC; 16s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 3571 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
Main PID: 3576 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
├─3576 /usr/sbin/httpd -DFOREGROUND
├─3578 /usr/sbin/httpd -DFOREGROUND
├─3579 /usr/sbin/httpd -DFOREGROUND
├─3580 /usr/sbin/httpd -DFOREGROUND
├─3581 /usr/sbin/httpd -DFOREGROUND
└─3582 /usr/sbin/httpd -DFOREGROUND

Apr 18 08:35:12 server1.centos7-test.com systemd[1]: Starting The Apache HTTP Server...
Apr 18 08:35:13 server1.centos7-test.com systemd[1]: Started The Apache HTTP Server.
[root@server1 activated_rules]# tail -f /etc/httpd/logs/error_log
[Mon Apr 18 08:35:13.237779 2016] [suexec:notice] [pid 3576] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Apr 18 08:35:13.237912 2016] [:notice] [pid 3576] ModSecurity for Apache/2.7.3 (http://www.modsecurity.org/) configured.
[Mon Apr 18 08:35:13.237921 2016] [:notice] [pid 3576] ModSecurity: APR compiled version="1.4.8"; loaded version="1.4.8"
[Mon Apr 18 08:35:13.237929 2016] [:notice] [pid 3576] ModSecurity: PCRE compiled version="8.32 "; loaded version="8.32 2012-11-30"
[Mon Apr 18 08:35:13.237936 2016] [:notice] [pid 3576] ModSecurity: LUA compiled version="Lua 5.1"
[Mon Apr 18 08:35:13.237941 2016] [:notice] [pid 3576] ModSecurity: LIBXML compiled version="2.9.1"
[Mon Apr 18 08:35:13.441258 2016] [auth_digest:notice] [pid 3576] AH01757: generating secret for digest authentication ...
[Mon Apr 18 08:35:13.442048 2016] [lbmethod_heartbeat:notice] [pid 3576] AH02282: No slotmem from mod_heartmonitor
[Mon Apr 18 08:35:13.476079 2016] [mpm_prefork:notice] [pid 3576] AH00163: Apache/2.4.6 (CentOS) configured -- resuming normal operations
[Mon Apr 18 08:35:13.476135 2016] [core:notice] [pid 3576] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'

Gewährleistung der Serversicherheit mit ModSecurity

Jetzt können wir die Funktionsweise von ModSecurity auf unserem Server testen. Versuchen Sie einfach, über den Browser auf eine beliebige Datei vom Server zuzugreifen. Ich habe gerade versucht, über den Browser auf die Datei /etc/shadow zuzugreifen, und sie hat den verbotenen Fehler gemeldet.

Überprüfen der Details auf dem Server aus den ModSecurity-Protokollen (/var/log/httpd/modsec_audit.log). Dies ist, was auf der Serverseite gemeldet wird.

--ffddb332-A--
[19/Apr/2016:05:40:50 +0000] VxXE4nawj6tDGNi3ESgy8gAAAAM 101.63.70.47 60553 45.33.76.60 80
--ffddb332-B--
GET /etc/shadow HTTP/1.1
Host: 45.33.76.60
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:43.0) Gecko/20100101 Firefox/43.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: Drupal.toolbar.collapsed=0; SESS1dba846f2abd54265ae8178776146216=cVBBus2vUq_iMWD3mvj-0rM8ca21X1D7UrcVRzsmIZ8
Connection: keep-alive

--ffddb332-F--
HTTP/1.1 403 Forbidden
Content-Length: 212
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1

--ffddb332-E--

--ffddb332-H--
Message: Access denied with code 403 (phase 2). Pattern match "^[\\d.:]+$" at REQUEST_HEADERS:Host. [file "/etc/httpd/modsecurity.d/activated_rules/modsecurity_crs_21_protocol_anomalies.conf"] [line "98"] [id "960017"] [rev "2"] [msg "Host header is a numeric IP address"] [data "45.33.76.60"] [severity "WARNING"] [ver "OWASP_CRS/2.2.9"] [maturity "9"] [accuracy "9"] [tag "OWASP_CRS/PROTOCOL_VIOLATION/IP_HOST"] [tag "WASCTC/WASC-21"] [tag "OWASP_TOP_10/A7"] [tag "PCI/6.5.10"] [tag "http://technet.microsoft.com/en-us/magazine/2005.01.hackerbasher.aspx"]
Action: Intercepted (phase 2)
Stopwatch: 1461044450304152 4953 (- - -)
Stopwatch2: 1461044450304152 4953; combined=735, p1=505, p2=135, p3=0, p4=0, p5=91, sr=158, sw=4, l=0, gc=0
Response-Body-Transformed: Dechunked
Producer: ModSecurity for Apache/2.7.3 (http://www.modsecurity.org/); OWASP_CRS/2.2.9.
Server: Apache/2.4.6 (CentOS)
Engine-Mode: "ENABLED"

--ffddb332-Z--

Dieses Protokoll gibt eindeutig die IP 101.63.70.47 an Details, die waren versuchen, eine Datei /etc/shadow herunterzuladen vom Server. Und laut den Protokollen hat das HTTP einen verbotenen Fehler vom Server gemeldet. Die Details für diese Serverantwort werden auch in den Protokollen gemeldet, da sie gemäß der ModSecurity-Regel „/etc/httpd/modsecurity.d/activated_rules/modsecurity_crs_21_protocol_anomalies.conf“ verweigert wurde. Der Server hat diese Webanfrage als Verstoß gegen die angegebene Modsecurity-Regel erkannt und diesen Fehlercode gemeldet.

Jetzt sehen Sie, wie einfach sich ModSecurity unter CentOS 7 installieren und konfigurieren lässt. ModSecurity härtet bei richtiger Konfiguration einen Apache-Webserver gegen mehrere Bedrohungen aus, darunter DDoS-Angriffe, SQL-Injections, böswillige Angriffe, und sollte bei Bereitstellungen im Internet in Betracht gezogen werden.

Ich hoffe, Sie haben es genossen, diesen Artikel zu lesen. Vielen Dank für das Lesen :) Ich würde Ihre wertvollen Vorschläge und Empfehlungen dazu empfehlen.


Cent OS
  1. So installieren Sie einen FTP-Server unter CentOS 7 mit VSFTPD

  2. Sicheres ProFTPD-Server-Setup auf CentOS 7 mit TLS

  3. So sichern Sie Nginx mit Letsencrypt unter Rocky Linux/Centos 8

  4. So installieren Sie SpamAssassin auf einem virtuellen Server mit CentOS 6

  5. So richten Sie einen Mailserver mit PostfixAdmin auf CentOS 7 ein

So richten Sie einen zentralen Sicherungsserver mit Amanda unter CentOS 7 ein

So schützen Sie E-Mail-Server vor Hacking mit VPN (CentOS/RHEL)

So installieren Sie den Mailserver mit PostfixAdmin unter CentOS 7

So sichern Sie SSH mit Fail2Ban

So sichern Sie Apache mit Let’s Encrypt unter CentOS 8

So sichern Sie Nginx mit Let’s Encrypt unter CentOS 8