Jump to content

Port scanner problem


Deoctor

Recommended Posts

Hai

recently i developed one app through which u can check the opened and closed ports under an ip address or domain.but there is a small error.

if no port numbers are given then it should scan from 1-100 ports.but it is scanning only first 5 ports..

can anyone help me out..

<html>
<title>Check the Open ports</title>
<pre>                                    <font size=3><b>Hai
                         Using this application u can check the ports that are opened in the ip address
                         
                             Common Ports Used are 
                         
                                FTP    21
                                SSH    22
                                Telnet    23
                                SMTP    25
                                Web    80
                                Pop 3    110
                                IMAP    143
                                Other Applications
                                    Remote Desktop    3389
                                    PC Anywhere    5631</b></font>
</pre>

<body background="image01.jpg" bgproperties="fixed">
<form action="timer.php" method="POST">
<br><br><br>
<table align="center" border="1" bordercolor="black">
<tr>
<td align="left" bgcolor="transparent" valign="center">Ip address:<input type=text style="color: #FF0000;font-family: Verdana;font-weight: bold;font-size: 14px;background-color: transparent;" maxlength='30' name=address></td></tr><tr></tr> 
<tr><td align="left" bgcolor="transparent" valign="center">Port Number:<input type=text style="color: #FF0000;font-family: Verdana;font-weight: bold;font-size: 14px;background-color: transparent;" maxlength='25' name=service></td></tr>
<tr><td align="center" valign="center"><input type=submit name=submit value=Submit></td>
</tr>
</table>
</form>
</body>
</html>
<?php
error_reporting(0); 
$address = $_POST['address']; 
$service = $_POST['service']; 
if($address && $service)
{
    if(fsockopen($address,$service,$errno,$errstr,10)) 
{
      //echo "$address:$service is up!";
    echo ("<table><td bgcolor=yellow width=100% align='center'><font face=Verdana, Arial, Helvetica, sans-serif size=2><b>$address:$service is up!</b></font></td></table>");

}
else 
{
     //echo "$address:$service is NOT up!";
     echo ("<table><td bgcolor=yellow width=100% align='center'><font face=Verdana, Arial, Helvetica, sans-serif size=2><b>$address:$service is Down!</b></font></td></table>");
}
}
elseif($address)
{
for($service=10;$service<=100;$service++)
{
     $sock_check=fsockopen($address,$service,$errno,$errstr,10);
    if(!$sock_check)
    {
        echo ("<table><td bgcolor=yellow width=100% align='center'><font face=Verdana, Arial, Helvetica, sans-serif size=2><b>$address:$service is Down!</b></font></td></table>");
    }
    else
    {
        echo ("<table><td bgcolor=yellow width=100% align='center'><font face=Verdana, Arial, Helvetica, sans-serif size=2><b>$address:$service is up!</b></font></td></table>");

    }
}
}
else
{
    
}
?>

Link to comment
Share on other sites

My suggestion would be to remove that error_reporting function call..

You wont be able to see the errors if you have that there..

 

Take it out and see if any errors show themselves..

 

I would also suggest to close each connection after you have determined its status..

Link to comment
Share on other sites

hi

i have done that but of no use, it takes only first 5 ports and leaves the remaining.

<html>
<title>Check the Open ports</title>
<pre>                                    <font size=3><b>Hai
                         Using this application u can check the ports that are opened in the ip address
                         
                             Common Ports Used are 
                         
                                FTP    21
                                SSH    22
                                Telnet    23
                                SMTP    25
                                Web    80
                                Pop 3    110
                                IMAP    143
                                Other Applications
                                    Remote Desktop    3389
                                    PC Anywhere    5631</b></font>
</pre>

<body background="image01.jpg" bgproperties="fixed">
<form action="timer.php" method="POST">
<br><br><br>
<table align="center" border="1" bordercolor="black">
<tr>
<td align="left" bgcolor="transparent" valign="center">Ip address:<input type=text style="color: #FF0000;font-family: Verdana;font-weight: bold;font-size: 14px;background-color: transparent;" maxlength='30' name=address></td></tr><tr></tr> 
<tr><td align="left" bgcolor="transparent" valign="center">Port Number:<input type=text style="color: #FF0000;font-family: Verdana;font-weight: bold;font-size: 14px;background-color: transparent;" maxlength='25' name=service></td></tr>
<tr><td align="center" valign="center"><input type=submit name=submit value=Submit></td>
</tr>
</table>
</form>
</body>
</html>
<?php
//error_reporting(0); 
$address = $_POST['address']; 
$service = $_POST['service']; 
if($address && $service)
{
    if(fsockopen($address,$service,$errno,$errstr,10)) 
{
      //echo "$address:$service is up!";
    echo ("<table><td bgcolor=yellow width=100% align='center'><font face=Verdana, Arial, Helvetica, sans-serif size=2><b>$address:$service is up!</b></font></td></table>");

}
else 
{
     //echo "$address:$service is NOT up!";
     echo ("<table><td bgcolor=yellow width=100% align='center'><font face=Verdana, Arial, Helvetica, sans-serif size=2><b>$address:$service is Down!</b></font></td></table>");
}
}
elseif($address)
{
for($service=10;$service<=100;$service++)
{
     $sock_check=fsockopen($address,$service,$errno,$errstr,10);
    if(!$sock_check)
    {
        echo ("<table><td bgcolor=yellow width=100% align='center'><font face=Verdana, Arial, Helvetica, sans-serif size=2><b>$address:$service is Down!</b></font></td></table>");
    }
    else
    {
        echo ("<table><td bgcolor=yellow width=100% align='center'><font face=Verdana, Arial, Helvetica, sans-serif size=2><b>$address:$service is up!</b></font></td></table>");

    }
    fclose($sock_check);
}
}
else
{
    
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.