import nmap
scanner = nmap.PortScanner()
target = '192.168.8.121'
scanner.scan(target, arguments='-p-')
for host in scanner.all_hosts():
print(host)
if scanner[host].state() == 'up':
print('Host: %s (%s)' % (host, scanner[host].hostname()))
print('State: %s' % scanner[host].state())
for proto in scanner[host].all_protocols():
print('----------')
print('Protocol: %s' % proto)
lport = scanner[host][proto].keys()
for port in lport:
print ('Port : %s\tState : %s' % (port, scanner[host][proto][port]['state']))
标签:scanner,proto,nmap,端口,扫描,host,print,port
From: https://www.cnblogs.com/lianhaifeng/p/17347271.html