def get_ip_by_netmask(ip, port, netmask):
"""return {ip:product}, which port is open from ip's netmask"""
print('Scaning')
return_value = {}
nm = nmap.PortScanner()
nm.scan(hosts='%s/%s' % (ip, netmask), ports=port, arguments='')
print(nm.command_line())
hosts_list = [(x, nm[x]['tcp'][int(port)]['product']) for x in nm.all_hosts()]
print("Len of hosts_list: %s" % len(hosts_list))
for i in hosts_list:
if 1:
return_value[i[0]] = i[1]
else:
print("I pass")
return return_value
# ----------------------------------------------------------------------
评论列表
文章目录