Search code examples
certificatersabrute-forcepassphrase

How to bruteforce an RSA private-key's passphrase?


I have an encrypted RSA key which needs a pass-phrase to unlock. I have forgotten the pass-phrase, but I remember that there are only 6 digits in that pass-phrase. I think brute-forcing it would give me the pass-phrase.

Thanks for your help iabdhv liasbv


Solution

  • Well you could google for this and as in the comment the tag john the ripper was mentioned, but is not there anymore, I still assume that you initially wanted to use jtr. A manual is given here.

    It's basic steps are:

    1. Download and compile the Jumbo version of John the Ripper from Github.

    2. Use gpg2john to convert your rsa_key to a jtr understandable format refered as file1 now.

    3. Use john --incremental file1 to start jtr in brute-force mode.

    Note however that the third step will make jtr also use chars and not only digits. You could change this by via settings in the config or you could simply create a small script to generate a password list with all possible passwords.

    for number1 in range(0,9):
      for number2 in range(0,9):
        for number3 in range(0,9):
          for number4 in range(0,9):
            for number5 in range(0,9):
              for number6 in range(0,9):
                print str(number1) + str(number2) + str(number3) + str(number4) + str(number5) + str(number6) 
    

    And then start this script on linux using python scriptname.py > passwords.txt after it terminated start jtr using the following command: john --wordlist=passwords.txt file1