Bitcoin Forum
November 11, 2024, 10:05:38 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Electrum Wallet Seed Recovery  (Read 2651 times)
S_D (OP)
Full Member
***
Offline Offline

Activity: 198
Merit: 112



View Profile
January 14, 2017, 01:43:44 PM
Last edit: January 15, 2017, 04:40:30 AM by S_D
 #1

Hey everyone,

I am not in trouble here, this topic is created just for info.

Is it possible to recover wallet seed from 'wallet' file in following scenes:

Assuming I dint have the seed in both cases.

Scenario 1:
I have an unencrypted wallet i.e. no password was set for the wallet.
I have the wallet file; when we I open the file as text I could see
Code:
....
        "seed": "431a62f1c86555d3c45e5c4d9e10c8c7",
....
In this case I don't see the actual seed, so I guess this is in encrypted form. Is it possible to decrypt this to get the correct 12 word seed?


Scenario 2:
I have an encrypted wallet i.e. a password was set for the wallet.
I have the wallet file; when we I open the file as text I could see
Code:
....
        "seed": "bBbGXH3ivbmwapRODeAn7wp7VviwDkpNOcaRdW9EDiA5xeYXj8CtrUidHvRbCubIJhMaPjlEOfO0kQM13RB6Zw==",
....
In this case believe the above string was further encrypted. Is it possible to decrypt this to get the correct 12 word seed?


Progress

Scene 1 - Solved : the hex code mentioned in the file as "seed" can be used as seed while recreating the wallet.

Scene 2 - In Progress :

Function used :
Code:
def mnemonic_to_seed(self, mnemonic, passphrase):
        PBKDF2_ROUNDS = 2048
        mnemonic = normalize_text(mnemonic)
        passphrase = normalize_text(passphrase)
        return pbkdf2.PBKDF2(mnemonic, 'electrum' + passphrase, iterations = PBKDF2_ROUNDS, macmodule = hmac, digestmodule = hashlib.sha512).read(64)

Encryption = PBKDF2 (maybe hard-coded to sha256)
Iterations = 2048
pass = mnemonic = seed (So I assume seed in hex mentioned above can be used)
salt = 'electrum' + passphrase (Not sure what this means yet)

Free bitcoins, to reveal private key scratch here ==>>  5▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
longbob72
Hero Member
*****
Offline Offline

Activity: 574
Merit: 503


V2h5IGFyZSB5b3UgcmVhZGluZyB0aGlzPw==


View Profile
January 14, 2017, 03:45:43 PM
 #2

The seed field should show the actual unencrypted seed unless you have set a password. What type of wallet are you using? Do you have any problem sending bitcoins?

                                                                       
    ▄▄███████▄▄                           ▄      ▄
   ██████████████▄                       ███    ███
  ███▀ ▄▄▄▄▄▄▄ ▀████                     ███    ███
  █████████████▄ ▀███                    ███    ███   █▄ ▄▄
   ▀████▄  ▄▄███  ▀███                   ███    ███  ▄████
   ▄███████████   ▄███                  ███    ███  ▀▀███▀▀
   ███           ▄███         ▄▄▄▄      ███    ███     █    ▄▄  ▄▄▄▄
  ▄███     ▄▄▄▄█████        ▄█████▄    ▄██▀   ▄██▀    ███   █████████
  ███▄    ████████         ▄███▀▀███   ███    ███    ███▀   █████▀████
   ███     ▀▀█████▄      ▄█████▄ ███   ███    ███    ███    ████   ███
   ███         ▀███▄     ███▀███ ███  ███▀   ███▀    ███    ███▀   ███
   ███           ███▄    ███  ▀▀ ███  ███    ███    ███▀   ▄███    ███
   ▀██▄           ███    ███▄  ▄███   ███    ███    ███    ███    ███▀
    ███           ▀███▄   ████████    ███    ███    ███    ███    ███
    ▀██            ▀████   ▀████▀      ██     ██    ▀██    ▀█▀    ▀█▀


.
.
.
        ▄▄▀                ▀▄▄
     ▄ ▀▀                    ▀▀ ▄
   ▄ ▀▀▀                      ▀▀▀ ▄
  ▄▀▀▀                          ▀▀▀▄
 ▀█▄▄                            ▄▄█▀
