├── .env ├── LICENSE ├── README.md ├── challenge.yml ├── contracts └── Example.sol ├── docker-compose.yml └── flag.txt /.env: -------------------------------------------------------------------------------- 1 | WEB3_PROVIDER_URI=http://ethereum:8545 2 | ALLOC_ADDRESS_PRIVATE_KEY=1a244b0c79968c206e59c7ac07751c2767ad949c1fdd25a8223d521825e81bd6 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # solidity-ctf-template -------------------------------------------------------------------------------- /challenge.yml: -------------------------------------------------------------------------------- 1 | contract: Greeter # The class name of the challenge contract 2 | 3 | description: | 4 | Can you make the isSolved() function return true? 5 | 6 | constructor: 7 | args: ["hello"] # The argument(s) to be passed to the contract constructor 8 | value: 0 # The amount of wei to be sent to the contract upon deployment 9 | #gas: 1000000 # The gas limit to execute the contract constructor, default is the response value of the eth_estimateGas JSON-RPC 10 | 11 | show_source: True # Set to False if you don't want the contract source code to be displayed to players 12 | 13 | # solved_event: EmitFlag # Verify the challenge has been solved by checking if the event was emitted instead of calling the isSolved() view function by default 14 | 15 | -------------------------------------------------------------------------------- /contracts/Example.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity 0.8.9; 3 | 4 | contract Greeter { 5 | string greeting; 6 | 7 | constructor(string memory _greeting) { 8 | greeting = _greeting; 9 | } 10 | 11 | function greet() public view returns (string memory) { 12 | return greeting; 13 | } 14 | 15 | function setGreeting(string memory _greeting) public { 16 | greeting = _greeting; 17 | } 18 | 19 | function isSolved() public view returns (bool) { 20 | string memory expected = "HelloChainFlag"; 21 | return keccak256(abi.encodePacked(expected)) == keccak256(abi.encodePacked(greeting)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | challenge: 4 | image: chainflag/solidctf:1.0.0 5 | restart: unless-stopped 6 | ports: 7 | - "20000:20000" 8 | env_file: 9 | - .env 10 | volumes: 11 | - ./flag.txt:/ctf/flag.txt 12 | - ./contracts:/ctf/contracts 13 | - ./challenge.yml:/ctf/challenge.yml 14 | 15 | ethereum: 16 | image: chainflag/fogeth:latest 17 | restart: unless-stopped 18 | container_name: fogeth 19 | ports: 20 | - "8545:8545" 21 | env_file: 22 | - .env 23 | volumes: 24 | - ./data:/data 25 | - ./logs:/var/log/nginx 26 | 27 | faucet: 28 | image: chainflag/eth-faucet:1.1.0 29 | restart: unless-stopped 30 | container_name: eth_faucet 31 | ports: 32 | - "8080:8080" 33 | links: 34 | - ethereum 35 | env_file: 36 | - .env 37 | command: -wallet.provider http://ethereum:8545 -wallet.privkey ${ALLOC_ADDRESS_PRIVATE_KEY} -faucet.minutes 1 38 | depends_on: 39 | - ethereum 40 | -------------------------------------------------------------------------------- /flag.txt: -------------------------------------------------------------------------------- 1 | flag{placeholder} 2 | --------------------------------------------------------------------------------