简体   繁体   English

更改 Plutus.py 的比特币钱包地址范围

[英]Changing Bitcoin Wallet Address Range for Plutus.py

I am working with the following script from https://github.com/Isaacdelly/Plutus/blob/master/plutus.py我正在使用https://github.com/Isaacdelly/Plutus/blob/master/plutus.py 中的以下脚本

The script works for wallet addresses in the 2^160 range.该脚本适用于 2^160 范围内的钱包地址。 I am curious where in the script I can change this to look at the 2^128 range or 2^n range.我很好奇我可以在脚本中的哪个位置更改它以查看 2^128 范围或 2^n 范围。 Would it be possible to even have a window?甚至有可能有一个窗口吗? Like 2^0 - 2^100?像 2^0 - 2^100?

Not trying to do anything malicious, just trying to get data to show that even selecting ranges is futile due to the large number of addresses.不试图做任何恶意的事情,只是试图获取数据以表明由于地址数量众多,即使选择范围也是徒劳的。

 # Plutus Bitcoin Brute Forcer
# Made by Isaac Delly
# https://github.com/Isaacdelly/Plutus

try:
    import sys
    import os
    import time
    import hashlib
    import binascii
    import multiprocessing
    from multiprocessing import Process, Queue
    from multiprocessing.pool import ThreadPool
    import threading
    import base58
    import ecdsa
    import requests
except ImportError:
    import subprocess
    subprocess.check_call(["python", '-m', 'pip', 'install', 'base58==1.0.0'])
    subprocess.check_call(["python", '-m', 'pip', 'install', 'ecdsa==0.13'])
    subprocess.check_call(["python", '-m', 'pip', 'install', 'requests==2.19.1'])
    import base58
    import ecdsa
    import requests

def generate_private_key():
    return binascii.hexlify(os.urandom(32)).decode('utf-8')

def private_key_to_WIF(private_key):
    var80 = "80" + str(private_key) 
    var = hashlib.sha256(binascii.unhexlify(hashlib.sha256(binascii.unhexlify(var80)).hexdigest())).hexdigest()
    return str(base58.b58encode(binascii.unhexlify(str(var80) + str(var[0:8]))), 'utf-8')

def private_key_to_public_key(private_key):
    sign = ecdsa.SigningKey.from_string(binascii.unhexlify(private_key), curve = ecdsa.SECP256k1)
    return ('04' + binascii.hexlify(sign.verifying_key.to_string()).decode('utf-8'))

def public_key_to_address(public_key):
    alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
    count = 0; val = 0
    var = hashlib.new('ripemd160')
    var.update(hashlib.sha256(binascii.unhexlify(public_key.encode())).digest())
    doublehash = hashlib.sha256(hashlib.sha256(binascii.unhexlify(('00' + var.hexdigest()).encode())).digest()).hexdigest()
    address = '00' + var.hexdigest() + doublehash[0:8]
    for char in address:
        if (char != '0'):
            break
        count += 1
    count = count // 2
    n = int(address, 16)
    output = []
    while (n > 0):
        n, remainder = divmod (n, 58)
        output.append(alphabet[remainder])
    while (val < count):
        output.append(alphabet[0])
        val += 1
    return ''.join(output[::-1])

def get_balance(address):
    try:
        response = requests.get("https://bitaps.com/api/address/" + str(address))
        return int(response.json()['balance']) 
    except:
        return -1

def data_export(queue):
    while True:
        private_key = generate_private_key()
        public_key = private_key_to_public_key(private_key)
        address = public_key_to_address(public_key)
        data = (private_key, address)
        queue.put(data, block = False)

def worker(queue):
    while True:
        if not queue.empty():
            data = queue.get(block = True)
            balance = get_balance(data[1])
            process(data, balance)

def process(data, balance):
    private_key = data[0]
    address = data[1]
    if (balance == 0):
        print("{:<34}".format(str(address)) + ": " + str(balance))
    if (balance > 0):
        file = open("plutus.txt","a")
        file.write("address: " + str(address) + "\n" +
                   "private key: " + str(private_key) + "\n" +
                   "WIF private key: " + str(private_key_to_WIF(private_key)) + "\n" +
                   "public key: " + str(private_key_to_public_key(private_key)).upper() + "\n" +
                   "balance: " + str(balance) + "\n\n")
        file.close()

def thread(iterator):
    processes = []
    data = Queue()
    data_factory = Process(target = data_export, args = (data,))
    data_factory.daemon = True
    processes.append(data_factory)
    data_factory.start()
    work = Process(target = worker, args = (data,))
    work.daemon = True
    processes.append(work)
    work.start()
    data_factory.join()

if __name__ == '__main__':
    try:
        pool = ThreadPool(processes = multiprocessing.cpu_count()*2)
        pool.map(thread, range(0, 10))
    except:
        pool.close()
        exit()

Thank you谢谢

You seem to be misunderstanding the purpose of the 2^160 bit range.您似乎误解了 2^160 位范围的用途。

Each standard bitcoin address is tied to the HASH160 of the public key.每个标准比特币地址都与公钥的 HASH160 相关联。 A HASH160 is 160 bits long, which is why your search space is 2^160. HASH160 是 160 位长,这就是为什么您的搜索空间是 2^160。 If you are able to find two private keys for which the HASH160 of the public keys are equal, any of those two private keys can spend coins sent to that address.如果你能找到两个公钥的 HASH160 相等的私钥,那么这两个私钥中的任何一个都可以花费发送到该地址的硬币。

Searching a smaller space does not make sense since you are no longer searching for bitcoin addresses.搜索较小的空间没有意义,因为您不再搜索比特币地址。 If you just want to search random hash functions, then you simply need to replace RIPEMD160 hash function with another one that has an output in whatever bitsize you wish to search.如果您只想搜索随机散列函数,那么您只需将 RIPEMD160 散列函数替换为另一个具有您希望搜索的任何位大小的输出的散列函数。

Note that if you do that, the rest of the code talking about checking balances etc. will be of no use, since your output will no longer be a bitcoin address.请注意,如果你这样做了,其余的关于检查余额等的代码将毫无用处,因为你的输出将不再是比特币地址。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM