Created
May 4, 2016 14:36
-
-
Save ype/57787d40964df5c1d284ed5797b57740 to your computer and use it in GitHub Desktop.
wenz u wantz domainz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Name: Check for domain name availability | |
# Author: ype | |
# Source: https://github.com/ype/canihazdomain | |
# Based On: linuxconfig.org | |
# Usage: | |
# canihazdomain domain_name | |
INPUT="$@" | |
if [ "$INPUT" == "0" ]; then | |
echo "You need tu supply at least one argument!" | |
exit 1 | |
fi | |
DOMAINS=( ) | |
icann_top_level_domains_list() { | |
local TLDS_LIST="$HOME/tmp/tlds-alpha-by-domain.txt" | |
echo -e "\e[2mFetching ICANN Top-Level Domains list...\e[0m"; | |
curl -sL \ | |
--url "http://data.iana.org/TLD/tlds-alpha-by-domain.txt" \ | |
| sed 1d \ | |
| tr '[[:upper:]]' '[[:lower:]]' > "$TLDS_LIST" | |
while read TLD; do | |
DOMAINS+=( $(echo ".$TLD") ); | |
done <"$TLDS_LIST" | |
} | |
check_domains() { | |
ELEMENTS=${#DOMAINS[@]}; | |
while (( "$#" )); do | |
for (( i=0;i<$ELEMENTS;i++)); do | |
whois $1${DOMAINS[${i}]} \ | |
| egrep -q '^No match|^NOT FOUND|^Not fo|AVAILABLE|^No Data Fou|has not been regi|No entri|connect: Connection refused' | |
if [ $? -eq 0 ]; then | |
printf "%s\e[1m\e[32m%-20s\e[0m\e[0m<<<<<<>>>>>>%20s\e[0m\n" \ | |
"$1" \ | |
"${DOMAINS[${i}]}" \ | |
"available" | |
fi | |
done | |
shift | |
done | |
} | |
main() { | |
icann_top_level_domains_list; | |
sleep 2; | |
check_domains "$INPUT"; | |
} | |
main; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment