Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import nmap
- nm = nmap.PortScanner()
- def scanNet(networkAddress, networkBits, numberPortsToScan):
- nm.scan((hosts='{0}/{1}', arguments='-n -sP -PE --top-ports {2}').format(networkAddress, networkBits, numberPortsToScan))
- def getLiveHosts()
- hostList = []
- for host in nm.all_hosts()
- hostList.insert({'ip': host,
- 'hostname': nm[host].hostname()})
- return hostList
- def getHostPorts(host)
- return nm[host].all_protocols()
- hosts_list = [(x, nm[x]['status']['state']) for x in nm.all_hosts()]
- for host, status in hosts_list:
- print('{0}:{1}'.format(host, status))
- for liveHost in nmHandler.getLiveHosts()
- print("{0} | {1}").format(liveHost['ip'], liveHost['hostname']
- nmHandler.getHostPorts(liveHost);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement