#!/usr/local/bin/perl # Autogenerated block to include site configuration # generated on Tue Mar 21 19:42:47 PST 2000 BEGIN { %::RIPEConfig = ( VERSION => q#3.0.0b2#, LIBDIR => q#/home/david/db/src//lib#, DEFCONFIG => q#/home/david/db/src//etc/ripedb.config#, WHOISHOST => q#whois.6bone.net#, ); # Add library path unless running from source directory use FindBin; if ($FindBin::Bin =~ m#/src$#) { unshift @INC, $FindBin::Bin; $::RIPEConfig{DEFCONFIG}=$FindBin::Bin."/../etc/ripedb.config"; } else { unshift @INC, $::RIPEConfig{LIBDIR}; } # Select DBM package other then the default one use Fcntl; use DB_File; $DBMPACKAGE="DB_File"; } # End of autogenerated block #line 1 #line 0 whois.pl # $RCSfile: whois.pl,v $ # $Revision: 1.1.1.1 $ # $Author: eddy $ # $Date: 1997/10/27 20:13:45 $ # Original code is written by various authors # Copyright (c) 1993, 1994, 1995, 1996, 1997 The TERENA Association # Copyright (c) 1998 RIPE NCC # # All Rights Reserved # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, # provided that the above copyright notice appear in all copies and that # both that copyright notice and this permission notice appear in # supporting documentation, and that the name of the author not be # used in advertising or publicity pertaining to distribution of the # software without specific, written prior permission. # # THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING # ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL # AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN # AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # Copyright (c) 1997,1998 by the University of Southern California # All rights reserved. # # Permission to use, copy, modify, and distribute this software and its # documentation in source and binary forms for lawful non-commercial # purposes and without fee is hereby granted, provided that the above # copyright notice appear in all copies and that both the copyright # notice and this permission notice appear in supporting documentation, # and that any documentation, advertising materials, and other materials # related to such distribution and use acknowledge that the software was # developed by the University of Southern California, Information # Sciences Institute. The name of the USC may not be used to endorse or # promote products derived from this software without specific prior # written permission. # # THE UNIVERSITY OF SOUTHERN CALIFORNIA DOES NOT MAKE ANY # REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY # PURPOSE. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, # TITLE, AND NON-INFRINGEMENT. # # IN NO EVENT SHALL USC, OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY # SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, WHETHER IN CONTRACT, TORT, # OR OTHER FORM OF ACTION, ARISING OUT OF OR IN CONNECTION WITH, THE USE # OR PERFORMANCE OF THIS SOFTWARE. # # Copyright (c) 1998, 1999 by Qwest Communications International # All rights reserved. # # Permission to use, copy, modify, and distribute this software and its # documentation in source and binary forms for lawful non-commercial # purposes and without fee is hereby granted, provided that the above # copyright notice appear in all copies and that both the copyright # notice and this permission notice appear in supporting documentation, # and that any documentation, advertising materials, and other materials # related to such distribution and use acknowledge that the software was # developed by Qwest Communications International. The name of Qwest # Communications International may not be used to endorse or # promote products derived from this software without specific prior # written permission. # # Qwest Communications International DOES NOT MAKE ANY # REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY # PURPOSE. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, # TITLE, AND NON-INFRINGEMENT. # # IN NO EVENT SHALL Qwest Communications International OR ANY OTHER # CONTRIBUTOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL # DAMAGES, WHETHER IN CONTRACT, TORT, OR OTHER FORM OF ACTION, ARISING # OUT OF OR IN CONNECTION WITH, THE USE OR PERFORMANCE OF THIS SOFTWARE. # # Author(s): David Kessens # This is a very simple whois client, but it knows the new server arguments require "getopts.pl"; # # The file 'whoisqry.pl' is included here # #line 0 whoisqry.pl # $RCSfile: whoisqry.pl,v $ # $Revision: 1.1.1.1 $ # $Author: eddy $ # $Date: 1997/10/27 20:13:49 $ # Original code is written by David Kessens # Copyright (c) 1993, 1994, 1995, 1996, 1997 The TERENA Association # Copyright (c) 1998 RIPE NCC # # All Rights Reserved # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, # provided that the above copyright notice appear in all copies and that # both that copyright notice and this permission notice appear in # supporting documentation, and that the name of the author not be # used in advertising or publicity pertaining to distribution of the # software without specific, written prior permission. # # THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING # ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL # AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN # AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # Copyright (c) 1997,1998 by the University of Southern California # All rights reserved. # # Permission to use, copy, modify, and distribute this software and its # documentation in source and binary forms for lawful non-commercial # purposes and without fee is hereby granted, provided that the above # copyright notice appear in all copies and that both the copyright # notice and this permission notice appear in supporting documentation, # and that any documentation, advertising materials, and other materials # related to such distribution and use acknowledge that the software was # developed by the University of Southern California, Information # Sciences Institute. The name of the USC may not be used to endorse or # promote products derived from this software without specific prior # written permission. # # THE UNIVERSITY OF SOUTHERN CALIFORNIA DOES NOT MAKE ANY # REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY # PURPOSE. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, # TITLE, AND NON-INFRINGEMENT. # # IN NO EVENT SHALL USC, OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY # SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, WHETHER IN CONTRACT, TORT, # OR OTHER FORM OF ACTION, ARISING OUT OF OR IN CONNECTION WITH, THE USE # OR PERFORMANCE OF THIS SOFTWARE. # # Copyright (c) 1998, 1999 by Qwest Communications International # All rights reserved. # # Permission to use, copy, modify, and distribute this software and its # documentation in source and binary forms for lawful non-commercial # purposes and without fee is hereby granted, provided that the above # copyright notice appear in all copies and that both the copyright # notice and this permission notice appear in supporting documentation, # and that any documentation, advertising materials, and other materials # related to such distribution and use acknowledge that the software was # developed by Qwest Communications International. The name of Qwest # Communications International may not be used to endorse or # promote products derived from this software without specific prior # written permission. # # Qwest Communications International DOES NOT MAKE ANY # REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY # PURPOSE. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, # TITLE, AND NON-INFRINGEMENT. # # IN NO EVENT SHALL Qwest Communications International OR ANY OTHER # CONTRIBUTOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL # DAMAGES, WHETHER IN CONTRACT, TORT, OR OTHER FORM OF ACTION, ARISING # OUT OF OR IN CONNECTION WITH, THE USE OR PERFORMANCE OF THIS SOFTWARE. # # Author(s): David Kessens # This is a very simple whois client module use sigtrap; use Socket; sub getwhoisportandproto { local($port)=@_; local($name,$aliases,$proto); if ($port=~ /^\d+$/) { $proto=getprotobyname('tcp'); } else { ($name,$aliases,$port,$proto)=getservbyname("whois", "tcp"); die "cannot find portnumber for \'whois\' service" if (!$port); #print STDERR "-$port-$proto-"; } ($name,$aliases,$proto)=getprotobyname($proto); return ($port,$proto); } sub initwhoisqry { local($host, $port, $string)=@_; local($proto,$address); local($socket)="WHOIS_S"; if ($host=~ /^\s*\d+\.\d+\.\d+\.\d+\s*$/) { $address=pack("C4",split(/\./,$host)); } else { $address=(gethostbyname($host))[4]; } # find valid port and protocol number for whois service #print "*$port*\n"; ($port,$proto)=&getwhoisportandproto($port); # # connect socket($socket, PF_INET, SOCK_STREAM, $proto) || return("", "socket creation failed"); if (connect($socket, sockaddr_in ($port, $address))) { # # no buffering local($oldhandle)=select($socket); $| = 1; select($oldhandle); # # print options print $socket $string, "\n"; } else { return ("", "Connect to host: $host port: $port failed"); } return ($socket, ""); } 1; # # End of included 'whoisqry.pl' data is here # #line 91 whois.pl &Getopts('abeFg:h:i:lKLmMo:p:rRs:St:T:uv:'); if ((!@ARGV) && (!$opt_t) && (!$opt_v) && (!$opt_g) && (!$opt_l)) { print <<"EOF"; Usage: whois [-aceFlKLmMrRu] [-h hostname|hostnamealias] [-s sources] [-T types] [-i attrs] [-o attrs] keys whois -b whois -[tv] type Where: -a search all databases -b show builtin list of aliases for common whois servers -c show \'changed:\' attribute lines -l don't do default less specific lookups for IP number and IP prefix lookups -e expand objects that contain macro definitions (not implemented yet) -F RIPE [12].x backwards compatibility mode -h hostname search alternate server Default - $::RIPEConfig{WHOISHOST} -i attr[[,attr] ... ] do an inverse lookup for specified attributes -K do PGP key lookup (RADB only) -l do an exact match instead of default less specific -L find all Less specific matches -m find first level more specific matches -M find all More specific matches -o attr[[,attr] ... ] only show attributes in list -p port port to connect to -r turn off recursive lookups -R turn off external recursive lookups -s source[[,source] ... ] search databases with source 'source' -t type requests template for object of type 'type' -T type[[,type] ... ] only look for objects of type 'type' -u treat keys as a unique key, use tab as separator -v type requests verbose template for object of type 'type' Please note that most of these flags are NOT understood by non RIPE whois servers EOF exit(0); } local(%WHOISTABLE)=("internic", "whois.internic.net", "com", "whois.internic.net", "net", "whois.internic.net", "org", "whois.internic.net", "edu", "whois.internic.net", "arin", "whois.arin.net", "radb", "whois.ra.net", "mci", "whois.mci.net", "6bone", "whois.6bone.net", "ripe", "whois.ripe.net", "apnic", "whois.apnic.net", "connect", "whois.connect.com.au", "aunic", "whois.aunic.net", "au", "whois.aunic.net" ); if ($opt_b) { print "\nInternally configured whois servers:\n\n"; foreach (keys %WHOISTABLE) { print $_, " - ", $WHOISTABLE{$_}, "\n"; } print "\n"; exit; } $opt_h=$WHOISTABLE{$opt_h} if (defined($WHOISTABLE{$opt_h})); $opt_h=$::RIPEConfig{WHOISHOST} if (!$opt_h); if ($opt_L) { print STDERR "whois: warning -L overrides -m\n" if $opt_m; print STDERR "whois: warning -L overrides -M\n" if $opt_M; $opt_m = 0; $opt_M = 0; } if ($opt_m) { print STDERR "whois: warning -m overrides -M\n" if $opt_M; $opt_M = 0; } local($query)=""; $query.="-a " if ($opt_a); $query.="-c " if ($opt_c); $query.="-e " if ($opt_e); # # undocumented option, get specified updates: # # -g Source:First-Last get updates with 'Source' from # serial 'First' till 'Last' (you may use LAST) $query.="-g ".$opt_g." " if ($opt_g); $query.="-F " if ($opt_F); $query.="-i ".$opt_i." " if ($opt_i); $query.="-K " if ($opt_K); $query.="-l " if ($opt_l); $query.="-L " if ($opt_L); $query.="-m " if ($opt_m); $query.="-M " if ($opt_M); $query.="-o ".$opt_o." " if ($opt_o); $query.="-r " if ($opt_r); $query.="-R " if ($opt_R); $query.="-s ".$opt_s." " if ($opt_s); $query.="-t ".$opt_t." " if ($opt_t); $query.="-T ".$opt_T." " if ($opt_T); $query.="-u " if ($opt_u); $query.="-v ".$opt_v." " if ($opt_v); # # tell the server what version of RIPE whois we are running, # but only if we are sure that we are talking to an # RIPE whois server if (($opt_h=~ /(ripe\.net|apnic\.net|mci\.net|isi\.edu|rs\.net|6bone\.net|garr\.it|ans\.net|aunic\.net|connect\.com\.au)$/i) || $opt_a || $opt_c || $opt_l || $opt_e || $opt_g || $opt_F || $opt_i || $opt_m || $opt_M || $opt_L || $opt_o || $opt_r || $opt_R || $opt_s || $opt_t || $opt_T || $opt_u || $opt_v) { # a space after -V is the new syntax if ($opt_h=~ /(ripe\.net|isi\.edu|6bone\.net|rs\.net|aunic\.net|connect\.com\.au)$/) { $query.="-V wp3.0 "; } else { $query.="-Vwp3.0 "; } } $query.=join(" ",@ARGV); # # exit cleanly when asked to ... sub quitconnection { close($socket); print "\nConnection closed.\n"; exit; } $SIG{'HUP'}='quitconnection'; $SIG{'INT'}='quitconnection'; $SIG{'KILL'}='quitconnection'; $SIG{'TERM'}='quitconnection'; local(@referrals)=($query); local($socket,$msg); local($newlines); local($counter)=0; while (@referrals) { $counter++; if ($counter>30) { print STDERR "\nCannot resolve more then 30 referrals\nThere was possibly a referral loop\n\n"; print "\n"; print "\n" if (!$newlines); exit 1; } #print "try: ", @referrals, "\n"; $query=shift(@referrals); if ($query=~ s/^\%\s*referto\s*:\s*whois\s+\-h\s*(\S+)\s+\-p\s*(\S+)\s*//i) { $opt_h=$1; $opt_p=$2; $query=~ s/\s+$//; # print "fsdf: ",$1,$2,$opt_h, $opt_p, " - ", $query,"\n"; } ($socket,$msg)=&initwhoisqry($opt_h,$opt_p?$opt_p:"",$query); if (!$socket) { print STDERR $msg, "\n\n"; exit 1; } $newlines=0; while (defined($_=<$socket>)) { if (/^\%\s*referto\s*\:/) { push(@referrals, $_); # print "ref:", @referrals, "\n"; } else { if (/^\s*$/) { $newlines++; print if ($newlines<=1); } else { $newlines=0; print; } } } close($socket); } print "\n"; print "\n" if (!$newlines); # end of program