UtamaBeritaTutorialBlogTool

Port Scanner in PHP

Posted By: zainal on February, 05 2007

This is a very basic port scanner in PHP.

for($port = $from; $port <= $to; $port++)
{
$fp = fsockopen(”$host”, $port);
if ($fp)
{
print(”port $port opened \r”);
fclose($fp);
}






4 Comments so far

  1. Arthur Dittrich on March 25th, 2008

    Can someone implement a simple solution for UDP in this code ?

  2. joe velez on June 6th, 2008

    for UDP just make $host contain the request type in the format udp://IP

  3. Nash on July 1st, 2011

    brilliant!

  4. BinaryTides on October 24th, 2011

    For udp you cannot do udp://IP simply. It will show all ports as open. UDP port scanning requires a different approach.


Leave a reply

= Please answer this math (required)