Home > Article > Backend Development > A simple php online port scanner_PHP tutorial
PHP is a powerful web development language. It has high development efficiency and simple syntax. It is tailor-made for dynamic websites and is more object-oriented (closer to C++ and has some connections with JAVA). Unfortunately, it is single-threaded (this is its fatal weakness. It is said that PHP is written in CC++.), You can also use C, C++, and JAVA to develop the middle layer and call COM. The server maintenance is easy and there are few failures.
Since it is tailor-made for dynamic websites, it is destined not to develop a powerful scanner like X-scan, but if you want to implement some simple functions, it is more than enough.
Port scanning is our most commonly used means of checking. If you are in a place like an Internet cafe, it will be more troublesome to download a special scanner. If you use the port scanning provided by the existing web service. That really saves a lot of trouble.
Let’s take a look at the source code of the PHP port scanner I wrote:
Code:
//Codz by angel
$youip=$HTTP_SERVER_VARS["REMOTE_ADDR"]; // Get the local IP address
$remoteip=$HTTP_POST_VARS['remoteip']; // Get the IP address of form submission
?>
Click here to return");
}
// Define the prompt message for submitting the wrong IP
$ips=explode(".",$remoteip);
// Split the IP address with .
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 segments is less than 1 or greater than 255, an error will be 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 the second and third IP segments is less than 0 or greater than 255, an error will be prompted
$closed='This port is currently closed. ';
$opened='This port is currently open! ';
$close="Close";
$open="Open";
$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'
);
// After checking the IP format, use an array to define the service name and status corresponding to each port
echo "
The IP you scanned: color=red>".$remoteip." | n";
port | n";service | n";Detection results | n";description | n";
".$port[$i]." | ".$msg[$i]." | align=center>".$close."".$closed." | |
".$port[$i]." | ".$msg[$i]." | align=center>".$open."".$opened." | |
n"; echo "Continue scanning>>> | n";
Copyright © 2004 Security Angel Team[S4T] All Rights Reserved. | n";
Your IP:".$youip." | n";
Copyright © 2004 Security Angel Team[S4T] All Rights Reserved. |