Skip to content

A Template for efficient ctf testing & scripts

Notifications You must be signed in to change notification settings

m4k2/foundry-ctf-template

 
 

Repository files navigation

CTF Setup

This was a template for the Spearbit Rearguard team (or anyone else who finds it) to use for Paradigm CTF 2022.

I update it to match any CTF, you can found the template here.

Set Up

  • Create a .env file in the root directory with RPC_URL and PRIVATE_KEY (these will be used for submission scripts)
  • Run the commande source .env to update these new env variable.
  • Your tests will run forking the rpc targeted chain.

Running Challenges

  • Create a folder in /src with the contracts for the challenge.
  • Edit the Template.t.sol file in /test and set it up for the challenge. Link in needed contracts (including mocks). It's already set up to fork the CTF network at the start of the test.
  • Copy and Write exploit in the test (after vm.createSelectFork(vm.rpcUrl("CTFnetwork"));). Use cast commands in terminal or console.logs in the test to aid as needed. Run tests with this cmd : forge test --match-path test/Template/Template.t.sol -vvv adapting the test path.
  • When the test succeeds, copy everything in a folder over to script/Exploitoor.s.sol, in between startBroadcast() and stopBroadcast(). (remove all vm.prank(), they won't work in script, substitute them with vm.broadcast()).
  • Call bash exploit.sh to run the script on the CTFnetwork ($RPC_URL) network with your private key ($PRIVATE_KEY).

WriteUp

Compose your write-up and share it.

About

A Template for efficient ctf testing & scripts

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Solidity 100.0%