▄█  ▄                            ▄  █▄
▀█ █▀                            ▀█ █▀
█▄  ▄                            ▄  ▄█
▀█ █                              █ █▀
█▄   █                          █   ▄█
 ██▄█▀                          ▀█▄██
  ▀▀  ▄█                      █▄  ▀▀
  ▀██▄ ▀  █▄              ▄█  ▀ ▄██▀
    ▀▀▀   ██  █▄      ▄█  ██   ▀▀▀
     ▀███▄▄▀  ███    ███  ▀▄▄███▀
        ▀▀▀▀▄▄▄▄▀    ▀▄▄▄▄▀▀▀▀
          ▀▀█████▀▀▀▀█████▀▀
.
.
Free Bitcoins
Chat Lottery & Games
Level Up System with Rewards
▄████████▄  ▄████████▄
██      ██  ██      ██
██      ██  ██      ██
██      ██  ██      ██
██      ██  ██      ██
 ████████    ████████
██      ██  ██      ██
██      ██  ██      ██
██      ██  ██      ██
██      ██  ██      ██
▀████████▀  ▀████████▀
.
S_D (OP)
Full Member
***
Offline Offline

Activity: 198
Merit: 112



View Profile
January 14, 2017, 06:10:52 PM
 #3

The seed field should show the actual unencrypted seed unless you have set a password. What type of wallet are you using? Do you have any problem sending bitcoins?
I am using Electrum Installer Version 2.7.17
I am able to send and receive bitcoins.

Free bitcoins, to reveal private key scratch here ==>>  5▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
kolloh
Legendary
*
Offline Offline

Activity: 1736
Merit: 1023


View Profile
January 14, 2017, 06:36:34 PM
 #4

Yes, it should be possible to convert this to the seed words. Electrum has the ability to show you the seed words ( Click Wallet->Seed ).

These snippets of Electrum's code look to be relevant:
Code:
import old_mnemonic
# see if seed was entered as hex
seed = seed.strip()
if seed:
    try:
        seed.decode('hex')
        return str(seed)
    except Exception:
        pass
words = seed.split()
seed = old_mnemonic.mn_decode(words)
if not seed:
    raise Exception("Invalid seed")
return seed

Code:
def mnemonic_decode(self, seed):
    n = len(self.wordlist)
    words = seed.split()
    i = 0
    while words:
        w = words.pop()
        k = self.wordlist.index(w)
        i = i*n + k
    return i

It looks like there are functions to convert the hex seed back into words and vice versa.
S_D (OP)
Full Member
***
Offline Offline

Activity: 198
Merit: 112



View Profile
January 14, 2017, 07:35:16 PM
 #5

Yes, it should be possible to convert this to the seed words. Electrum has the ability to show you the seed words ( Click Wallet->Seed ).
...
It looks like there are functions to convert the hex seed back into words and vice versa.

Well lets assume I got only the wallet file.

I am not a python wizard, may be an electrum or python dev could enlighten us.

Free bitcoins, to reveal private key scratch here ==>>  5▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
longbob72
Hero Member
*****
Offline Offline

Activity: 574
Merit: 503


V2h5IGFyZSB5b3UgcmVhZGluZyB0aGlzPw==


View Profile
January 14, 2017, 08:49:27 PM
Last edit: January 14, 2017, 09:01:59 PM by longbob72
 #6

So apparently hex seed were a thing. Didn't know that.

You can actually recover your wallet just by entering the hex seed, you know. I just tried and it works.
If you want to get the non-hex seed just do it from the client.

                                                                       
    ▄▄███████▄▄                           ▄      ▄
   ██████████████▄                       ███    ███
  ███▀ ▄▄▄▄▄▄▄ ▀████                     ███    ███
  █████████████▄ ▀███                    ███    ███   █▄ ▄▄
   ▀████▄  ▄▄███  ▀███                   ███    ███  ▄████
   ▄███████████   ▄███                  ███    ███  ▀▀███▀▀
   ███           ▄███         ▄▄▄▄      ███    ███     █    ▄▄  ▄▄▄▄
  ▄███     ▄▄▄▄█████        ▄█████▄    ▄██▀   ▄██▀    ███   █████████
  ███▄    ████████         ▄███▀▀███   ███    ███    ███▀   █████▀████
   ███     ▀▀█████▄      ▄█████▄ ███   ███    ███    ███    ████   ███
   ███         ▀███▄     ███▀███ ███  ███▀   ███▀    ███    ███▀   ███
   ███           ███▄    ███  ▀▀ ███  ███    ███    ███▀   ▄███    ███
   ▀██▄           ███    ███▄  ▄███   ███    ███    ███    ███    ███▀
    ███           ▀███▄   ████████    ███    ███    ███    ███    ███
    ▀██            ▀████   ▀████▀      ██     ██    ▀██    ▀█▀    ▀█▀


