___________.__ _____ .__ .__ .__ __
\__ ___/| |__ ____ / _ \ | | ____ | |__ ____ _____ |__| _______/ |_
| | | | \ _/ __ \ / /_\ \ | | _/ ___\ | | \ _/ __ \ / \ | | / ___/\ __\
| | | Y \\ ___/ / | \| |__\ \___ | Y \\ ___/ | Y Y \| | \___ \ | |
|____| |___| / \___ > \____|__ /|____/ \___ >|___| / \___ >|__|_| /|__|/____ > |__|
\/ \/ \/ \/ \/ \/ \/ \/
Port Scanner
= 65536)
{
$upper = 65535;
}
$numberof = ($upper - $lower) + 1; //number of parallel requests
$ar = range($lower,$upper); //putting all the ports in an array
for($i=0 ; $i < $numberof ; $i++)
{
$ch[$i] = curl_init($target);
curl_setopt($ch[$i], CURLOPT_PORT, $ar[$i]);
curl_setopt($ch[$i], CURLOPT_RETURNTRANSFER, true);
}
$mh = curl_multi_init();
// Thanks to PeopleUnderTheStairs for the idea of using multi cURL
for($i=0 ; $i < $numberof ; $i++)
{
curl_multi_add_handle($mh,$ch[$i]);
}
$running = NULL;
do
{
curl_multi_exec($mh,$running);
}while($running);
for($i = 0 ; $i < $numberof ; $i++)
{
if(!curl_error($ch[$i]))
{
$flag = 1;
echo '
Port '.$ar[$i].' is open';
}
curl_multi_remove_handle($mh,$ch[$i]);
curl_close($ch[$i]);
}
curl_multi_close($mh); //All the curl handlers and multi curl handlers are closed
if($flag == 0)
{
echo '
No open ports found between '.$lower.' and '.$upper.'';
}
}
?>