[精讚] [會員登入]
1158

測試及處理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

你可能感興趣的文章

setup jira using ssl on apache reverse proxy 設定jira使用https連線

在家設定openvpn server on pfsense 在家設定openvpn server on pfsense

nginx+ssl+certbot安裝設定雜記 using certbot on nginx to setup https connection

bitbucket repository control application setup 安裝完bitbucket服務後,須設定bitbucket.properties

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

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

隨機好文

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

bitbucket repository control application setup 安裝完bitbucket服務後,須設定bitbucket.properties

centos7 apache ssl.conf設定狀況 在apache更新或重啟後可能遇到ssl.conf衝突問題

在windows環境下強制刪除無法以檔案總管刪除的檔案或目錄 how to remove directories or files that cannot be deleted by default file manager

被蘋果帳號釣魚網站詐騙的心得 請小心小額電信代收費詐騙