/eth-challenge-base

xinetd docker for building ethereum contract challenges

Primary LanguagePythonMIT LicenseMIT

eth-challenge-base

xinetd docker for building ethereum contract challenges in capture the flag (CTF).

Getting Started

Quick Demo

docker run -it -p 20000:20000 -e WEB3_PROVIDER_URI=uri chainflag/eth-challenge-base:0.9.2
nc 127.0.0.1 20000

Usage

Create challenge project based on example

  • contracts is the challenge contract directory, you should code isSolved() function for the contract to check if it is solved
  • challenge.yml is the config for specifying challenge description, flag, contract name, constructor, gas limit etc. See comments in this file for more detail
  • .env is used to set environment variables of docker container, including web3 provider, token secret and proof of work difficulty

Environment variable defaults

Name Default Value
TOKEN_SECRET /dev/urandom
POW_DIFFICULTY 0(no proof of work)

You can build multi-contract challenges by deploying contracts in a setup contract's constructor

Start serving your 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.2

or

docker-compose up -d

Development

Prerequisites

  • Python3
  • Packages
pip install -r requirements.txt

Run in dev mode

python develop.py

Format python source

pip install -r requirements-dev.txt
make format

License

Distributed under the MIT License. See LICENSE for more information.

Acknowledgements