Skip to content

Instantly share code, notes, and snippets.

@shubham-kanodia
Created November 3, 2022 03:51
Show Gist options
  • Save shubham-kanodia/f28ecbfb6c8035e4261779cc7469496e to your computer and use it in GitHub Desktop.
Save shubham-kanodia/f28ecbfb6c8035e4261779cc7469496e to your computer and use it in GitHub Desktop.
Dappcamp CTF Description

This level walks you through the very basics of how to play the game. You can follow the steps below to do the setup or go through the walkthrough video to get started.

 

1. Get test ether

To play the game, you will need test ether. The easiest way to get some testnet ether is via a faucet.

Once you see some ether in your balance, move on to the next step.

 

2. Connect to Goerli network

Make sure you are connected to the Goerli test network in your metamask.

 

3. Contract's Adress

In this CTF, at each level you will get a new contract instance deployed for you to hack! This contract address will be visible on the level's page once you have clicked on Get new instance button.

 

4. Getting a level instance

In this CTF, you need to generate a level instance for you at each level. To do so, click the blue button at the bottom of the page. Go do it now and come back!

You should be prompted by MetaMask to authorize the transaction. Do so, and you should see the deployed contract's address now visible at the top of the page. Note that this is deploying a new contract on the Goerli testnet and might take a few seconds, so please be patient when requesting new level instances!

 

5. Setup

Create an empty directory which you will be using as a workspace for this challenge. Create a .env file in it containing the following information. Replace the values of YOUR_RPC_URL_HERE and YOUR_PRIVATE_KEY_HERE with your rpc url (which you can get from Alchemy) and wallet's private key.

RPC_URL="YOUR_RPC_URL_HERE"
PRIVATE_KEY="YOUR_PRIVATE_KEY_HERE"

Open a terminal with this directory as the present working directory. Use the following command to populate the environment variables

source .env

 

6. To complete this level follow the steps below

To use cast, you need to install foundry. Follow the foundry installation guide to setup foundry.

Use the following cast command to get the password to unlock the level

cast call "CONTRACT_ADDRESS" "password()" --rpc-url $RPC_URL | cast --to-ascii 

Submit the password to authenticate function using cast send command

cast send "CONTRACT_ADDRESS" "authenticate(string)" "PASSWORD_HERE" --rpc-url $RPC_URL --private-key $PRIVATE_KEY

 

7. Submission

You can now click on Submit Instance button at the end of the page to complete submission and approve the metamask popup. Once done, you will be able to see a tick mark in front of the level name in the sidebar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment