-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_whois_records.sh
81 lines (65 loc) · 1.98 KB
/
check_whois_records.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
for dom in `cat domains.txt`
do
w=""
echo "Checking $dom";
# If the zone is a subdomain or a rDNS zone skip it
sub=`echo $dom | grep -oP "\." | wc -l`
if [ $sub -gt 1 ] && [[ "$dom" != *.co.uk ]] && [[ "$dom" != *.co.jp ]]
then
continue
fi
# get nameserver for specific TLDs
out+="$dom "
if [[ "$dom" == *.de ]]
then
w=`whois $dom | grep -i "Nserver:" | cut -d " " -f2`
elif [[ "$dom" == *.com || "$dom" == *.net || "$dom" == *.org || "$dom" == *.biz ]]
then
sleep 1
w=`whois $dom | grep "Name Server:" | cut -d " " -f3`
elif [[ "$dom" == *.ch ]]
then
sleep 1
w=`whois $dom | grep -A5 "Name servers:" | grep -v "Name servers:" | cut -f1`
elif [[ "$dom" == *.jp ]] && [[ "$dom" != *.co.jp ]]
then
w=`whois $dom | grep "\[Name Server\]" | tr -s " " | cut -d " " -f3`
elif [[ "$dom" == *.nl ]]
then
w=`whois $dom | grep -A4 "Domain nameservers:" | grep "^ " | sed "s/\ //g"`
elif [[ "$dom" == *.se || "$dom" == *.fr ]]
then
w=`whois $dom | grep -i "Nserver:" | tr -s " " | cut -d " " -f2`
elif [[ "$dom" == *.eu ]]
then
w=`whois $dom | grep -A5 "\Name servers" | grep "^ " | tr -s " " | cut -d " " -f2`
elif [[ "$dom" == *.co.uk ]]
then
w=`whois $dom | grep -A5 "\Name servers" | grep -e "\t" | grep -v WHOIS | tr -s " " | cut -d " " -f2`
elif [[ "$dom" == *.co.jp ]]
then
w=`whois $dom | grep "p. \[Name Server\]" | tr -s " " | cut -d " " -f4`
# if the TLD is not configured above, drop an error
else
w="ERROR_no_Registry_found \n"
out+="$w \n"
continue
fi
# if we havent found a nameserver, check if the zone is registered
if [ "$w" == "" ]
then
unreg=`whois $dom | egrep 'do not have an entry|NOT FOUND|No match|Status: AVAILABLE' | wc -l`
if [ "$unreg" == "1" ]
then
w="ERROR_Domain_not_registered \n"
out+="$w \n"
else
out+="ERROR - nothing matched \n"
fi
# if its registred pull the nameserver in the output
else
out+="$w \n"
fi
done
echo -e $out | column -t