Last active
June 4, 2017 05:36
-
-
Save Oritz/986f3ecea8cab835c3a1349d23f11a94 to your computer and use it in GitHub Desktop.
把 wydomain 的结果转换为 IP 列表
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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