Jump to content

Php port scan script


netpumber

Recommended Posts

hi!!

 

i have wrote this script.. as a port scanner:

<?php
ini_set("display_errors", 1);
$host = "www.site.com";
for($i=50;$i<6669;$i++) {
$fp = @fsockopen($host,$i,$errno,$errstr,10);
if($fp)
{
echo "port " . $i . " open on " . $host . "\n";
@fclose($fp);
}

flush();
} //end for
?>

 

It scans just for open ports in the hostname. I run it through console and it prints results but to slow.. Also if i runt through web browser doesnt seems to work.. Have you any idea on how to make it faster and work through browser ?

 

Thanks for any of your answer

Link to comment
https://forums.phpfreaks.com/topic/190847-php-port-scan-script/
Share on other sites

You have a 10 second timeout.  If the port is not open then you'll have to wait 10 seconds for it to time out and return (I think).  I'm guessing that's why it's so slow.

 

To speed it up, I'd fork child threads and have each thread check a pool of ports.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.