Skip to content

Solutions to the "Ethernaut" smart contract security CTF.

Notifications You must be signed in to change notification settings

johnsaigle/ethernaut-solutions

Repository files navigation

ethernaut-solutions

Solutions to Ethernaut CTF/LiftTicket for Avax.

The unit-test solution format is based on the work done by MrToph Check out his work! His blog posts helped me to get started with smart contract auditing. This repository uses unit tests instead of cloning Ethernaut as-is. For a beginner, this greatly simplifies the deployment and build process.

Current Progress

  • 0-Hello.sol (but not in this repo)
  • 1-Fallback.sol (but not in this repo)
  • 2-Fallout.sol (but not in this repo)
  • 3-CoinFlip.sol
  • 4-Telephone.sol
  • 5-Token.sol
  • 6-Delegation.sol
  • 7-Force.sol
  • 8-Vault.sol
  • 9-King.sol
  • 10-ReEntrancy.sol
  • 11-Elevator.sol
  • 12-Privacy.sol
  • 13-GatekeeperOne.sol
  • 14-GatekeeperTwo.sol
  • 15-NaughtCoin.sol
  • 16-Preservation.sol
  • 17-Recovery.sol
  • 18-MagicNumber.sol
  • 19-AlienCodex.sol
  • 20-Denial.sol
  • 21-Shop.sol

I may attempt and add solutions to the more recent puzzles in the future.

Development

npm i

You need to configure environment variables:

cp .env.template .env
# fill out

Pick a mnemonic and the resulting accounts will be used in the challenges.

Hardhat

This repo uses hardhat to run the CTF challenges. Challenges are implemented as hardhat tests in /test.

The tests run on a local hardnet network but it needs to be forked from Rinkeby because it interacts with the challenge factory and submission contract. To fork the Rinkeby testnet, you need an archive URL like the free ones from Alchemy.

Running challenges

Optionally set the block number in the hardhat.config.ts hardhat network configuration to the rinkeby head block number such that the challenge contract is deployed.

# fork rinkeby but run locally
npx hardhat test test/0-hello.ts

About

Solutions to the "Ethernaut" smart contract security CTF.

Topics

Resources

Stars

Watchers

Forks