def getdns(self, domain): DNS.ParseResolvConf('/etc/resolv.conf') dom = domain if self.subdo is True: dom = domain.split('.') dom.pop(0) rootdom = '.'.join(dom) else: rootdom = dom if self.nameserver == "": try: r = DNS.Request(rootdom, qtype='SOA').req() primary, email, serial, refresh, retry, expire, minimum = r.answers[ 0]['data'] test = DNS.Request( rootdom, qtype='NS', server=primary, aa=1).req() except Exception as e: print(e) try: # Check if variable is defined. test except NameError: print('Error, test is not defined.') sys.exit() if test.header['status'] != 'NOERROR': print('[!] Error') sys.exit() self.nameserver = test.answers[0]['data'] elif self.nameserver == 'local': self.nameserver = nameserver return self.nameserver
def getdns(self, domain): DNS.ParseResolvConf("/etc/resolv.conf") # nameserver=DNS.defaults['server'][0] dom = domain if self.subdo == True: dom = domain.split(".") dom.pop(0) rootdom = ".".join(dom) else: rootdom = dom if self.nameserver == "": try: r = DNS.Request(rootdom, qtype='SOA').req() primary, email, serial, refresh, retry, expire, minimum = r.answers[ 0]['data'] test = DNS.Request(rootdom, qtype='NS', server=primary, aa=1).req() except Exception as e: print(e) try: #check if variable is defined test except NameError: print("Error, test is not defined") sys.exit() if test.header['status'] != "NOERROR": print("Error") sys.exit() self.nameserver = test.answers[0]['data'] elif self.nameserver == "local": self.nameserver = nameserver return self.nameserver
def __init__(self, range, verbose=True): self.range = range self.iplist = '' self.results = [] self.verbose = verbose try: DNS.ParseResolvConf('/etc/resolv.conf') nameserver = DNS.defaults['server'][0] except: print('Error in DNS resolvers') sys.exit()