Advertisement
skip420

.datCracker

Jan 21st, 2022
1,086
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import re
  2. import hashlib
  3. import base58
  4. import binascii
  5. import argparse
  6. import glob
  7. import fileinput
  8. import argparse
  9. import requests
  10. import pycoin
  11. from time import sleep
  12.  
  13. from pycoin.key.Key import Key
  14. from pycoin.ecdsa import generator_secp256k1, public_pair_for_secret_exponent
  15.  
  16. mode = input('(gather) keys or (check) balanaces: ')
  17. location = input('Location of .dat files or keylist: ')
  18. coinname = input('BTC, LTC, DOGE, or DASH: ').upper()
  19.  
  20. def from_long(v, prefix, base, charset):
  21.     l = bytearray()
  22.     while v > 0:
  23.         try:
  24.             v, mod = divmod(v, base)
  25.             l.append(charset(mod))
  26.         except Exception:
  27.             raise EncodingError("can't convert to character corresponding to %d" % mod)
  28.     l.extend([charset(0)] * prefix)
  29.     l.reverse()
  30.     return bytes(l)
  31.  
  32. def to_bytes_32(v):
  33.     v = from_long(v, 0, 256, lambda x: x)
  34.     if len(v) > 32:
  35.         raise ValueError("input to to_bytes_32 is too large")
  36.     return ((b'\0' * 32) + v)[-32:]
  37.  
  38. def bytetohex(byteStr):
  39.     return ''.join( [ "%02X" % x for x in byteStr ] ).strip()
  40.  
  41. litecoin = [b"\x30", b"\xb0"]
  42. dogecoin = [b"\x1e", b"\x71"]
  43. bitcoin = [b"\x00", b"\x80"]
  44. dash = [b"\x4c", b"\xcc"]
  45.  
  46. if coinname == "LTC": cointype = litecoin
  47. elif coinname == "BTC": cointype = bitcoin
  48. elif coinname == "DOGE": cointype = dogecoin
  49. elif coinname == "DASH": cointype = dash
  50.  
  51. #process all keys
  52. if mode == 'check':
  53.     fKeyListFiltered = open(str(location)+"\\unique_keys_"+coinname+".txt", "r")
  54.     keylist = []
  55.     for privkey in fKeyListFiltered:
  56.         privkey = privkey.strip()
  57.         if privkey not in keylist and privkey != '':
  58.             keylist.append(privkey)
  59.     keylist.sort()
  60.  
  61.     for key in keylist:
  62.         key = bytes.fromhex(key)
  63.         public_x, public_y = public_pair_for_secret_exponent(generator_secp256k1, int(bytetohex(key), 16))
  64.         public_key = b'\4' + to_bytes_32(public_x) + to_bytes_32(public_y)
  65.         compressed_public_key = bytes.fromhex("%02x%064x" % (2 + (public_y & 1), public_x))
  66.  
  67.         m = hashlib.new('ripemd160')
  68.         m.update(hashlib.sha256(public_key).digest())
  69.         ripe = m.digest()
  70.  
  71.         m = hashlib.new('ripemd160')
  72.         m.update(hashlib.sha256(compressed_public_key).digest())
  73.         ripe_c = m.digest()
  74.  
  75.         extRipe = cointype[0] + ripe
  76.         extRipe_c = cointype[0] + ripe_c
  77.  
  78.         chksum = hashlib.sha256(hashlib.sha256(extRipe).digest()).digest()[:4] # Step 5-7
  79.         chksum_c = hashlib.sha256(hashlib.sha256(extRipe_c).digest()).digest()[:4] # Step 5-7
  80.  
  81.         addr = extRipe + chksum
  82.         addr_c = extRipe_c + chksum_c
  83.  
  84.         keyWIF = cointype[1] + key
  85.         keyWIF_c = cointype[1] + key + b"\x01"
  86.        
  87.         chksum = hashlib.sha256(hashlib.sha256(keyWIF).digest()).digest()[:4]
  88.         chksum_c = hashlib.sha256(hashlib.sha256(keyWIF_c).digest()).digest()[:4]
  89.  
  90.         addr = keyWIF + chksum
  91.         addr_c = keyWIF_c + chksum_c
  92.  
  93.         str(bytetohex(key))
  94.         private_key_static = str(bytetohex(key))
  95.         extended_key = "80"+private_key_static
  96.         first_sha256 = hashlib.sha256(binascii.unhexlify(extended_key)).hexdigest()
  97.         second_sha256 = hashlib.sha256(binascii.unhexlify(first_sha256)).hexdigest()
  98.         final_key = extended_key+second_sha256[:8]
  99.         WIF = base58.b58encode(binascii.unhexlify(final_key))
  100.         str(WIF)
  101.  
  102.        
  103.         CWIF = base58.b58encode(addr_c)
  104.         str(CWIF)
  105.         pkey = Key(secret_exponent=int.from_bytes(key, 'big'))
  106.         pkey._netcode = coinname
  107.         address = pkey.address()
  108.         fNoBalance = open(str(location)+"\\no_balance_"+coinname+".txt", "a")
  109.         fHasBalance = open(str(location)+"\\has_balance_"+coinname+".txt", "a")
  110.         success = False
  111.         while success == False:
  112.             #sleep(0.1) #enable/adjust this if you are getting rate limited or blocked.
  113.             sleep(1)
  114.             success = False
  115.             if coinname == 'BTC': req = 'https://insight.bitpay.com/api/addr/'+address+'/balance'
  116.             elif coinname == 'LTC': req = 'https://insight.litecore.io/api/addr/'+address+'/balance'
  117.             elif coinname == 'DASH': req = 'https://insight.dash.org/api/addr/'+address+'/balance'
  118.             elif coinname == 'DOGE': req = ' https://dogechain.info/api/v1/address/balance/'+address
  119.             print(req)
  120.             response = requests.get(req)
  121.             if response.status_code == 200:
  122.                 content = response.json()
  123.                 if coinname == 'DOGE':
  124.                     balance = float(content['balance'])
  125.                 else:
  126.                     balance = content / 100000000
  127.                 out = "ADD:"+address+" BAL: "+str(balance)+" WIF:" + str(CWIF)[2:99][:-1] + "\n"
  128.                 print(out)
  129.                 if balance == 0: fNoBalance.write(out)
  130.                 else:
  131.                     fHasBalance.write(out)
  132.                     print("\a")
  133.                 success = True
  134.             continue
  135.  
  136. #Gather all keys
  137. elif mode == 'gather':
  138.     walletHandle = []
  139.     for file in glob.glob(str(location)+"/*.dat"):
  140.         if file.endswith('.dat'):
  141.             print(file)
  142.             walletHandle = open(file, "rb")
  143.             wallet = walletHandle.read()
  144.             privKeys_re_c=re.compile(b'\x30\x81\xD3\x02\x01\x01\x04\x20(.{32})', re.DOTALL)
  145.             privKeys=set(privKeys_re_c.findall(wallet))
  146.             print("Found %d privKeys" % len(privKeys))
  147.             fKeyList = open(str(location)+"\\all_keys_"+coinname+".txt", "a")
  148.             for key in privKeys:
  149.                 #add to file containing ALL keys, just to make sure we don't accidently lose any data
  150.                 fKeyList.write(str(bytetohex(key))+"\n")
  151.             continue
  152.         else:
  153.             continue
  154.     fKeyList = open(str(location)+"\\all_keys_"+coinname+".txt", "r")
  155.     keylist = []
  156.  
  157.     for privkey in fKeyList:
  158.         privkey = privkey.strip()
  159.         if privkey not in keylist and privkey != '':
  160.             keylist.append(privkey)
  161.  
  162.     fKeyListFiltered = open(str(location)+"\\unique_keys_"+coinname+".txt", "w+")
  163.     for privkey in fKeyListFiltered:
  164.         privkey = privkey.strip()
  165.         if privkey not in keylist and privkey != '':
  166.             keylist.append(privkey)
  167.     keylist.sort()
  168.  
  169.     #print("\n".join(keylist))
  170.     fKeyListFiltered.write("\n".join(keylist))
  171.     walletHandle.close()
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement