andy-h
2/12/2014 - 10:22 PM

Get list of all active TLD's w/whois server

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