<?php
$subnet = "192.168.3.";
$ports = [
21, 22, 23, 25, 53, 80, 110, 111,
135, 139, 143, 389, 443, 445, 587,
631, 636, 8000, 8080, 8443, 3306,
3389, 5357, 5900, 8009
];
$timeout = 0.3;
$total = 254 * count($ports);
$current = 0;
function progress($current, $total) {
$p = round(($current / $total) * 100, 2);
echo "\r[ $p% ] scanning...";
}
for ($h = 1; $h <= 254; $h++) {
$host = $subnet . $h;
foreach ($ports as $port) {
$current++;
progress($current, $total);
$fp = @fsockopen($host, $port, $errno, $errstr, $timeout);
if ($fp) {
stream_set_timeout($fp, 1);
$banner = @fread($fp, 2048);
fclose($fp);
echo "\nOPEN $host:$port";
if ($banner && strlen(trim($banner)) > 0) {
$banner = trim($banner);
echo " | Banner: " . substr($banner, 0, 200);
}
echo "\n";
}
}
}
echo "\nDone.\n";