Skip to content

A Minimalistic Rust library to extract all potential function selectors from EVM bytecode without source code.

Notifications You must be signed in to change notification settings

g00dv1n/evm-hound-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EVM Hound

A Minimalistic Rust library to extract all potential function selectors from EVM bytecode without source code.

Installation

$ cargo add evm_hound

Usage

// examples/basic.rs
use ethers::{
    providers::{Http, Middleware, Provider},
    types::Address,
};
use eyre::Result;

use evm_hound::{selectors_from_bytecode, string_selectors_from_bytecode};

// To Try:
// cargo run --example basic

#[tokio::main]
async fn main() -> Result<()> {
    let provider = Provider::<Http>::try_from("https://rpc.flashbots.net/fast")?;
    let token_addr: Address = "0xdac17f958d2ee523a2206206994597c13d831ec7".parse()?;

    let code = provider.get_code(token_addr, None).await?;

    let raw_selectors = selectors_from_bytecode(&code);
    let string_selectors = string_selectors_from_bytecode(&code);

    println!("found {} selectors", raw_selectors.len());
    println!("{raw_selectors:?}");
    println!("{string_selectors:?}");

    Ok(())
}

Also, EVM Hound can detect basic contract types using extracted selectors:

pub enum ContractType {
    /// ERC20 - Typical token contract
    ERC20,
    /// ERC721 - Typical NFT contract
    ERC721,
    /// Any other contract
    ANY,
}

Check out example at examples/contract_type.rs.

Credits

Made for Hackers.tools Trading Simulator to search/bruteforce for potential methods that start trading.

About

A Minimalistic Rust library to extract all potential function selectors from EVM bytecode without source code.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages