Skip to content

Instantly share code, notes, and snippets.

@Oritz
Last active June 4, 2017 05:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Oritz/986f3ecea8cab835c3a1349d23f11a94 to your computer and use it in GitHub Desktop.
Save Oritz/986f3ecea8cab835c3a1349d23f11a94 to your computer and use it in GitHub Desktop.
把 wydomain 的结果转换为 IP 列表
import sys
import json
import dns.resolver
resolver = dns.resolver.Resolver()
resolver.nameservers = ['8.8.8.8']
result = set()
domain_file = sys.argv[1]
with open(domain_file) as raw_domain:
domains = json.load(raw_domain)
for domain in domains:
try:
IPs = resolver.query(domain)
for IP in IPs:
result.add(str(IP))
print('[+] %s: %s' % (domain, IP))
except Exception:
print('[!] None of DNS query names exist: %s' % domain)
out_filename = domain_file + '_ips.txt'
with open(out_filename, 'w') as out_file:
json.dump(sorted(result), out_file, indent=4)
print('[√] Saved to %s' % out_filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment