项目作者: nobro

项目描述 :
Resolve a list of domains/subdomains to IPv4 and IPV6 IPs
高级语言: Python
项目地址: git://github.com/nobro/Domains2Ips.git
创建时间: 2018-01-03T16:23:27Z
项目社区:https://github.com/nobro/Domains2Ips

开源协议:MIT License

下载


Domains 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.

Install:

Requires pyperclip to copy the json result to the clipboard:

  1. pip3 install pyperclip

Requires tldextract to extract domains/subdomains from list:

  1. pip3 install tldextract

Requires validators to validate domains/subdomains from list:

  1. pip3 install validators

Requires pandas to save output to a HTML file

  1. pip3 install pandas

Requires python-libnmap to parse a nmap xml scan:

  1. pip3 install python-libnmap

Requires ipinfo (https://github.com/ipinfo/python) to get additional IP information

  1. pip3 install ipinfo

or install all requirements:

  1. 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”.

  1. def ipinfo_get(ip_address):
  2. """Uses https://github.com/ipinfo/python to get additional information about IP addresses"""
  3. # get an API token from https://ipinfo.io/
  4. access_token=""

Domain list:

The file must contain a list with only one domain/subdomain per line.

Valid example list:

  1. yourname.xyz
  2. yourname.xyz
  3. www.yourname.xyz
  4. www.yourname.xyz/index.html
  5. http://yourname.xyz
  6. http://yourname.xyz/
  7. https://yourname.xyz
  8. https://yourname.xyz/index.html
  9. someinvaliddomain12312313.com

Usage:

  • run this module without arguments —> get help message
  • run with ‘—file’ or ‘-f’ —> Select the file to be parsed - Must be set!
  • run with ‘—jsondomain’ or ‘-jd’ —> Outputs results as json sorted by domain
  • run with ‘—jsonip’ or ‘-ji’ —> Outputs results as json sorted by ip
  • run with ‘—jsonipinfo’ or ‘-jii’ —> Outputs results as json sorted by ip with additional information about the IP from ipinfo.io
  • run with ‘—version6’ or ‘-v6’ —> Outputs IPV6 ips too, by default only IPV4 ips are outputted
  • run with ‘—clipboard’ or ‘-c’ —> Will copy the resulting json to the clipboard for easy paste
  • run with ‘—web’ or ‘-w’ —> Will make a HTML file with the results from —jsonipinfo. -jii must be used!
  • run with ‘—nmap’ or ‘-n’ —> Will make a html file with -jii and -w and add ports from parsing a nmap XML scan file
  • run with ‘—help’ or ‘-h’ —> shows standard help message

Run:

./d2i.py domainlist.txt # IPV4 only

  1. ======># Starting script #<=======
  2. Input file is --> domainlist.txt
  3. ==================================
  4. * yourname.xyz * --> 104.24.123.106, 104.24.122.106
  5. * yourname.xyz * --> 104.24.123.106, 104.24.122.106
  6. * www.yourname.xyz * --> 104.24.122.106, 104.24.123.106
  7. * yourname.xyz * --> 104.24.123.106, 104.24.122.106
  8. * yourname.xyz * --> 104.24.123.106, 104.24.122.106
  9. * yourname.xyz * --> 104.24.123.106, 104.24.122.106
  10. * yourname.xyz * --> 104.24.123.106, 104.24.122.106
  11. IPV4: someinvaliddomain12312313.com Error: [Errno 8] nodename nor servname provided, or not known
  12. ===========># Stats: #<===========
  13. The input file contained 9 lines and 2 domains/subdomains are unique. Difference: 7
  14. ==================================

./d2i.py domainlist.txt -v6 # IPV4 and IPV6

  1. ======># Starting script #<=======
  2. Input file is --> domainlist.txt
  3. ==================================
  4. * yourname.xyz * --> 104.24.123.106, 104.24.122.106
  5. * yourname.xyz * --> 2400:cb00:2048:1::6818:7a6a
  6. * yourname.xyz * --> 2400:cb00:2048:1::6818:7b6a
  7. * yourname.xyz * --> 104.24.123.106, 104.24.122.106
  8. * yourname.xyz * --> 2400:cb00:2048:1::6818:7a6a
  9. * yourname.xyz * --> 2400:cb00:2048:1::6818:7b6a
  10. * www.yourname.xyz * --> 104.24.122.106, 104.24.123.106
  11. * www.yourname.xyz * --> 2400:cb00:2048:1::6818:7b6a
  12. * www.yourname.xyz * --> 2400:cb00:2048:1::6818:7a6a
  13. * yourname.xyz * --> 104.24.123.106, 104.24.122.106
  14. * yourname.xyz * --> 2400:cb00:2048:1::6818:7a6a
  15. * yourname.xyz * --> 2400:cb00:2048:1::6818:7b6a
  16. * yourname.xyz * --> 104.24.123.106, 104.24.122.106
  17. * yourname.xyz * --> 2400:cb00:2048:1::6818:7a6a
  18. * yourname.xyz * --> 2400:cb00:2048:1::6818:7b6a
  19. * yourname.xyz * --> 104.24.123.106, 104.24.122.106
  20. * yourname.xyz * --> 2400:cb00:2048:1::6818:7a6a
  21. * yourname.xyz * --> 2400:cb00:2048:1::6818:7b6a
  22. * yourname.xyz * --> 104.24.123.106, 104.24.122.106
  23. * yourname.xyz * --> 2400:cb00:2048:1::6818:7a6a
  24. * yourname.xyz * --> 2400:cb00:2048:1::6818:7b6a
  25. IPV4: someinvaliddomain12312313.com Error: [Errno 8] nodename nor servname provided, or not known
  26. IPV6: someinvaliddomain12312313.com Error: [Errno 8] nodename nor servname provided, or not known
  27. ===========># Stats: #<===========
  28. The input file contained 9 lines and 2 domains/subdomains are unique. Difference: 7
  29. ==================================

./d2i.py domainlist.txt -ji # IPV4 with JSON sorted by IP

  1. ...
  2. ** Sorted IPv4 ips by domains as JSON **
  3. {
  4. "104.24.122.106": [
  5. "www.yourname.xyz",
  6. "yourname.xyz"
  7. ],
  8. "104.24.123.106": [
  9. "www.yourname.xyz",
  10. "yourname.xyz"
  11. ]
  12. }

./domains2ips.py domainlist.txt -jd # IPV4 with JSON sorted by Domain

  1. ...
  2. ** Sorted Domains by IPv4 ips as JSON **
  3. {
  4. "www.yourname.xyz": [
  5. "104.24.122.106",
  6. "104.24.123.106"
  7. ],
  8. "yourname.xyz": [
  9. "104.24.123.106",
  10. "104.24.122.106"
  11. ]
  12. }

./d2i.py domainlist.txt -ji -jd # IPV4 with JSON sorted by IP and Domain

  1. ...
  2. ** Sorted IPv4 ips with domains as JSON **
  3. {"sorted by ip":
  4. {
  5. "104.24.122.106": [
  6. "www.yourname.xyz",
  7. "yourname.xyz"
  8. ],
  9. "104.24.123.106": [
  10. "www.yourname.xyz",
  11. "yourname.xyz"
  12. ]
  13. },"sorted by domain":
  14. {
  15. "www.yourname.xyz": [
  16. "104.24.122.106",
  17. "104.24.123.106"
  18. ],
  19. "yourname.xyz": [
  20. "104.24.123.106",
  21. "104.24.122.106"
  22. ]
  23. }
  24. }

./d2i.py -jii domainlist.txt

  1. ...
  2. ** Sorted IPs by domains and subdomains as JSON with additional information from ipinfo.io **
  3. {
  4. "104.24.116.11": [
  5. {
  6. "city": "New York City",
  7. "country": "US",
  8. "org": "AS13335 Cloudflare, Inc.",
  9. "region": "New York"
  10. },
  11. [
  12. "yourname.xyz",
  13. "www.yourname.xyz"
  14. ]
  15. ],
  16. "104.24.117.11": [
  17. {
  18. "city": "New York City",
  19. "country": "US",
  20. "org": "AS13335 Cloudflare, Inc.",
  21. "region": "New York"
  22. },
  23. [
  24. "yourname.xyz",
  25. "www.yourname.xyz"
  26. ]
  27. ]
  28. }

./d2i.py -jii -w domainlist.txt

Outputs results in a html file in the curent_folder/results/