Skip to content

Instantly share code, notes, and snippets.

@kolobus
Created February 12, 2014 22:22
Show Gist options
  • Save kolobus/8965748 to your computer and use it in GitHub Desktop.
Save kolobus/8965748 to your computer and use it in GitHub Desktop.
Get list of all active TLD's w/whois server
#!/bin/bash
# 1
wget -qO root.zone http://www.internic.net/domain/root.zone
# 2
cat root.zone | grep "IN\sNS" | awk '{print $1}' | uniq | sort | sed -r 's/\.//g' | sed '/^$/d' > zone.list 2> /dev/null
# 3
mkdir zones
# Generating whois.iana.db.php
echo "<?php" > whois.iana.db.php
echo "\$ianawhois = Array (" >> whois.iana.db.php
for zn in `cat zone.list`; do
whois -h whois.iana.org $zn > zones/$zn.whois
echo " \"$zn\" => \"`cat zones/$zn.whois | grep "whois:\s" | awk '{print $2}'`\"," >> whois.iana.db.php
sleep 2
done
echo ");" >> whois.iana.db.php
echo "?>" >> whois.iana.db.php
# Yaiks
rm -rf zones
rm -f root.zone
rm -f zone.list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment