Bitcoin Forum
May 12, 2024, 11:43:29 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoin Wallet Key Batch Extractor.  (Read 378 times)
lightlord (OP)
Donator
Legendary
*
Offline Offline

Activity: 3226
Merit: 1226


★Bitvest.io★ Play Plinko or Invest!


View Profile WWW
October 17, 2019, 01:53:24 PM
Merited by LoyceV (2), ABCbits (2), hugeblack (2), joniboini (2)
 #1

Basically, I was searching through my drive and old files, and forgot about this tool, not sure if its a working version or not.
Might be useful to others that are digging through their old files. I used this about a year ago and found 300,000 dogecoins and 0.3 Bitcoins.

I combined several codes together and came up with a utility a year ago or so. The prompt: "Gather Keys or Check Keys"

Might be useful, for users digging up wallet.dat files, or searching files back from 2010,2011, etc. I have attached both the source code, and the executable file. KeyExtractor.rar - "PrivateKey.exe" - https://filebin.net/peiyfi092vs1m6w0

1)



2)



3)



4)



Executable File:

Code:
import re
import hashlib
import base58
import binascii
import argparse
import glob
import fileinput
import argparse
import requests
import pycoin
from time import sleep
 
from pycoin.key.Key import Key
from pycoin.ecdsa import generator_secp256k1, public_pair_for_secret_exponent
 
mode = input('(gather) keys or (check) balanaces: ')
location = input('Location of .dat files or keylist: ')
coinname = input('BTC, LTC, DOGE, or DASH: ').upper()
 
def from_long(v, prefix, base, charset):
    l = bytearray()
    while v > 0:
        try:
            v, mod = divmod(v, base)
            l.append(charset(mod))
        except Exception:
            raise EncodingError("can't convert to character corresponding to %d" % mod)
    l.extend([charset(0)] * prefix)
    l.reverse()
    return bytes(l)
 
def to_bytes_32(v):
    v = from_long(v, 0, 256, lambda x: x)
    if len(v) > 32:
        raise ValueError("input to to_bytes_32 is too large")
    return ((b'\0' * 32) + v)[-32:]
 
def bytetohex(byteStr):
    return ''.join( [ "%02X" % x for x in byteStr ] ).strip()
 
litecoin = [b"\x30", b"\xb0"]
dogecoin = [b"\x1e", b"\x71"]
bitcoin = [b"\x00", b"\x80"]
dash = [b"\x4c", b"\xcc"]
 
if coinname == "LTC": cointype = litecoin
elif coinname == "BTC": cointype = bitcoin
elif coinname == "DOGE": cointype = dogecoin
elif coinname == "DASH": cointype = dash
 
#process all keys
if mode == 'check':
    fKeyListFiltered = open(str(location)+"\\unique_keys_"+coinname+".txt", "r")
    keylist = []
    for privkey in fKeyListFiltered:
        privkey = privkey.strip()
        if privkey not in keylist and privkey != '':
            keylist.append(privkey)
    keylist.sort()
 
    for key in keylist:
        key = bytes.fromhex(key)
        public_x, public_y = public_pair_for_secret_exponent(generator_secp256k1, int(bytetohex(key), 16))
        public_key = b'\4' + to_bytes_32(public_x) + to_bytes_32(public_y)
        compressed_public_key = bytes.fromhex("%02x%064x" % (2 + (public_y & 1), public_x))
 
        m = hashlib.new('ripemd160')
        m.update(hashlib.sha256(public_key).digest())
        ripe = m.digest()
 
        m = hashlib.new('ripemd160')
        m.update(hashlib.sha256(compressed_public_key).digest())
        ripe_c = m.digest()
 
        extRipe = cointype[0] + ripe
        extRipe_c = cointype[0] + ripe_c
 
        chksum = hashlib.sha256(hashlib.sha256(extRipe).digest()).digest()[:4] # Step 5-7
        chksum_c = hashlib.sha256(hashlib.sha256(extRipe_c).digest()).digest()[:4] # Step 5-7
 
        addr = extRipe + chksum
        addr_c = extRipe_c + chksum_c
 
        keyWIF = cointype[1] + key
        keyWIF_c = cointype[1] + key + b"\x01"
       
        chksum = hashlib.sha256(hashlib.sha256(keyWIF).digest()).digest()[:4]
        chksum_c = hashlib.sha256(hashlib.sha256(keyWIF_c).digest()).digest()[:4]
 
        addr = keyWIF + chksum
        addr_c = keyWIF_c + chksum_c
 
        str(bytetohex(key))
        private_key_static = str(bytetohex(key))
        extended_key = "80"+private_key_static
        first_sha256 = hashlib.sha256(binascii.unhexlify(extended_key)).hexdigest()
        second_sha256 = hashlib.sha256(binascii.unhexlify(first_sha256)).hexdigest()
        final_key = extended_key+second_sha256[:8]
        WIF = base58.b58encode(binascii.unhexlify(final_key))
        str(WIF)
 
       
        CWIF = base58.b58encode(addr_c)
        str(CWIF)
        pkey = Key(secret_exponent=int.from_bytes(key, 'big'))
        pkey._netcode = coinname
        address = pkey.address()
        fNoBalance = open(str(location)+"\\no_balance_"+coinname+".txt", "a")
        fHasBalance = open(str(location)+"\\has_balance_"+coinname+".txt", "a")
        success = False
        while success == False:
            #sleep(0.1) #enable/adjust this if you are getting rate limited or blocked.
            sleep(1)
            success = False
            if coinname == 'BTC': req = 'https://insight.bitpay.com/api/addr/'+address+'/balance'
            elif coinname == 'LTC': req = 'https://insight.litecore.io/api/addr/'+address+'/balance'
            elif coinname == 'DASH': req = 'https://insight.dash.org/api/addr/'+address+'/balance'
            elif coinname == 'DOGE': req = ' https://dogechain.info/api/v1/address/balance/'+address
            print(req)
            response = requests.get(req)
            if response.status_code == 200:
                content = response.json()
                if coinname == 'DOGE':
                    balance = float(content['balance'])
                else:
                    balance = content / 100000000
                out = "ADD:"+address+" BAL: "+str(balance)+" WIF:" + str(CWIF)[2:99][:-1] + "\n"
                print(out)
                if balance == 0: fNoBalance.write(out)
                else:
                    fHasBalance.write(out)
                    print("\a")
                success = True
            continue
 
#Gather all keys
elif mode == 'gather':
    walletHandle = []
    for file in glob.glob(str(location)+"/*.dat"):
        if file.endswith('.dat'):
            print(file)
            walletHandle = open(file, "rb")
            wallet = walletHandle.read()
            privKeys_re_c=re.compile(b'\x30\x81\xD3\x02\x01\x01\x04\x20(.{32})', re.DOTALL)
            privKeys=set(privKeys_re_c.findall(wallet))
            print("Found %d privKeys" % len(privKeys))
            fKeyList = open(str(location)+"\\all_keys_"+coinname+".txt", "a")
            for key in privKeys:
                #add to file containing ALL keys, just to make sure we don't accidently lose any data
                fKeyList.write(str(bytetohex(key))+"\n")
            continue
        else:
            continue
    fKeyList = open(str(location)+"\\all_keys_"+coinname+".txt", "r")
    keylist = []
 
    for privkey in fKeyList:
        privkey = privkey.strip()
        if privkey not in keylist and privkey != '':
            keylist.append(privkey)
 
    fKeyListFiltered = open(str(location)+"\\unique_keys_"+coinname+".txt", "w+")
    for privkey in fKeyListFiltered:
        privkey = privkey.strip()
        if privkey not in keylist and privkey != '':
            keylist.append(privkey)
    keylist.sort()
 
    #print("\n".join(keylist))
    fKeyListFiltered.write("\n".join(keylist))
    walletHandle.close()



.
.BIG WINNER!.
[15.00000000 BTC]


▄████████████████████▄
██████████████████████
██████████▀▀██████████
█████████░░░░█████████
██████████▄▄██████████
███████▀▀████▀▀███████
██████░░░░██░░░░██████
███████▄▄████▄▄███████
████▀▀████▀▀████▀▀████
███░░░░██░░░░██░░░░███
████▄▄████▄▄████▄▄████
██████████████████████

▀████████████████████▀
▄████████████████████▄
██████████████████████
█████▀▀█▀▀▀▀▀▀██▀▀████
█████░░░░░░░░░░░░░████
█████░░░░░░░░░░░░▄████
█████░░▄███▄░░░░██████
█████▄▄███▀░░░░▄██████
█████████░░░░░░███████
████████░░░░░░░███████
███████░░░░░░░░███████
███████▄▄▄▄▄▄▄▄███████

██████████████████████
▀████████████████████▀
▄████████████████████▄
███████████████▀▀▀▀▀▀▀
███████████▀▀▄▄█░░░░░█
█████████▀░░█████░░░░█
███████▀░░░░░████▀░░░▀
██████░░░░░░░░▀▄▄█████
█████░▄░░░░░▄██████▀▀█
████░████▄░███████░░░░
███░█████░█████████░░█
███░░░▀█░██████████░░█
███░░░░░░████▀▀██▀░░░░
███░░░░░░███░░░░░░░░░░

██░▄▄▄▄░████▄▄██▄░░░░
████████████▀▀▀▀▀▀▀██
█████████████░█▀▀▀█░███
██████████▀▀░█▀░░░▀█░▀▀
███████▀░▄▄█░█░░░░░█░█▄
████▀░▄▄████░▀█░░░█▀░██
███░▄████▀▀░▄░▀█░█▀░▄░▀
█▀░███▀▀▀░░███░▀█▀░███░
▀░███▀░░░░░████▄░▄████░
░███▀░░░░░░░█████████░░
░███░░░░░░░░░███████░░░
███▀░██░░░░░░▀░▄▄▄░▀░░░
███░██████▄▄░▄█████▄░▄▄

██░████████░███████░█
▄████████████████████▄
████████▀▀░░░▀▀███████
███▀▀░░░░░▄▄▄░░░░▀▀▀██
██░▀▀▄▄░░░▀▀▀░░░▄▄▀▀██
██░▄▄░░▀▀▄▄░▄▄▀▀░░░░██
██░▀▀░░░░░░█░░░░░██░██
██░░░▄▄░░░░█░██░░░░░██
██░░░▀▀░░░░█░░░░░░░░██
██░░░░░▄▄░░█░░░░░██░██
██▄░░░░▀▀░░█░██░░░░░██
█████▄▄░░░░█░░░░▄▄████
█████████▄▄█▄▄████████

▀████████████████████▀




Rainbot
Daily Quests
Faucet
There are several different types of Bitcoin clients. The most secure are full nodes like Bitcoin Core, which will follow the rules of the network no matter what miners do. Even if every miner decided to create 1000 bitcoins per block, full nodes would stick to the rules and reject those blocks.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715514209
Hero Member
*
Offline Offline

Posts: 1715514209

View Profile Personal Message (Offline)

Ignore
1715514209
Reply with quote  #2

1715514209
Report to moderator
1715514209
Hero Member
*
Offline Offline

Posts: 1715514209

View Profile Personal Message (Offline)

Ignore
1715514209
Reply with quote  #2

1715514209
Report to moderator
1715514209
Hero Member
*
Offline Offline

Posts: 1715514209

View Profile Personal Message (Offline)

Ignore
1715514209
Reply with quote  #2

1715514209
Report to moderator
ashraful1980
Newbie
*
Offline Offline

Activity: 24
Merit: 0


View Profile
July 15, 2020, 04:45:29 PM
 #2

Basically, I was searching through my drive and old files, and forgot about this tool, not sure if its a working version or not.
Might be useful to others that are digging through their old files. I used this about a year ago and found 300,000 dogecoins and 0.3 Bitcoins.

I combined several codes together and came up with a utility a year ago or so. The prompt: "Gather Keys or Check Keys"

Might be useful, for users digging up wallet.dat files, or searching files back from 2010,2011, etc. I have attached both the source code, and the executable file. KeyExtractor.rar - "PrivateKey.exe" - https://filebin.net/peiyfi092vs1m6w0

1)

https://i.imgur.com/YMLdrZz.png

2)

https://i.imgur.com/HcvncYQ.png

3)

https://i.imgur.com/sgACvbE.png

4)

[img width=300]https[Suspicious link removed]cutable File:

Code:
import re
import hashlib
import base58
import binascii
import argparse
import glob
import fileinput
import argparse
import requests
import pycoin
from time import sleep
 
from pycoin.key.Key import Key
from pycoin.ecdsa import generator_secp256k1, public_pair_for_secret_exponent
 
mode = input('(gather) keys or (check) balanaces: ')
location = input('Location of .dat files or keylist: ')
coinname = input('BTC, LTC, DOGE, or DASH: ').upper()
 
def from_long(v, prefix, base, charset):
    l = bytearray()
    while v > 0:
        try:
            v, mod = divmod(v, base)
            l.append(charset(mod))
        except Exception:
            raise EncodingError("can't convert to character corresponding to %d" % mod)
    l.extend([charset(0)] * prefix)
    l.reverse()
    return bytes(l)
 
def to_bytes_32(v):
    v = from_long(v, 0, 256, lambda x: x)
    if len(v) > 32:
        raise ValueError("input to to_bytes_32 is too large")
    return ((b'\0' * 32) + v)[-32:]
 
def bytetohex(byteStr):
    return ''.join( [ "%02X" % x for x in byteStr ] ).strip()
 
litecoin = [b"\x30", b"\xb0"]
dogecoin = [b"\x1e", b"\x71"]
bitcoin = [b"\x00", b"\x80"]
dash = [b"\x4c", b"\xcc"]
 
if coinname == "LTC": cointype = litecoin
elif coinname == "BTC": cointype = bitcoin
elif coinname == "DOGE": cointype = dogecoin
elif coinname == "DASH": cointype = dash
 
#process all keys
if mode == 'check':
    fKeyListFiltered = open(str(location)+"\\unique_keys_"+coinname+".txt", "r")
    keylist = []
    for privkey in fKeyListFiltered:
        privkey = privkey.strip()
        if privkey not in keylist and privkey != '':
            keylist.append(privkey)
    keylist.sort()
 
    for key in keylist:
        key = bytes.fromhex(key)
        public_x, public_y = public_pair_for_secret_exponent(generator_secp256k1, int(bytetohex(key), 16))
        public_key = b'\4' + to_bytes_32(public_x) + to_bytes_32(public_y)
        compressed_public_key = bytes.fromhex("%02x%064x" % (2 + (public_y & 1), public_x))
 
        m = hashlib.new('ripemd160')
        m.update(hashlib.sha256(public_key).digest())
        ripe = m.digest()
 
        m = hashlib.new('ripemd160')
        m.update(hashlib.sha256(compressed_public_key).digest())
        ripe_c = m.digest()
 
        extRipe = cointype[0] + ripe
        extRipe_c = cointype[0] + ripe_c
 
        chksum = hashlib.sha256(hashlib.sha256(extRipe).digest()).digest()[:4] # Step 5-7
        chksum_c = hashlib.sha256(hashlib.sha256(extRipe_c).digest()).digest()[:4] # Step 5-7
 
        addr = extRipe + chksum
        addr_c = extRipe_c + chksum_c
 
        keyWIF = cointype[1] + key
        keyWIF_c = cointype[1] + key + b"\x01"
       
        chksum = hashlib.sha256(hashlib.sha256(keyWIF).digest()).digest()[:4]
        chksum_c = hashlib.sha256(hashlib.sha256(keyWIF_c).digest()).digest()[:4]
 
        addr = keyWIF + chksum
        addr_c = keyWIF_c + chksum_c
 
        str(bytetohex(key))
        private_key_static = str(bytetohex(key))
        extended_key = "80"+private_key_static
        first_sha256 = hashlib.sha256(binascii.unhexlify(extended_key)).hexdigest()
        second_sha256 = hashlib.sha256(binascii.unhexlify(first_sha256)).hexdigest()
        final_key = extended_key+second_sha256[:8]
        WIF = base58.b58encode(binascii.unhexlify(final_key))
        str(WIF)
 
       
        CWIF = base58.b58encode(addr_c)
        str(CWIF)
        pkey = Key(secret_exponent=int.from_bytes(key, 'big'))
        pkey._netcode = coinname
        address = pkey.address()
        fNoBalance = open(str(location)+"\\no_balance_"+coinname+".txt", "a")
        fHasBalance = open(str(location)+"\\has_balance_"+coinname+".txt", "a")
        success = False
        while success == False:
            #sleep(0.1) #enable/adjust this if you are getting rate limited or blocked.
            sleep(1)
            success = False
            if coinname == 'BTC': req = 'https://insight.bitpay.com/api/addr/'+address+'/balance'
            elif coinname == 'LTC': req = 'https://insight.litecore.io/api/addr/'+address+'/balance'
            elif coinname == 'DASH': req = 'https://insight.dash.org/api/addr/'+address+'/balance'
            elif coinname == 'DOGE': req = ' https://dogechain.info/api/v1/address/balance/'+address
            print(req)
            response = requests.get(req)
            if response.status_code == 200:
                content = response.json()
                if coinname == 'DOGE':
                    balance = float(content['balance'])
                else:
                    balance = content / 100000000
                out = "ADD:"+address+" BAL: "+str(balance)+" WIF:" + str(CWIF)[2:99][:-1] + "\n"
                print(out)
                if balance == 0: fNoBalance.write(out)
                else:
                    fHasBalance.write(out)
                    print("\a")
                success = True
            continue
 
#Gather all keys
elif mode == 'gather':
    walletHandle = []
    for file in glob.glob(str(location)+"/*.dat"):
        if file.endswith('.dat'):
            print(file)
            walletHandle = open(file, "rb")
            wallet = walletHandle.read()
            privKeys_re_c=re.compile(b'\x30\x81\xD3\x02\x01\x01\x04\x20(.{32})', re.DOTALL)
            privKeys=set(privKeys_re_c.findall(wallet))
            print("Found %d privKeys" % len(privKeys))
            fKeyList = open(str(location)+"\\all_keys_"+coinname+".txt", "a")
            for key in privKeys:
                #add to file containing ALL keys, just to make sure we don't accidently lose any data
                fKeyList.write(str(bytetohex(key))+"\n")
            continue
        else:
            continue
    fKeyList = open(str(location)+"\\all_keys_"+coinname+".txt", "r")
    keylist = []
 
    for privkey in fKeyList:
        privkey = privkey.strip()
        if privkey not in keylist and privkey != '':
            keylist.append(privkey)
 
    fKeyListFiltered = open(str(location)+"\\unique_keys_"+coinname+".txt", "w+")
    for privkey in fKeyListFiltered:
        privkey = privkey.strip()
        if privkey not in keylist and privkey != '':
            keylist.append(privkey)
    keylist.sort()
 
    #print("\n".join(keylist))
    fKeyListFiltered.write("\n".join(keylist))
    walletHandle.close()


Dear Sir,
I would like to inform you that i have try to run your script (bitwalletrecover.py) for recovering my old or encrypted wallet.dat (Bitcoin); but it is not run following error massage found:

Traceback (most recent call last):
File "bitwalletrecover.py", line 23, in
from pycoin.ecdsa import generator_secp256k1, public_pair_for_secret_exponent
ImportError: cannot import name 'generator_secp256k1' from 'pycoin.ecdsa' (C:\Python37\lib\site-packages\pycoin-0.0.0-py3.7.egg\pycoin\ecdsa_init_.py)

Could you please advice how it is solve..

Thanks & Regards,
Md. Ashraful Alam
HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4316

<insert witty quote here>


View Profile
July 15, 2020, 11:05:38 PM
 #3

Have you installed Python 2.7 or Python 3? Huh

I suspect that most of these older scripts that you're trying to run will NOT work with Python 3... so make sure you have downloaded and installed Python 2.7 from here: https://www.python.org/downloads/release/python-2717/

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


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
MrlostinBTC
Jr. Member
*
Offline Offline

Activity: 45
Merit: 29


View Profile
August 19, 2023, 09:22:38 PM
Merited by nc50lc (1), Cricktor (1)
 #4

Quote
Dear Sir,
I would like to inform you that i have try to run your script (bitwalletrecover.py) for recovering my old or encrypted wallet.dat (Bitcoin); but it is not run following error massage found:

Traceback (most recent call last):
File "bitwalletrecover.py", line 23, in
from pycoin.ecdsa import generator_secp256k1, public_pair_for_secret_exponent
ImportError: cannot import name 'generator_secp256k1' from 'pycoin.ecdsa' (C:\Python37\lib\site-packages\pycoin-0.0.0-py3.7.egg\pycoin\ecdsa_init_.py)

Could you please advice how it is solve..

Thanks & Regards,
Md. Ashraful Alam
Old thread but

I encountered the same issue. It seems to be caused by the latest pycoin release. It was corrected with.


Set python to version 2.7 as default.
https://netslovers.com/post/how-install-python-27-pip-ubuntu-22-04/

sudo python -m pip uninstall pycoin
sudo python -m pip install pycoin==0.80
sudo python -m pip install pycrypto

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!