Last active
January 19, 2019 14:17
-
-
Save gmolveau/80e946bcbe1b50a6a2961de3c14d0dc1 to your computer and use it in GitHub Desktop.
Python ssh passphrase dictionary bruteforce
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 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