<?
if ($submit==1) {
$starttime1=date("H:i:s");
$starttime2=time();
if ($ip=="127.0.0.1" | $ip=="localhost" ) { $ip=$REMOTE_ADDR; }
$port =explode("-", $port);
if (count($port)==1) {
$port =explode(",", $port[0]);
} elseif (count($port)>1) {
$a=min($port);
$b=0;
while (max($port)>$a-1) {
$tmpport[$b]=$a;
if ($b>100) { print "Do not scan more than 100 ports (bandwidth purposes)"; exit;}
$a++;
$b++;
}
$port=$tmpport;
}
$a=0;
$b=0;
$count= count($port);
print "<table><tr><td colspan=2>Scanning: $ip</td></tr>";
while ($b<$count) {
$fp = fsockopen ($ip, $port[$b], &$errno, &$errstr, 30);
if (!$fp) {
print "<tr><td width=30>Closed:</td><td>$port[$b]</td></tr>";
} else {
print "<tr><td width=30>Opened:</td><td>$port[$b]</td></tr>";
}
$b++;
}
print "</table>";
$endtime1=date("H:i:s");
$endtime2=time();
$totalsec=$endtime2-$starttime2;
if ($totalsec==0) { $totalsec=1; }
$portcount=count($port);
$pps=$portcount/$totalsec;
print " <br><br>
Script started at: $starttime1 and finished at: $endtime1 <br>
Script took: $totalsec seconds to complete<br>
Ports per second: $pps
Script by: <a href=mailto:the_eternal@wanadoo.nl>The_Eternal</a>";
} else {
print " <form action=$PHP_SELF>
<table>
<tr><td>Ip:</td> <td><input type=text name=ip></td></tr>
<tr><td>Port:</td> <td><input type=text name=port>
(You CAN use this: from port-to port or port,port,etc...)
</td></tr>
<input type=hidden value=1 name=submit>
<tr></tr><td><input type=submit value=Submit name=Submit></td></tr>
</table>
Script by: <a href=mailto:the_eternal@wanadoo.nl>The_Eternal</a>
</form>";
}
?>
Php做的端口嗅探器--可以指定网站和端口
<?
//Php做的端口嗅探器--可以指定网站和端口
//并返回嗅探结果
function http_request($server, $port) {
$data = "";
$query = "HEAD / HTTP/1.0";
$fp = fsockopen($server, $port);
if($fp) {
fputs($fp, $query."rnn");
while(!feof($fp)) {
$data .= fread($fp, 1000);
}
fclose($fp);
}
return $data;
}
?>
<FORM>
<INPUT TYPE=HIDDEN NAME=action VALUE=query>
Site: <INPUT TYPE=TEXT NAME=server VALUE="<?echo $server?>"> <SMALL>(ie: www.wackowoh.com)</SMALL><BR>
Port: <INPUT TYPE=TEXT NAME=port VALUE="80" SIZE="5" MAXLENGTH="5"><BR>
<INPUT TYPE=SUBMIT VALUE=" OK ">
</FORM>
<?
if($action == "query") {
$data = http_request($server, $port);
echo "Connected To $server on port $port.<p>";
echo "Output: <p><pre>$data</pre><p>";
}
?>