mdaxfr/extras/opennic

32 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
# OpenNIC AXFR - devloped by acidvegas (https://git.acid.vegas/mdaxfr)
# Todo: Find a better way to retrieve the TLDs so we don't have to hardcode them
servers=$(curl -s 'https://api.opennicproject.org/geoip/?list&ipv=all&res=100' | grep -oE '([0-9]{1,3}(\.[0-9]{1,3}){3}|[0-9a-fA-F:]+:[0-9a-fA-F:]+)')
tlds=("bbs" "chan" "cyb" "dyn" "epic" "geek" "gopher" "indy" "libre" "neo" "null" "o" "oss" "oz" "parody" "pirate" "opennic.glue" "dns.opennic.glue")
ptlds=("bazar" "bit" "coin" "emc" "lib" "fur" "ku" "te" "ti" "uu" "ko" "rm")
all_tlds=("${tlds[@]}" "${ptlds[@]}")
for tld in "${ptlds[@]}"; do
echo "Attempting zone transfer for $tld..."
success=0
for server in $servers; do
if ! output=$(dig AXFR "$tld." @"$server" 2>&1); then
echo "Error running dig for $tld at $server."
continue
fi
if echo "$output" | grep -q '; Transfer failed.'; then
echo "Zone transfer failed for $tld at $server."
else
echo "$output" > "${tld}.txt"
echo "Zone transfer successful for $tld at $server, output written to ${tld}.txt"
success=1
break
fi
done
if [ $success -eq 0 ]; then
echo "Zone transfer failed for $tld at all servers."
fi
done