Giter VIP home page Giter VIP logo

enigmacracker's Introduction

EnigmaCracker

EnigmaCracker is a tool for brute forcing Crypto Wallets

EnigmaCrackerV2

⚠️Disclaimer⚠️

This script is developed for educational and research purposes only.

By using this code, you agree to the following:

  1. You will not use this code, in whole or in part, for malicious intent, including but not limited to unauthorized mining on third-party systems.
  2. You will seek explicit permission from any and all system owners before running or deploying this code.
  3. You understand the implications of running mining software on hardware, including the potential for increased wear and power consumption.
  4. The creator of this script cannot and will not be held responsible for any damages, repercussions, or any negative outcomes that result from using this script.

If you do not agree to these terms, please do not use or distribute this code.

How it works?

We'll begin by delving into the foundational concepts. Upon establishing a wallet through platforms like Exodus/TrustWallet or similar services, users receive a mnemonic phrase (seed-phrase) comprised of 12 unique words. The selection of words for this passphrase isn't arbitrary; they are derived from a specific lexicon containing 2048 potential words. From this collection, the passphrase words are selected at random (the entire list of these words is accessible HERE). Utilizing this passphrase, an individual has the capability to access their wallet on any device and manage their assets. My application operates by employing brute force techniques to decipher these passphrases.

If EnigmaCracker finds a wallet with a balance, it will create wallets_with_balance.txt file that will contain the info of the discovered wallet.

Upon execution, EnigmaCracker generates a comprehensive log file named enigmacracker.log, which neatly records the entire session history for review and analysis.

Technical Details

Master Seed and Wallet Generation

derivation

EnigmaCracker is engineered around the key principle of the Master Seed in cryptocurrency wallet generation, as per the standards described in BIP 32 for Hierarchical Deterministic (HD) Wallets. The Python script provided within this repository is designed to create a mnemonic phrase (also known as a seed phrase), which essentially acts as the Master Seed from which all cryptographic keys can be derived.

For a more in-depth understanding of this topic, feel free to explore the detailed documentation available here: BIP 32 wiki.

The Role of Master Seed in EnigmaCracker

The script leverages the bip_utils library to generate a 12-word BIP39 mnemonic. This mnemonic is a human-readable representation of the wallet's Master Seed. This seed is then used to generate seeds for various cryptocurrency wallets, specifically for Bitcoin (BTC) and Ethereum (ETH), by following the BIP44 protocol that defines a logical hierarchy for deterministic wallets.

Code Workflow:

  1. Seed Generation: The bip() function in the script calls upon the BIP39 protocol to generate a new 12-word mnemonic. This is the first and most crucial step in the HD wallet creation process.

  2. Seed to Wallet Transformation: The functions bip44_ETH_wallet_from_seed and bip44_BTC_seed_to_address take the generated mnemonic and produce the corresponding wallet addresses for Ethereum and Bitcoin, respectively. These addresses are derived from the master seed and follow a deterministic path outlined by BIP44, ensuring that each mnemonic generates a unique and recoverable set of addresses.

  3. Balance Checking: With the generated addresses, the script uses online blockchain explorers through their APIs (Etherscan for Ethereum and Blockchain.info for Bitcoin) to check if the generated wallets contain any balance.

  4. Logging Results: If a balance is found, the script writes the mnemonic, the derived addresses, and the wallet balances to a file (wallets_with_balance.txt), preserving the potentially valuable information for further examination.

Through the integration of BIP39 and BIP44 protocols, EnigmaCracker serves as a practical example of how the Master Seed forms the bedrock of cryptocurrency wallets, allowing for a secure, hierarchical structure of key derivation and management.

Installation

Clone the repository using:

git clone https://github.com/yaron4u/EnigmaCracker

Remember to install the required libraries using:

pip install -r requirements.txt

Configuration

  1. Obtain an Etherscan API key following the instructions here.
  2. Navigate to the script's directory and insert your API key in EnigmaCracker.env:
# In EnigmaCracker.env
etherscan_api_key = your_api_key_here <--- Replace with your actual API key

Execution

Run EnigmaCracker from the command line:

cd path/to/EnigmaCracker
python EnigmaCracker.py

Running EnigmaCracker in Docker

Prerequisites

  • Docker installed on your system. You can download and install Docker from Docker's official website.
  • Docker Compose (usually comes with the Docker installation).

Steps to Run

  1. Clone the Repository
    If you haven't already, clone the EnigmaCracker repository to your local machine:

    git clone https://github.com/yaron4u/EnigmaCracker
  2. Setting Up Environment Variables
    Before running the Docker container, you need to set up your environment variables:

    • Navigate to the cloned directory.
    • Open the EnigmaCracker.env file and replace your_etherscan_api_key with your actual Etherscan API key.
    • Open the docker-compose.yml file and replace your_etherscan_api_key with your actual Etherscan API key.
  3. Building the Docker Image
    From the root directory of the project in the EnigmaCracker-Docker folder (where the Dockerfile is located), run the following command to build the Docker image:

    docker-compose build

    This command reads the Dockerfile and docker-compose.yml to build the EnigmaCracker Docker image.

  4. Running the Docker Container
    After the build is complete, start the Docker container using Docker Compose:

    docker-compose up

    This command starts the EnigmaCracker service defined in docker-compose.yml. The script inside the Docker container (EC.py) will automatically execute.

  5. Viewing Logs and Output
    The output of the script, including any logs, will be displayed in your terminal. Additionally, log files and any generated files like wallets_with_balance.txt will be stored in the ./data directory on your host machine, which is mapped to /usr/src/app/data in the container for persistent storage.

  6. Stopping the Container
    To stop the Docker container, use the command:

    docker-compose down

    This command stops and removes the containers, networks, and volumes created by docker-compose up.

Note

  • The Docker environment provides an isolated and consistent runtime for EnigmaCracker.
  • Ensure that the Docker daemon is running before executing these commands.
  • Adjustments to the script or environment variables require a rebuild of the Docker image for changes to take effect.
  • Modified Script for Docker: The Docker version of EnigmaCracker runs a slightly modified version of the script (EC.py) compared to the standalone version. These modifications are specifically tailored for the Docker environment to ensure smooth operation within a container. For instance, any code segments that require GUI interaction or OS-specific commands have been adjusted or removed since Docker containers typically run in a headless (non-GUI) environment.
  • Streamlined Dependencies: The requirements.txt file for the Docker version contains fewer libraries. This is because Docker provides a controlled environment where only the necessary dependencies are included to run the script. This streamlined approach helps in reducing the overall size of the Docker image and improves the efficiency of the script within the container.

Running EnigmaCracker on AWS

This guide will walk you through the process of using EnigmaCracker on AWS. The steps include setting up an Amazon ECR repository for your Docker image, creating an EC2 instance with Ubuntu, and then pulling and running the EnigmaCracker Docker container on that instance.

Step 1: Uploading Your Docker Image to Amazon ECR

  1. Create an ECR Repository:

    • Navigate to the Amazon ECR console.
    • Click on "Create repository."
    • Name your repository (e.g., enigmacracker-docker), and click "Create repository."
  2. Authenticate Docker to Your ECR Repository:

    • Retrieve the docker login command that you can use to authenticate your Docker client to your registry:
      aws ecr get-login-password --region [your-region] | docker login --username AWS --password-stdin [your-account-id].dkr.ecr.[your-region].amazonaws.com
    • Replace [your-region] and [your-account-id] with your AWS region and account ID.
  3. Tag Your Docker Image:

    • Tag your local EnigmaCracker Docker image with the ECR repository URI:
      docker tag enigmacracker:latest [your-account-id].dkr.ecr.[your-region].amazonaws.com/enigmacracker-docker:latest
  4. Push the Image to ECR:

    • Push your Docker image to the ECR repository:
      docker push [your-account-id].dkr.ecr.[your-region].amazonaws.com/enigmacracker-docker:latest

