eth-challenge-base
xinetd docker for building ethereum contract challenges in capture the flag (CTF).
Getting Started
Quick Demo
Use the following command to run a quick demo:
docker run -it -p 20000:20000 -e WEB3_PROVIDER_URI=https://rpc.sepolia.org chainflag/eth-challenge-base
nc 127.0.0.1 20000
Usage
example
Create challenge project based on- The
contracts
directory is where you should code the challenge contract, specifically, you need to implement isSolved() function to check if it is solved. - The
challenge.yml
file is the config for specifying challenge description, flag, contract name, constructor, gas limit etc. Refer to the comments in this file for more details. - The
.env
file is used to set environment variables of docker container, including web3 provider, token secret and proof of work difficulty.
You can build multi-contract challenges by deploying contracts in a setup contract's constructor
Start serving your contract challenge
Use the following command to start serving the contract challenge:
docker run -d -p 20000:20000 --env-file .env -v `pwd`/contracts:/home/ctf/contracts -v `pwd`/challenge.yml:/home/ctf/challenge.yml chainflag/eth-challenge-base:0.9.3
Alternatively, you can use docker-compose:
docker-compose up -d
Advance
Use private PoA Ethereum network as challenge environment
- Launch an anti-plagiarism PoA network by following the instructions here.
- Keep the web3 provider defaults in the
.env
file. - Run the docker container using the following command:
docker run -d -p 20000:20000 --network geth_default --env-file .env -v `pwd`/contracts:/home/ctf/contracts -v `pwd`/challenge.yml:/home/ctf/challenge.yml chainflag/eth-challenge-base:0.9.3
Development
Prerequisites
Before you start, make sure you have the following installed:
- Docker
- Python3
- Required packages (
pip install -r requirements.txt
)
Run in development mode
- Generate protobuf code and run server
make protoc
export WEB3_PROVIDER_URI="your web3 provider"
make dev
- Open another terminal to run client
python run.py
Format python source
To format the Python source code, you will need to install additional packages (pip install -r requirements-dev.txt
) and run the following command:
make format
License
Distributed under the MIT License. See LICENSE for more information.