[ Web Proxy ]
URL:
Viewing: https://thepythoncode.com/code/dns-enumeration-with-python [Back]  [Original]

Code for How to Perform DNS Enumeration in Python - Python Code
Python Code [Python Code]  The Python Code Menu

Code for How to Perform DNS Enumeration in Python Tutorial


View on Github

dns_enumeration.py

import dns.resolver

# Set the target domain and record type
target_domain = "thepythoncode.com"
record_types = ["A", "AAAA", "CNAME", "MX", "NS", "SOA", "TXT"]
# Create a DNS resolver
resolver = dns.resolver.Resolver()
for record_type in record_types:
    # Perform DNS lookup for the specified domain and record type
    try:
        answers = resolver.resolve(target_domain, record_type)
    except dns.resolver.NoAnswer:
        continue
    # Print the answers
    print(f"{record_type} records for {target_domain}:")
    for rdata in answers:
        print(f" {rdata}")


Enter your email:
Python Code [Python Code]  The Python Code

Web Proxy Viewer  |  New URL  |  Original Page