Parse the root tlds from the root nameservers instead, added more ozones

This commit is contained in:
Dionysus 2023-11-06 21:09:15 -05:00
parent 48d482f536
commit 03c09942fe
Signed by: acidvegas
GPG Key ID: EF4B922DB85DC9DE
3 changed files with 26 additions and 6 deletions

17
mdaxfr
View File

@ -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

View File

@ -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

6
ozones
View File

@ -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?
```