Git Product home page Git Product logo

forge-poc-templates's Introduction

GitHub issues Foundry LGPLv3 license

Immunefi Discord Twitter Medium YouTube

Overview

Welcome to the Immunefi PoC Templates repository! Here, you'll find reusable and easily modifiable Proof of Concept (PoC) examples for various Ethereum Virtual Machine (EVM) based vulnerabilities. Clone the branch corresponding to the chosen attack template. The aim is to enhance bug reporting quality and provide whitehat hackers with efficient tools to create PoCs and validate their findings quickly. These templates are intended for testing proof of concepts in local forks for submission to bug bounty programs. Any other use is explicitly prohibited.

Installation

To utilize this repository, you need to have Foundry installed. Check out the installation guide for Foundry.

Getting Started ๐Ÿ“–

  1. Initialize Forge Repository: Start by initializing a forge repository with the desired attack template. Use the command below, replacing [template] with the chosen template from the Template Categories:

    forge init --template immunefi-team/forge-poc-templates --branch [template]
    
  2. Download Contract Interfaces: Obtain contract interfaces either by creating your own or using Foundry's tools:

    • Create Interface Automatically: Use Foundry's cast interface commandline tool to automatically generate interfaces based on contract ABIs.
    cast interface [address] -o src/external/interfaces/IExample.sol -n IExample
    
    • Download Entire Source Code: Alternatively, download entire contract source codes using cast etherscan-source command line tool.
    cast etherscan-source [address] -d src/external
    
  3. Write the Test: Import your attack contract into PoCTest.sol and modify the setUp() function to replicate necessary attack preconditions. Execute the attack in the testAttack() function.

    The test should extend the PoC contract, which introduces functionality to automatically snapshot and print account balances before and after a test.

    Use the modifier snapshot(address account, IERC20[] tokens) on the test* function to automatically print information such as pre-attack balances, post-attack balances, and profit. Passing a token with address(0x0) corresponds to the native token of the chain.

Running a PoC ๐Ÿš€

To run a test, execute the following command in the console:

forge test -vv --match-path test/[test_name]

Template Categories ๐Ÿชฒ

Explore various vulnerability categories along with their respective branches, source codes, and documentation in the table below:

Categorization Branch Source Documentation
Default default
Reentrancy reentrancy Source Readme
Flash Loan flash_loan Source Readme
Price Manipulation price_manipulation Source Readme
Boilerplate Mocks mocks Source Readme
Oracle Mocks oracles Source Readme
Sandwich Attacks sandwich

Foundry Concepts

Refer to Foundry for comprehensive understanding.

Community PoCs โœจ

Explore PoCs contributed by our community members:

Contribute

We sincerely appreciate contributions to Immunefi's templates. Please review the contribution guidelines and code of conduct to ensure your contributions are merged as soon as possible.

Contributors

Showcasing the contributors behind this project:

Need Assistance?

For any queries or concerns, please don't hesitate to raise them at our GitHub issues.

Finally, if you're eager to collaborate and searching for beginner-friendly tasks, explore the issues labeled as "Good first issue".

Thank you for your time and contributions! ๐Ÿ™Œ

forge-poc-templates's People

Contributors

alejandro-immunefi avatar janbro avatar gibranakbaromil avatar arbaz-immunefi avatar arbazkiraak avatar infosec-us-team avatar goncalomagalhaes avatar iphelix avatar juliusbrain avatar pepin-immunefi 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.