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.
Demo
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:
- Track offset.
- Find length from offset.
- Get values.
- If values have dynamic types map them to a second branch.
- 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
:
- Check value above -> Is there a main body param above or is it standalone?
- Check value below -> Is it the offset? if not its the next main body param.
- Are there enough bytes to finish the dynamic type?
- 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 :)