Resolve a list of domains/subdomains to IPv4 and IPV6 IPs
Simple script that converts a list of domains/subdomains to DNS A Records (IPV4) and DNS AAAA Records (IPV6).
Does optional JSON and HTML output also.
Uses socket to get IPs so it is subject to locally configured resolver.
Requires pyperclip to copy the json result to the clipboard:
pip3 install pyperclip
Requires tldextract to extract domains/subdomains from list:
pip3 install tldextract
Requires validators to validate domains/subdomains from list:
pip3 install validators
Requires pandas to save output to a HTML file
pip3 install pandas
Requires python-libnmap to parse a nmap xml scan:
pip3 install python-libnmap
Requires ipinfo (https://github.com/ipinfo/python) to get additional IP information
pip3 install ipinfo
or install all requirements:
pip3 install -r requirements.txt
Currently, ipinfo.io offers a 50.000 request per month API key from https://ipinfo.io/ that can be manually set in d2i.py for the “access_token”.
def ipinfo_get(ip_address):
"""Uses https://github.com/ipinfo/python to get additional information about IP addresses"""
# get an API token from https://ipinfo.io/
access_token=""
The file must contain a list with only one domain/subdomain per line.
Valid example list:
yourname.xyz
yourname.xyz
www.yourname.xyz
www.yourname.xyz/index.html
http://yourname.xyz
http://yourname.xyz/
https://yourname.xyz
https://yourname.xyz/index.html
someinvaliddomain12312313.com
./d2i.py domainlist.txt # IPV4 only
======># Starting script #<=======
Input file is --> domainlist.txt
==================================
* yourname.xyz * --> 104.24.123.106, 104.24.122.106
* yourname.xyz * --> 104.24.123.106, 104.24.122.106
* www.yourname.xyz * --> 104.24.122.106, 104.24.123.106
* yourname.xyz * --> 104.24.123.106, 104.24.122.106
* yourname.xyz * --> 104.24.123.106, 104.24.122.106
* yourname.xyz * --> 104.24.123.106, 104.24.122.106
* yourname.xyz * --> 104.24.123.106, 104.24.122.106
IPV4: someinvaliddomain12312313.com Error: [Errno 8] nodename nor servname provided, or not known
===========># Stats: #<===========
The input file contained 9 lines and 2 domains/subdomains are unique. Difference: 7
==================================
./d2i.py domainlist.txt -v6 # IPV4 and IPV6
======># Starting script #<=======
Input file is --> domainlist.txt
==================================
* yourname.xyz * --> 104.24.123.106, 104.24.122.106
* yourname.xyz * --> 2400:cb00:2048:1::6818:7a6a
* yourname.xyz * --> 2400:cb00:2048:1::6818:7b6a
* yourname.xyz * --> 104.24.123.106, 104.24.122.106
* yourname.xyz * --> 2400:cb00:2048:1::6818:7a6a
* yourname.xyz * --> 2400:cb00:2048:1::6818:7b6a
* www.yourname.xyz * --> 104.24.122.106, 104.24.123.106
* www.yourname.xyz * --> 2400:cb00:2048:1::6818:7b6a
* www.yourname.xyz * --> 2400:cb00:2048:1::6818:7a6a
* yourname.xyz * --> 104.24.123.106, 104.24.122.106
* yourname.xyz * --> 2400:cb00:2048:1::6818:7a6a
* yourname.xyz * --> 2400:cb00:2048:1::6818:7b6a
* yourname.xyz * --> 104.24.123.106, 104.24.122.106
* yourname.xyz * --> 2400:cb00:2048:1::6818:7a6a
* yourname.xyz * --> 2400:cb00:2048:1::6818:7b6a
* yourname.xyz * --> 104.24.123.106, 104.24.122.106
* yourname.xyz * --> 2400:cb00:2048:1::6818:7a6a
* yourname.xyz * --> 2400:cb00:2048:1::6818:7b6a
* yourname.xyz * --> 104.24.123.106, 104.24.122.106
* yourname.xyz * --> 2400:cb00:2048:1::6818:7a6a
* yourname.xyz * --> 2400:cb00:2048:1::6818:7b6a
IPV4: someinvaliddomain12312313.com Error: [Errno 8] nodename nor servname provided, or not known
IPV6: someinvaliddomain12312313.com Error: [Errno 8] nodename nor servname provided, or not known
===========># Stats: #<===========
The input file contained 9 lines and 2 domains/subdomains are unique. Difference: 7
==================================
./d2i.py domainlist.txt -ji # IPV4 with JSON sorted by IP
...
** Sorted IPv4 ips by domains as JSON **
{
"104.24.122.106": [
"www.yourname.xyz",
"yourname.xyz"
],
"104.24.123.106": [
"www.yourname.xyz",
"yourname.xyz"
]
}
./domains2ips.py domainlist.txt -jd # IPV4 with JSON sorted by Domain
...
** Sorted Domains by IPv4 ips as JSON **
{
"www.yourname.xyz": [
"104.24.122.106",
"104.24.123.106"
],
"yourname.xyz": [
"104.24.123.106",
"104.24.122.106"
]
}
./d2i.py domainlist.txt -ji -jd # IPV4 with JSON sorted by IP and Domain
...
** Sorted IPv4 ips with domains as JSON **
{"sorted by ip":
{
"104.24.122.106": [
"www.yourname.xyz",
"yourname.xyz"
],
"104.24.123.106": [
"www.yourname.xyz",
"yourname.xyz"
]
},"sorted by domain":
{
"www.yourname.xyz": [
"104.24.122.106",
"104.24.123.106"
],
"yourname.xyz": [
"104.24.123.106",
"104.24.122.106"
]
}
}
./d2i.py -jii domainlist.txt
...
** Sorted IPs by domains and subdomains as JSON with additional information from ipinfo.io **
{
"104.24.116.11": [
{
"city": "New York City",
"country": "US",
"org": "AS13335 Cloudflare, Inc.",
"region": "New York"
},
[
"yourname.xyz",
"www.yourname.xyz"
]
],
"104.24.117.11": [
{
"city": "New York City",
"country": "US",
"org": "AS13335 Cloudflare, Inc.",
"region": "New York"
},
[
"yourname.xyz",
"www.yourname.xyz"
]
]
}
./d2i.py -jii -w domainlist.txt
Outputs results in a html file in the curent_folder/results/