#!/local/bin/perl5 ############################################################################## # $Id: whois.txt,v 1.1 2003/03/28 23:48:29 xwolf Exp $ # # COPYRIGHT NOTICE # # Copyright 1999 Wolfgang Wiese All Rights Reserved. # # EMail: xwolf@xwolf.com # # URL : http://www.xwolf.com # # # # This script may be used and modified free of charge by anyone so long as # # this copyright notice and the comments above remain intact. By using this # # code you agree to indemnify Wolfgang Wiese from any liability that # # might arise from it's use. # # # # Selling the code for this program without prior written consent is # # expressly forbidden. In other words, please ask first before you try and # # make money off of my program. # # # # Obtain permission before redistributing this software over the Internet or # # in any other medium. In all cases copyright and header must remain intact.# ############################################################################## # Last Modified on: $Date: 2003/03/28 23:48:29 $ # By: $Author: xwolf $ # Version: $Revision: 1.1 $ ############################################################################## use strict; require "getopts.pl"; my @LISTE; my %NICKSERVER = ( "de", "whois.denic.de", "com", "whois.networksolutions.com", "net", "whois.networksolutions.com", "org", "whois.networksolutions.com", "edu", "whois.networksolutions.com", ); my $WHOISPROG = "/usr/bin/whois"; ############################################################################## # Main program starts after this point. Change only if you know what to do. ############################################################################## if (not $ARGV[0]) { print "Syntax: $0 [Domainame.TLD | Dateiname]\n"; exit; } if (-r $ARGV[0]) { @LISTE = &ReadFile($ARGV[0]); my $i; for ($i=0; $i<=$#LISTE; $i++) { sleep(1); &GetUrlData($LISTE[$i]); } } else { &GetUrlData($ARGV[0]); } exit(0); ############################################################################## # Subroutinen ############################################################################## sub GetUrlData { my $url = shift; my $whois; my @parts = split(/\./,$url); my $tld = pop(@parts); my $sld = pop(@parts); my $unbelegt; my $host = "$sld.$tld"; my $server = $NICKSERVER{$tld} || "whois.ripe.net"; my $key; my $l; my $startperson; my $val; my $found_border; my $already; print "[$url]\n"; # print STDERR "\tQuerying server \"$server\"\n"; my @whois = `whois -h $server $host`; for ($l=0; $l<=$#whois; $l++) { # if ($whois[$l] =~ /^%/) { if ($whois[$l]=~ /No entries/) { $unbelegt =1; } # } } if (not $unbelegt) { if ($server =~ /denic/) { for ($l=0; $l<=$#whois; $l++) { next if ($whois[$l] =~ /^%/); if ($whois[$l] =~ /^\s+/) { $found_border =1; } else { $found_border =0; } ($key, $val) = split(/:\s+/,$whois[$l],2); if (($key =~ /^person/i) && (not $already)) { $startperson = 1; print "\t$whois[$l]"; } elsif ($startperson) { if ($found_border) { $already =1; $startperson =0; } else { print "\t$whois[$l]"; } } } } elsif ($server =~ /networksolutions/) { for ($l=0; $l<=$#whois; $l++) { if ($whois[$l] =~ /\s*Administrative Contact/) { $found_border =1; } elsif ($found_border) { if ($whois[$l] =~ /\s*Technical Contact/) { $found_border =0; } elsif ($whois[$l] =~ /^[\s*]$/) { $found_border =0; } else { print "$whois[$l]"; } } } } } else { print "No entry for domain $host found.\n"; } print "\n"; } ############################################################################## sub ReadFile { my $file = shift; my @result; open(f1,"$file") || die("Cannot read $file\n"); while() { chomp($_); if (($_) && ($_ !~ /^\s*#/)) { push(@result, $_); } } close f1; return @result; } ############################################################################## # EOF ##############################################################################