def nmap_A_scan(network_prefix):
nm = nmap.PortScanner()
scan_raw_result = nm.scan(hosts=network_prefix, arguments='-v -n -A')
os_dict = {}
for host in scan_raw_result['scan']:
if scan_raw_result['scan'][host]['status']['state'] == 'up':
for os in scan_raw_result['scan'][host]['osmatch']:
os_dict[scan_raw_result['scan'][host]['addresses']['ipv4']] = re.split(',|or', os['name'])
for x,y in os_dict.items():
y = [i.strip() for i in y]
newy = []
for z in y:
if z != '':
newy.append(z)
os_dict[x] = newy
return os_dict
评论列表
文章目录