#!/usr/bin/perl
#
# Psuedo spoofing Web Server + OS checking utility.
#
# Author: Cody Tubbs (loophole of hhp).
# Site:   www.hhp-programming.net
# Email:  pigspigs@yahoo.com
# Date:   12/17/2000
#
# This little utility will use a public service to check the
# web  server version and operating system of a remote host.
# Totally legal, totally with their hostname. :D
#
# (NOTE: I found this service via checking through our web server logs.)
# 195.92.95.15 - - [17/Dec/2000:15:17:47 -0500] "HEAD / HTTP/1.1" 200 0 "-" "-"
# We now block 195.92.95.0/24, Thank you, time out and come again. :D

use IO::Socket;
($host)=(@ARGV) or die "Usage: $0 <Server>\n";
$site="uptime.netcraft.com";
$grab="/up/graph/?host=$host";
$count=0;
$sock=IO::Socket::INET->new(PeerAddr=>$site,PeerPort=>"80",Proto=>"tcp")
    or die "Can't connect with psuedo spoof service, try again later\n";
print $sock "GET $grab\n";
while(<$sock>){
 $count++;
 if(/not process your requested site,\. The error was:/){
   $heh=$count;
   print "$host: ERROR: ";
  }
 if(/(.*) <p>/){
  $heh++;
  if($count==$heh){
   if($1=~/\s{1,}(.*)/){print "$1\n";}else{print "$1\n";}
  }
 }
 if(/The site <a href=".*\/">(.*)<\/a> runs <b>(.*)<\/b> on <b>(.*)<\/b>$/){
  print "$1: $2: $3\n";
  exit 0;
 }
}

