solidctf
solidctf copied to clipboard
SolidCTF is an infrastructure solution that simplifies the build of Solidity CTF challenges.
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=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
contractsis the challenge contract directory, you should code isSolved() function for the contract to check if it is solvedchallenge.ymlis the config for specifying challenge description, flag, contract name, constructor, gas limit etc. See comments in this file for more detail.envis 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
- Launch an anti-plagiarism PoA network by referring here
- Keep the web3 provider defaults in the
.envfile - 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
- https://github.com/eth-brownie/brownie
- https://github.com/hitcxy/blockchain_template
- https://github.com/paradigm-operations/paradigm-ctf-2021
- https://github.com/balsn/proof-of-work