Hello everybody.
I have made a TCP-portscanner for my visitors, and try to implement UDP-scan.
The TCP-scanner works perfectly, but with UDP, the scanner shows all ports as open (or closed with some modification).
I can not get the scanner to different between open and closed UDP-ports.
Does anybody have a good idea to get the UDP-scanner working?
Here are simplified codes:
.................................................................................
if ($val["name"] == "TCP")
{
$handle = @fsockopen($host, $val["port"], $errno, $errstr, $timeout);
if ($handle)
{
echo "Open";
fclose($handle);
}
else
{
echo "Closed";
}
flush();
}
.................................................................................
if ($val["name"] == "UDP")
{
$fp = @fsockopen("udp://$host", $val["port"]);
if ($fp)
{
socket_set_timeout ($fp, 3);
$write = fwrite($fp, "\x00");
$startTime = time();
$header = fread($fp, 3);
$endTime = time();
$timeDiff = $endTime - $startTime;
if ($timeDiff >= 3) {
{
echo "Open"
fclose($handle);
}
else
{
echo "Closed";
}
}
else
{
echo "Closed";
}
flush();
}
.................................................................................
Best wishes from esp