mdaxfr

- Mass DNS AXFR
git clone git://git.acid.vegas/mdaxfr.git
Log | Files | Refs | Archive | README | LICENSE

commit 6fc5d41124ec1dd4f164e9b2e0f5d54058d00895
parent a4987c644734ebfbfa5ec3258901520bfcad518c
Author: acidvegas <acid.vegas@acid.vegas>
Date: Sat, 28 Oct 2023 22:10:35 -0400

Finalized POSIX shell script

Diffstat:
Daxfr.sh | 17-----------------
Amdaxfr | 48++++++++++++++++++++++++++++++++++++++++++++++++
Raxfr.py -> mdaxfr.py | 0

3 files changed, 48 insertions(+), 17 deletions(-)

diff --git a/axfr.sh b/axfr.sh
@@ -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
@@ -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