I have a wallet.dat file which is encrypted and I can remember that I have put only numbers as password(4 or 5 digits, not more, not less).
My friend suggested to do brute force on it using python.
I tried googling and unfortunately(poor programming) didn't got any python script. Can anyone help me please ?


I would approach this using JSON-RPC with the programming language of your choice and the walletpassphrase command.

walletpassphrase "12345" 60

The 60 at the end is number of seconds before the passphrase times out and needs to be entered again. Now all you need to do is create a loop that iterates through all number combinations.

If the guess is wrong the bitcoin client will return
Error: The wallet passphrase entered was incorrect. (code -14)

If the guess is correct the bitcoin client will return

So all you would need to do is check for the response and if null then the guess is correct and you can stop your loop.


To bruteforce a wallet.dat file you would need to follow these steps.

  1. Install python from python.org
  2. Download john the ripper from github
  3. run the script bitcoin2john.py to extract the hash
  4. get hashcat from hashcat.net

With hashcat you can search the entire space of numbers of your choice using a mask ?d?d?d?d?d?d and increment.

Your hashcat command would look like: hashcat -m 11300 wallethash.txt -a 3 ?d?d?d?d?d?d?d --increment etc would work

Once the password is found you can use it to export the private key from core.

Not the answer you're looking for? Browse other questions tagged or ask your own question.