Notice : 해당 자료가 저작권등에 의해서 문제가 있다면 바로 삭제하겠습니다.
연구목적으로 사용하지 않고 악의적인 목적으로 이용할 경우 발생할 수 있는 법적은 책임은 모두 본인에게 있습니다.
해당 도메인의 DNS 정보를 가져오는 스크립트를 작성해보았다..
이 스크립트를 사용하기 위해서는 dnspython(http://www.dnspython.org/) 모듈을 설치해야 한다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# -*- coding: utf-8 -*- import optparse, time, dns.resolver resolver = dns.resolver.Resolver() resolver.nameservers = ['8.8.8.8'] def checkDns(domain) : try : answers = resolver.query(domain, 'A') for rdata in answers: print "A : "+str(rdata.address) except dns.resolver.NoAnswer, dns.resolver.NXDOMAIN : #print "dns.resolver.NoAnswer" pass try : answers = resolver.query(domain, 'AAAA') for rdata in answers: print "AAAA : "+str(rdata.address) except dns.resolver.NoAnswer, dns.resolver.NXDOMAIN : #print "dns.resolver.NoAnswer" pass try : answers = resolver.query(domain, 'MX') for rdata in answers: print 'MX : host='+str(rdata.exchange)+' has preference='+str(rdata.preference) except dns.resolver.NoAnswer, dns.resolver.NXDOMAIN : #print "dns.resolver.NoAnswer" pass try : answers = resolver.query(domain, 'NS') for rdata in answers: print "NS : "+str(rdata.to_text()) except dns.resolver.NoAnswer, dns.resolver.NXDOMAIN : #print "dns.resolver.NoAnswer" pass def parseDomain(url) : domain = url.replace('http://','') domain = domain.replace('https://','') idx = domain.find('/') if idx > 0 : domain = domain[:idx] return domain def main(): parser = optparse.OptionParser('usage dns_query.py -f domain_list') parser.add_option('-f', dest='filename', type='string', help='input file') (options, args) = parser.parse_args() filename = options.filename if filename == None : print parser.usage exit(0) f = file(filename, 'r') while True: line = f.readline() if not line : # file end break else : domain = parseDomain(line.rstrip('\n')) print "======================> "+domain checkDns(domain) time.sleep(1) if __name__ == '__main__': main() |
실행결과..
1 2 3 4 5 6 |
> python dns_query.py -f domain_list.txt ======================> apollo89.com A : xxx.xxx.xxx.xxx NS : ns13.dnstool.net. NS : ns12.dnstool.net. NS : ns11.dnstool.net. |