#!/bin/bash # version of script VER="wlofie/w0nderer whois script 0.1 ALPHA:2003-07-15:w0nderers_delight at yahoo dot com" #check commandline for 1 argument, else printout error and exit with error test "${1}" = "" && echo -e "usage is $0 domain2lookup.tld\n\n" && exit 1 #the version of whois you use, needs to accept -h whois.server syntax WH="/usr/bin/whois" # capitalize the searched for domain if it's not capped (short records demand CAPS domain) CAPDOMAIN=`echo $1 | sed y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/` #do some filtering here for .org .info .mit .biz .tv .il if test `echo $1 |tail -c 4` = "org" then WHOISSERVER=whois.pir.org #info to user echo ".org matched, switching to alternate whois $WHOISSERVER for first whois cycle" #lookup the refer server WHOISREF=$(echo `$WH $CAPDOMAIN -h $WHOISSERVER|grep 'Whois Server:' |tail -n 1 |cut -f 3 -d':'` |dos2unix |sed s/'$'/""/g) #do the second sweep echo "doing the second whois against $WHOISREF for $1" $WH $1 -h $WHOISREF elif test `echo $1|tail -c 5` = "info" then WHOISSERVER=whois.afilias.info WHOISREF=$WHOISSERVER #set WHOISREF to make debugging output properly echo "info matched, switching to alternate whois $WHOISSERVER for _only_ cycle" $WH $1 -h $WHOISSERVER elif test "$2" = "-mit" then WHOISSERVER=whois.melbourneit.com WHOISREF=$WHOISSERVER #switch to let debug output something for WHOISREF echo -e "-mit commandline arg matched\n switching to alternate whois $WHOISSERVER for whois cycle" $WH $1 -h $WHOISSERVER elif test `echo $1|tail -c 4` = "biz" then WHOISSERVER=whois.whois.biz WHOISREF=$WHOISSERVER #switch to let debug print it out echo ".biz matched, switching to alternate whois $WHOISSERVER for _only_ whois cycle" $WH $1 -h $WHOISSERVER elif test `echo $1|tail -c 3` = "tv" then WHOISSERVER=whois.www.tv WHOISREF=$WHOISSERVER # switch to let debug do something echo "info matched, switching to alternate whois $WHOISSERVER for first whois cycle" $WH $1 -h $WHOISSERVER elif test `echo $1|tail -c 3` = "il" then WHOISSERVER=whois.isoc.org.il WHOISREF=$WHOISSERVER #set WHOISREF to allow debug info echo "info matched, switching to alternate whois $WHOISSERVER for first whois cycle" $WH $1 -h $WHOISSERVER else #THIS BLOCK is COMPLETED-WORKING WHOISSERVER=whois.crsnic.net echo "no weirdo's detected, using normal whois: $WHOISSERVER for first sweep" # do the first whois, asking what whois server to use to look up the domain, #filter that out and put it into WHOISREF variable WHOISREF=`$WH -h $WHOISSERVER =$1 |grep $CAPDOMAIN'$' -A 12 | grep 'Whois Server' |cut -c 17-50` #second and final whois, using the above referance as whois host #and notify user what we are doing echo "Doing Second whois against $WHOISREF looking for $1" $WH $1 -h $WHOISREF fi #debugging information function below--COMPLETED-WORKING function extrainfo { echo "-----------------------------------------------------" echo "$VER" echo "---------info on whois searches just run-------------" echo "first whois (to get referance) was against: "$WHOISSERVER echo "second whois (to get info) was against: "$WHOISREF echo "domain name CAPITALIZED : "$CAPDOMAIN echo "domain (arg \$1) to get info on : "$1 echo "-------------------------------------------------------" #exit with 'success' status exit 0 } #comment out "extrainfo" if you don't want that info extrainfo $1 #exit with success exit 0