Skip to content

Commit 990d6f1

Browse files
committed
Add build directories
1 parent 9f85109 commit 990d6f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+7776
-5
lines changed

challenges/202312_SECCON_CTF_2023_Finals/misc/whitespace-js/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Don't worry, this is not an esolang challenge.
1313
Launch a challenge server:
1414

1515
```
16-
cd files/whitespace-js
16+
cd build
1717
docker compose up
1818
```
1919

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
services:
2+
sandbox:
3+
build: ./sandbox
4+
restart: unless-stopped
5+
ports:
6+
- 3000:3000
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM node:21-slim
2+
3+
WORKDIR /app
4+
5+
COPY package.json package-lock.json ./
6+
RUN npm install
7+
8+
COPY flag.txt .
9+
RUN mv flag.txt /flag-$(md5sum flag.txt | cut -c-32).txt
10+
11+
COPY . .
12+
13+
USER 404:404
14+
15+
CMD ["node", "index.js"]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SECCON{P4querett3_Down_the_Bunburr0ws}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>whitespace.js</title>
6+
<link rel="stylesheet" href="https://unpkg.com/simpledotcss/simple.min.css">
7+
</head>
8+
<body>
9+
<h1>whitespace.js</h1>
10+
<div style="display: flex; gap: 1rem;">
11+
<input id="expr" type="text" placeholder="7 * 7">
12+
<button id="calc" type="button">Calculate</button>
13+
</div>
14+
<pre id="result" style="text-align: center; font-size: 3rem; margin: 1rem 0;"> </pre>
15+
16+
<script>
17+
const $ = document.getElementById.bind(document);
18+
$("calc").addEventListener("click", async () => {
19+
const expr = $("expr").value;
20+
if (!expr) return;
21+
22+
const result = await fetch("/", {
23+
method: "POST",
24+
headers: {
25+
"Content-Type": "application/json",
26+
},
27+
body: JSON.stringify({ expr }),
28+
}).then((r) => r.text());
29+
30+
$("result").textContent = result;
31+
});
32+
</script>
33+
</body>
34+
</html>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const fs = require("node:fs").promises;
2+
const execFile = require("node:util").promisify(
3+
require("node:child_process").execFile
4+
);
5+
6+
const app = require("fastify")();
7+
const PORT = 3000;
8+
9+
app.get("/", async (req, res) => {
10+
const html = await fs.readFile("index.html");
11+
res.type("html").send(html);
12+
});
13+
14+
app.post("/", async (req, res) => {
15+
const { expr } = req.body;
16+
17+
const proc = await execFile("node", ["whitespace.js", expr], {
18+
timeout: 2000,
19+
}).catch((e) => e);
20+
21+
res.send(proc.killed ? "Timeout" : proc.stdout);
22+
});
23+
24+
app.listen({ port: PORT, host: "0.0.0.0" }).catch((err) => {
25+
app.log.error(err);
26+
process.exit(1);
27+
});

0 commit comments

Comments
 (0)