Skip to content

Instantly share code, notes, and snippets.

@abhishekbhardwaj
Forked from kolobus/whois.db.sh
Created December 17, 2018 07:48
Show Gist options
  • Save abhishekbhardwaj/eb19786c3c9b179ca66f8e71b93b4e8c to your computer and use it in GitHub Desktop.
Save abhishekbhardwaj/eb19786c3c9b179ca66f8e71b93b4e8c 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