Pull the root tlds from a root nameserver instead

This commit is contained in:
Dionysus 2023-11-06 21:17:31 -05:00
parent 9238739c1e
commit d7c0c075c2
Signed by: acidvegas
GPG Key ID: EF4B922DB85DC9DE
1 changed files with 8 additions and 2 deletions

10
tldsec
View File

@ -16,8 +16,14 @@ NC='\033[0m' # No Color
# Create the output directory if it doesn't exist
mkdir -p output
# Fetch the list of TLDs using curl
tld_list=$(curl -s "https://data.iana.org/TLD/tlds-alpha-by-domain.txt")
# Parse the tld list from a root nameserver (todo: randomize the root nameserver)
rndroot=$(dig AXFR . @a.root-servers.net | grep -E 'IN\s+NS' | awk '{print $1}' | sed 's/\.$//' | sort -u)
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=$(echo | )
fi
# Check if the list was retrieved successfully
if [ -z "$tld_list" ]; then