<?php
$cfg = array();
$cfg["site"]["name"] = "端口在线扫描器";
$cfg["site"]["keys"] = "端口扫描器,端口扫描工具,在线端口扫描";
$cfg["site"]["desc"] = "通过该工具可以扫描常用的端口和指定的端口是否开放。";
$cfg["black"]["domain"] = array("localhost", "hechaocheng.cn", "hechaoliang.cn", "www.genzi.win");
$cfg["black"]["ip"] = array("10", "127", "168", "192");
$cfg["adsense"] = array(
'<a class="r" href="http://dwz.cn/BandWaGonHost">搬瓦工高性价比VPS<a>',
'<a class="b" href="http://dwz.cn/weloveservers">我爱服务器<a>',
'<a class="g" href="http://dwz.cn/Henghost">恒创科技<a>',
'<a class="r" href="https://www.aliyun.com/daily-act/ecs/activity_selection?userCode=izs9czq8">云服务器新人特惠</a>',
'<a class="g" href="https://developer.aliyun.com/mission/invite?taskCode=5274&recordId=e279a98cc2c737524876c09af9b68fc9&share_source=copy_link">阿里云开发者大家庭</a>',
'<a class="b" href="https://www.aliyun.com/activity/emas/mqcexpert?userCode=izs9czq8">阿里云</a>',
//'<a class="" href="">111</a>',
//'<a class="" href="">111</a>'
);
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* Powered by Hechaocheng|0xE1D53B70|Hi[at]hechaocheng[dot]com */
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
error_reporting(0);
error_reporting(E_ALL^E_ERROR^E_WARNING^E_PARSE);
ini_set("max_execution_time", 10);
header("content-type:text/html;charset=utf-8");
define("version", "v1.0.1");
$domain = "my.hechaocheng.cn";
$port = array(21,80,443,3306,3389,8080);
class HccTools{
var $typ = array(" 未知 ","FTP", "SSH", "TELNET", "SMTP", "Whois", "DNS", "HTTP", "POP3", "NTP", "IMAP", "HTTPS", "IMAP:SSL", "SMTP:SSL", "POP3:SSL", "MSSQL/udp", "MYSQL", "TERMINAL", "QQ Client", "WWW 代理");
var $por = array(0, 21, 22, 23, 25, 43, 53, 80, 110, 123, 143, 443, 993, 994, 995, 1433, 3306, 3389, 4000, 8080);
public function __construct(){
//setcookie("HccToos", time(), time()+5);
date_default_timezone_set("PRC");
$this->selfname = basename($_SERVER["PHP_SELF"]);
}
public function timestamp(){
list($millisecond, $second) = explode(" ",microtime());
return ((float)$millisecond + (float)$second);
}
public function c($domain = "", $port = ""){
if(!function_exists("fsockopen")) return '终止:当前主机环境不支持 fsockopen! <a href="//t.cn/Rq6yB3s" target="_blank">向群友[23 189 103]请求协助.</a>';
$res = array();
foreach($port as $v){
if($v < 63365){
$start = $this->timestamp();
$fp = fsockopen($domain, $v, $errno, $errstr, 2);
$finish = $this->timestamp();
$execute = ceil(($finish - $start) * 1000);
$service = array_search($v, $this->por);
if(!$fp){
$fp && fclose($fp);
array_push($res, array(0, $v, $this->typ[$service], ' Timeout '));
}else{
$fp && fclose($fp);
array_push($res, array(1, $v, $this->typ[$service], $execute));
}
}
}
return $res;
}
public function f($num = 0, $unit = "ms"){
$num = (float)$num;
if( $num <= 50 ) $color = "#008000";
elseif( $num <= 100 ) $color = "#00ff40";
elseif( $num <= 150 ) $color = "#0000ff";
elseif( $num <= 200 ) $color = "#fdab02";
elseif( $num <= 250 ) $color = "#ff6600";
elseif( $num <= 300 ) $color = "#ff0000";
else $color = "#ff0000";
return sprintf("<font color=\"%s\">%d %s</font>", $color, $num, $unit);
}
}
$Tools = new HccTools;
setcookie("HccToos", time(), time() + 2);
if( $_SERVER['REQUEST_METHOD'] === 'POST' ) {
$domain = isset( $_POST["domain"] ) && strlen( $_POST["domain"] ) > 0 ? $_POST["domain"] : "";
$domain = preg_replace("/\/(.*)$/is", "", preg_replace("/^(.*):\/\//is", "", $domain));
$port = isset( $_POST["port"] ) && strlen( $_POST["port"] ) > 0 ? $_POST["port"] : "";
$port = preg_replace("/[^\d|,]+/is", "", $port);
$port = rtrim($port, ",");
$port = explode(",", $port);
$port = array_filter($port);
$outhtml = '<table cellspacing="1"><tr><th colspan="5"><span>'. date('Y-m-d H:i:s') .'</span>扫描结果</th></tr><tr class="ite"><td width="10%">端口</td><td width="15%">服务</td><td width="20%">响应</td><td width="20%">状态</td><td width="35%">赞助商</td></tr>';
if(isset($_COOKIE["HccToos"])) $outhtml .= '<tr><td colspan="5" class="err">查询间隔时间太短,请稍后重试!</td></tr></table>';
else{
$st = $Tools->timestamp();
if( strlen($domain) > 3 && preg_match("/(.*)\.(.*)/is", $domain) ){
if(count($port) > 0){
if(in_array(strtok($domain, "."), $cfg["black"]["ip"]) || array_search($domain, $cfg["black"]["domain"])) $limit = '操作受限:该请求不允许查询.';
$port = array_filter( preg_replace( '/\D/', '', array_filter($port) ) );
sort($port);
shuffle($cfg["adsense"]);
$reslut = $Tools->c($domain, $port);
$length = count($reslut);
if($length > 0){
for($i = 0; $i < $length; $i++){
if($reslut[$i][0] == 1){
$reslut[$i][0] = '#ede1e3';
$reslut[$i][3] = $Tools->f($reslut[$i][3]);
$reslut[$i][4] = '<font color="#ff0000">开放</font>';
}else{
$reslut[$i][0] = "#f5faea";
$reslut[$i][3] = "";
$reslut[$i][4] = '<font color="#008000">关闭</font>';
}
$cfg["adsense"][$i] = isset($cfg["adsense"][$i]) ? $cfg["adsense"][$i] : "";
$outhtml .= "<tr style='background-color:{$reslut[$i][0]}'><td>{$reslut[$i][1]}</td><td>{$reslut[$i][2]}</td><td>{$reslut[$i][3]}</td><td>{$reslut[$i][4]}</td><td>{$cfg["adsense"][$i]}</td></tr>";
}
}
$et = $Tools->timestamp();
$rt = ceil(($et - $st) * 1000);
$outhtml .= '<tr><td colspan="5">共扫描 '. $domain .' 端口 '. $length .' 个, 耗时 '. $rt .' 毫秒!</td></tr></table>';
}else $outhtml .= '<tr><td colspan="5" class="err">无效端口</td></tr></table>';
}else $outhtml .= '<tr><td colspan="5" class="err">无交往的域名或IP</td></tr></table>';
}
}?><!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $cfg["site"]["name"];?></title>
<meta name="renderer" content="webkit" />
<meta http-equiv="cache-control" content="public" />
<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="theme-color" content="#616378" />
<meta name="document-state" content="static" />
<meta name="generator" content="HccTools v1.0.0" />
<meta itemprop="name" content="<?php echo $cfg["site"]["name"];?>" />
<meta itemprop="description" content="<?php echo $cfg["site"]["desc"];?>" />
<meta itemprop="image" content="//hechaocheng.cn/favicon.ico" />
<meta name="keywords" content="<?php echo $cfg["site"]["keys"];?>">
<meta name="description" content="<?php echo $cfg["site"]["desc"];?>">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<meta name="robots" content="index,follow,max-snippet:-1,max-image-preview:large,max-video-preview:-1" />
<link href="//hechaocheng.cn/favicon.ico" rel="bookmark" />
<link href="//hechaocheng.cn/favicon.ico" rel="shortcut icon" />
<link rel="stylesheet" type="text/css" href="HccTools/css/default.css"/>
<link rel="author" href="https://plus.google.com/109839096083180034412?rel=author" />
<link rel="dns-prefetch" href="https://css-js.mo.cloudinary.net/" />
<link rel="preconnect" href="https://css-js.mo.cloudinary.net/" />
<link rel="preload" as="script" href="https://css-js.mo.cloudinary.net/opensug.js" />
<base target="_blank">
</head>
<body>
<div class="wrapper">
<a target="_top" href="<?php echo $Tools->selfname;?>" title="<?php echo $cfg["site"]["name"];?>">
<div class="header">
<div><?php echo $cfg["site"][