mirror of
https://github.com/lopes/netbox-scanner.git
synced 2025-07-20 12:24:46 +02:00
Remove extra function since no need (nmap after all has an option to force always DNS resolution)
This commit is contained in:
parent
afecb475a5
commit
e5ae3f73b5
18
nbs/nmap.py
18
nbs/nmap.py
@ -1,8 +1,5 @@
|
|||||||
import socket
|
|
||||||
|
|
||||||
import nmap3
|
import nmap3
|
||||||
|
|
||||||
|
|
||||||
class Nmap(object):
|
class Nmap(object):
|
||||||
|
|
||||||
def __init__(self, unknown, networks):
|
def __init__(self, unknown, networks):
|
||||||
@ -14,27 +11,14 @@ class Nmap(object):
|
|||||||
def scan(self):
|
def scan(self):
|
||||||
nmap = nmap3.NmapHostDiscovery() # instantiate nmap object
|
nmap = nmap3.NmapHostDiscovery() # instantiate nmap object
|
||||||
for item in self.networks:
|
for item in self.networks:
|
||||||
temp_scan_result = nmap.nmap_no_portscan(item.replace('\n', ''))
|
temp_scan_result = nmap.nmap_no_portscan(item.replace('\n', ''), args="-R --system-dns")
|
||||||
self.scan_results = {**self.scan_results, **temp_scan_result}
|
self.scan_results = {**self.scan_results, **temp_scan_result}
|
||||||
self.scan_results.pop("stats")
|
self.scan_results.pop("stats")
|
||||||
self.scan_results.pop("runtime")
|
self.scan_results.pop("runtime")
|
||||||
return self.scan_results
|
return self.scan_results
|
||||||
|
|
||||||
def dns_resolution(self):
|
|
||||||
# Try to improve DNS resolution since NMAP is not consistent
|
|
||||||
for ip, v in self.scan_results.items():
|
|
||||||
try:
|
|
||||||
name, arpa, ip = socket.gethostbyaddr(ip)
|
|
||||||
try:
|
|
||||||
v["hostname"][0]["name"]
|
|
||||||
except (TypeError, IndexError):
|
|
||||||
v.update({"hostname": {"name": name, "type": 'PTR'}})
|
|
||||||
except socket.herror:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.scan()
|
self.scan()
|
||||||
self.dns_resolution()
|
|
||||||
for k,v in self.scan().items():
|
for k,v in self.scan().items():
|
||||||
try:
|
try:
|
||||||
self.hosts.append((
|
self.hosts.append((
|
||||||
|
Loading…
x
Reference in New Issue
Block a user