Zend - The PHP Company




Security

Add Code


port scanner  

Type: application
Added by: stonerguy
Entered: 26/05/2002
Last modified: 06/12/2001
Rating: - (fewer than 3 votes)
Views: 7571
Simple and raw php port scanner


Here's the html page

<html>
<head>
<title>PORT SCANNER</title></head>
<body bgcolor="black" text="white">

<center>
<br>
<br>
<form action="scan.php" method="post">
<input type="text" size="26" name="host">   target<br><p>
<input type="submit" value="go!">
</form>
</body>
</html>

...and here's the php related code

<html>
<head><title>PORTSCANNER</title></head>
<body bgcolor="black" text="white">
<h3>PORTSCAN RESULTS ON <STRONG><? echo $host ?></strong> :</h3>
</body>
</html>
<?
$lport 
1;
$hport 80;
if (
$host == "") {
header("Location: http://localhost/scan.htm");
exit;
}

for ( 
$port=$lport$port<=$hport$port++ )
{
$fp fsockopen"$host"$port, &$errno, &$errstr);

if ( !
$fp )
{
 echo 
"Port $port seems to be closed/filtered:nDesc: $errstr<br>n";

}
else
{
$serv getservbyport($portTCP);
echo 
"<strong>Port $port / $serv seems open...</strong><br>n";
}
}


?>



Usage Example




Rate This Script





Search



This Category All Categories