PHP Port Scanner

Source: Internet
Author: User
Tags format define empty reserved

<?php

Codz by Angel
Welcome to my Website
Http://www.4ngel.net

$youip = $HTTP _server_vars["REMOTE_ADDR"];        //Get native IP address
$ remoteip= $HTTP _post_vars[' Remoteip '];             /Get form Submit IP address
?>
<title> Security Angel--Port online detection </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<style type=" Text/css ">
<!--
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>
<body>
<center>
<?php
if (!empty ($REMOTEIP)) {
//The decision to enter the IP address format if the form is not empty

function err () {
Die ("Sorry, the IP address is not legal <p><a Href=javascript:history.back (1) > Click here to return </a>");
}
To define a message that submits error IP

$ips =explode (".", $remoteip);
Use. Split IP Address

if (intval ($ips [0]) <1 or intval ($ips [0]) >255 or Intval ($ips [3]) <1 or intval ($ips [3]>255)) Err ();
If the number of the first and last IP is less than 1 or greater than 255, an error is prompted

if (Intval ($ips [1]) <0 or Intval ($ips [1]) >255 or Intval ($ips [2]) <0 or intval ($ips [2]>255)) Err ();
If the number of IP in the second and third segments is less than 0 or greater than 255, an error is prompted

$closed = ' This port is currently off. ';
$opened = ' <font color=red> This port is currently open! </font> ';
$close = "Close";
$open = "<font color=red> open </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 '
;    
///IP format after checking to define the corresponding service name and status of each port

Echo "<table   border=0 cellpadding=15 cellspacing=0>\n";
echo "<tr>\n"; The
Echo <td align=center><strong> the Ip:<font
color=red> you scanned. $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> port </span></td>\n";
Echo "<td><span class=style1> service </span></td>\n";
echo "<td><span class=style1> detection results </span></td>\n";
echo "<td><span class=style1> description </span></td>\n";
echo "</tr>\n";
//output table displayed

for ($i =0; $i <sizeof ($port); $i + +)
{
$fp = @fsockopen ($remoteip, $port [$i], & $errno, & $errstr, 1); br>   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> ";
  }
}
////With the For statement, use the Fsockopen function to connect the remote host's associated port, and output the result

Echo "<tr><td colspan=4 align=center>\n";
Echo <a href=portscan.php><font color= #FFFFFF > Continue scanning >>></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©2004 security Angel team[s4t] all Rights reserved.</b></ Td>\n ";
echo "</tr>\n";
echo "</table>\n";
echo "</center>\n";
echo "</body>\n";
echo " Exit;
}
//Probe end

echo "<table border=0 cellpadding=15 cellspacing=0>\n";
echo "<tr>\n";
echo "<td align=center><strong> your Ip:<font color=red>". $youip. " </font></strong></td>\n ";
echo "</tr>\n";
echo "<form method=post action=portscan.php>\n";
echo "<tr><td>\n";
echo "<input type=text name=remoteip size=12>\n";
echo "<input type=submit value= scan name=scan>\n";
echo "</td></tr>\n";
echo "</form>";
echo "</table>\n";
Displays a form that submits an IP address if the form is empty

?>

<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>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.