php扫描端口

2018-01-03  本文已影响10人  CSeroad

php实现对指定IP进行端口扫描

代码为

<html>

<head>

<meta http-equiv="Content-Type" content="text-html; charset=GBK" />

<title>IP port  Scan</title>

<style type="text/css">

td{   padding:10px;   margin: 10px;   border-width:1px solid #eee;   text-align: center; }

span{ color: red; }

</style>

</head>

<body>

<form action="" method="POST">

please enter the IP address <input type="text" name="ip" >

<input type="submit" value="submit" style="display:none">

</form>

<?php

$ip=@$_POST['ip'];

$port=array(21,80,135,443,445,3306,3389,39000);

$time=4;

exec("ping $ip -n $time",$info);

//执行ping命令

if(count($info)>10){

foreach($port as $key=>$value){

$fp=@fsockopen($ip,$value,$errno,$errstr,30);

//打开一个网络连接

    $result=$fp?'<span>open<span>':'close';

echo "<table><tr><td>port</td><td>statue</td>";

echo "<td>".$value."<td/><td>".$result."<td/></tr></table>";

}

}else{

echo implode("<br/>",$info);

}

?>

</body>

</html>

上一篇下一篇

猜你喜欢

热点阅读