Giter Site home page Giter Site logo

g00dv1n / evm-hound-rs Goto Github PK

View Code? Open in Web Editor NEW
33.0 2.0 3.0 172 KB

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

Home Page: https://crates.io/crates/evm_hound

Rust 100.00%
abi bytecode ethereum evm rust

evm-hound-rs's Introduction

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.

evm-hound-rs's People

Contributors

g00dv1n 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

Watchers

 avatar  avatar

Forkers

0xfuje elyase

evm-hound-rs's Issues

Accuracy and speed results from EVMole benchmark

Hi,
I've added your project to the accuracy and speed benchmark of cdump/evmole

I think you may be interested in that results, to examine errors of evm-hound-rs you can run:

$ sudo apt install git-lfs
$ git clone https://github.com/cdump/evmole 
$ cd evmole/

# you need GNU Make, https://formulae.brew.sh/formula/make - if you are using macos

$ PROVIDERS="etherscan evm-hound-rs" make -C benchmark
$ poetry run python3 benchmark/compare.py --providers etherscan evm-hound-rs --web-listen 0.0.0.0:8080 

# skip PROVIDERS/--providers to compare with other tools, like whatsabi & evmole

Open http://127.0.0.1:8080 after that and you'll see the results:

20231202_10h19m10s_grim

P.S. I'm not a Rust developer and using your tool in benchmark is literally my first written rust code, if you believe I am using your project incorrectly, please feel free to submit a pull request with fixes.

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.