Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import sys
  4. try:
  5. import nmap
  6. except:
  7. sys.exit("[!] Install the nmap library: pip install python-nmap")
  8.  
  9. #Validados de argumentos
  10. if len(sys.argv) !=5:
  11. sys.exit("[!] Please provide four arguments the first being the targets the second the ports, the third the username and the fourth the password")
  12. password = str(sys.argv[4])
  13. username = str(sys.argv[3])
  14. ports = str(sys.argv[2])
  15. hosts = str(sys.argv[1])
  16.  
  17. home_dir="/root"
  18. gateways = {}
  19. network_ifaces = {}
  20.  
  21. if __name__ == '__main__':
  22. gateways = get_gateways()
  23. network_ifaces = get_networks(gateways)
  24. hosts_file = target_identifier(home_dir,username,password,hosts,ports,network_ifaces)
  25. resource_file_builder(home_dir, username, password, hosts, ports, host_file)
  26.  
  27. scanner = nmap.PortScanner()
  28. scanner.scan(addrs, ports)
  29. for host in scanner.all_hosts():
  30. if not scanner[host].hostname():
  31. print("The host's IP address is %s and it's hostname was not found") % (host)
  32. else:
  33. print("The host's IP address is %s and it's hostname is %s") % (host, scanner[host].hostname())
  34. #
  35.  
  36. def resource_file_builder(dir, user, passwd, ips, port_num, hosts_file):
  37. "ssh_login.py" 81L, 2862C 20,0-1 Top
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement