[精讚] [會員登入]
1223

測試及處理slow http attack on Apache 2.4.6 at CentOS-7

avoiding and testing slow http attack

分享此文連結 //n.sfs.tw/14866

分享連結 測試及處理slow http attack on Apache 2.4.6 at CentOS-7@外行中的外行
(文章歡迎轉載,務必尊重版權註明連結來源)
2020-12-12 22:32:34 最後編修
2020-12-12 21:58:31 By jung
 

弱點掃描傳來一個歷史悠久(問谷歌大約十年前了)的弱點,叫做slow http attack

看起來是利用apache會暫時保留http連線以加快存取速度的運作方式,用http method(POST,GET)間隔送出header 或body request的方式,逐漸消耗apache資源達到DoS攻擊效果,它不需要大量頻寬或連線數來達成,只要利用timeout間隔就可達成中斷服務的成效,

問了大神,說有三種處理方式

1. mod_qos: apache2.4之後不支援了

2. mod_reqtimeout: 最簡單

在CentOS-7 /etc/httpd/conf/httpd.conf檔案新增下列IfModule

<IfModule mod_reqtimeout.c>
  RequestReadTimeout header=20-40,MinRate=500 body=20-40,MinRate=500
</IfModule>

Apache2 預設已經加入mod_reqtimeout的函式庫,直接引入就可以

3. mod_security:設定最複雜

先安裝:yum install mod_security

重啟apache:systemctl restart httpd

到/etc/httpd/conf.d目錄下會發現多了一個mod_security.conf

/etc/httpd/目錄下多了一個目錄modsecurity.d/activated_rules裡面是空的

下載及設定 OWASP (Open Web Application Security Project) 的 rule 作為基本設定

切到/etc/httpd目錄下

得到一個範例目錄owasp-modsecurity-crs 我改名為modsecurity-crs

切換到modsecurity-crs下將範例規則放到modsecurity.d/activated_rules/目錄下

cp crs-setup.conf.example ../modsecurity.d/activated_rules/modsecurity_crs_10_config.conf

重新啟動httpd就完成了

測試結果:我做了2.mod_reqtimeout和3.mod_security

在ubuntu20.04版用slowhttptest這個套件測試

https://github.com/shekyan/slowhttptest/wiki/InstallationAndUsage

一開始先用mod_reqtimeout 感覺沒有差別

./slowhttptest -c 1000 -H -g -o my_header_stats -i 10 -r 200 -t GET -u https://myseceureserver/resources/index.html -x 24 -p 3

 

服務還是中斷了大概30幾秒~哭哭

後改用mod_security

服務中斷的時間變短了@@

最後修改apache2 的mpm (Multi-Processing Module) 為 event module 事件模式(thread based)

好像有好一點...嗎@@

後來用httperf 測出我這台CentOS-7 上的 Apache2.4.6 最大線程數就大約200...slowhttptest 連線超過的話,服務就中斷了~

https://www.netadmin.com.tw/netadmin/zh-tw/technology/79EE785099FF4659A813C710D92834D8

$httperf --server myserver.com --port 443 --num-conn 200 --num-call 10 --rate 200 --timeout 5

於是把slowhttptest的參數改了一下(汗顏)

slowhttptest1.8.2/bin/slowhttptest -c 200 -H -g -o header_stats -i 10 -r 200 -t GET -u https://myserver.com/ -x 24 -p 3

最多一次200個連線數,看起來就...好像可以@@

 

後來測了一個知名大網站oidc.tanet

看看人家的圖表多麼厲害~1000個連線數,完全沒有中斷服務

到底是~設定還是系統環境差別在哪裡呢@@

參考文件:

https://blog.lpchen.me/2016/08/19/How-to-mitigate-Slow-HTTP-Dos-Attack-on-Apache-2-4-in-Ubuntu/

https://github.com/shekyan/slowhttptest/wiki/InstallationAndUsage

https://www.researchgate.net/publication/323194627_A_Review_of_Defense_Against_Slow_HTTP_Attack

https://www.opencli.com/apache/rhel-centos-install-mod_security

https://www.netadmin.com.tw/netadmin/zh-tw/technology/79EE785099FF4659A813C710D92834D8

https://www.tomica.net/blog/2016/07/change-apache-mpm-on-centos-7

 

END

你可能感興趣的文章

JIRA instance migration phase1 how to migrate JIRA from centos6 to centos7

installation and implementation of k8s clusters on CentOS8 k8s入坑

logrotate執行權限問題 logrotate will failed to execute if selinux policy not setup correctly

how to add physical disks into HP smart array through esxi interface 如何在磁碟陣列卡上加入新的硬碟-未完待續

proxmox5.x using duplicati as cloud backup strategy install duplicati program on Proxmox host for remote backup using google drive account

JIRA using gmail as smtp outgoing mail sender 如何設定jira使用gmail信箱送信

隨機好文

[java]縣市IDP建置 使用NetBeans建置IDP程式

使用virtualbox每次都忘記的事情 share folder from win host to linux guest vm

在debian9使用apt-key add gpg key from ubuntu keyserver

在apache http server停用TLS 1.0/1.1 and SSL 2.0/3.0 How to disable outdated versions of SSL/TLS on Apache

intellij IDEA git設定說明 whenever using git push fuction in the intellij IDEA