.
.
.
        ▄▄▀                ▀▄▄
     ▄ ▀▀                    ▀▀ ▄
   ▄ ▀▀▀                      ▀▀▀ ▄
  ▄▀▀▀                          ▀▀▀▄
 ▀█▄▄                            ▄▄█▀
▄█  ▄                            ▄  █▄
▀█ █▀                            ▀█ █▀
█▄  ▄                            ▄  ▄█
▀█ █                              █ █▀
█▄   █                          █   ▄█
 ██▄█▀                          ▀█▄██
  ▀▀  ▄█                      █▄  ▀▀
  ▀██▄ ▀  █▄              ▄█  ▀ ▄██▀
    ▀▀▀   ██  █▄      ▄█  ██   ▀▀▀
     ▀███▄▄▀  ███    ███  ▀▄▄███▀
        ▀▀▀▀▄▄▄▄▀    ▀▄▄▄▄▀▀▀▀
          ▀▀█████▀▀▀▀█████▀▀
.
.
Free Bitcoins
Chat Lottery & Games
Level Up System with Rewards
▄████████▄  ▄████████▄
██      ██  ██      ██
██      ██  ██      ██
██      ██  ██      ██
██      ██  ██      ██
 ████████    ████████
██      ██  ██      ██
██      ██  ██      ██
██      ██  ██      ██
██      ██  ██      ██
▀████████▀  ▀████████▀
.
S_D (OP)
Full Member
***
Offline Offline

Activity: 198
Merit: 112



View Profile
January 14, 2017, 10:00:04 PM
 #7

So apparently hex seed were a thing. Didn't know that.

You can actually recover your wallet just by entering the hex seed, you know. I just tried and it works.
If you want to get the non-hex seed just do it from the client.

Now how cool is that. This solves my problem in Scene 1 (Still curious whats the relation between the hex and the 12 word seed)

And for the Scene 2 now, What encryption is used to encrypt the hex in Scene 1...
Any devs here to help?

Free bitcoins, to reveal private key scratch here ==>>  5▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
kolloh
Legendary
*
Offline Offline

Activity: 1736
Merit: 1023


View Profile
January 14, 2017, 11:01:17 PM
 #8

And for the Scene 2 now, What encryption is used to encrypt the hex in Scene 1...
Any devs here to help?

I believe that it uses the password to encrypt using pbkdf2 in the following manner:
Code:
  def mnemonic_to_seed(self, mnemonic, passphrase):
        PBKDF2_ROUNDS = 2048
        mnemonic = normalize_text(mnemonic)
        passphrase = normalize_text(passphrase)
        return pbkdf2.PBKDF2(mnemonic, 'electrum' + passphrase, iterations = PBKDF2_ROUNDS, macmodule = hmac, digestmodule = hashlib.sha512).read(64)
S_D (OP)
Full Member
***
Offline Offline

Activity: 198
Merit: 112



View Profile
January 15, 2017, 04:43:48 AM
 #9

I believe that it uses the password to encrypt using pbkdf2 in the following manner:
Code:
  def mnemonic_to_seed(self, mnemonic, passphrase):
        PBKDF2_ROUNDS = 2048
        mnemonic = normalize_text(mnemonic)
        passphrase = normalize_text(passphrase)
        return pbkdf2.PBKDF2(mnemonic, 'electrum' + passphrase, iterations = PBKDF2_ROUNDS, macmodule = hmac, digestmodule = hashlib.sha512).read(64)

Hey thanks,
Now I need to figure out how to push this info in this function-

Wallet pass = 125
Seed = 431a62f1c86555d3c45e5c4d9e10c8c7

Free bitcoins, to reveal private key scratch here ==>>  5▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
kolloh
Legendary
*
Offline Offline

Activity: 1736
Merit: 1023


View Profile
January 15, 2017, 05:01:20 AM
 #10

I believe that it uses the password to encrypt using pbkdf2 in the following manner:
Code:
  def mnemonic_to_seed(self, mnemonic, passphrase):
        PBKDF2_ROUNDS = 2048
        mnemonic = normalize_text(mnemonic)
        passphrase = normalize_text(passphrase)
        return pbkdf2.PBKDF2(mnemonic, 'electrum' + passphrase, iterations = PBKDF2_ROUNDS, macmodule = hmac, digestmodule = hashlib.sha512).read(64)

Hey thanks,
Now I need to figure out how to push this info in this function-

Wallet pass = 125
Seed = 431a62f1c86555d3c45e5c4d9e10c8c7

Do you need to do this outside of Electrum? Why not just restore the seed into a new wallet then go to Wallet->Seed and it will reveal the seed words.
kolloh
Legendary
*
Offline Offline

Activity: 1736
Merit: 1023


View Profile
January 15, 2017, 05:20:20 AM
Last edit: January 15, 2017, 05:38:09 AM by kolloh
 #11

I found out you can decode it via electrum's console fairly easily as shown:

Code:
>> import aes
>> from electrum import wallet
>> wallet.pw_decode('bBbGXH3ivbmwapRODeAn7wp7VviwDkpNOcaRdW9EDiA5xeYXj8CtrUidHvRbCubIJhMaPjlEOfO0kQM13RB6Zw==','125')
u'431a62f1c86555d3c45e5c4d9e10c8c7'

Let me know if this works for what you need.

For further fun, here is how you get the seed words:
Code:
>> import old_mnemonic
>> old_mnemonic.mn_encode('431a62f1c86555d3c45e5c4d9e10c8c7')
['constant', 'forest', 'adore', 'false', 'green', 'weave', 'stop', 'guy', 'fur', 'freeze', 'giggle', 'clock']

It's using the old_mnemonic as the seed is in the old format I believe.
Abdussamad
Legendary
*
Offline Offline

Activity: 3682
Merit: 1580



View Profile
January 15, 2017, 09:24:42 AM
 #12

And for the Scene 2 now, What encryption is used to encrypt the hex in Scene 1...
Any devs here to help?

I believe that it uses the password to encrypt using pbkdf2 in the following manner:
Code:
  def mnemonic_to_seed(self, mnemonic, passphrase):
        PBKDF2_ROUNDS = 2048
        mnemonic = normalize_text(mnemonic)
        passphrase = normalize_text(passphrase)
        return pbkdf2.PBKDF2(mnemonic, 'electrum' + passphrase, iterations = PBKDF2_ROUNDS, macmodule = hmac, digestmodule = hashlib.sha512).read(64)


Hashing functions are not encryption functions. That's converting the seed words to the master private key. There is no encryption involved there. This function is actually from bip39 although electrum uses a different seed mnemonic format. The passphrase in this instance is the "extend your seed with custom words" thing that electrum introduced recently. To see that option create a new wallet and during the seed display window phase click on options.
 
I see you've figured out how to decrypt the new seed from scene 2 using the console. But the OP could just have opened the wallet file using electrum and then viewed the seed via the GUI menu option wallet > seed. You can open a different wallet file using file > open or with the -w command line switch.

S_D (OP)
Full Member
***
Offline Offline

Activity: 198
Merit: 112



View Profile
January 16, 2017, 07:46:54 AM
 #13

I am trying to understand how Electrum works exactly here Roll Eyes.

I hate the easy way, Dont wanna go through the GUI way that wont tell me anything about how Electrum works!

Thanks for the input though.

Free bitcoins, to reveal private key scratch here ==>>  5▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
Abdussamad
Legendary
*
Offline Offline

Activity: 3682
Merit: 1580



View Profile
January 16, 2017, 08:14:26 AM
 #14

I am trying to understand how Electrum works exactly here Roll Eyes.

That's actually a very nice outlook. People like you force us to look deeper and everyone learns something new from that. So yeah ask away Smiley
S_D (OP)
Full Member
***
Offline Offline

Activity: 198
Merit: 112



View Profile
January 16, 2017, 10:00:12 AM
 #15


That's actually a very nice outlook. People like you force us to look deeper and everyone learns something new from that. So yeah ask away Smiley

Well thanks a lot, I was about to close this thread and then boom! someone who understands me  Cheesy

Now that we know why we are talking, is it possible to calculate encrypted key on a calculator on some thing like this:
https://asecuritysite.com/encryption/PBKDF2z

Free bitcoins, to reveal private key scratch here ==>>  5▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
Abdussamad
Legendary
*
Offline Offline

Activity: 3682
Merit: 1580



View Profile
January 16, 2017, 11:51:12 AM
 #16


That's actually a very nice outlook. People like you force us to look deeper and everyone learns something new from that. So yeah ask away Smiley

Well thanks a lot, I was about to close this thread and then boom! someone who understands me  Cheesy

Now that we know why we are talking, is it possible to calculate encrypted key on a calculator on some thing like this:
https://asecuritysite.com/encryption/PBKDF2z

PBKDF2 is not an encryption function. I explained that above but it's also explained on that page:

Quote
this is used to create an encryption key from a defined password, and where it is not possible to reverse the password from the hashed value.

A hash function is not an encryption function. Electrum uses AES to encrypt your seed:

https://github.com/spesmilo/electrum/blob/59ed5932a859fd807232960404764b8686355830/lib/bitcoin.py#L119
Haigo
Newbie
*
Offline Offline

Activity: 5
Merit: 0


View Profile
November 16, 2017, 12:15:24 PM
 #17

This post has seriously grabbed my attention. I very foolishly have managed to lose my password and seed (I know, I know) for my Electrum wallet.

After reading this:
"I see you've figured out how to decrypt the new seed from scene 2 using the console"

And seeing this:
>> import aes
>> from electrum import wallet
>>wallet.pw_decode('bBbGXH3ivbmwapRODeAn7wp7VviwDkpNOcaRdW9EDiA5xeYXj8CtrUidHvRbCubIJhMaPjlEOfO0kQM 13RB6Zw==','125')
u'431a62f1c86555d3c45e5c4d9e10c8c7'

Am I right in thinking it is somehow possible to decrypt the password? I do have the original wallet file in full.
I did try the above example but received an error message:
"InvalidPassword: Incorrect password"

Any help here would be massively appreciated - certainly willing to reward if I find a way to decrypt the seed.
Spendulus
Legendary
*
Offline Offline

Activity: 2926
Merit: 1386



View Profile
November 17, 2017, 12:05:03 PM
 #18

So apparently hex seed were a thing. Didn't know that.

You can actually recover your wallet just by entering the hex seed, you know. I just tried and it works.
If you want to get the non-hex seed just do it from the client.

Now how cool is that. This solves my problem in Scene 1 (Still curious whats the relation between the hex and the 12 word seed)

And for the Scene 2 now, What encryption is used to encrypt the hex in Scene 1...
Any devs here to help?

Interesting. Question: Do you use the phrase "hex" here to imply the base 58 encoded string? Hex traditionally meant base 16 eg 0-9 and a,b,c,d,e,f.

HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4361

<insert witty quote here>


View Profile
November 17, 2017, 11:24:42 PM
 #19

This post has seriously grabbed my attention. I very foolishly have managed to lose my password and seed (I know, I know) for my Electrum wallet.

After reading this:
"I see you've figured out how to decrypt the new seed from scene 2 using the console"

And seeing this:
>> import aes
>> from electrum import wallet
>>wallet.pw_decode('bBbGXH3ivbmwapRODeAn7wp7VviwDkpNOcaRdW9EDiA5xeYXj8CtrUidHvRbCubIJhMaPjlEOfO0kQM 13RB6Zw==','125')
u'431a62f1c86555d3c45e5c4d9e10c8c7'

Am I right in thinking it is somehow possible to decrypt the password? I do have the original wallet file in full.
No... what that function is doing, is decoding he encrypted seed from the wallet file... using the password!

I think you missed the bit where he said his password was '125'...
...
Now I need to figure out how to push this info in this function-
Wallet pass = 125
Seed = 431a62f1c86555d3c45e5c4d9e10c8c7


You have to give the function the password as the second argument... hence:
Quote
wallet.pw_decode('bBbGXH3ivbmwapRODeAn7wp7VviwDkpNOcaRdW9EDiA5xeYXj8CtrUidHvRbCubIJhMaPjlEOfO0kQM 13RB6Zw==','125')




Interesting. Question: Do you use the phrase "hex" here to imply the base 58 encoded string? Hex traditionally meant base 16 eg 0-9 and a,b,c,d,e,f.

No... he meant "hex"... the "seed" which is essentially just a big number... was previously stored in the wallet file in hex... as per the OP:
Scenario 1:
I have an unencrypted wallet i.e. no password was set for the wallet.
I have the wallet file; when we I open the file as text I could see
Code:
....
        "seed": "431a62f1c86555d3c45e5c4d9e10c8c7",
....

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!