Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import nmap
  3. nm = nmap.PortScanner()
  4.  
  5. def scanNet(networkAddress, networkBits, numberPortsToScan):
  6. nm.scan((hosts='{0}/{1}', arguments='-n -sP -PE --top-ports {2}').format(networkAddress, networkBits, numberPortsToScan))
  7.  
  8.  
  9.  
  10. def getLiveHosts()
  11. hostList = []
  12. for host in nm.all_hosts()
  13. hostList.insert({'ip': host,
  14. 'hostname': nm[host].hostname()})
  15. return hostList
  16.  
  17. def getHostPorts(host)
  18. return nm[host].all_protocols()
  19.  
  20.  
  21.  
  22. hosts_list = [(x, nm[x]['status']['state']) for x in nm.all_hosts()]
  23. for host, status in hosts_list:
  24. print('{0}:{1}'.format(host, status))
  25.  
  26.  
  27.  
  28. for liveHost in nmHandler.getLiveHosts()
  29. print("{0} | {1}").format(liveHost['ip'], liveHost['hostname']
  30. nmHandler.getHostPorts(liveHost);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement