Created
January 14, 2020 03:34
-
-
Save orangepeelbeef/1cb2ab76663ccc4799ea826baf6dbcd8 to your computer and use it in GitHub Desktop.
bruteforce ssh rsa from wordlist
This file contains hidden or 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
# wordlist named pass.lst | |
# encrypted ssh key private.pem (watch out for the permissions 0600 is ok) | |
from subprocess import PIPE, Popen | |
import subprocess | |
import sys | |
def cmdline(command): | |
proc = subprocess.Popen(str(command), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) | |
(out, err) = proc.communicate() | |
return err | |
def main(): | |
words = [line.strip() for line in open('pass.lst')] | |
print("\n") | |
count=0 | |
for w in words: | |
strcmd = "ssh-keygen -y -f private.pem -P "+w | |
res=cmdline(strcmd) | |
#print(res) | |
if 'incorrect' not in res: | |
print("\nThe key is: "+w) | |
sys.exit() | |
print(str(count)+"/"+str(w)) | |
count=count+1 | |
print("\n") | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment