A black-box raw calldata decoder using only calldata to guess types and parse parameters.

Overview

Calldata Decoder

A black-box raw calldata decoder using only calldata. Based off the topics discussed in DeGatchi's article, Reverse The EVM: Raw Calldata.

Calldata Decoder Thumbnail


Demo

Decoder Output


Features

  • Selector detector
  • Parameter parser
    • Parameter relation mapping
  • Parameter type guesser
    • For main body
    • Nested (multicall)
    • Optimised address detector

Todo

[ ] - Put tests in their own files bc they're so big (to decode the values).

[ ] - Parameter parser: Parameter relation mapping

How to implement

If dynamic type:

  1. Track offset.
  2. Find length from offset.
  3. Get values.
  4. If values have dynamic types map them to a second branch.
  5. Then we can build the potential struct/array used as a param.

[ ] - Parameter type guesser: For main body

How to implement

Value Slot
0xe5 0x20
0x60 -> start at 0x80 (end of 0x60) 0x40
0x01 0x60
0x02 0x80

For 0x60 at 0x40:

  1. Check value above -> Is there a main body param above or is it standalone?
  2. Check value below -> Is it the offset? if not its the next main body param.
  3. Are there enough bytes to finish the dynamic type?
  4. Is there any more params after?

Then we need to create a test for this ^


Contributing

This repo can be expanded to become much more sophisticated. There are some core features missing.

If you feel contributing please feel free to make a pr :)

You might also like...
Frost in Rust (Study only)

FROST (Study only) This implementation was part of the contribution for the following paper: Chelsea Komlo, Ian Goldberg. "FROST: Flexible Round-Optim

Avalanche primitive types in Rust (experimental)

AvalancheGo Compatibility Crate Version(s) AvalancheGo Version(s) Protocol Version v0.0.134-155 v1.9.2,v1.9.3 19 v0.0.156-176 v1.9.4 20 v0.0.177-200 v

Simple shared types for multi-threaded Rust programs

Keep Calm (and call Clone) Simple shared types for multi-threaded Rust programs: keepcalm gives you permission to simplify your synchronization code i

🐺 Starknet Rust types 🦀

types-rs 🐺 Starknet Rust types 🦀 This repository is an initiative by a group of maintainers to address the fragmentation in the Starknet Rust ecosys

This crate provides data-types defined by the VDA5050 standard.

VDA5050 Types This crate provides data-types for the rust programming language defined by the VDA5050 standard. VDA5050 is an open standard for commun

A simple and secure rust command-line tool to protect your text by encrypting and decrypting it using the robust AES-256 algorithm.

Secret Keeper A simple and secure command-line tool to protect your text by encrypting and decrypting it using the robust AES-256 algorithm. Built wit

Ethereum (and Ethereum like) indexer using P2P message to fetch blocks and transactions

Ethereum P2P indexer This project is an indexer for Ethereum and Ethereum forks. It takes advantage of the ETH (Ethereum Wire Protocol) to fetch block

shavee is a Program to automatically decrypt and mount ZFS datasets using Yubikey HMAC as 2FA or any USB drive with support for PAM to auto mount home directories.

shavee is a simple program to decrypt and mount encrypted ZFS user home directories at login using Yubikey HMAC or a Simple USB drive as 2FA written in rust.

A prototype project integrating jni rust into Kotlin and using protobuf to make them work together

KotlinRustProto a prototype project integrating jni rust into Kotlin and using protobuf to make them work together How to start add a RPC call in Droi

Owner
DeGatchi
Binary addict | Rust + Solidity
DeGatchi
Tiny CLI for submitting large calldata transactions to EVM networks to stress test the networking layer

Tiny CLI for submitting large calldata transactions to EVM networks to stress test the networking layer. Main motivation: EIP4844blobs.

Paradigm 50 Jan 4, 2023
Generates a unique hash/identifier for a system given a set of parameters.

uniqueid ?? Generates a unique hash/identifier for a system given a set of parameters. Example usage use uniqueid; pub fn main() { let data = vec

Checksum 2 Aug 19, 2022
Anchor Design of contract - Accounts, Parameters

MarketplaceDesign Anchor Design of contract - Accounts, Parameters Main Instructions are Initialize ListForSale AcceptOffer CancelList MakeOffer Cance

James Johnson 8 Sep 1, 2022
A secure development tool box and fintech application made with Rust to be used for developing cryptocurrencies on the blockchain.

Crypto Fintech Tools for Rust (CFT) Dependencies Rust MacOS Homebrew # xcode cli tools xcode-select --install # install dependencies using Homebrew b

Phil Hills 1 Apr 15, 2022
ssh-box: use ssh keys to encrypt files

ssh-box: use ssh keys to encrypt files work in progress ssh-box file format A file encrypted by ssh-box is an ASCII-armored binary file. The binary co

Tony Finch 3 Jun 27, 2022
Benson Box built on Substrate for a world UNcorporated.

Benson Box built on Substrate. For getting started and technical guides, please refer to the Benson Wiki.

Arthur·Thomas 13 Mar 13, 2022
The parser library to parse messages from crypto-crawler.

crypto-msg-parser The parser library to parse messages from crypto-crawler. Architecture crypto-msg-parser is the parser library to parse messages fro

null 5 Jan 2, 2023
Turnstile encrypts data so that it can only be decrypted on another computer

Turnstile - One Way Encryption Turnstile encrypts data so that it can only be decrypted on another computer (and can't be decrypted on the encrypting

Faded Bee 4 May 6, 2022
An implementation of the append-only log described in the Certificate Transparency specification (RFC 6962)

CT Merkle This is an implementation of the append-only log described in the Certificate Transparency specification (RFC 6962). The log is a Merkle tre

Michael Rosenberg 30 Dec 2, 2022
A simple key-value store with a log-structured, append-only storage architecture where data is encrypted with AES GCM.

akvdb A simple key-value store with a log-structured, append-only storage architecture where data is encrypted with AES GCM. Modified from the actionk

Olle W 3 Oct 10, 2022