home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / src / PHP / webserverspy.php3.txt < prev    next >
Encoding:
Text File  |  2002-05-06  |  2.3 KB  |  75 lines

  1. WebServerSpy 
  2.  
  3. WebServerSpy checks which kind of Webserver is running (via HTTP 1.0 Server-Header) 
  4.  
  5.  
  6. <?PHP 
  7. /* 
  8.  * Function WebServerSpy created to check, which kind of WebServer is 
  9.  * running (e.g. NS Fasttrack, Apache etc.). 
  10.  * 
  11.  * (c) 1999 by: Bernhard Ostheimer (bernhard.ostheimer@uni-mainz.de) 
  12.  * 
  13.  * View Example @ http://service.wiwi.uni-mainz.de/~ostheimer/php/webserverspy/ 
  14.  * 
  15.  * Permission to use and modify this software and its  
  16.  * documentation for any purpose other than its incorporation  
  17.  * into a commercial product is hereby granted without fee,  
  18.  * as long as the author is notified that this piece of software  
  19.  * is being used in other applications.  
  20.  * Permission to copy and distribute this software and its  
  21.  * documentation only for non-commercial use is also granted  
  22.  * without fee, provided, however, that the above copyright  
  23.  * notice appear in all copies, that both that copyright notice  
  24.  * and this permission notice appear in supporting documentation.  
  25.  * The author makes no representations about the suitability  
  26.  * of this software for any purpose.  It is provided ''as is'',  
  27.  * without express or implied warranty.  
  28.  */ 
  29.  
  30. function WebServerSpy($ServerURL)  
  31.   $filepointer = fsockopen($ServerURL,80,&$errno,&$errstr); 
  32.   if(!$filepointer)  
  33.   { 
  34.     $WebServer= "Error: $errstr ($errno)<br>\n"; 
  35.   }  
  36.   else  
  37.   { 
  38.     fputs($filepointer, "GET / HTTP/1.0\n\n"); 
  39.     while(!feof($filepointer))  
  40.     { 
  41.       $WebServer=fgets($filepointer,4096); 
  42.       if (ereg( "^Server:",$WebServer))  
  43.       { 
  44.         $WebServer=trim(ereg_replace( "^Server:", "",$WebServer)); 
  45.         break; 
  46.       } 
  47.     } 
  48.     fclose($filepointer); 
  49.   } 
  50.   return($WebServer); 
  51. ?> 
  52. <?PHP  /**************** Example *******************/ 
  53. if ($ServerURL<> "") { $WebServer=WebServerSpy($ServerURL); } 
  54. ?> 
  55. <HTML> 
  56. <HEAD> 
  57. <TITLE>Ostis WebServer Spy</TITLE> 
  58. </HEAD> 
  59. <BODY> 
  60. <?PHP  
  61. if ($WebServer<> "" and $ServerURL<> "")  
  62.   echo( "<PRE>Server $ServerURL is running $WebServer.</PRE>"); 
  63. ?> 
  64. <FORM ACTION=" <?PHP echo($PHP_SELF); ?>" METHOD="post"> 
  65.   http:// <INPUT TYPE="text" NAME="ServerURL" SIZE="40" MAXLENGTH="100"> 
  66.   <INPUT TYPE=hidden NAME="WebServer" VALUE=""> 
  67.   <INPUT TYPE=submit VALUE="Spy this Server!"><INPUT TYPE=reset VALUE="Reset"> 
  68. </FORM> 
  69. </BODY> 
  70. </HTML>
  71.