This Python script helps you check subdomains for CNAME records and identify the targets they point to.
- Checks subdomains from a text file.
- Uses Google Public DNS (8.8.8.8) by default for lookups (configurable).
- Outputs results in JSON format (default) or text format.
- Add option for summery report
- Add option for show only unique cname records
- Get subdomains in pipe (cat subdomains | python3 cname-mapper.py )
options:
-h, --help show this help message and exit
-f FILE, --file FILE Path to the text file containing subdomains
-ns NAMESERVER, --nameserver NAMESERVER
Optional, nameserver to use for DNS queries (defaults to 8.8.8.8)
-o {text,json}, --output {text,json}
Optional, Output format (JSON, or text(default))
-c, --cname Optional, Show only cnames
-d, --delete Optional, Show all subdomains whitout CNAMEs
-s, --silent Do not show the report
Requirements:
- Python 3
- Clone the project.
cd cname-mapper
pip3 install -r requirements.txt
- Run the script from the command line:
python3 cname-mapper.py --file subdomains.txt
python3 cname-mapper.py -f subdomains.txt
cat subdomains.txt | python3 cname-mapper.py
python3 cname-mapper.py -f subdomains.txt -r # show summery report
python3 cname-mapper.py -f subdomains.txt -c # only show unique CNAME
python3 cname-mapper.py -f subdomains.txt -d # remove CNAME and print result
python3 cname-mapper.py -f subdomains.txt -ns # use custom name server for DNS queries
The script iterates through the subdomains in the provided file and performs DNS queries using the dnspython library. It checks for CNAME records and returns the target domain if found. The results are then stored in a dictionary and finally converted to JSON (or printed in text format depending on the chosen output).