|
| 1 | +# How to write beaverCDS challenge.yaml config |
| 2 | + |
| 3 | +tldr: see [the TCP example](#full-tcp-example) or [the web example](#full-http-example). |
| 4 | + |
| 5 | +### Metadata |
| 6 | + |
| 7 | +Self explanatory. |
| 8 | + |
| 9 | +```yaml |
| 10 | +name: yet another pyjail |
| 11 | +author: somebody, John Author |
| 12 | +``` |
| 13 | +
|
| 14 | +### Description |
| 15 | +
|
| 16 | +Challenge description supports markdown and Jinja-style templating for challenge info. |
| 17 | +The Jinja template fields available are: |
| 18 | +
|
| 19 | +| Field name | Description | |
| 20 | +| ----------- | ----------- | |
| 21 | +| `hostname` | The hostname or domain for the challenge |
| 22 | +| `port` | The port that the challenge is listening on |
| 23 | +| `nc` | Insert the `nc` command to connect to TCP challenges (`nc {{hostname}} {{port}}`) |
| 24 | +| `link` | Create a Markdown link to the exposed hostname/port |
| 25 | +| `url` | The URL from `link` without the accompanying Markdown |
| 26 | +| `challenge` | The full challenge.yaml config for this challenge, with subfields |
| 27 | + |
| 28 | +You probably only want `{{ nc }}` or `{{ link }}`. |
| 29 | + |
| 30 | +Example: |
| 31 | + |
| 32 | +```yaml |
| 33 | +description: | |
| 34 | + Some example challenge. Blah blah blah flavor text. |
| 35 | +
|
| 36 | + In case you missed it, this was written by {{ challenge.author }} |
| 37 | + and is called {{ challenge.name }}. |
| 38 | +
|
| 39 | + {{ link }} # -becomes-> [example.chals.thectf.com](https://example.chals.thectf.com) |
| 40 | + {{ nc }} # -becomes-> `nc example.chals.thectf.com 12345` |
| 41 | +``` |
| 42 | + |
| 43 | + |
| 44 | +### Flag |
| 45 | + |
| 46 | +Read flag from file: |
| 47 | + |
| 48 | +```yaml |
| 49 | +flag: |
| 50 | + file: ./flag |
| 51 | +``` |
| 52 | +
|
| 53 | +### Pods |
| 54 | +
|
| 55 | +Defines how any container images for this challenge are built and deployed. |
| 56 | +
|
| 57 | +The pod `name` is also used for extracting files, see [Providing files to |
| 58 | +users](<for-challenge-authors#Providing files to users>). |
| 59 | + |
| 60 | +`build` works similar to [Docker Compose](https://docs.docker.com/reference/compose-file/build/#illustrative-example), |
| 61 | +either: |
| 62 | + - a string path to the build context folder |
| 63 | + - yaml with explicit `context` path, `dockerfile` path within context folder, and `args` build args \ |
| 64 | + (only `context`, `dockerfile`, and `args` are supported for the detailed form) |
| 65 | + |
| 66 | +`ports` controls how the container is exposed. This should be a list of what port the container is listening, and how |
| 67 | +that port should be exposed to players: |
| 68 | +- For TCP challenges, set `expose.tcp` to the subdomain and port: `<subdomain>:<port>` |
| 69 | +- For HTTP challenges, set `expose.http` to the subdomain only: `<subdomain>` \ |
| 70 | + The website domain will automatically be set up with an HTTPS cert. |
| 71 | + |
| 72 | + |
| 73 | +```yaml |
| 74 | +pods: |
| 75 | + - name: tcp-example |
| 76 | + build: . |
| 77 | + replicas: 2 |
| 78 | + ports: |
| 79 | + - internal: 31337 |
| 80 | + expose: |
| 81 | + tcp: thechal:30124 # exposed at thechal.<challenges_domain>:30124 |
| 82 | +
|
| 83 | + - name: web-example |
| 84 | + build: |
| 85 | + context: src/ |
| 86 | + dockerfile: Containerfile |
| 87 | + replicas: 2 |
| 88 | + ports: |
| 89 | + - internal: 31337 |
| 90 | + expose: |
| 91 | + http: webchal # exposed at https://webchal.<challenges_domain> |
| 92 | +``` |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | +This can be omitted if there are no containers for the challenge. |
| 98 | + |
| 99 | +### Providing files to users |
| 100 | + |
| 101 | +Files to give to players as downloads in frontend. |
| 102 | + |
| 103 | +These can be from the challenge folder in the repository, or from the |
| 104 | +challenge's built container. These can also be zipped together into one file, or |
| 105 | +uploaded separately. |
| 106 | + |
| 107 | +This can be omitted if there are no files provided. |
| 108 | + |
| 109 | +```yaml |
| 110 | +provide: |
| 111 | + # file from the challenge folder in the repo |
| 112 | + - somefile.txt |
| 113 | +
|
| 114 | + # multiple files from chal_folder/src/, zipped as together.zip |
| 115 | + - as: together.zip |
| 116 | + include: |
| 117 | + - src/file1 |
| 118 | + - src/file2 |
| 119 | + - src/file3 |
| 120 | +
|
| 121 | + # extract these files from inside of the container image |
| 122 | + # for the `main` pod (see previous section) |
| 123 | + - from: main |
| 124 | + include: |
| 125 | + - /chal/notsh |
| 126 | + - /lib/x86_64-linux-gnu/libc.so.6 |
| 127 | + |
| 128 | + # same as above, but now zipped together |
| 129 | + - from: main |
| 130 | + as: notsh.zip |
| 131 | + include: |
| 132 | + - /chal/notsh |
| 133 | + - /lib/x86_64-linux-gnu/libc.so.6 |
| 134 | +``` |
| 135 | +
|
| 136 | +
|
| 137 | +
|
| 138 | +
|
| 139 | +
|
| 140 | +# Examples |
| 141 | +
|
| 142 | +## Full TCP example |
| 143 | +
|
| 144 | +```yaml |
| 145 | +name: notsh |
| 146 | +author: John Author |
| 147 | +description: |- |
| 148 | + This challenge isn't a shell |
| 149 | +
|
| 150 | + {{ nc }} |
| 151 | +
|
| 152 | +provide: |
| 153 | + - from: main |
| 154 | + include: |
| 155 | + - /chal/notsh |
| 156 | + - /lib/x86_64-linux-gnu/libc.so.6 |
| 157 | + |
| 158 | +flag: |
| 159 | + file: ./flag |
| 160 | + |
| 161 | +pods: |
| 162 | + - name: main |
| 163 | + build: . |
| 164 | + replicas: 2 |
| 165 | + ports: |
| 166 | + - internal: 31337 |
| 167 | + expose: |
| 168 | + tcp: 30124 |
| 169 | +``` |
| 170 | +
|
| 171 | +## Full HTTP example |
| 172 | +
|
| 173 | +```yaml |
| 174 | +name: bar |
| 175 | +author: somebody |
| 176 | +description: | |
| 177 | + can you order a drink from the webserver? |
| 178 | +
|
| 179 | + {{ url }} |
| 180 | +
|
| 181 | +difficulty: 1 |
| 182 | + |
| 183 | +flag: |
| 184 | + file: ./flag |
| 185 | + |
| 186 | +# no provide: section needed if no files |
| 187 | + |
| 188 | +pods: |
| 189 | + - name: bar |
| 190 | + build: |
| 191 | + context: . |
| 192 | + dockerfile: Containerfile |
| 193 | + replicas: 1 |
| 194 | + ports: |
| 195 | + - internal: 80 |
| 196 | + expose: |
| 197 | + http: bar # subdomain only |
| 198 | +``` |
0 commit comments