这可能是重复的帖子,但我没有看到任何正确解决此问题的答案。
我正在尝试找到一个可以正确确定 TCP 或 UDP 端口状态的 php 脚本。
我已经尝试了一些我在网上找到的方法,但它们都返回了错误的结果。EG:在我的本地网络上,我打开了端口 5000 UDP 和 5060 TCP/UDP 并正确路由。
如果我通过http://www.ipfingerprints.com/portscan.php或 GRC Shields Up 运行测试,则会返回正确的结果,但我尝试过的所有 PHP 脚本都失败并显示端口已关闭。
我正在通过我的托管帐户运行 php 脚本并尝试扫描和测试我自己的网络。
这是我尝试过的脚本之一:
<html>
<head>
<?php echo "<title>Port Scanning " . $_GET['host'] . "</title>"; ?>
</head>
<body>
<?php
ini_set('display_errors', 0);
if(isset($_GET['host']) == true)
$host = $_GET['host'];
else
{
echo "You didn't set the host parameter";
die();
}
if(isset($_GET['sport']) == true)
$sport = $_GET['sport'];
else
{
echo "You didn't set the sport parameter";
die();
}
if(isset($_GET['eport']) == true)
$eport = $_GET['eport'];
else
{
echo "You didn't set the eport parameter";
die();
}
if($sport > $eport)
{
$sport = $eport;
}
$scanned = 0;
$openports = 0;
$maxports = 1;
$totalports = ($eport - $sport) + 1;
$mins = floor(($totalports / 10) / 60);
$secs = ($totalports / 10) - $mins * 60;
echo "<font color=\"blue\">Scanning " . $totalports . " ports on " . $host . ", this should take around " . $mins . " minute(s) and " . $secs . " second(s), probably more depending on local website load, hardware, and other factors.<br/><br/></font>";
flush();
do
{
if($scanned >= $maxports && $maxports != 0)
{
echo "<font color=\"darkgreen\" size=\"4\">Scan limit of " . $maxports . " ports reached, scanning stopped.</font><br/><br/><font color=\"darkred\" size=\"4\">Scanner written by Samo502</font>";
flush();
die();
}
if(fsockopen($host, $sport, $errorno, $errorstr, 0.1))
{
echo "<font color=\"darkgreen\">Port " . $sport . " is open on " . $host . "</font><br/>";
$openports++;
flush();
}
else
{
echo "<font color=\"red\">Port " . $sport . " is not open on " . $host . "</font><br/>";
flush();
}
$scanned++;
$sport++;
} while($sport <= $eport);
echo "<br/><font color=\"blue\">Done, " . $openports . " out of " . $totalports . " ports are open.</font><br/><br/><br/><font color=\"darkred\" size=\"4\">Scanner written by Samo502</font>";
die();
?>
</body>
</html>
有谁知道正确执行此操作的方法?
谢谢
**更新** 我发现这似乎工作得更好一些,但它仍然没有检测到端口 21 目前在我的网络上打开..
http://resources.infosecinstitute.com/php-build-your-own-mini-port-scanner-2/
感激地收到任何帮助。谢谢