/rattle

evm binary static analysis

Primary LanguagePython

rattle

Rattle is an EVM binary static analysis framework designed to work on deployed smart contracts. Rattle takes EVM byte strings, uses a flow-sensitive analysis to recover the original control flow graph, lifts the control flow graph into an SSA/infinite register form, and optimizes the SSA – removing DUPs, SWAPs, PUSHs, and POPs. The conversion from a stack machine to SSA form removes 60%+ of all EVM instructions and presents a much friendlier interface to those who wish to read the smart contracts they’re interacting with.

Example

$ python3 rattle-cli.py --input inputs/kingofether/KingOfTheEtherThrone.bin -O

Would produce a register machine output like this:

King of Ether numberOfMonarchs

Functions are recovered and split off. Additionally function arguments, memory locations, and storage locations are recovered.

Troubleshooting

If you get a syntax error like this:

  File "rattle-cli.py", line 16
    def main() -> None:
               ^
SyntaxError: invalid syntax

You likely ran rattle with python2 instead of python3.

License

Rattle is licensed and distributed under the AGPLv3 license.