netpumber Posted February 3, 2010 Share Posted February 3, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/190847-php-port-scan-script/ Share on other sites More sharing options...
roopurt18 Posted February 3, 2010 Share Posted February 3, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/190847-php-port-scan-script/#findComment-1006434 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.