Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#! /usr/bin/python
import nmap
# python-nmap url :
nm = nmap.PortScanner()
nm.scan(hosts='', arguments='-n -p 161 -sU ')
hosts_list = [(x, nm[x][u'udp'][161]['state']) for x in nm.all_hosts()]
#print nm.all_hosts()
#print nm[u''][u'udp'][161]['state']
for host, status in hosts_list:
print('{0}:{1}'.format(host, status))

This comment has been minimized.

Copy link
Owner Author

@mike-zhang mike-zhang commented Nov 19, 2012


launch 'nmap -V', we wait after 'Nmap version 5.0 ( )'

p = subprocess.Popen(['nmap', '-V'], bufsize=10000, stdout=subprocess.PIPE)
self._nmap_last_output = p.communicate()[0] # store stdout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment