一个简单的php在线端口扫描器
<?php
$youip=$HTTP_SERVER_VARS["REMOTE_ADDR"];//获取本机IP地址
$remoteip=$HTTP_SERVER_VARS["remoteip"];//获取表单提交的IP地址
?>
<html>
<head>
<title>断口在线检测</title>
<meta http-equiv="Content-Type" c>
<style>
<!--
BODY { FONT-SIZE: 12px; FONT-FAMILY: Verdana;color:#000000;
}
TD {
FONT-SIZE: 12px;
FONT-FAMILY: Verdana;
color:#000000;
line-height: 14px;
}
.style1 {color: #FFFFFF}
-->
</style>
</head>
<body>
<center>
<?php
$remoteip=$_POST["remoteip"]; //原文没有 这是作者的失误
if(!empty($remoteip)){
//如果表单不为空就进入IP地址格式判断
function err(){
die("对不起,该IP地址不合法<p><a href=javascript:history.back(1)>点击这里返回</a>");//定义提交错误IP的提示信息
}
$ips=explode(".",$remoteip);//用.分割IP地址
if(intval($ips[0])<1 or intval($ips[0])>255 or intval($ips[3])<1 or intval($ips[3])>255) err();// 如果第一段和最后一段IP的数字小于1或者大于255,则提示错误
if(intval($ips[1])<0 or intval($ips[1])>255 or intval($ips[2])<0 or intval($ips[2])>255) err();// 如果第二段和第三段IP的数字小于0或者大于255。则提示出错
$closed="此断口目前处于关闭状态。";
$opened="<font color=red>此断口目前处于打开状态</font>";
$close="关闭";
$open="<font color=red>打开</font>";
$port=array(21,23,25,79,80,110,135,137,138,139,143,443,445,1433,3306,3389);
$msg=array("Ftp","Telnet","Smtp","Finger","Http","Pop3","Location Service","Netbios-NS","Netbios-DGM","Netbios-SSN","IMAP","Https","Microsoft-DS","MSSQL","MYSQL","Terminal Services");
echo"<table border=0 cellpadding=15 cellspacing=0>\n";
echo"<tr>\n";
echo"<td align=center><strong>您扫描的IP:<font color=red>".$remoteip."</font></strong></td>\n";
echo"</tr>\n";
echo"</table>\n";
echo"<table cellpadding=5 cellspacing=1 bgcolor=#636194>\n";
echo "<tr bgcolor=#7371A5 align=center>\n";
echo"<td><span class=style1>断口</span></td>\n";
echo"<td><span class=style1>服务</span></td>\n";
echo"<td><span class=style1>检测结果</span></td>\n";
echo"<td><span class=style1>描述</span></td>\n";
echo"</tr>\n";
for($i=0;$i<sizeof($port);$i++){
$fp=@fsockopen($remoteip,$port[$i],$errno,$errstr,1);[email=$fp=@fsockopen($remoteip,$port[$i],$errno,$errstr,1);//$fp=@fsockopen($remoteip,$port[$i],$errno,$errstr,1]/*原文是这样的[email=$fp=@fsockopen($remoteip,$port[$i],&$errno,&$errstr,1]$fp=@fsockopen($remoteip,$port[$i],&$errno,&$errstr,1[/email][/email]) 但是有出错 去掉 & 就没事了*/
if(!$fp){
echo"<tr bgcolor=#ffffff><td align=center>".$port[$i]."</td><td>".$msg[$i]."</td><td align=center>".$close."</td><td>".$closed."</td></tr>\n";
}
else{
echo "<tr bgcolor=#f4f7f9><td align=center>".$port[$i]."</td><td>".$msg[$i]."</td><td align=center>".$open."</td><td>".$opened."</td></tr>";
}
}
//用for语句 分别用fsockopen函数 连接远程主机的相关断口。并输出结果
echo "<tr><td colspan=4 align=center>\n";
echo"<a href=port.php><font color=#ffffff>继续扫描>></font></a></td>\n";
echo"</tr>\n";
echo"</table>\n";
echo"<table cellspacing=0 cellpadding=10 width=100% border=0>\n";
echo"<tr>\n";
echo"<td align=center><b>Copyright © 2008 secrinnglr All Right Reserved.</b></td>\n";
echo"</tr>\n";
echo"</table>\n";
echo"</center>\n";
echo"</body>";
echo"</html>\n";
exit;
}
//探测结束
echo "<table border=0 cellpadding=15 cellspacing=0>\n";
echo "<tr>\n";
echo"<td align=center><strong>您的IP:<font color=red>".$youip."</font></strong></td>\n";
echo"</tr>\n";
echo"<form method=post action=port.php>\n";
echo"<tr><td>\n";
echo"<input type=text name=remoteip size=12>\n";
echo"<input type=submit value=扫描 name=scan>\n";
echo"</td></tr>\n";
echo"</form>";
echo"</table>\n";
?>
<TABLE cellSpacing=0 cellPadding=10 width="100%" border=0>
<TR>
<TD align=center><b>Copyright © 2004 Security Angel Team[S4T]
All Rights Reserved.</b></TD>
</TR>
</TABLE>
</center>
</body>
</html>
不是原创啊 但是发现了几个错误 我给该掉了