[精讚] [會員登入]
917

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

你可能感興趣的文章

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

wireguard vpn setup and implementation 在UBUNTU20.04LTS server架設wireguard vpn讓ios及android裝置使用

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

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

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

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

我有話要說

>>

限制:留言最高字數1000字。 限制:未登入訪客,每則留言間隔需超過10分鐘,每日最多5則留言。

訪客留言

[無留言]

隨機好文

[網管心得]qnap+proxmox 韌體更新及nfs掛載或變更

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

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

更新程式環境到wildfly18+openjdk11-phase4: 認證程式更新 認證程式更新

ubuntu18.04網路設定無法啟動問題 network connection failed due to networkmanager settings