Commit | Line | Data |
---|---|---|
21c4e167 H |
1 | <?php |
2 | //Service checker | |
3 | //$search = "(linux|apache|debian|ubuntu|redhat)"; | |
4 | $search = "(microsoft|iis|windows)"; | |
5 | $port = 80; | |
6 | $timeout = 1; | |
7 | ||
8 | $stdin = fopen("php://stdin", "r"); | |
9 | function readline($echo="") { | |
10 | echo ($echo); | |
11 | return trim(fgets($GLOBALS["stdin"])); | |
12 | } | |
13 | ||
14 | function get_http_header($host, $port = 80, $timeout = 1) { | |
15 | $fp = pfsockopen($host, $port, $errno, $err, $timeout); | |
16 | $header = "GET / HTTP/1.1\n\n"; | |
17 | fwrite($fp, $header); | |
18 | $header = ""; | |
19 | while(!feof($fp) && $fp) { | |
20 | $line = fgets($fp); | |
21 | if (trim($line) == "") { break; } | |
22 | $header = $header.$line; | |
23 | } | |
24 | fclose($fp); | |
25 | return $header; | |
26 | } | |
27 | ||
28 | function get_banner($host, $port, $timeout = 1) { | |
29 | $fp = pfsockopen($host, $port, $errno, $err, $timeout); | |
30 | $header = "CAO-VOE\n\n"; | |
31 | fwrite($fp, $header); | |
32 | stream_set_blocking($fp, 0); | |
33 | return(fgets($fp)); | |
34 | } | |
35 | ||
36 | //die(get_http_header('server00.skola')); //Debug | |
37 | //die(get_banner('pernicek.mooo.com', $port)); //Debug | |
38 | ||
39 | error_reporting(0); //Vypneme vypis chyb | |
40 | while(!feof($stdin) && $stdin) { | |
41 | while(!feof($stdin) && $stdin) { | |
42 | $host = readline(); //Nacteme url | |
43 | if($port == 80 || $port == 8080 || $port == 443) { | |
44 | $header = get_http_header($host, $port, $timeout); | |
45 | } else { | |
46 | $header = get_banner($host, $port, $timeout); | |
47 | } | |
48 | //echo("$header\n"); //Debug | |
49 | if ( eregi($search, $header) ) { | |
50 | echo("\t!Match: $host:$port\r\n$header\n\n"); | |
51 | } | |
52 | //echo($header); //debug | |
53 | } |