Monday, December 27, 2010

Check open port (php)

 Hmm simply save it *.php
It will check n display opened ports

<html><head><title>Check Open Ports</title></head>
<body>
<center>
<br><br>
<h1>You IP is:<br><font color='blue'><?php echo $_SERVER['REMOTE_ADDR'];?></font></h1>
<br>
<form action="" method="post">
<h2>Enter ip adress to check: <h2><br><input type="text" name="ip" value="<?php echo $_SERVER['REMOTE_ADDR'];?>" size="30"/><br><br>
<h2>Enter port to check: <h2><br><input type="text" name="port" size="20"/><br><br>
<input type="submit" value="check"/>
</form> 
</center>


<?php
$ip=$_POST["ip"];

$port = $_POST["port"];
if ($ip && $port){
$fp = @fsockopen($ip,$port,$errno,$errstr,5);
if(!$fp)
{
echo " <center><h3>Destination IP is <br><font color='blue'>".$ip."</font><br>Cannot connect to server  <br> Port <font color='red'>".$port." </font>is<br><h2> <b><font color='red'>Closed</b></h2></h3></center>";
}

else{
echo "<center><h3>Destination IP is <br><font color='blue'>".$ip."</font><br>Connect was successful <br> Port <font color='green'>".$port." </font> is<br><h2> <b><font color='green'>Open</b></h2></h3></center>";
fclose($fp);
}
}

?>
</body></html>


0 comments:

Post a Comment