如何应对SlowHTTPTest等dos攻击

如何使用应对SlowHTTPTest等dos攻击


dos拒绝服务式攻击,初级的人员可以是用SlowHTTPTest进行一个慢http攻击,如果服务器配置不当,就无法承受此攻击行为,Slowloris 与Slow HTTP POST dos工具依赖http协议,他们会在服务器处理完一个完整的请求前将服务器的资源耗尽,达到攻击行为,Slow Read DoS 攻击跟slowloris 与 slow POST的延长http服务时间不同的是,它会发送合法的请求,并且慢慢的读取服务器的相应数据,最终把服务器资源耗尽

今天我们来演示一下,禁止使用此工具进行非法活动

在linux内核的系统中打开terminal,执行以下命令

# update repos first
sudo apt-get update

# Install the tool
sudo apt-get install slowhttptest

好了,工具安装好了,下面我们来模拟一下攻击行为

slowhttptest -c 500 -H -g -o ./output_file -i 10 -r 200 -t GET -u http://yourwebsite-or-server-ip.com -x 24 -p 2

我们来解释一下参数

-c: 建立http连接的数量,通常200就会让一个没有任何保护措施的服务器瘫痪
-H: 开始 slowhttptest in SlowLoris 模式, 发送未处理完 的HTTP 请求.
-g: 将结果保存为html或cvs.
-o: 自定义输出文件名称
-i: 两次数据发送的间隔(秒)for slowrois and Slow POST tests (in seconds).
-r: 每秒建立http连接的数量 速率
-t: 指定http方式 post或get等.
-u: 攻击的url或ip地址.
-x: 开启slowhttptest 慢读模式,慢慢地读取http 返回数据
-p: 检测服务器连接dosed的时间间隔 (秒).

好,执行完后,我们看看效果


我们看到服务器依然返回yes,看来是做了防止dos攻击的防护,我们看看生成的html文件


如果服务器没做dos防护处理,那么我们会看到以下的结果



好了,攻击演示完了,下面我们来看看如何防护这种dos行为呢

apache服务器要安装mod_qos模块

执行一下命令

# Update repos
sudo apt-get update

# Install the apache extension
sudo apt-get install libapache2-mod-qos

安装完后我们来配置一下,打开配置文件

# Edit the qos.conf file with your favorite terminal editor, we'll use nano
nano /etc/apache2/mods-available/qos.conf

<IfModule qos_module>
   # handle connections from up to 100000 different IPs 最大处理不同ip数量
   QS_ClientEntries 100000
   # allow only 50 connections per IP 单个ip最大处理并发连接数
   QS_SrvMaxConnPerIP 50
   # limit maximum number of active TCP connections limited to 256 最大活动并发tcp连接数
   MaxClients 256
   # disables keep-alive when 180 (70%) TCP connections are occupied
   QS_SrvMaxConnClose 180 当180个tcp被占用后禁用keep-alive
   # minimum request/response speed  最小请求回应速度
   # (deny slow clients blocking the server, keeping connections open without requesting anything
   QS_SrvMinDataRate 150 1200
</IfModule>

好了,重启一下apache,ok搞定了

sudo service apache2 restart


{{collectdata}}

网友评论0