Created
August 6, 2020 10:56
-
-
Save jjf012/3f49a00b78ef05a239106ebd12e58993 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$blackDomain = array('localhost'); //屏蔽查询 | |
$blackIP = array('127', '27.151.'); //屏蔽查询内网IP | |
class HccTools{ | |
var $typ = array(' 未知 ','FTP', 'SSH', 'TELNET', 'SMTP','DNS', 'HTTP', 'net-Bios', 'SMB', 'RDP', 'VNC', 'HTTP', 'MSSQL', 'MYSQL', 'Oracle', 'IMAP', 'HTTPS', 'POP3'); | |
var $por = array(0,21, 22, 23, 25, 53, 80, 139,445, 3389, 5901, 8080, 1433, 3306,1521, 143, 443, 110); | |
public function runtime(){ | |
list($h,$c) = explode(' ',microtime()); | |
return ((float)$h + (float)$c); | |
} | |
public function check($ip, $port){ | |
if(!function_exists('fsockopen')) return '终止:当前主机环境不支持 fsockopen!'; | |
//if(!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE)) $ip = gethostbyname($host); | |
$start = $this->runtime(); | |
$fp = @fsockopen($ip, $port, $ErrCode, $ErrMsg, 1); | |
$finish = $this->runtime(); | |
$execute = ceil(($finish - $start) * 1000); | |
$service = array_search($port, $this->por); | |
if(!$fp){ | |
$fp && fclose($fp); | |
return array(0, $port, $this->typ[$service], ' - '); | |
}else{ | |
$fp && fclose($fp); | |
return array(1, $port, $this->typ[$service], $execute); | |
} | |
} | |
} | |
error_reporting(E_ALL^E_NOTICE); | |
ini_set('max_execution_time', 0); | |
date_default_timezone_set('PRC'); | |
header('Content-type: text/html; charset=utf-8'); | |
setcookie('HccToos', time(), time()+2); | |
define(H, substr($_SERVER['PHP_SELF'],strrpos($_SERVER['PHP_SELF'],'/')+1)); | |
define(S, $_SERVER['SERVER_NAME']); | |
$Ports = $_POST['p']; | |
$Query = preg_replace("/\/(.*)$/is", '', preg_replace("/^(.*):\/\//is", '', $_POST['s'])); | |
if(in_array(strtok($Query, '.'), $blackIP) || array_search($Query, $blackDomain)) $limit = '操作受限:该请求不允许查询.'; | |
if(!empty($Query) && isset($_COOKIE['HccToos']) && !isset($limit)) $limit = '查询间隔时间太短,请稍后重试!'; | |
$tools = new HccTools; | |
?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<title>端 口 测 试<?php echo $Query ? ' : '. $Query : '';?></title> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<meta name="renderer" content="webkit"> | |
<meta http-equiv="Cache-Control" content="no-siteapp" /> | |
<meta http-equiv="Cache-Control" content="no-transform " /> | |
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" > | |
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"> | |
<style> | |
body,td,th{font-family:Arial, Helvetica, sans-serif;font-size:12px;} | |
body{margin-top:0px;background-color:#616378}a{font-size:12px;cursor:pointer}a:link,a:active{color:#333366;text-decoration:none;}a:visited{color:#333366;text-decoration:none;}a:hover{color:#FF0000;text-decoration:underline;}input,button,textarea{vertical-align:middle;padding:3px;outline:none;}/*input:focus,textarea:focus{color:#4d90fd}*/textarea{margin:0px auto;border:1px solid #ccc;width:98%;height:60px;overflow:visible;resize:none;padding:6px;wrap:off}ul,li{margin:0;padding:0;font:12px/1.5 arial;}ul,li{list-style:none;}.HCC{width:expression(this.offsetWidth>728?'728px':true);max-width:718px;margin:auto;background-color:#FFF;padding:0px 5px}@media screen and (max-width:480px){#help{display:none}} | |
#CJP{width:100%;background-color:#B2B2B2;border:0;margin:5px auto;}#CJP tr{background-color:#FFFFFF;text-align:center;padding:5px}#CJP td{padding:5px}#CJP td#Pn a:hover{background-color:#4D90FD;color:#FFF;text-decoration:none}.HCC_body .FirendLinks,.Nav{word-wrap:break-word;background-color:#F2F3F7;padding:5px;margin:3px auto}.HCC .Nav a{line-height:18px;background-repeat:no-repeat;background-position:left;vertical-align:middle;margin:2px;padding-left:17px}.HCC_footer{margin-top:3px;padding:5px;text-align:center;}#HccMenu{margin-top:10px;height:25px;border-bottom:1px solid #ccc;}#HccMenu li{float:left;width:64px; height:24px;line-height:24px; margin:0 5px; text-align:center;border-bottom:none;cursor:pointer}#HccMenu .act{position:relative;height:24px;margin-bottom:-1px;background:#fff;border:1px solid #ccc;border-top:2px solid #ccc;border-bottom:none;font-weight:bold;}#PL .hide{display:none;}#PL{margin:0 auto;border-top::1px solid #ccc;border-top:none;padding:10px;height:auto !important;min-height:200px;}ul.s li{float:left;width:89px;height:24px;line-height:24px;margin:3px;padding:2px; text-align:center}ul.s li a:hover{display:block; background-color:#F2F3F7} | |
</style> | |
</head> | |
<body> | |
<div class="HCC"> | |
<ul id="HccMenu"> | |
<li class="act">端 口 测 试</li> | |
</ul> | |
<div id="PL"> | |
<div> | |
<form action="" method="post" name="$" onsubmit="return CheckForm(this);"> | |
<p style="text-align:center">IP或域名 :<input type="text" name="s" id="s" autofocus="autofocus" onfocus="this.select()" value="<?php echo $Query ? $Query : '172.16.1.1';?>" autocomplete="off" style="border:#616378 2px solid;" /><input type="submit" value="开始扫描" style="background-color:#616378;border:#616378 2px solid; color:#FFF" /></p> | |
<p style="text-align:right;color:#CCC"><?php echo $limit ? '<span style="float:left;color:red;text-align:left;">'. $limit .'</span>' : '';?>多个端口请用逗号隔开 例80,8080</p> | |
<textarea name="p" id="p"><?php echo $Ports ? $Ports : '21,22,23,25,53,80,139,445,3389,5901,8080,1433,3306,1521,143,443,110';?></textarea> | |
</form> | |
<?php | |
if(!empty($Query) && !empty($Ports) && empty($limit) && !isset($_COOKIE['HccToos'])){ | |
$port = explode(',',$_POST['p']); | |
$cc = array_filter(preg_replace('/\D/','',array_filter($port))); | |
sort($cc); | |
?> | |
<table id="CJP" cellspacing="1"> | |
<tr><td colspan="5" style="text-align:left;background-color:#ccc;color:blue"><span style="float:right;color:#FFF"><? echo date('Y-m-d H:i:s');?></span><?php echo $Query;?></td></tr> | |
<tr style="background-color:#E3E3E3;"> | |
<td width="10%">端口</td> | |
<td width="15%">服务</td> | |
<td width="20%">响应</td> | |
<td width="20%">状态</td> | |
<td width="35%">赞助商</td> | |
</tr> | |
<?php | |
$st = $tools->runtime(); | |
$co = 0; | |
for($i=0; $i<count($cc); $i++){ | |
if($cc[$i] < 63365){ | |
$tmp = $tools->check($Query, $cc[$i]); | |
if(is_numeric($tmp[3])){ | |
if( $tmp[3] <= 50 ){ $time = '<font color="green">'. $tmp[3] .' 毫秒</font>'; | |
}elseif( $tmp[3] <= 100 ){ $time = '<font color="#00FF40">'. $tmp[3] .' 毫秒</font>'; | |
}elseif( $tmp[3] <= 150 ){ $time = '<font color="blue">'. $tmp[3] .' 毫秒</font>'; | |
}elseif( $tmp[3] <= 200 ){ $time = '<font color="#FDAB02">'. $tmp[3] .'v</font>'; | |
}elseif( $tmp[3] <= 250 ){ $time = '<font color="#F60">'. $tmp[3] .' 毫秒</font>'; | |
}elseif( $tmp[3] <= 300 ){ $time = '<font color="red">'. $tmp[3] .' 毫秒</font>'; | |
}else{$time = '<font color="red"><b>'. $tmp[3] .'</b> 毫秒</font>';} | |
}else{ | |
$time = ''; | |
} | |
$status = $tmp[0] == 1 ? '<font color="red">开放</font>' : '<font color="green">关闭</font>'; | |
$statu2 = $tmp[0] == 1 ? ' style="background-color:#EDE1E3"' : ''; | |
echo '<tr'. $statu2 .'><td>'. $tmp[1] .'</td><td>'. $tmp[2] .'</td><td>'. $time .'</td><td>'. $status .'</td><td> </td></tr>'; | |
$co++; | |
} | |
} | |
$et = $tools->runtime(); | |
$rt = ceil(($et - $st) * 1000); | |
echo '<tr><td colspan="5">共扫描 '. $Query .' 端口 '. $co .' 个, 耗时 '. $rt .' 毫秒!</td></tr></table>'; | |
} | |
?> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment