diff --git a/mdaxfr b/mdaxfr index a6c7ec8..633628a 100755 --- a/mdaxfr +++ b/mdaxfr @@ -3,6 +3,8 @@ OUTPUT_DIR="axfrout" mkdir -p "$OUTPUT_DIR" +mkdir -p "$OUTPUT_DIR/root" +mkdir -p "$OUTPUT_DIR/psl" resolve_nameserver() { dig +short "$1" A || dig +short "$1" AAAA @@ -31,11 +33,20 @@ attempt_axfr() { # For root nameservers for root in $(dig +short . NS); do - attempt_axfr "." "$root" "$OUTPUT_DIR/$root.txt" + attempt_axfr "." "$root" "$OUTPUT_DIR/root/$root.txt" done +# Parse the tld list from a root nameserver +rndroot=$(find $OUTPUT/root/*.root-servers.net.txt -type f | shuf -n 1) +if [ -z $rndroot ]; then + echo "Failed to AXFR a root nameserver (using IANA list instead)" + tlds=$(curl -s 'https://data.iana.org/TLD/tlds-alpha-by-domain.txt' | tail -n +2 | tr '[:upper:]' '[:lower:]') +else + tlds=$(cat $rndroot | grep -E 'IN\s+NS' | awk '{print $1}' | sed 's/\.$//' | sort -u) +fi + # For TLD nameservers -for tld in $(curl -s 'https://data.iana.org/TLD/tlds-alpha-by-domain.txt' | tail -n +2 | tr '[:upper:]' '[:lower:]'); do +for tld in $tlds; do for ns in $(dig +short "$tld" NS); do attempt_axfr "$tld" "$ns" "$OUTPUT_DIR/$tld.txt" done @@ -44,6 +55,6 @@ done # For Public Suffix List TLD nameservers for tld in $(curl -s https://publicsuffix.org/list/public_suffix_list.dat | grep -vE '^(//|.*[*!])' | grep '\.' | awk '{print $1}'); do for ns in $(dig +short "$tld" NS); do - attempt_axfr "$tld" "$ns" "$OUTPUT_DIR/$tld.txt" + attempt_axfr "$tld" "$ns" "$OUTPUT_DIR/psl/$tld.txt" done done diff --git a/mdaxfr.py b/mdaxfr.py index d29a862..6482ba5 100644 --- a/mdaxfr.py +++ b/mdaxfr.py @@ -60,8 +60,13 @@ def get_nameservers(target: str) -> list: def get_root_tlds() -> list: - '''Get the root TLDs from IANA.''' - tlds = urllib.request.urlopen('https://data.iana.org/TLD/tlds-alpha-by-domain.txt').read().decode('utf-8').lower().split('\n')[1:] + '''Get the root TLDs from a root nameservers.''' + rndroot = [root for root in os.listdir('root') if root.endswith('.root-servers.net.txt')][0] + if rndroot: + tlds = sorted(set([item.split()[0][:-1] for item in open(rndroot).read().split('\n') if item and 'IN' in item and 'NS' in item])) + else: + logging.warning('Failed to find root nameserver list, using IANA list') + tlds = urllib.request.urlopen('https://data.iana.org/TLD/tlds-alpha-by-domain.txt').read().decode('utf-8').lower().split('\n')[1:] random.shuffle(tlds) return tlds diff --git a/ozones b/ozones index d679305..1f848dc 100755 --- a/ozones +++ b/ozones @@ -1,5 +1,5 @@ #!/bin/sh -# Mass DNS AXFR (POSIX version) - developed by acidvegas (https://git.acid.vegas/mdaxfr) +# Mass DNS AXFR (other zones) - developed by acidvegas (https://git.acid.vegas/mdaxfr) ```bash curl -s https://www.internic.net/domain/root.zone | awk '$4=="NS" {gsub(/\.$/, "", $NF); print $NF}' @@ -15,6 +15,7 @@ dig @zonedata.switch.ch li. AXFR -y hmac-sha512:tsig-zonedata-li-public-21-01:t8 dig @zonedata.iis.se se AXFR > se.txt dig @zonedata.iis.se nu AXFR > nu.txt dig @zone.internet.ee ee. AXFR > ee.txt +dig @ns1.gov.ps xn--ygbi2ammx. AXFR > xn--ygbi2ammx.txt wget -O sk.txt https://sk-nic.sk/subory/domains.txt @@ -23,5 +24,8 @@ wget -O nc.txt https://www.domaine.nc/whos?who=A* # https://www.afnic.fr/produits-services/services-associes/donnees-partagees/ +# not sure about this one.... +curl -s -H 'Accept: application/json' 'https://odata.domain.fi/OpenDomainData.svc/Domains?$inlinecount=allpages' + wget -O dn42.txt http://ix.ucis.nl/dn42/dnszone2.php? ```