POSIX version now attempts IPv4 & IPv6, Python & POSIX version now correctly attempts every IP beloging to the nameserver
This commit is contained in:
parent
03c09942fe
commit
b73cc90d52
@ -16,7 +16,7 @@ It is expected to set *realistic* expectations when using this tool. In contempo
|
|||||||
| `-t`, `--timeout` | DNS timeout *(default: 30)* |
|
| `-t`, `--timeout` | DNS timeout *(default: 30)* |
|
||||||
|
|
||||||
## Information
|
## Information
|
||||||
I only wrote this to shit on **[this bozo](https://github.com/flotwig/TLDR-2/tree/main)** who took a dead project & brought it back to life by making it even worse. Rather than making a pull request to give this bloke more credit in his "tenure" as a developer, I decided to just rewrite it all from scratch so people can fork off of *clean* code instead.
|
I only wrote this to shit on **[this bozo](https://github.com/flotwig/TLDR-2/)** who took a dead project & brought it back to life by making it even worse. Rather than making a pull request to give this bloke more credit in his "tenure" as a developer, I decided to just rewrite it all from scratch so people can fork off of *clean* code instead.
|
||||||
|
|
||||||
This repostiory also contains a [pure POSIX version](./mdaxfr) for portability, aswell as a [script](./opennic) to do zone transfers on [OpenNIC TLDs](https://wiki.opennic.org/opennic/dot).
|
This repostiory also contains a [pure POSIX version](./mdaxfr) for portability, aswell as a [script](./opennic) to do zone transfers on [OpenNIC TLDs](https://wiki.opennic.org/opennic/dot).
|
||||||
|
|
||||||
|
23
mdaxfr
23
mdaxfr
@ -7,7 +7,7 @@ mkdir -p "$OUTPUT_DIR/root"
|
|||||||
mkdir -p "$OUTPUT_DIR/psl"
|
mkdir -p "$OUTPUT_DIR/psl"
|
||||||
|
|
||||||
resolve_nameserver() {
|
resolve_nameserver() {
|
||||||
dig +short "$1" A || dig +short "$1" AAAA
|
dig +short AAAA $1 +short -t A $1 2>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
attempt_axfr() {
|
attempt_axfr() {
|
||||||
@ -16,19 +16,22 @@ attempt_axfr() {
|
|||||||
filename="$3"
|
filename="$3"
|
||||||
temp_file="${filename}.temp"
|
temp_file="${filename}.temp"
|
||||||
|
|
||||||
nameserver_ip=$(resolve_nameserver "$nameserver")
|
nameserver_ips=$(resolve_nameserver "$nameserver")
|
||||||
if [ -z "$nameserver_ip" ]; then
|
if [ -z "$nameserver_ips" ]; then
|
||||||
echo "Failed to resolve nameserver $nameserver"
|
echo "Failed to resolve nameserver $nameserver"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
dig AXFR "$tld" "@$nameserver_ip" > "$temp_file"
|
for nameserver_ip in $nameserver_ips; do
|
||||||
if [ $? -eq 0 ]; then
|
dig AXFR "$tld" "@$nameserver_ip" > "$temp_file"
|
||||||
mv "$temp_file" "$filename"
|
if [ $? -eq 0 ]; then
|
||||||
else
|
mv "$temp_file" "$filename"
|
||||||
echo "Failed to perform zone transfer from $nameserver for $tld"
|
return
|
||||||
rm -f "$temp_file"
|
else
|
||||||
fi
|
echo "Failed to perform zone transfer from $nameserver for $tld"
|
||||||
|
rm -f "$temp_file"
|
||||||
|
fi
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# For root nameservers
|
# For root nameservers
|
||||||
|
20
mdaxfr.py
20
mdaxfr.py
@ -29,17 +29,19 @@ def attempt_axfr(tld: str, nameserver: str, filename: str):
|
|||||||
else:
|
else:
|
||||||
for ns in nameserver: # Let's try all the IP addresses for the nameserver
|
for ns in nameserver: # Let's try all the IP addresses for the nameserver
|
||||||
try:
|
try:
|
||||||
with open(temp_file, 'w') as file:
|
xfr = dns.query.xfr(ns, tld+'.', lifetime=300)
|
||||||
xfr = dns.query.xfr(nameserver.address, tld+'.', lifetime=300)
|
if xfr:
|
||||||
for msg in xfr:
|
with open(temp_file, 'w') as file:
|
||||||
for rrset in msg.answer:
|
for msg in xfr:
|
||||||
for rdata in rrset:
|
for rrset in msg.answer:
|
||||||
file.write(f'{rrset.name}.{tld} {rrset.ttl} {rdata}\n')
|
for rdata in rrset:
|
||||||
os.rename(temp_file, filename)
|
file.write(f'{rrset.name}.{tld} {rrset.ttl} {rdata}\n')
|
||||||
|
os.rename(temp_file, filename)
|
||||||
|
break
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
if os.path.exists(temp_file):
|
if os.path.exists(temp_file):
|
||||||
os.remove(temp_file)
|
os.remove(temp_file)
|
||||||
logging.error(f'Failed to perform zone transfer from {nameserver.address} for {tld}: {ex}')
|
logging.error(f'Failed to perform zone transfer from {nameserver} ({ns}) for {tld}: {ex}')
|
||||||
|
|
||||||
|
|
||||||
def get_nameservers(target: str) -> list:
|
def get_nameservers(target: str) -> list:
|
||||||
@ -109,7 +111,7 @@ if __name__ == '__main__':
|
|||||||
parser = argparse.ArgumentParser(description='Mass DNS AXFR')
|
parser = argparse.ArgumentParser(description='Mass DNS AXFR')
|
||||||
parser.add_argument('-c', '--concurrency', type=int, default=30, help='maximum concurrent tasks')
|
parser.add_argument('-c', '--concurrency', type=int, default=30, help='maximum concurrent tasks')
|
||||||
parser.add_argument('-o', '--output', default='axfrout', help='output directory')
|
parser.add_argument('-o', '--output', default='axfrout', help='output directory')
|
||||||
parser.add_argument('-t', '--timeout', type=int, default=30, help='DNS timeout (default: 30)')
|
parser.add_argument('-t', '--timeout', type=int, default=15, help='DNS timeout (default: 15)')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
os.makedirs(args.output, exist_ok=True)
|
os.makedirs(args.output, exist_ok=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user