home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / 01-portscan.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  947 b   |  30 lines

  1. <?php
  2. /** $Id: 01-portscan.php,v 1.2 2003/04/22 12:03:35 mj Exp $ */
  3. require_once "Net/Portscan.php";
  4.  
  5. /** Test for checkPort() and getService() */
  6. if (Net_Portscan::checkPort("localhost", 80) == NET_PORTSCAN_SERVICE_FOUND) {
  7.     echo "There is a service on your machine on port 80 (" . Net_Portscan::getService(80) . ").\n";
  8. }
  9.  
  10. /** Test for checkPortRange() */
  11. echo "Scanning localhost ports 70-90\n";
  12. $result = Net_Portscan::checkPortRange("localhost", 70, 90);
  13.  
  14. foreach ($result as $port => $element) {
  15.     echo "Port " . $port . ": ";
  16.     if ($element == NET_PORTSCAN_SERVICE_FOUND) {
  17.         echo " Service found.\n";
  18.     } else {
  19.         echo " No service found.\n";
  20.     }
  21. }
  22.  
  23. /** Test for getService() */
  24. echo "On port 22, there service " . Net_Portscan::getService(22) . " is running.\n";
  25.  
  26. /** Test for getPort() */
  27. echo "The finger service usually runs on port " . Net_Portscan::getPort("finger") . ".\n";
  28.  
  29. ?>
  30.