gurnec / btcrecover

An open source Bitcoin wallet password and seed recovery tool designed for the case where you already know most of your password/seed, but need assistance in trying different possible combinations.
GNU General Public License v2.0
1.28k stars 683 forks source link

BIP38 support #88

Open S1W opened 7 years ago

S1W commented 7 years ago

Hi! I found your amazing tooling when looking for a way to decrypt a BIP38 key in a more or less efficient way. I do have parts of the passphrase, but I suppose btcrecover does not support BIP38? Will there be any BIP38 implementation some day? Thanks!

S1W commented 7 years ago

Attached a bit of code I used before, maybe this is usable to integrate in BTCrecover?

decrypt_bip38.txt

gurnec commented 7 years ago

Thanks!

I'm certainly not against implementing some sort of BIP38 support... (here comes the "but") but it's not very popular, and it is a bit complex. I'll definitely keep this open for now though.

Thanks for the code reference, it'll certainly be helpful at some point. Unfortunately, this code has two attributes which I've been trying very hard to avoid: it's hard to install on a supported OS (Windows in this case), and it implements EC math in pure python (slow, but not a problem if you're not using the EC multiply option). In other words, it could require a lot of work if I want to keep the same rules for this wallet format that I do for others...

Having said all that, since you're familiar with Python, there's no reason you couldn't use btcrecover together with your script. You'd have to modify your script to read passwords from stdin, and then you could run btcrecover with the --listpass option to have it feed passwords to your script which then does all the "real" crypto work.

S1W commented 7 years ago

Great! Thanks for your response. In the meanwhile I will use the --listpass work around. Could you explain a little bit more about what exactly casuses problems with EC math implementation? I thnink the whole idea was to delibaretly make bruteforcing slow on a BIP38 key by design?

gurnec commented 7 years ago

I didn't mean that I thought there was something wrong with this particular implementation nor with BIP38 itself for the most part, only that btcrecover (indirectly) uses Crypto++ for EC math, and I'd like to keep doing this, and btcrecover uses pylibscrypt[1] for scrypt, and I'd like to keep doing this too.

[1]: which on Linux ends up using libscrypt most of the time, and on Windows uses libsodium since compiling either libscrypt or the Python scrypt module for Windows is a bit of a pain and not something I'd expect most end-users to know how to do.

Newbie62 commented 6 years ago

At the risk of sounding like an idiot, how would you modify this script to read passwords from stdin on a mac? Thanks.

S1W commented 6 years ago

You could use the --listpass option to generate your password list and feed that to the script I uploaded before. Edit the scrip and fill the bip = '' variable with your BIP38 string that needs to be tested.

Newbie62 commented 6 years ago

I can't seem to execute the script via my Terminal.app. Would you be able to help me understand what I'm doing wrong? Since I'm on a mac (High Sierra, the latest version) I need to use pythonw rather than simply python. I fill in the bip = ' ' with the name of the txt file (located under btcrecover-master) listing the various passwords created using my tokenlist.txt file using --listpass. I followed the script exactly,except for the gap between lines 64 and 67 because I kept getting an error message regarding indentation. As I'm sure you can tell, I've got a bit learning curve as I am just getting started with python.

Here's my screen:

$ /usr/local/bin/pythonw Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 12:01:12) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information.

import sys, os import getopt import random import time from pybip38 import bip38decrypt from random import choice

inputfile = '' pswd_counter = 0 bip = '54withsecondwallet5.txt'

bip = '54withsecondwallet5.txt'

... def decrypt_key(paswd): ... return bip38decrypt(paswd, bip, outputlotsequence=False) ...

def loop_words(wordlist):

... # for pwd in open(wordlist): ... # result = decrypt_key(pwd) ... # print "Wachtwoord: %s private key: %s" % (pwd, result) ... def loop_words(wordlist): ... global pswd_counter ... result = "" ... for pwd in open(wordlist): ... pswd_counter += 1 ... pwd = pwd.strip() ... result = decrypt_key(pwd) ... if str(result) == "False": ... print "Counter %s Wachtwoord: %s private key: %s" % (pswd_counter, pwd, result) ... else: ... print "Counter %s Wachtwoord: %s private key: %s" % (pswd_counter, pwd, result) ... sys.exit() ... def loopdir(dir): ... for root, , files in os.walk(dir): ... for f in files: ... print os.path.join(root, f) ... loop_words(os.path.join(root, f)) ... def check_input(input): ... if os.path.isdir(input): ... print "Found directory...start looking for wordlists..." ... loop_dir(input) ... def check_input(input): ... if os.path.isdir(input): ... print "Found directory...start looking for wordlists..." ... loop_dir(input) ... elif os.path.isfile(input): ... print "Found file...start looking for passwords..." ... loop_words(input) ... def main(argv): ... try: ... opts, args = getopt.getopt(argv,"hi:k:",["ifile=","key="]) ... except getopt.GetoptError: ... print 'decrypt_wordlist.py -i -k ' ... sys.exit(2) ... key = '' ... inputfile = '' ... for opt, arg in opts: ... if opt == '-h': ... print 'decrypt_wordlist.py -i -k ' ... sys.exit() ... elif opt in ("-i", "--ifile"): ... inputfile = arg ... elif opt in ("-k", "--key"): ... key = arg ... check_input(inputfile) ... if name == "main": ... main(sys.argv[1:]) Grateful for any guidance. Thanks for taking the time.

S1W commented 6 years ago

Sure ;)

You need to put the BIP38 string you want to crack where it says bip = ''. So put a key like this there bip='6PYWndUBwfPBfbijjXZNVrkubTniN6CsViNHpKP6xn2uKBnqZBsT68nezG'.

Leave the inputfile ='' like that. Now Run the script like this:

Python decrypt_bip38.py -i yourpasswordlist.txt

Now the script will iterate through all passwords and try one by one on the bip38 string you inserted in the script.

Newbie62 commented 6 years ago

Thanks so much!

Zeetster2K commented 5 years ago

"PLEASE LEAVE THIS THREAD OPEN". I have a BIP38 paper wallet and a password for it and I created it on bitadress.org. I couldn't see a download for BIP38 in your github instructions. So I find this thread useful as it is going to take me awhile to figure it out. Thanks

3rdIteration commented 3 years ago

My updated fork of BTCRecover now supports BIP38 wallets for Bitcoin, Litecoin, etc. via the --bip38-enc-privkey argument

You can find it here: https://github.com/3rdIteration/btcrecover

CybertSys commented 3 years ago

Thank you. I'm having trouble locating the documentation on how to use it on BIP38 paper wallets.

3rdIteration commented 3 years ago

Documentation available here https://btcrecover.readthedocs.io/en/latest/Usage_Examples/basic_password_recoveries/

CybertSys commented 2 years ago

Ok, I think I'll let you try. I have tried all year.

On Wed, Nov 10, 2021, 5:37 AM password cracker @.***> wrote:

hi, if you still have wallet problem. I can recover your lost wallet. I have powerful servers and excellent software that can find any password. and my fee is only 15-25% of the recovered fund here is my telegram id: @viladmir2022 https://github.com/viladmir2022 and Gmail: @.***

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gurnec/btcrecover/issues/88#issuecomment-965002088, or unsubscribe https://github.com/notifications/unsubscribe-auth/APEJULKQEFIUDQMFV5NDB2DULJDOZANCNFSM4DTJZPNQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

isieditors commented 2 years ago

@CybertSys I can also try it if you are tired of trying it any more my contact details is on my profile