Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import sys
- try:
- import nmap
- except:
- sys.exit("[!] Install the nmap library: pip install python-nmap")
- #Validados de argumentos
- if len(sys.argv) !=5:
- sys.exit("[!] Please provide four arguments the first being the targets the second the ports, the third the username and the fourth the password")
- password = str(sys.argv[4])
- username = str(sys.argv[3])
- ports = str(sys.argv[2])
- hosts = str(sys.argv[1])
- home_dir="/root"
- gateways = {}
- network_ifaces = {}
- if __name__ == '__main__':
- gateways = get_gateways()
- network_ifaces = get_networks(gateways)
- hosts_file = target_identifier(home_dir,username,password,hosts,ports,network_ifaces)
- resource_file_builder(home_dir, username, password, hosts, ports, host_file)
- scanner = nmap.PortScanner()
- scanner.scan(addrs, ports)
- for host in scanner.all_hosts():
- if not scanner[host].hostname():
- print("The host's IP address is %s and it's hostname was not found") % (host)
- else:
- print("The host's IP address is %s and it's hostname is %s") % (host, scanner[host].hostname())
- #
- def resource_file_builder(dir, user, passwd, ips, port_num, hosts_file):
- "ssh_login.py" 81L, 2862C 20,0-1 Top
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement