PHP implementation of online port scanning example code_PHP tutorial
Release: 2016-07-13 17:40:37
Original
892 people have browsed it
$youip=$HTTP_SERVER_VARS["REMOTE_ADDR"];
$remoteip=$HTTP_POST_VARS[remoteip];
?>
-
- php实现端口在线检测
-
-
if (!empty($remoteip)){
function err() {
die(" 对不起,该IP地址不合法点击这里返回");
}
// 定义提交错误IP的提示信息
$ips=explode(".",$remoteip);
// 用.分割IP地址
if (intval($ips[0])<1 or intval($ips[0])>255 or intval($ips[3])<1 or intval($ips[3]>255)) err();
// 如果第一段和最后一段IP的数字小于1或者大于255,则提示出错
if (intval($ips[1])<0 or intval($ips[1])>255 or intval($ips[2])<0 or intval($ips[2]>255)) err();
// 如果第二段和第三段IP的数字小于0或者大于255,则提示出错
$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,Sm tp ,Finger,Http,Pop3,Location Service,Netbios-NS,Netbios-DGM,Netbios-SSN,IMAP,Https,Microsoft-DS,MSSQL,MYSQL,Terminal Services);
// Pass After checking the IP format, use an array to define the service name and status corresponding to each port
echo "
";
echo "
";
echo "The IP you scanned: ".$remoteip." strong> |
";
echo "
";
echo "
";
echo "
";
echo "
";
echo "port |
";
echo "Service |
";
echo "Detection results |
";
echo "description |
";
echo "
";
//Output the displayed table
for($i=0;$i
{
$fp = @fsockopen($remoteip, $port[$i], &$errno, &$errstr, 1);
if (!$fp) {
echo "".$port[$i]." | < td>".$msg[$i]."".$close." | ".$closed." |
";
} else {
echo "".$port[$i]." | ".$msg[$i]." | ".$open." | ".$opened ." |
";
}
}
// Use the for statement to connect to the relevant ports of the remote host using the fsockopen function, and output the results
echo "
"; echo "Continue scanning>>>< /td>
"; echo " |
echo "
";
echo "
";
echo "
";
echo "port scan |
";
echo "
";
echo "
";
echo "
";
echo "
";
echo "
";
exit;
http://www.bkjia.com/PHPjc/486202.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486202.htmlTechArticle?php $youip=$HTTP_SERVER_VARS["REMOTE_ADDR"]; $remoteip=$HTTP_POST_VARS[remoteip]; ? html head titlephp implements port online detection/title meta http-equiv="Content-Type" content="text/h...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31