TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [TCLUG:7320] detect OS and web server
Attached is a perl script you can use to detect it.
----
Nate Carlson
the infinite loop
natecars@infiniteloop.com
On Tue, 3 Aug 1999, Ben Luey wrote:
> I lost the URL for the site that can detect what OS and web server a web
> site is running. Anyone have it?
>
> Thanks,
>
> Ben
>
> Ben Luey
> lueyb@carleton.edu
> ICQ: 19144397
>
> I'd a helluva lot rather have them talking about this than the fact the fact we
> are the party of the rich and that prices are high. This story is not helpful
> but, to the average guy, whether the Republicans bugged the Democrats doesn't
> mean a goddamned thing. It means something to intellectuals. It means something
> to people who are concerned about repression and credibility and all that
> bullshit. But the average guy is chewing his pretzel."
> -- Richard Nixon about Watergate.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tclug-list-unsubscribe@mn-linux.org
> For additional commands, e-mail: tclug-list-help@mn-linux.org
>
#!/usr/bin/perl
# query.pl - simple webserver/proxy version utility
# ./query.pl <hostname of webserver>
use Socket;
my($remote,$port,$iaddr,$paddr,$proto,$line);
$remote = $ARGV[0];
$port = "80";
unless ($remote) {
die "Usage:\nquery <hostname>\n\n";
}
$iaddr = inet_aton($remote) or die "Error: $!";
$paddr = sockaddr_in($port, $iaddr) or die "Error: $!";
$proto = getprotobyname('tcp') or die "Error: $!";
socket(SOCK, PF_INET, SOCK_STREAM, $proto) or die "Error: $!";
connect(SOCK, $paddr) or die "Error: $!";
$msg = "HEAD / HTTP/1.1 \n\n";
send(SOCK, $msg, 0) or die "Cannot send query: $!";
while ($hrm = <SOCK>) {
if ($hrm =~ /Server:/) {
$hrm =~ s/Server://;
print "$remote: $hrm";
}
}