Created
February 1, 2017 10:29
-
-
Save agustik/48f323a6d4f9780e1995949ff903b4e4 to your computer and use it in GitHub Desktop.
zonetransfer script
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
#!/bin/bash | |
domain=$1 | |
dns=$(dig $domain ns +noall +additional | grep "IN" -A 100 | awk '{print $1}') | |
stop= | |
function fetchAXFR(){ | |
d=$(dig axfr $1 @$2); | |
x=$(echo $d | grep "failed" -q ); | |
e=$? | |
if [[ "$e" == "1" ]]; then | |
echo "$d"; | |
fi | |
} | |
for server in $dns; do | |
if [[ ! -z "$stop" ]]; then | |
exit | |
fi | |
zone=$(fetchAXFR $domain $server); | |
if [[ ! -z "$zone" ]]; then | |
echo "$zone"; | |
stop=1; | |
else | |
echo "$server does not allow zone transfer"; | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment