wuliuwang 发表于 2018-12-20 10:05:53

php hash漏洞测试及补丁

  PHP hash漏洞测试环境:
Ip:xx.xx.31.167    Nginx0.8+php5.2.14  4颗CPU 。

一、未打补丁前:
# curl --head http://127.0.0.1
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 06 Jan 2012 06:10:09 GMT
Content-Type: text/html
Connection: keep-alive
X-Powered-By: PHP/5.2.14    php5.2.14版本,负载0
http://blog.运维网.com/attachment/201201/082449673.jpg

测试***代码:
链接下载地址:http://www.linuxso.com/linuxbiancheng/15500.html
1)       dos.php脚本   pow(2,15)是构架hash碰撞的post数据data

测试单个并发连接http://xx.xx.31.167/dos.php?a=.1.  结果单个php-cgi进程,单个CPU占100%。

http://blog.运维网.com/attachment/201201/082528216.jpg
如开两个窗口并发连接,则两个PHP进程,两个CPU 都占满100%。

2)       ddos.php 脚本    php模拟post提交数据





DDOS







http://xx.xx.31.167/ddos.php 访问测试结果:

http://blog.运维网.com/attachment/201201/082604900.jpg

xx.xx.31.167 - - "POST /test.php HTTP/1.1" 502 191 "-" "API REQUEST(CURL)" "-"
xx.xx.194.180 - - "GET /test2.php HTTP/1.1" 200 31 "-" "Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17" "-"
xx.xx.31.167 - - "POST /test.php HTTP/1.1" 502 191 "-" "API REQUEST(CURL)" "-"
xx.xx.194.180 - - "GET /test2.php HTTP/1.1" 200 31 "-" "Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17" "-"
php模拟post提交,CPU瞬间全占满100%.

二、打补丁
1.补丁下载地址(打入前先备份相关php配置文件):https://github.com/laruence/laruence.github.com/tree/master/php-5.2-max-input-vars
2.具体操作:
#/usr/local/php/sbin/php-fpm stop 停止php服务
# cd /tmp/php-5.2.14  进入源码目录
# patch -p1 < ../php-5.2.14-max-input-vars.patch 打入补丁包
#./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-gd --enable-gd-native-ttf --with-mcrypt --with-openssl --with-mhash --enable-sockets --enable-pcntl --with-xmlrpc --enable-zip --enable-soap   重新编译
#make clean
#make ZEND_EXTRA_LIBS='-liconv'
#make install

查看配置文件是否被覆盖安装。开启php-fpm服务
# curl --head http://127.0.0.1   
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 06 Jan 2012 08:05:38 GMT
Content-Type: text/html
Connection: keep-alive
X-Powered-By: PHP/5.2.14p1  补丁已打上5.2.14p1  
再次php hash***测试:
访问http://xx.xx.31.167/ddos.php

http://blog.运维网.com/attachment/201201/082640834.jpg
很强大,已无影响.





页: [1]
查看完整版本: php hash漏洞测试及补丁