{"id":19147793,"url":"https://github.com/refcell/reversevm","last_synced_at":"2025-05-07T03:03:27.970Z","repository":{"id":150177797,"uuid":"446142223","full_name":"refcell/reversevm","owner":"refcell","description":"Notes on Reverse Engineering EVM Bytecode","archived":false,"fork":false,"pushed_at":"2022-01-10T14:06:41.000Z","size":223,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-05T15:54:42.716Z","etag":null,"topics":["bytecode","ethereum","evm","radare2","reverse-engineering"],"latest_commit_sha":null,"homepage":"","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/refcell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-09T16:28:10.000Z","updated_at":"2024-02-06T14:53:29.000Z","dependencies_parsed_at":"2023-04-15T02:25:04.860Z","dependency_job_id":null,"html_url":"https://github.com/refcell/reversevm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"refcell/femplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refcell%2Freversevm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refcell%2Freversevm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refcell%2Freversevm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refcell%2Freversevm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/refcell","download_url":"https://codeload.github.com/refcell/reversevm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252804208,"owners_count":21806769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bytecode","ethereum","evm","radare2","reverse-engineering"],"created_at":"2024-11-09T07:52:24.004Z","updated_at":"2025-05-07T03:03:27.917Z","avatar_url":"https://github.com/refcell.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# reversevm  • [![tests](https://github.com/abigger87/reversevm/actions/workflows/tests.yml/badge.svg)](https://github.com/abigger87/reversevm/actions/workflows/tests.yml) [![lints](https://github.com/abigger87/reversevm/actions/workflows/lints.yml/badge.svg)](https://github.com/abigger87/reversevm/actions/workflows/lints.yml) ![GitHub](https://img.shields.io/github/license/abigger87/reversevm) ![GitHub package.json version](https://img.shields.io/github/package-json/v/abigger87/reversevm)\n\nNotes on Reverse Engineering EVM Bytecode.\n\n## Blueprint\n\n```ml\nlib\n├─ ds-test\n├─ solmate\nsrc\n├─ tests\n│  └─ Greeter.t — \"Greeter Tests\"\n└─ Greeter — \"A Minimal Greeter Contract\"\n```\n\n## Development\n\n### First time with Forge/Foundry?\n\nDon't have [rust](https://www.rust-lang.org/tools/install) installed?\nRun\n```bash\ncurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\n```\n\nThen, install [foundry](https://github.com/gakonst/foundry) with:\n```bash\ncargo install --git https://github.com/gakonst/foundry --bin forge --locked\n```\n\n### Dependencies\n\n```bash\nyarn setup\n```\n\n### Run Tests\n\n```bash\nyarn test\n```\n\n## Reverse Engineering\n\n### Prerequisites\n\nRequirement: Install `r2`:\n```bash\ngit clone https://github.com/radareorg/radare2\ncd radare2 ; sys/install.sh\n```\n\n(UbInstall libjansson-dev:\n```bash\nsudo apt install libjansson-dev\n```\n\nInstall `evm` using r2pm:\n```bash\nr2pm -gi evm\n```\n\nInstall the [iaito](https://github.com/radareorg/iaito) graphical interface:\n```bash\nr2pm -ci iaito\n```\n\n### Disassembling\n\nCompile `Greeter.sol` to binary code using `solc`:\n```bash\nsolc ./src/Greeter.sol --bin-runtime -o ./out/ --overwrite\nls ./out/\n```\n\nWe need to use `--bin-runtime` instead of `--bin` to exclude the prepended code for blockchain placement.\n\nNow convert the hexadecimal format from `solc` into pure binary format using `rax2`:\n```bash\nrax2 -s \u003c ./out/Greeter.bin-runtime \u003e ./out/Greeter.bin-runtime.bin\n```\n\nAnalyze with `r2`:\n```bash\nr2 -a evm ./out/Greeter.bin-runtime.bin\n```\n\nThen, enter `aa` for the first prompt:\n```bash\n[0x00000000]\u003e aa\n[Warning: set your favourite calling convention in `e anal.cc=?`\n[x] Analyze all flags starting with sym. and entry0 (aa)\n```\n\nNext, disassemble 30 instructions with `pd 30`:\n```bash\n[0x00000000]\u003e pd 30\n┌ 1077: fcn.00000000 ();\n│           0x00000000      60\n│           0x00000001      80\n...\n```\n\n\n\n## License\n\n[AGPL-3.0-only](https://github.com/abigger87/reversevm/blob/master/LICENSE)\n\n# Resources \u0026 Acknowledgements\n\n- [Radare2 Book](https://book.rada.re/) (select `ayu` color trust me :)\n- [Practical Eth Decompilation](https://blog.ret2.io/2018/05/16/practical-eth-decompilation/)\n- [ICO Security Tips radare2](https://blog.positive.com/reversing-evm-bytecode-with-radare2-ab77247e5e53)\n- [foundry](https://github.com/gakonst/foundry)\n- [solmate](https://github.com/Rari-Capital/solmate)\n- [Georgios Konstantopoulos](https://github.com/gakonst) for [forge-template](https://github.com/gakonst/forge-template) resource.\n\n## Disclaimer\n\n_These smart contracts are being provided as is. No guarantee, representation or warranty is being made, express or implied, as to the safety or correctness of the user interface or the smart contracts. They have not been audited and as such there can be no assurance they will work as intended, and users may experience delays, failures, errors, omissions, loss of transmitted information or loss of funds. We are not liable for any of the foregoing. Users should proceed with caution and use at their own risk._\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frefcell%2Freversevm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frefcell%2Freversevm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frefcell%2Freversevm/lists"}