Scan a server : fsockopen « File Directory « PHP






Scan a server

 
<?php
   ini_set("max_execution_time", 120);

   $rangeStart = 0;
   $rangeStop = 1024;

   $target = "www.example.com";
   
   $range =range($rangeStart, $rangeStop);

   echo "<p>Scan results for $target</p>";

   foreach ($range as $port) {
      $result = @fsockopen($target, $port,$errno,$errstr,1);
      if ($result) echo "<p>Socket open at port $port</p>";
   }

?>
  
  








Related examples in the same category

1.Outputting the Status Lines Returned by Web Servers
2.fsockopen() function establishes a socket connection, TCP or UDP.
3.fsockopen.php
4.SSL Streams
5.Sockets Are Files
6.Retrieving a Web Page Using fsockopen()