t0hka1 / eth-challenge-base

xinetd docker for building ethereum contract challenges

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

eth-challenge-base

Docker CI Docker size Latest tag License: MIT

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=https://ropsten.infura.io/v3/YOUR-PROJECT-ID chainflag/eth-challenge-base
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 openssl rand
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.3

or

docker-compose up -d

Advance

Use private PoA Ethereum network as challenge environment

  1. Launch an anti-plagiarism PoA network by referring here
  2. Keep the web3 provider defaults in the .env file
  3. 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

  • 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

About

xinetd docker for building ethereum contract challenges

License:MIT License


Languages

Language:Python 76.2%Language:Shell 9.8%Language:JavaScript 6.4%Language:Dockerfile 3.7%Language:Solidity 3.0%Language:Makefile 0.9%