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 getdns(self, domain): dom = domain if self.subdo is True: dom = domain.split('.') dom.pop(0) rootdom = '.'.join(dom) else: rootdom = dom if self.nameserver is False: 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() 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 is True: dom = domain.split(".") dom.pop(0) rootdom = ".".join(dom) else: rootdom = dom if self.nameserver is False: 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() 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 run(self, tld): self.nameserver = self.getdns(self.domain) hostname = self.domain.split(".")[0] + "." + tld if self.verbose: ESC = chr(27) sys.stdout.write(ESC + '[2K' + ESC + '[G') sys.stdout.write("\r\tSearching for: " + hostname) sys.stdout.flush() try: test = DNS.Request(hostname, qtype='a', server=self.nameserver).req() hostip = test.answers[0]['data'] return hostip + ":" + hostname except Exception as e: pass
def run(self, host): if self.nameserver == "": self.nameserver = self.getdns(self.domain) print("\n\033[94m[-] Using DNS server: " + self.nameserver + "\033[1;33;40m\n") hostname = str(host.split("\n")[0]) + "." + str(self.domain) if self.verbose: ESC = chr(27) sys.stdout.write(ESC + '[2K' + ESC + '[G') sys.stdout.write("\r" + hostname) sys.stdout.flush() try: test = DNS.Request(hostname, qtype='a', server=self.nameserver).req() # TODO FIX test is sometimes not getting answers and leads to an indexing erro hostip = test.answers[0]['data'] return hostname + ":" + hostip except Exception as e: pass