xONEIROS / wallet-finder

پیداکردن والت بیتکوینی با تست کردن پابلیک کی و پرایویت کی ! فرضیه تا بررسی
16 stars 3 forks source link

ImportError #2

Closed rezazarrabi closed 1 month ago

rezazarrabi commented 1 month ago

سلام، موقع اجرا این ارور رو دریافت میکنم

reza@haji:~/wallet-finder$ python3 script.py Traceback (most recent call last): File "/home/reza/wallet-finder/script.py", line 6, in from bitcoinlib.keys import PrivateKey ImportError: cannot import name 'PrivateKey' from 'bitcoinlib.keys' (/home/reza/.local/lib/python3.10/site-packages/bitcoinlib/keys.py)

finder

xONEIROS commented 1 month ago

اینو بزن pip show bitcoinlib نتیجشو بفرست

rezazarrabi commented 1 month ago

reza@haji:~/wallet-finder$ pip show bitcoinlib Name: bitcoinlib Version: 0.6.15 Summary: Bitcoin cryptocurrency Library Home-page: http://github.com/1200wd/bitcoinlib Author: 1200wd Author-email: info@1200wd.com License: GNU3 Location: /home/reza/.local/lib/python3.10/site-packages Requires: ecdsa, fastecdsa, numpy, pycryptodome, requests, SQLAlchemy Required-by:

finder2

xONEIROS commented 1 month ago

این کد رو تست کن

  1. اجرا کن pip install requests pysocks bitcoin tqdm

  2. محتوا زیر رو در یک فایل جدید با پسوند .py ذخیره کن

import os
import hashlib
import requests
import time
from itertools import cycle
import socket
import socks
from concurrent.futures import ThreadPoolExecutor, as_completed
from bitcoin import privkey_to_address, random_key
import logging
from tqdm import tqdm

NUM_KEYS = 1000000
NUM_WORKERS = 10
PROXY_FILE = "proxy.txt"
OUTPUT_FILE = "found_wallets.txt"
LOG_FILE = "wallet_finder.log"
BALANCE_THRESHOLD = 1 
PROXY_CHANGE_INTERVAL = 120  
logging.basicConfig(filename=LOG_FILE, level=logging.INFO,
                    format='%(asctime)s - %(levelname)s - %(message)s')
def load_proxies(file_path):
    """Load proxies from file"""
    with open(file_path, 'r') as f:
        proxies = f.read().splitlines()
    return cycle(proxies)

def set_proxy(proxy):
    """Set up proxy for requests"""
    proxy = proxy.strip()
    if '@' in proxy:
        user_pass, ip_port = proxy.split('@')
        user, password = user_pass.split(':')
        ip, port = ip_port.split(':')
    else:
        ip, port = proxy.split(':')
        user, password = None, None

    socks.set_default_proxy(socks.SOCKS5, ip, int(port), username=user, password=password)
    socket.socket = socks.socksocket

def check_proxy(proxy):
    """Check if proxy is working"""
    try:
        set_proxy(proxy)
        response = requests.get('http://www.google.com', timeout=5)
        return response.status_code == 200
    except:
        return False
def generate_private_key():
    """Generate a random private key"""
    return bytes.fromhex(random_key())
def private_key_to_address(private_key):
    """Convert private key to Bitcoin public address"""
    return privkey_to_address(private_key.hex())
def check_balance(address):
    """Check balance of a Bitcoin address"""
    url = f"https://blockchain.info/rawaddr/{address}"
    try:
        response = requests.get(url, timeout=10)
        if response.status_code == 200:
            data = response.json()
            return data.get('final_balance', 0)
    except requests.exceptions.RequestException as e:
        logging.error(f"Error checking balance for {address}: {str(e)}")
    return 0
def save_wallet_info(private_key, address, balance):
    """Save wallet information to file"""
    with open(OUTPUT_FILE, "a") as f:
        f.write(f"Private Key: {private_key.hex()}, Address: {address}, Balance: {balance} satoshis\n")
    logging.info(f"Found wallet with balance: Address {address}, Balance {balance} satoshis")
def process_key(index):
    private_key = generate_private_key()
    address = private_key_to_address(private_key)
    balance = check_balance(address)
    if balance >= BALANCE_THRESHOLD:
        save_wallet_info(private_key, address, balance)
    return balance >= BALANCE_THRESHOLD
def main():
    proxy_cycle = load_proxies(PROXY_FILE)
    current_proxy = next(proxy_cycle)
    while not check_proxy(current_proxy):
        logging.warning(f"Proxy {current_proxy} not working, trying next...")
        current_proxy = next(proxy_cycle)
    set_proxy(current_proxy)
    start_time = time.time()
    found_count = 0
    with ThreadPoolExecutor(max_workers=NUM_WORKERS) as executor:
        futures = {executor.submit(process_key, i): i for i in range(NUM_KEYS)}
        with tqdm(total=NUM_KEYS, desc="Checking wallets") as pbar:
            for future in as_completed(futures):
                index = futures[future]
                try:
                    if future.result():
                        found_count += 1
                except Exception as exc:
                    logging.error(f"Key {index} generated an exception: {exc}")

                pbar.update(1)

                if time.time() - start_time > PROXY_CHANGE_INTERVAL:
                    current_proxy = next(proxy_cycle)
                    while not check_proxy(current_proxy):
                        current_proxy = next(proxy_cycle)
                    set_proxy(current_proxy)
                    start_time = time.time()
                    logging.info(f"Changed proxy to {current_proxy}")

    logging.info(f"Scan complete. Found {found_count} addresses with balance >= {BALANCE_THRESHOLD} satoshis.")
    print(f"Scan complete. Found {found_count} addresses with balance >= {BALANCE_THRESHOLD} satoshis.")
    print(f"Results saved in {OUTPUT_FILE}")

if __name__ == "__main__":
    main()

بعد از اون اجرا کن ، دقت کن مسیر دهی پراکسی ها درست باشه + پراکسی ها کار کنند

این کد تست شد

اگر ارور محیط مجازی پایتون گرفتی میتونی از این اموزش کد هارو در یک محیط مجازی پایتون ران کنی