Skip to content

Commit 218d8a1

Browse files
author
JVancata
committed
ctf-3
1 parent d56deb7 commit 218d8a1

7 files changed

Lines changed: 94 additions & 1 deletion

File tree

.env.docker.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
SOUNDBOARD_API_URL="http://localhost:3000"
33
STEAM_STICKERS_API_CACHE_PATH="/mnt/steam-stickers-cache"
44
CTF_1_FLAG="CTF_1_FLAG"
5-
CTF_2_FLAG="CTF_2_FLAG"
5+
CTF_2_FLAG="CTF_2_FLAG"
6+
CTF_3_FLAG="CTF_3_FLAG"

apps/ctf-3/.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Rename this file to .env
2+
CTF_3_FLAG="PROSEK{neleakuj_si_secrets_do_gitu_lol_minimalne_je_pak_zrotuj}"

apps/ctf-3/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM node:24.8-alpine
2+
3+
ENV NODE_ENV=production
4+
5+
COPY package.json .
6+
RUN npm install
7+
8+
COPY . .
9+
10+
CMD ["node", "index.ts"]
11+
EXPOSE 3000

apps/ctf-3/index.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import express from 'express'
2+
import cors from 'cors'
3+
4+
const app = express()
5+
const port = 3000
6+
7+
app.use(cors())
8+
app.use(express.json());
9+
10+
const FLAG = process.env.CTF_3_FLAG;
11+
12+
if (!FLAG) {
13+
console.error("No CTF_3_FLAG .env value specified! Killing process...");
14+
process.exit(1);
15+
}
16+
17+
app.get('/', (_request, response) => {
18+
response.send('Poslal*a si GET request. Musíš poslat POST request s tělem { "input": "string" }, aby si ověřil*a vlajku.');
19+
})
20+
21+
app.post('/', (request, response) => {
22+
const input = request.body.input;
23+
24+
if (!input || !(typeof input === "string")) {
25+
response.send('Tělo musí být { "input": "string" }, aby si ověřil*a vlajku.');
26+
return;
27+
};
28+
29+
if (input === FLAG) {
30+
response.send(`✅ Výborně!`);
31+
return;
32+
}
33+
34+
response.send(`❌ Zkoušej to dál...`);
35+
return;
36+
})
37+
38+
app.listen(port, () => {
39+
console.log(`ctf-3 running on port ${port}`)
40+
})

apps/ctf-3/package.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "ctf-3",
3+
"version": "1.0.0",
4+
"main": "index.ts",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "node --watch --experimental-strip-types --env-file=.env index.ts",
8+
"docker:build": "docker build -t ctf-3 .",
9+
"docker:run": "docker run -p 3000:3000 ctf-3"
10+
},
11+
"author": "",
12+
"license": "ISC",
13+
"description": "",
14+
"dependencies": {
15+
"cors": "^2.8.5",
16+
"express": "^5.1.0"
17+
},
18+
"devDependencies": {
19+
"@types/cors": "^2.8.18",
20+
"@types/express": "^5.0.2"
21+
}
22+
}

compose.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,12 @@ services:
5656
ports:
5757
- "3007:80"
5858

59+
ctf-3:
60+
build: apps/ctf-3
61+
environment:
62+
CTF_3_FLAG: $CTF_3_FLAG
63+
ports:
64+
- "3008:3000"
65+
5966
volumes:
6067
steam-stickers-cache:

nginx.config

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ server {
8686
proxy_cache_bypass $http_upgrade;
8787
}
8888

89+
# The trailing slash must not be here because of the weird proxying behavior
90+
location /ctf-3 {
91+
proxy_pass http://localhost:3008/;
92+
proxy_http_version 1.1;
93+
proxy_set_header Upgrade $http_upgrade;
94+
proxy_set_header Connection 'upgrade';
95+
proxy_set_header Host $host;
96+
proxy_cache_bypass $http_upgrade;
97+
}
98+
8999
listen [::]:443 ssl ipv6only=on; # managed by Certbot
90100
listen 443 ssl; # managed by Certbot
91101
ssl_certificate /etc/letsencrypt/live/materialy.jakub.dev/fullchain.pem; # managed by Certbot

0 commit comments

Comments
 (0)