Step 2: Creating an EC2 Instance with Ubuntu OS

  1. Launch an EC2 Instance:

    • Go to the EC2 Dashboard in AWS Management Console.
    • Click "Launch Instance."
    • Choose an "Ubuntu Server" AMI (Amazon Machine Image).
    • Select an instance type (e.g., t2.micro for testing purposes).
    • Configure instance settings as needed, then click "Review and Launch."
  2. Configure Security Group:

    • Add rules to allow SSH access to the instance.
  3. Launch and Access the Instance:

    • Review your settings and click "Launch."
    • Select a key pair or create a new one, and then launch the instance.
    • Once the instance is running, connect to it via SSH.

Step 3: Pulling and Running the EnigmaCracker Docker Container

  1. Install Docker on EC2 Instance:

    • Connect to your EC2 instance via SSH.
    • Update the package list and install Docker:
      sudo apt update
      sudo apt install docker.io
  2. Authenticate EC2 Docker to ECR:

    • Run the same docker login command used earlier to authenticate Docker to your ECR repository.
  3. Pull the Docker Image:

    • Pull the EnigmaCracker image from your ECR repository:
      docker pull [your-account-id].dkr.ecr.[your-region].amazonaws.com/enigmacracker-docker:latest
  4. Run the EnigmaCracker Container:

    • Run the Docker container:
      docker run [your-account-id].dkr.ecr.[your-region].amazonaws.com/enigmacracker-docker:latest

Step 4: Monitoring and Interacting with the EnigmaCracker Container

To monitor and interact with the EnigmaCracker container running on your EC2 instance, you can use the following steps:

  1. Access the EC2 Instance:

    • Connect to your EC2 instance using SSH.
  2. Elevate to Root (Optional):

    • If necessary, switch to the root user for broader permissions. However, be cautious as root access can modify critical system files.
      sudo su
  3. List All Containers:

    • Check the status of all Docker containers, including the EnigmaCracker container.
      docker ps -a
  4. Copy Log Files from Container to EC2 Instance:

    • If you want to inspect the log files generated by EnigmaCracker, copy them from the container to your EC2 instance. Replace enigmacracker_container with the actual container ID or name.
      docker cp enigmacracker_container:/usr/src/app/enigmacracker.log /home/ubuntu/enigmacracker.log
  5. Review the Log File:

    • Navigate to the directory where you copied the log file and use grep or other tools to analyze it. For example, to count the number of founded wallets in the log file:
      cd /home/ubuntu
      grep -c '!' enigmacracker.log

Conclusion

Setting up EnigmaCracker on an AWS EC2 instance with your Docker image in Amazon ECR offers improved scalability and reliability for your wallet scanning tasks. This approach provides a streamlined and effective solution to harness EnigmaCracker’s full potential on a powerful cloud platform.


Updates

  • Dual Cryptocurrency Detection: EnigmaCracker now supports detection of both BTC and ETH wallets.
  • AWS Integration: I've developed a comprehensive guide to help you deploy EnigmaCracker on AWS (Amazon Web Services). This integration enables you to utilize cloud computing resources for better performance and scalability. The guide includes detailed instructions for setting up EnigmaCracker on Amazon EC2 (Elastic Compute Cloud) instances and using Amazon ECR (Elastic Container Registry) for efficient cloud-based operations.

How to open the discovered wallet?

For assistance with accessing a discovered wallet, reach me out to [email protected], for paid service that I provide.

(I will not help anybody that asks for help to setup EnigmaCracker, every email in that subject will be ignored)

Contributions

If you want to thank me for the prize you found, I will appreciate it!

BTC: bc1qqa207jge9e48syfeevduumq0p6ct79cglu3gn6

ETH: 0xD8E91636cc6F55221545BFB7e1E417f0D2242d17

ADA: addr1q9rans3fgyr6wz23scnuvycgwzh8s6q4h4jfsml3u26ly0j8m8pzjsg85uy4rp38ccfssu9w0p5pt0tynphlrc447glqm4eyzx

USDT (ETH Network): 0xD8E91636cc6F55221545BFB7e1E417f0D2242d17

Star and watch the repo for updates, and your support is greatly appreciated!

enigmacracker's People

Contributors

elharaka avatar yaron4u avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

enigmacracker's Issues

hello can u help me with this error

EnigmaCracker/EnigmaCracker/EnigmaCracker.py", line 10, in
from bip_utils import (
ModuleNotFoundError: No module named 'bip_utils'

this is the error that shows when i try to python EnigmaCracker.py

impossible to import the bip_utils module

PS C:\Users\conta\Desktop\EnigmaCracker-main\EnigmaCracker> pip install bip_utils
Collecting bip_utils
Using cached bip_utils-2.8.0-py3-none-any.whl.metadata (12 kB)
Collecting cbor2~=5.1 (from bip_utils)
Using cached cbor2-5.5.1-cp312-cp312-win_amd64.whl.metadata (6.1 kB)
Requirement already satisfied: coincurve<19.0.0,>=15.0.1 in c:\users\conta\appdata\local\programs\python\python312\lib\site-packages (from bip_utils) (17.0.0)
Collecting crcmod~=1.7 (from bip_utils)
Using cached crcmod-1.7.tar.gz (89 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: ecdsa~=0.15 in c:\users\conta\appdata\local\programs\python\python312\lib\site-packages (from bip_utils) (0.18.0)
Collecting ed25519-blake2b~=1.4 (from bip_utils)
Using cached ed25519-blake2b-1.4.tar.gz (871 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [31 lines of output]
C:\Users\conta\AppData\Local\Temp\pip-install-5bu4yadr\ed25519-blake2b_08a32b6ab55a444c856e049c4acc888f\versioneer.py:467: SyntaxWarning: invalid escape sequence
'\s'
LONG_VERSION_PY['git'] = '''
Traceback (most recent call last):
File "C:\Users\conta\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 353, in
main()
File "C:\Users\conta\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\conta\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\conta\AppData\Local\Temp\pip-build-env-0uw0_ee6\overlay\Lib\site-packages\setuptools\build_meta.py", line 355, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\conta\AppData\Local\Temp\pip-build-env-0uw0_ee6\overlay\Lib\site-packages\setuptools\build_meta.py", line 325, in _get_build_requires
self.run_setup()
File "C:\Users\conta\AppData\Local\Temp\pip-build-env-0uw0_ee6\overlay\Lib\site-packages\setuptools\build_meta.py", line 507, in run_setup
super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script)
File "C:\Users\conta\AppData\Local\Temp\pip-build-env-0uw0_ee6\overlay\Lib\site-packages\setuptools\build_meta.py", line 341, in run_setup
exec(code, locals())
File "", line 109, in
File "C:\Users\conta\AppData\Local\Temp\pip-install-5bu4yadr\ed25519-blake2b_08a32b6ab55a444c856e049c4acc888f\versioneer.py", line 1405, in get_version
return get_versions()["version"]
^^^^^^^^^^^^^^
File "C:\Users\conta\AppData\Local\Temp\pip-install-5bu4yadr\ed25519-blake2b_08a32b6ab55a444c856e049c4acc888f\versioneer.py", line 1339, in get_versions
cfg = get_config_from_root(root)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\conta\AppData\Local\Temp\pip-install-5bu4yadr\ed25519-blake2b_08a32b6ab55a444c856e049c4acc888f\versioneer.py", line 399, in get_config_from_root
parser = configparser.SafeConfigParser()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'configparser' has no attribute 'SafeConfigParser'. Did you mean: 'RawConfigParser'?
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

For people who has error

sudo su
python -m pip install --upgrade pip
pip install -r requirements.txt
pip3 install ecdsa
pip3 install wheel
pip install --upgrade wheel
pip install --upgrade setuptools
pip install ed25519-blake2b
pip3 install crcmod
pip3 install coincurve
pip3 install cbor2
python -m pip install --upgrade pip
apt install gcc
sudo apt install python3-devel (if you have python ver2, sudo apt install python2-devel)
pip3 install python-dotenv
pip3 install bip-utils
apt install gnome-terminal
apt install mesa-dri-drivers.i686
apt install dbus-x11
python EnigmaCracker.py

it will work now :D

if you don't do this again

sudo su
python -m pip install --upgrade pip
pip install -r requirements.txt
pip3 install ecdsa
pip3 install wheel
pip install --upgrade wheel
pip install --upgrade setuptools
pip install ed25519-blake2b
pip3 install crcmod
pip3 install coincurve
pip3 install cbor2
python -m pip install --upgrade pip
apt install gcc
sudo apt install python3-devel (if you have python ver2, sudo apt install python2-devel)
pip3 install python-dotenv
pip3 install bip-utils
apt install gnome-terminal
apt install mesa-dri-drivers.i686
apt install dbus-x11
python EnigmaCracker.py

[BUG] Brief description of the bug

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

[QUESTION] Will I ever find anything?

I was just wondering if running this in the background for a long period of time will actually see results, such as a wallet with eth or btc, and if so, how long it could take.

Log file not created during/after running (on docker)

When i run the program and stop it, i search for the .log file inside and outside data folder, but there's nothing.

I don't know if this issue usually come to anyone who run the program. And i've done restarting my pc and run the program then stop it. No .log file created.

Is there any solution?

image

  • OS: Windows 10 Pro

Thanks. :)

[FEATURE] quicker way of checking CONTAINERS on AWS?

Hi, I have setup docker and AWS completely and absolutely love everything you have done! My only request is whenever I'm on my Ubuntu server I pull up all of my active containers with "docker ps -a" and want to check all of the active containers quickly to see if I have any hits but I have to individually change the container ID and enter the commands each time after saving the log file for each active container. Is there any better way of quickly having all of my containers checked for hits?

Example of what I'm talking about:
"docker cp "MYCONTAINERID":/usr/src/app/enigmacracker.log /home/ubuntu/enigmacracker.log" then, "cd /home/ubuntu" and "grep -c '!' enigmacracker.log"

^ I have to change the mycontainerid and run the following commands each time for every container and it's a slow process when u have multiple active containers running.

For people who has error ((Fedora, RHEL, Oracle))

sudo su

python -m pip install --upgrade pip
pip install -r requirements.txt
pip3 install ecdsa
pip3 install wheel
pip install --upgrade wheel
pip install --upgrade setuptools
pip install ed25519-blake2b
pip3 install crcmod
pip3 install coincurve
pip3 install cbor2
python -m pip install --upgrade pip
dnf install gcc
sudo dnf install python3-devel (if you have python ver2, sudo dnf install python2-devel)
pip3 install python-dotenv
pip3 install bip-utils
dnf install gnome-terminal
dnf install mesa-dri-drivers.i686
dnf install dbus-x11
python EnigmaCracker.py

it will work now :D

if you don't do this again

sudo su
python -m pip install --upgrade pip
pip install -r requirements.txt
pip3 install ecdsa
pip3 install wheel
pip install --upgrade wheel
pip install --upgrade setuptools
pip install ed25519-blake2b
pip3 install crcmod
pip3 install coincurve
pip3 install cbor2
python -m pip install --upgrade pip
dnf install gcc
sudo dnf install python3-devel (if you have python ver2, sudo dnf install python2-devel)
pip3 install python-dotenv
pip3 install bip-utils
dnf install gnome-terminal
dnf install mesa-dri-drivers.i686
dnf install dbus-x11
python EnigmaCracker.py

Kali Linux

Please make this program for linux terminal.

Error

ERROR: Could not find a version that satisfies the requirement requirements.txt
ERROR: No matching distribution found for requirements.txt

How to fix?

[BUG] Brief description of the bug

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Asynchronous requests

Made requests asynchronous, so it works faster :)

# EnigmaCracker for Docker
import sys
import os
import aiohttp
import asyncio
import logging
from dotenv import load_dotenv
from bip_utils import (
    Bip39MnemonicGenerator,
    Bip39SeedGenerator,
    Bip44,
    Bip44Coins,
    Bip44Changes,
    Bip39WordsNum,
)

# Constants
LOG_FILE_NAME = "enigmacracker.log"
ENV_FILE_NAME = "EnigmaCracker.env"
WALLETS_FILE_NAME = "wallets_with_balance.txt"

# Get the absolute path of the directory where the script is located
directory = os.path.dirname(os.path.abspath(__file__))
# Initialize directory paths
log_file_path = os.path.join(directory, "data", LOG_FILE_NAME)
env_file_path = os.path.join(directory, ENV_FILE_NAME)
wallets_file_path = os.path.join(directory, "data", WALLETS_FILE_NAME)

# Configure logging
logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s - %(levelname)s - %(message)s",
    handlers=[
        logging.FileHandler(log_file_path),  # Log to a file
        logging.StreamHandler(sys.stdout),  # Log to standard output
    ],
)

# Load environment variables from .env file
load_dotenv(env_file_path)

# Environment variable validation
required_env_vars = ["ETHERSCAN_API_KEY"]
missing_vars = [var for var in required_env_vars if not os.getenv(var)]
if missing_vars:
    raise EnvironmentError(f"Missing environment variables: {', '.join(missing_vars)}")


def bip():
    # Generate a 12-word BIP39 mnemonic
    return Bip39MnemonicGenerator().FromWordsNumber(Bip39WordsNum.WORDS_NUM_12)


def bip44_ETH_wallet_from_seed(seed):
    # Generate an Ethereum wallet from a BIP39 seed.

    # Generate the seed from the mnemonic
    seed_bytes = Bip39SeedGenerator(seed).Generate()

    # Create a Bip44 object for Ethereum derivation
    bip44_mst_ctx = Bip44.FromSeed(seed_bytes, Bip44Coins.ETHEREUM)

    # Derive the account 0, change 0, address_index 0 path (m/44'/60'/0'/0/0)
    bip44_acc_ctx = (
        bip44_mst_ctx.Purpose()
        .Coin()
        .Account(0)
        .Change(Bip44Changes.CHAIN_EXT)
        .AddressIndex(0)
    )

    # Get the Ethereum address
    eth_address = bip44_acc_ctx.PublicKey().ToAddress()

    return eth_address


def bip44_BTC_seed_to_address(seed):
    # Generate the seed from the mnemonic
    seed_bytes = Bip39SeedGenerator(seed).Generate()

    # Generate the Bip44 object
    bip44_mst_ctx = Bip44.FromSeed(seed_bytes, Bip44Coins.BITCOIN)

    # Generate the Bip44 address (account 0, change 0, address 0)
    bip44_acc_ctx = bip44_mst_ctx.Purpose().Coin().Account(0)
    bip44_chg_ctx = bip44_acc_ctx.Change(Bip44Changes.CHAIN_EXT)
    bip44_addr_ctx = bip44_chg_ctx.AddressIndex(0)

    # Print the address
    return bip44_addr_ctx.PublicKey().ToAddress()


async def check_ETH_balance_async(session, address, etherscan_api_key, retries=3, delay=5):
    api_url = f"https://api.etherscan.io/api?module=account&action=balance&address={address}&tag=latest&apikey={etherscan_api_key}"

    for attempt in range(retries):
        try:
            async with session.get(api_url) as response:
                data = await response.json()

                if data["status"] == "1":
                    balance = int(data["result"]) / 1e18
                    return balance
                else:
                    logging.error("Error getting balance: %s", data["message"])
                    return 0
        except Exception as e:
            if attempt < retries - 1:
                logging.error(
                    f"Error checking balance, retrying in {delay} seconds: {str(e)}"
                )
                await asyncio.sleep(delay)
            else:
                logging.error("Error checking balance: %s", str(e))
                return 0

async def check_BTC_balance_async(session, address, retries=3, delay=5):
    for attempt in range(retries):
        try:
            async with session.get(f"https://blockchain.info/balance?active={address}") as response:
                data = await response.json()
                balance = data[address]["final_balance"]
                return balance / 100000000  # Convert satoshi to bitcoin
        except Exception as e:
            if attempt < retries - 1:
                logging.error(
                    f"Error checking balance, retrying in {delay} seconds: {str(e)}"
                )
                await asyncio.sleep(delay)
            else:
                logging.error("Error checking balance: %s", str(e))
                return 0


def write_to_file(seed, BTC_address, BTC_balance, ETH_address, ETH_balance):
    # Write the seed, address, and balance to a file in the script's directory
    with open(wallets_file_path, "a") as f:
        log_message = f"Seed: {seed}\nAddress: {BTC_address}\nBalance: {BTC_balance} BTC\n\nEthereum Address: {ETH_address}\nBalance: {ETH_balance} ETH\n\n"
        f.write(log_message)
        logging.info(f"Written to file: {log_message}")


async def main_async():
    global wallets_scanned
    try:
        async with aiohttp.ClientSession() as session:
            while True:
                # Generating a seed
                seed = bip()
                logging.info(f"Seed: {seed}")
                # BTC
                BTC_address = bip44_BTC_seed_to_address(seed)
                logging.info(f"BTC address: {BTC_address}")

                BTC_balance = await check_BTC_balance_async(session, BTC_address)
                logging.info(f"BTC balance: {BTC_balance} BTC")

                # ETH
                etherscan_api_key = os.getenv("ETHERSCAN_API_KEY")
                if etherscan_api_key:
                    ETH_address = bip44_ETH_wallet_from_seed(seed)
                    logging.info(f"ETH address: {ETH_address}")

                    ETH_balance = await check_ETH_balance_async(session, ETH_address, etherscan_api_key)
                    logging.info(f"ETH balance: {ETH_balance} ETH")
                else:
                    raise ValueError(
                        "The Etherscan API key must be set in the environment variables."
                    )

                logging.info("-" * 80)

                if BTC_balance > 0 or ETH_balance > 0:
                    logging.info("(!) Wallet with balance found!")
                    write_to_file(seed, BTC_address, BTC_balance, ETH_address, ETH_balance)

    except KeyboardInterrupt:
        logging.info("Program interrupted by user. Exiting...")

if __name__ == "__main__":
    asyncio.run(main_async())

PS. Due to forbidden policy for commits to projects I needed to create an Issue.

[FEATURE] Short description of the feature

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Faster scanning

I've used the software for a quite a while now and i would like to suggest using a faster and free api online? (etherscan.io has free 5 calls per second and my laptop results in only 30 per minute)
Considering you would program it to use any other api or multiple APIs at the same time? (like bitquery.io or arbisscan.io)
It would be faster and result in higher check speeds.
image

is it even work?

I ran it for past 24h , I don't expect to got any result in this time , but the question is ...
is it even work ? like is there any evidence of working this code ? like , is somebody test it on at least one real wallet to see if it can check the value of it correctly ?

How to use in Windows?

I try it use in Linux and Windows but the instructions are no clears.
I am new to this if you help me i would appreciate it.

[BUG] Brief description of the bug

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

An idea

I adjusted the code in the EnigmaCracker.py file that an email sent when a balance found as below:

from email.message import EmailMessage
import ssl
import smtplib

email_sender  = 'YOUR_EMAIL'
email_password  = 'YOUR_APPPASWORD'
email_receiver = 'YOUR_EMAIL'
subject = 'BTC Balance'

em = EmailMessage()
em['From'] = email_sender
em['To'] = email_receiver
em['Subject'] = subject
context = ssl.create_default_context()

In the condition part as below:

body = f"Seed: {seed}\nAddress: {BTC_address}\nBalance: {BTC_balance} BTC\n\nEthereum Address: {ETH_address}\nBalance: {ETH_balance} ETH\n\n"

em.set_content(body)
with smptlib.SMTP_SSL('smtp.gmail.com', 465, context=context) as smtp:
    smtp.login(email_sender, email_password)
    smtp.sendmail(email_sender, email_receiver, em.as_string())

The address of bitcoin wallet is constantly changing

Hi yaron4u,

In your code, you linked the generated seed with the address of the coin and the search is based on this correlation. Actually, the address is always changing. You can notice that when you restore your wallet on another app.
is this correlation in the code a crucial factor ?
Thanks ☺️

Error getting balance: NOTOK

I completed everything that was in the steps and I received this unknown error:
Screenshot 2024-02-28 193554
I don't know what it means please help

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.