def doDNSLookupsOnHosts(db, footprint_id): os.popen('echo "" > nmap_temp/dns_hosts') all_hosts = [] hosts_with_dns = [] count = 0 for host in dbfunctions.listHostsToQueryDNS(db, footprint_id): os.popen("echo {0} >> nmap_temp/dns_hosts".format(host)) count = count + 1 all_hosts.append(host) if count == 0: time.sleep(30) return data = os.popen( "nmap -iL nmap_temp/dns_hosts -sL | grep report | grep \( | cut -d \ -f 5,6" ).read().split("\n") for i in data: if i == "": continue ii = i.split(" ") host_name = ii[0] ip = ii[1][1:-1] if host_name != "rfc.private.address.invalid.query": dbfunctions.updateHostDNS_wo_commit(db, footprint_id, ip, host_name) hosts_with_dns.append(ip) for host in all_hosts: if host not in hosts_with_dns: dbfunctions.updateHostDNS_wo_commit(db, footprint_id, host, '')
def doDNSLookupsOnHosts(db, footprint_id): os.popen('echo "" > nmap_temp/dns_hosts') all_hosts = [] hosts_with_dns = [] count = 0 for host in dbfunctions.listHostsToQueryDNS(db, footprint_id): os.popen("echo {0} >> nmap_temp/dns_hosts".format(host)) count = count + 1 all_hosts.append(host) if count == 0: time.sleep(30) return data = os.popen("nmap -iL nmap_temp/dns_hosts -sL | grep report | grep \( | cut -d \ -f 5,6").read().split("\n") for i in data: if i == "": continue ii = i.split(" ") host_name = ii[0] ip = ii[1][1:-1] if host_name != "rfc.private.address.invalid.query": dbfunctions.updateHostDNS_wo_commit(db, footprint_id, ip, host_name) hosts_with_dns.append(ip) for host in all_hosts: if host not in hosts_with_dns: dbfunctions.updateHostDNS_wo_commit(db, footprint_id, host, '')
def doDNSLookupsOnRanges(db, footprint_id): for net_range in dbfunctions.listRangesToQueryDNS(db, footprint_id): data = os.popen("nmap {0} -sL | grep report | grep \( | cut -d \ -f 5,6".format(net_range)).read().split("\n") for i in data: if i == "": continue ii = i.split(" ") host_name = ii[0] ip = ii[1][1:-1] if host_name != "rfc.private.address.invalid.query": dbfunctions.updateHostDNS_wo_commit(db, footprint_id, ip, host_name) #db.commit() cursor = db.cursor() cursor.execute('update ranges set dns_lookups_done = %s where footprint_id = %s and net_range = %s', (1, footprint_id, net_range)) cursor.close()
def doDNSLookupsOnRanges(db, footprint_id): for net_range in dbfunctions.listRangesToQueryDNS(db, footprint_id): data = os.popen( "nmap {0} -sL | grep report | grep \( | cut -d \ -f 5,6".format( net_range)).read().split("\n") for i in data: if i == "": continue ii = i.split(" ") host_name = ii[0] ip = ii[1][1:-1] if host_name != "rfc.private.address.invalid.query": dbfunctions.updateHostDNS_wo_commit(db, footprint_id, ip, host_name) #db.commit() cursor = db.cursor() cursor.execute( 'update ranges set dns_lookups_done = %s where footprint_id = %s and net_range = %s', (1, footprint_id, net_range)) cursor.close()