Path: blob/master/Botnets/Exploits/GOAHEAD/mklist.py
5038 views
#!/usr/bin/python1import sys, time, os, ssl, socket2from threading import Thread3if len(sys.argv) < 3:4print "Usage: python "+sys.argv[0]+" <input> <threads> <output>"5sys.exit()6ips = map(lambda s: s.strip(), open(sys.argv[1], "r").readlines())7threads = int(sys.argv[2])8thread_count = len(ips) / threads9thread_chunks = [ips[x:x+thread_count] for x in xrange(0, len(ips), thread_count)]10output = sys.argv[3]11found = 012cons = 013fails = 014proc = 015port = 8116buf = 40961718headers = "GET /ftptest.cgi HTTP/1.0\r\n\r\n"1920def checkhost_headers(host):21global found22global cons23global fails24host = host.strip("\n")25cons += 126try:27sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)28try:29sock.settimeout(5)30sock.connect((host, port))31except:32failed += 133sock.close()34sock.send(headers)35time.sleep(2)36resp = sock.recv(1024)37if "GoAhead-Webs" in resp:38file = open(output, "a+")39file.write(host+"\n")40file.close()41found += 142sock.close()43cons -= 144except:45cons -= 146fails += 147pass48def worker(count):49global cons50global failed51global sent52global proc53global cons54count = int(count)55for i in thread_chunks[count]:56try:57proc += 158checkhost_headers(i)59except:60pass61for x in xrange(threads):62try:63t = Thread(target=worker, args=(x,))64t.start()65except KeyboardInterrupt:66sys.exit()67except:68pass69while True:70try: #prints the information like how many devices its tried71i = found72sys.stdout.write("\r\033[33mProccessed \033[92m[\033[93m"+str(proc)+"\033[92m]\033[33m || \033[33mFound \033[92m[\033[93m"+str(i)+"\033[92m]\033[33m || Conns \033[92m[\033[93m"+str(cons)+"\033[92m] || Fails \033[92m[\033[93m"+str(fails)+"\033[92m]\033[0m")73sys.stdout.flush()74time.sleep(0.25)75except KeyboardInterrupt:76sys.exit("Exiting On User Input")77except:78pass798081