Назад | Перейти на главную страницу

Защита от случайных запросов GET

Меня атакуют, и мой сайт постоянно получает тысячи таких запросов

GET /?HMPCL=INQUVOBHZ HTTP/1.1

У меня установлен mod-security, waf comodo и csf. Даже mod-security блокирует их и добавляет csf. Deny ips все еще может получить доступ к веб-серверу, и я понятия не имею, как они заблокированы. Что мне делать, чтобы этого не произошло. Я думаю это какой-то НАВОДНЕНИЕ

Я попытался перезагрузить сервер, очистить csf, перезапустить csf, lfd, iptables, но безуспешно.

Я в отчаянии, мой веб-сервер постоянно дает сбой.

[root@luka ~]# iptables -S | grep 62.116.184.40
-A DENYIN -s 62.116.184.40/32 ! -i lo -j DROP
-A DENYOUT -d 62.116.184.40/32 ! -o lo -j LOGDROPOUT

[root@luka ~]# iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination
ACCEPT     tcp  --  ns3-coloc.hetzner.de  anywhere             tcp dpt:domain
ACCEPT     udp  --  ns3-coloc.hetzner.de  anywhere             udp dpt:domain
ACCEPT     tcp  --  ns3-coloc.hetzner.de  anywhere             tcp spt:domain
ACCEPT     udp  --  ns3-coloc.hetzner.de  anywhere             udp spt:domain
ACCEPT     tcp  --  ns2-coloc.hetzner.de  anywhere             tcp dpt:domain
ACCEPT     udp  --  ns2-coloc.hetzner.de  anywhere             udp dpt:domain
ACCEPT     tcp  --  ns2-coloc.hetzner.de  anywhere             tcp spt:domain
ACCEPT     udp  --  ns2-coloc.hetzner.de  anywhere             udp spt:domain
LOCALINPUT  all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
INVALID    tcp  --  anywhere             anywhere
           tcp  --  anywhere             anywhere             tcp dpt:http state NEW recent: SET name: 80 side: source
PORTFLOOD  tcp  --  anywhere             anywhere             tcp dpt:http state NEW recent: UPDATE seconds: 5 hit_count: 20 name: 80 side: source
ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:ftp-data
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:ftp
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:6216
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:ssh
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:smtp
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:domain
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:http
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:pop3
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:imap
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:https
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:urd
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:submission
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:imaps
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:pop3s
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:tsrmagt
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:tpcsrvr
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:idware-router
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:autodesk-nlm
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:infowave
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:radsec
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:gnunet
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:eli
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:nbx-ser
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:nbx-dir
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:24565
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:24566
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpts:60000:65000
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:irdmi
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:vcom-tunnel
ACCEPT     udp  --  anywhere             anywhere             state NEW udp dpt:ftp-data
ACCEPT     udp  --  anywhere             anywhere             state NEW udp dpt:ftp
ACCEPT     udp  --  anywhere             anywhere             state NEW udp dpt:domain
ACCEPT     icmp --  anywhere             anywhere             icmp echo-request limit: avg 1/sec burst 5
ACCEPT     icmp --  anywhere             anywhere             icmp echo-reply limit: avg 1/sec burst 5
ACCEPT     icmp --  anywhere             anywhere             icmp time-exceeded
ACCEPT     icmp --  anywhere             anywhere             icmp destination-unreachable
LOGDROPIN  all  --  anywhere             anywhere

Chain FORWARD (policy DROP)
target     prot opt source               destination

Chain OUTPUT (policy DROP)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             ns3-coloc.hetzner.de  tcp dpt:domain
ACCEPT     udp  --  anywhere             ns3-coloc.hetzner.de  udp dpt:domain
ACCEPT     tcp  --  anywhere             ns3-coloc.hetzner.de  tcp spt:domain
ACCEPT     udp  --  anywhere             ns3-coloc.hetzner.de  udp spt:domain
ACCEPT     tcp  --  anywhere             ns2-coloc.hetzner.de  tcp dpt:domain
ACCEPT     udp  --  anywhere             ns2-coloc.hetzner.de  udp dpt:domain
ACCEPT     tcp  --  anywhere             ns2-coloc.hetzner.de  tcp spt:domain
ACCEPT     udp  --  anywhere             ns2-coloc.hetzner.de  udp spt:domain
LOCALOUTPUT  all  --  anywhere             anywhere
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:domain
ACCEPT     udp  --  anywhere             anywhere             udp dpt:domain
ACCEPT     tcp  --  anywhere             anywhere             tcp spt:domain
ACCEPT     udp  --  anywhere             anywhere             udp spt:domain
ACCEPT     all  --  anywhere             anywhere
INVALID    tcp  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:ftp-data
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:ftp
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:6216
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:ssh
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:smtp
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:time
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:nicname
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:domain
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:http
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:pop3
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:auth
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:https
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:submission
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:rsync
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:imaps
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:pop3s
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:gnunet
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:eli
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:sep
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:sms-chat
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:24565
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:24566
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpts:60000:65000
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:irdmi
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:vcom-tunnel
ACCEPT     udp  --  anywhere             anywhere             state NEW udp dpt:ftp-data
ACCEPT     udp  --  anywhere             anywhere             state NEW udp dpt:ftp
ACCEPT     udp  --  anywhere             anywhere             state NEW udp dpt:domain
ACCEPT     udp  --  anywhere             anywhere             state NEW udp dpt:auth
ACCEPT     udp  --  anywhere             anywhere             state NEW udp dpt:ntp
ACCEPT     udp  --  anywhere             anywhere             state NEW udp dpt:rsync
ACCEPT     udp  --  anywhere             anywhere             state NEW udp dpt:6277
ACCEPT     udp  --  anywhere             anywhere             state NEW udp dpt:24441
ACCEPT     icmp --  anywhere             anywhere             icmp echo-reply
ACCEPT     icmp --  anywhere             anywhere             icmp echo-request
ACCEPT     icmp --  anywhere             anywhere             icmp time-exceeded
ACCEPT     icmp --  anywhere             anywhere             icmp destination-unreachable
LOGDROPOUT  all  --  anywhere             anywhere

Chain ALLOWDYNIN (1 references)
target     prot opt source               destination
ACCEPT     all  --  212.178.246.86       anywhere
ACCEPT     all  --  173.249.178.212.adsl.dyn.beotel.net  anywhere

Chain ALLOWDYNOUT (1 references)
target     prot opt source               destination
ACCEPT     all  --  anywhere             212.178.246.86
ACCEPT     all  --  anywhere             173.249.178.212.adsl.dyn.beotel.net

Chain ALLOWIN (1 references)
target     prot opt source               destination
ACCEPT     tcp  --  secure.comodo.net    anywhere             tcp dpt:https
ACCEPT     tcp  --  secure.comodo.net    anywhere             tcp dpt:http
ACCEPT     tcp  --  secure.comodo.net    anywhere             tcp dpt:https
ACCEPT     tcp  --  secure.comodo.net    anywhere             tcp dpt:http
ACCEPT     tcp  --  no-dns-yet.ccanet.co.uk  anywhere             tcp dpt:https
ACCEPT     tcp  --  no-dns-yet.ccanet.co.uk  anywhere             tcp dpt:http
ACCEPT     tcp  --  no-dns-yet.ccanet.co.uk  anywhere             tcp dpt:https
ACCEPT     tcp  --  no-dns-yet.ccanet.co.uk  anywhere             tcp dpt:http
ACCEPT     all  --  212.178.244.42       anywhere

Chain ALLOWOUT (1 references)
target     prot opt source               destination
ACCEPT     all  --  anywhere             212.178.244.42

Chain DENYIN (1 references)
target     prot opt source               destination
DROP       all  --  mail.lp-advogados.com  anywhere
DROP       all  --  oxid5.topconcepts.de  anywhere
DROP       all  --  93.188.164.24        anywhere
DROP       all  --  opus15.register.it   anywhere
DROP       all  --  lysander.instanthosting.com.au  anywhere

Chain DENYOUT (1 references)
target     prot opt source               destination
LOGDROPOUT  all  --  anywhere             mail.lp-advogados.com
LOGDROPOUT  all  --  anywhere             oxid5.topconcepts.de
LOGDROPOUT  all  --  anywhere             93.188.164.24
LOGDROPOUT  all  --  anywhere             opus15.register.it
LOGDROPOUT  all  --  anywhere             lysander.instanthosting.com.au

Chain INVALID (2 references)
target     prot opt source               destination
INVDROP    all  --  anywhere             anywhere             state INVALID
INVDROP    tcp  --  anywhere             anywhere             tcp flags:FIN,SYN,RST,PSH,ACK,URG/NONE
INVDROP    tcp  --  anywhere             anywhere             tcp flags:FIN,SYN,RST,PSH,ACK,URG/FIN,SYN,RST,PSH,ACK,URG
INVDROP    tcp  --  anywhere             anywhere             tcp flags:FIN,SYN/FIN,SYN
INVDROP    tcp  --  anywhere             anywhere             tcp flags:SYN,RST/SYN,RST
INVDROP    tcp  --  anywhere             anywhere             tcp flags:FIN,RST/FIN,RST
INVDROP    tcp  --  anywhere             anywhere             tcp flags:FIN,ACK/FIN
INVDROP    tcp  --  anywhere             anywhere             tcp flags:PSH,ACK/PSH
INVDROP    tcp  --  anywhere             anywhere             tcp flags:ACK,URG/URG
INVDROP    tcp  --  anywhere             anywhere             tcp flags:!FIN,SYN,RST,ACK/SYN state NEW

Chain INVDROP (10 references)
target     prot opt source               destination
DROP       all  --  anywhere             anywhere

Chain LOCALINPUT (1 references)
target     prot opt source               destination
ALLOWDYNIN  all  --  anywhere             anywhere
ALLOWIN    all  --  anywhere             anywhere
DENYIN     all  --  anywhere             anywhere

Chain LOCALOUTPUT (1 references)
target     prot opt source               destination
ALLOWDYNOUT  all  --  anywhere             anywhere
ALLOWOUT   all  --  anywhere             anywhere
DENYOUT    all  --  anywhere             anywhere

Chain LOGDROPIN (1 references)
target     prot opt source               destination
DROP       tcp  --  anywhere             anywhere             tcp dpt:telnet
DROP       udp  --  anywhere             anywhere             udp dpt:telnet
DROP       tcp  --  anywhere             anywhere             tcp dpt:bootps
DROP       udp  --  anywhere             anywhere             udp dpt:bootps
DROP       tcp  --  anywhere             anywhere             tcp dpt:bootpc
DROP       udp  --  anywhere             anywhere             udp dpt:bootpc
DROP       tcp  --  anywhere             anywhere             tcp dpt:sunrpc
DROP       udp  --  anywhere             anywhere             udp dpt:sunrpc
DROP       tcp  --  anywhere             anywhere             tcp dpt:auth
DROP       udp  --  anywhere             anywhere             udp dpt:auth
DROP       tcp  --  anywhere             anywhere             tcp dpts:epmap:netbios-ssn
DROP       udp  --  anywhere             anywhere             udp dpts:epmap:netbios-ssn
DROP       tcp  --  anywhere             anywhere             tcp dpt:microsoft-ds
DROP       udp  --  anywhere             anywhere             udp dpt:microsoft-ds
DROP       tcp  --  anywhere             anywhere             tcp dpt:isakmp
DROP       udp  --  anywhere             anywhere             udp dpt:isakmp
DROP       tcp  --  anywhere             anywhere             tcp dpt:login
DROP       udp  --  anywhere             anywhere             udp dpt:login
DROP       tcp  --  anywhere             anywhere             tcp dpt:efs
DROP       udp  --  anywhere             anywhere             udp dpt:efs
LOG        tcp  --  anywhere             anywhere             limit: avg 30/min burst 5 LOG level warning prefix "Firewall: *TCP_IN Blocked* "
LOG        udp  --  anywhere             anywhere             limit: avg 30/min burst 5 LOG level warning prefix "Firewall: *UDP_IN Blocked* "
LOG        icmp --  anywhere             anywhere             limit: avg 30/min burst 5 LOG level warning prefix "Firewall: *ICMP_IN Blocked* "
DROP       all  --  anywhere             anywhere

Chain LOGDROPOUT (6 references)
target     prot opt source               destination
LOG        tcp  --  anywhere             anywhere             tcp flags:FIN,SYN,RST,ACK/SYN limit: avg 30/min burst 5 LOG level warning uid prefix "Firewall: *TCP_OUT Blocked* "
LOG        udp  --  anywhere             anywhere             limit: avg 30/min burst 5 LOG level warning uid prefix "Firewall: *UDP_OUT Blocked* "
LOG        icmp --  anywhere             anywhere             limit: avg 30/min burst 5 LOG level warning uid prefix "Firewall: *ICMP_OUT Blocked* "
DROP       all  --  anywhere             anywhere

Chain PORTFLOOD (1 references)
target     prot opt source               destination
LOG        all  --  anywhere             anywhere             limit: avg 30/min burst 5 LOG level warning prefix "Firewall: *Port Flood* "
DROP       all  --  anywhere             anywhere

Когда я проверяю с помощью csf -g

csf -g 62.116.184.40

Chain            num   pkts bytes target     prot opt in     out     source               destination

DENYIN           2        0     0 DROP       all  --  !lo    *       62.116.184.40        0.0.0.0/0

DENYOUT          2        0     0 LOGDROPOUT  all  --  *      !lo     0.0.0.0/0            62.116.184.40


ip6tables:

Chain            num   pkts bytes target     prot opt in     out     source               destination
No matches found for 62.116.184.40 in ip6tables

csf.deny: 62.116.184.40 # lfd: (mod_security) mod_security (id:970901) triggered by 62.116.184.40 (DE/Germany/oxid5.topconcepts.de): 5 in the last 3600 secs - Thu Feb  9 04:26:53 2017

IP "заблокирован", но в apache

2-0 -   0/0/1   .   0.01    103 28139   0.0 0.00    0.00    62.116.184.40   http/1.1    mysite.rs:80    GET /?XZFSTJMSOK=SPZZNDNPS HTTP/1.1

Вот информация из mod_security

Request:    GET /?TZSVUEJUU=JWJYEUW
Action Description: Access denied with redirection to http://www.example.com/ using status 302 (phase 4).
Justification:  Pattern match "^5\\d{2}$" at RESPONSE_STATUS.

Как заблокировать запросы, содержащие ^5\\d{2}$ в апаче?

НОВАЯ ИНФОРМАЦИЯ:

Каким-то образом мне удалось выполнить эту атаку самостоятельно, но этот метод, который я использовал, просто отправляет запросы на получение / без строки запроса. И безопасность мода обнаруживает и блокирует меня. Итак, iptables должен работать, но, возможно, он не может обрабатывать слишком много ip, потому что apache дает сбой, поэтому он не может пересчитать все. как предотвратить сбой apache

Быстро и грязно, попробуйте ограничить скорость с помощью iptables:

iptables -I INPUT -p tcp --dport 80 -i eth0 -m state --state NEW -m recent --update --seconds 60 --hitcount 100 -j DROP

Очевидно, вам нужно это настроить. В нем говорится: «Разрешить TCP-соединения через порт 80, но если 99 подключений произошло из того же источника в течение 60 секунд, отбросить последующие подключения».

Мне удалось защитить себя, установив для csf следующие параметры:

CONNLIMIT = 80;5
CT_LIMIT = 20
CT_INTERVAL = 10
PORTFLOOD = 80;tcp;10;3,443;tcp;10;3

Кроме того, я настроил apache (пониженные настройки), чтобы он не вылетал из-за большого использования памяти. Также я переключил MPM с prefork на EVENT. Еще одна полезная опция в CSF - это PT_USERKILL = On

Это убьет процесс перегрузки, этот процесс использовал более 300 МБ, поэтому это сработало для меня, не влияя на нормальную работу.

Сейчас мои сайты работают немного медленнее, но в течение 5 минут csf блокирует все. ПОКОРЯТЬ !