0

我在这里阅读了这篇文章 测试端口是否打开并使用 PHP 转发

关于如何扫描同一代理的端口。但我的问题是我想扫描不同 ip xxx.xxx.xxx.$i 的同一个端口,for loop 我尝试从 0 到 255 运行它。我在上面提到的帖子中使用了相同的脚本 for loop 。但是得到答案需要太长时间(实际上我没有得到任何答案)。这是代码

for($i=0;$i<2;$i++){
$host = 'xxx.xxx.xxx.'.$i;
  $connection = @fsockopen($host, 3128);

if (is_resource($connection))
{
    echo '<h2>' . $host . ':' . $port . ' ' . '(' . getservbyport($port, 'tcp') . ') is open.</h2>' . "\n";

    fclose($connection);
}

else
{
    echo '<h2>' . $host . ':' . $port . ' is not responding.</h2>' . "\n";
}

}

4

0 回答 0