Git Product home page Git Product logo

evm-opcode-finder's Introduction

Abilities

  1. Search for opcode in contracts in the latest block
  func FindOpcode(client *ethclient.Client, opcode vm.OpCode) {
	  block := latestBlock(client)
	  inspectContractsInBlock(client, block, opcode)
  }
  1. Search for opcode in certain contract
  func FindOpcodeInContract(client *ethclient.Client, address common.Address, opcode vm.OpCode) {
    _, bytecode := isContract(client, address)

    if compareOpcodes(bytecode, opcode) {
      success(opcode, address)
    }
  }

Note: it doesn't search for PUSH opcodes, since they're exist in bytecode of all contracts and it skips all PUSH instructions with their arguments

Example

  const opcode = "SELFDESTRUCT"

  func main() {
    client, err := ethclient.Dial(URL)

    if err != nil {
      log.Fatal(err)
    }

    finder.FindOpcode(client, vm.StringToOp(opcode))
  }

Search for SELFDESTRUCT opcode in contracts in the latest block

OUTPUT

  ========================
  Looking for SELFDESTRUCT in contracts
   in block 15888893
  ========================
  Catch opcode: SELFDESTRUCT
   in contract: 0x46A82Ec528d89154EF3Dc66d9E03fEd617886d2c
  Catch opcode: SELFDESTRUCT
   in contract: 0x1111111254fb6c44bAC0beD2854e76F90643097d
  Catch opcode: SELFDESTRUCT
   in contract: 0xe069aE4B336Ca73142cDc5206ed4a4d3A3ff39f6

Inspecting contracts in etherscan:

  1. https://etherscan.io/address/0x46A82Ec528d89154EF3Dc66d9E03fEd617886d2c#code ๐Ÿ‘ it has SELFDESTRUCT
  2. https://etherscan.io/address/0x1111111254fb6c44bAC0beD2854e76F90643097d#code ๐Ÿ‘ it has SELFDESTRUCT
  3. https://etherscan.io/address/0xe069aE4B336Ca73142cDc5206ed4a4d3A3ff39f6#code ๐Ÿ‘ it has SELFDESTRUCT (close to the end it has ff opcode which is SELFDESTRUCT)

Limitations

  1. At the moment it can return the same addresses in the block, i.e. it doesn't check for collisions
  2. It inspects only one latest block, stopping then execution

evm-opcode-finder's People

Contributors

daoio avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.