Skip to content

Instantly share code, notes, and snippets.

@fcicq
Forked from anfedorov/mywallet.py
Created August 16, 2012 08:49
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save fcicq/3368495 to your computer and use it in GitHub Desktop.
Save fcicq/3368495 to your computer and use it in GitHub Desktop.
tools to decrypt blockchain.info wallet.json.aes
#!/usr/bin/env python
import base64, hashlib, hmac, json, sys, getpass
from Crypto.Cipher import AES
from Crypto.Hash import RIPEMD, SHA256
base58_chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
def prompt(p):
return getpass.getpass(p + ": ")
def decrypt(encrypted, password):
encrypted = base64.b64decode(encrypted)
iv, encrypted = encrypted[:16], encrypted[16:]
aeshash = pbkdf2(password, iv, 10, 32)
clear = remove_iso10126_padding(AES.new(aeshash, AES.MODE_CBC, iv).decrypt(encrypted))
return clear
def remove_iso10126_padding(s):
ba = bytearray(s)
pad_len = ba[-1]
return str(ba[:-pad_len])
def base58_decode(v):
value = 0; ret = ''
for c in v: value = value*58 + base58_chars.find(c)
for i in range(32):
ret = "%c"%(value%256) + ret; value /= 256
return ret
def base58_encode(v):
value = 0; ret = ''
for c in v: value = value*256 + ord(c)
while value > 0:
ret = base58_chars[value%58] + ret; value /= 58
return ret
def to_sipa(s):
version = 128 # or 239 for testnet
key = chr(version) + base58_decode(s)
return base58_encode(key + SHA256.new(SHA256.new(key).digest()).digest()[:4])
# pbkdf2 from http://matt.ucc.asn.au/src/pbkdf2.py
from struct import pack
# this is what you want to call.
def pbkdf2( password, salt, itercount, keylen, hashfn = hashlib.sha1 ):
digest_size = hashfn().digest_size
# l - number of output blocks to produce
l = keylen / digest_size
if keylen % digest_size != 0:
l += 1
h = hmac.new( password, None, hashfn )
T = ""
for i in range(1, l+1):
T += pbkdf2_F( h, salt, itercount, i )
return T[0: keylen]
def xorstr( a, b ):
if len(a) != len(b):
raise "xorstr(): lengths differ"
ret = ''
for i in range(len(a)):
ret += chr(ord(a[i]) ^ ord(b[i]))
return ret
def prf( h, data ):
hm = h.copy()
hm.update( data )
return hm.digest()
# Helper as per the spec. h is a hmac which has been created seeded with the
# password, it will be copy()ed and not modified.
def pbkdf2_F( h, salt, itercount, blocknum ):
U = prf( h, salt + pack('>i',blocknum ) )
T = U
for i in range(2, itercount+1):
U = prf( h, U )
T = xorstr( T, U )
return T
clear = decrypt(prompt("encrypted wallet"), prompt("password"))
obj = json.loads(clear)
if (obj.has_key('double_encryption')):
print("wallet uses double encryption")
password = obj['sharedKey'].encode('ascii') + prompt("2nd password")
for key in obj['keys']: key['priv'] = decrypt(key['priv'], password)
for key in obj['keys']: key['priv_sipa'] = to_sipa(key['priv'])
print(json.dumps(obj, indent=4, sort_keys = True))
@catuss-a
Copy link

@QQQ126 I can try that for you

@b00053402
Copy link

b00053402 commented Oct 9, 2017

Maybe you could help me with:
You've registered for an online service that uses hash chains.

You've registered as user 'nOOB’ and have been given the hash chain seed 654e1c2ac6312d8c6441282f155c8ce9

Use the given information to figure out how to authenticate as the user 'ECSC' for the given challenge hash c89aa2ffb9edcc6604005196b5f0e0e4

i.e. Find the hash that hashes to this - This hash will be your solution.

For user nOOB used MD5,
IDK what i should to do with second part, have I use any blockchain algorithm before decode a hash?

@doctorresidual
Copy link

I am having this same issue. Can anyone help?

@redredmaster
Copy link

Well? absolutely not clear
where to insert what to do
for whom is this
if you are a professional coder, I think, and without this "smart file" it will be clear what to do, but for the noobs only gets angry?

@mirza123456786
Copy link

dear I will do brute force for you if you remember some part of your password
you can contact me at bewithhope2@gmail.com

@Hiroaki78
Copy link

My Ethereum *.json wallet that I bought at Ethereum crowd sale (Genesis). Unfortunately I don't know the password anymore.

How can i recover it? plz help me out.

@doge2021
Copy link

My Ethereum *.json wallet that I bought at Ethereum crowd sale (Genesis). Unfortunately I don't know the password anymore.

How can i recover it? plz help me out.
you may reach BTC recover , if you know what possible symbols you used, there is a good chance to recover it.
Ethereum presale wallet 🐞 password with special characters: symbols : (https://www.youtube.com/watch?v=BrFSYA9778w)

@doge2021
Copy link

I have an imported wallet aes.json file to be open in blockchain.info and believed was encrypted. I have an issue to login. My wallet password was not recognized any more. The only solution as per the technical support is to brute force the password. What is the tool to brute force the password for a layman like me. Meaning I do not have enough knowledge on programming but relying only to tutorial on that tool to use it. Any body who can share to me ideas to bruteforce it is very much appreciated and will donate if ever successful. Thank you..

you may reach BTC recover , if you have a idea of the password, there is a good chance to recover it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment