From 6fc5d41124ec1dd4f164e9b2e0f5d54058d00895 Mon Sep 17 00:00:00 2001 From: acidvegas Date: Sat, 28 Oct 2023 22:10:35 -0400 Subject: [PATCH] Finalized POSIX shell script --- axfr.sh | 16 --------------- mdaxfr | 48 ++++++++++++++++++++++++++++++++++++++++++++ axfr.py => mdaxfr.py | 0 3 files changed, 48 insertions(+), 16 deletions(-) delete mode 100644 axfr.sh create mode 100755 mdaxfr rename axfr.py => mdaxfr.py (100%) diff --git a/axfr.sh b/axfr.sh deleted file mode 100644 index 5775f9c..0000000 --- a/axfr.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -letters="abcdefghijklm" - -for letter in $(echo -n "$letters" | grep -o .); do - dig AXFR . @$letter.root-servers.net. +nocomments +nocmd +noquestion +nostats +time=15 -done - -tlds=$(curl -s https://data.iana.org/TLD/tlds-alpha-by-domain.txt | tail -n +2 | tr 'A-Z' 'a-z') - -for tld in $tlds; do - namesevers=$(dig +short ns ${tld}.) - for nameserver in $namesevers; do - dig AXFR ${tld}. @$nameserver +nocomments +nocmd +noquestion +nostats +time=15 - done -done \ No newline at end of file diff --git a/mdaxfr b/mdaxfr new file mode 100755 index 0000000..167f815 --- /dev/null +++ b/mdaxfr @@ -0,0 +1,48 @@ +#!/bin/sh +# Mass DNS AXFR - developed by acidvegas in posix shell script (https://git.acid.vegas/mdaxfr) + +OUTPUT_DIR="axfrout" +mkdir -p "$OUTPUT_DIR" + +attempt_axfr() { + tld="$1" + nameserver="$2" + filename="$3" + + ns_ip=$(dig +short $nameserver) + if [ -z "$ns_ip" ]; then + echo "Failed to resolve nameserver $nameserver" + return + fi + + dig axfr @$ns_ip $tld > "$filename.temp" + + if [ $? -eq 0 ]; then + mv "$filename.temp" "$filename" + else + echo "Failed to perform zone transfer from $nameserver for $tld" + rm -f "$filename.temp" + fi +} + +if [ "$1" = "--root" ]; then + for root in $(dig +short . NS); do + attempt_axfr "." $root "$OUTPUT_DIR/$root-root.txt" + done +fi + +if [ "$1" = "--tld" ]; then + tld="$2" + for ns in $(dig +short $tld NS); do + attempt_axfr "$tld" $ns "$OUTPUT_DIR/$tld.txt" + done +fi + +if [ "$1" = "--tlds" ]; then + for tld in $(curl -s 'https://data.iana.org/TLD/tlds-alpha-by-domain.txt' | tail -n +2); do + for ns in $(dig +short $tld NS); do + attempt_axfr "$tld" $ns "$OUTPUT_DIR/$tld.txt" + done + done +fi + diff --git a/axfr.py b/mdaxfr.py similarity index 100% rename from axfr.py rename to mdaxfr.py