-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdomaincheck.sh
executable file
·41 lines (37 loc) · 992 Bytes
/
domaincheck.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
#!/usr/bin/env bash
function string.monolithic.tolower
{
local __word=$1
local __len=${#__word}
local __char
local __octal
local __decimal
local __result
for (( i=0; i<__len; i++ ))
do
__char=${__word:$i:1}
case "$__char" in
[A-Z] )
printf -v __decimal '%d' "'$__char"
printf -v __octal '%03o' $(( $__decimal ^ 0x20 ))
printf -v __char \\$__octal
;;
esac
__result+="$__char"
done
REPLY="$__result"
}
fqdn="cyruslesser.com"
type="MX"
# Check WHOIS record for nameservers (far from guaranteed)
# whois_ns=$( whois "$fqdn" | grep "Name Server: " | sed 's/Name Server: //' )
whois_ns=$( cat /tmp/whois.txt | grep "Name Server: " | sed 's/ *Name Server: //' | sort -u )
string.monolithic.tolower "$whois_ns"
whois_nsa=($REPLY)
declare -p whois_nsa
for ns in "${whois_nsa[@]}"; do
# echo "$ns:"
echo dig +short "$type" "$fqdn" "@$ns"
dig +short "$type" "$fqdn" "@$ns"
echo
done