-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from sdslabs/unzip_pipeline
Implement challenge.tar.gz unzip pipeline
- Loading branch information
Showing
20 changed files
with
864 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
knock flag getter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
knock flag setter |
1 change: 1 addition & 0 deletions
1
challenge_template/knock/knock-challenge-checker/knock-challenge-checker.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
knock challenge checker |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM node:17.4.0-buster-slim | ||
|
||
RUN mkdir -p /app | ||
|
||
WORKDIR /app | ||
|
||
COPY package.json . | ||
|
||
RUN yarn | ||
|
||
COPY . . | ||
|
||
USER node | ||
|
||
CMD ["node", "index.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: knock-knock | ||
author: BrownieInMotion | ||
description: |- | ||
Knock knock? Who's there? Another pastebin!! | ||
${link_main_0} | ||
flag: dice{1_d00r_y0u_d00r_w3_a11_d00r_f0r_1_d00r} | ||
|
||
provide: | ||
- ./index.js | ||
- ./Dockerfile | ||
|
||
containers: | ||
main: | ||
build: . | ||
ports: | ||
- 3000 | ||
environment: | ||
FLAG: "dice{1_d00r_y0u_d00r_w3_a11_d00r_f0r_1_d00r}" | ||
|
||
expose: | ||
main: | ||
- target: 3000 | ||
http: knock-knock | ||
healthContent: Create Paste |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
const crypto = require('crypto'); | ||
|
||
class Database { | ||
constructor() { | ||
this.notes = []; | ||
this.secret = `secret-${crypto.randomUUID}`; | ||
} | ||
|
||
createNote({ data }) { | ||
const id = this.notes.length; | ||
this.notes.push(data); | ||
return { | ||
id, | ||
token: this.generateToken(id), | ||
}; | ||
} | ||
|
||
getNote({ id, token }) { | ||
if (token !== this.generateToken(id)) return { error: 'invalid token' }; | ||
if (id >= this.notes.length) return { error: 'note not found' }; | ||
return { data: this.notes[id] }; | ||
} | ||
|
||
generateToken(id) { | ||
return crypto | ||
.createHmac('sha256', this.secret) | ||
.update(id.toString()) | ||
.digest('hex'); | ||
} | ||
} | ||
|
||
const db = new Database(); | ||
db.createNote({ data: process.env.FLAG }); | ||
|
||
const express = require('express'); | ||
const app = express(); | ||
|
||
app.use(express.urlencoded({ extended: false })); | ||
app.use(express.static('public')); | ||
|
||
app.post('/create', (req, res) => { | ||
const data = req.body.data ?? 'no data provided.'; | ||
const { id, token } = db.createNote({ data: data.toString() }); | ||
res.redirect(`/note?id=${id}&token=${token}`); | ||
}); | ||
|
||
app.get('/note', (req, res) => { | ||
const { id, token } = req.query; | ||
const note = db.getNote({ | ||
id: parseInt(id ?? '-1'), | ||
token: (token ?? '').toString(), | ||
}); | ||
if (note.error) { | ||
res.send(note.error); | ||
} else { | ||
res.send(note.data); | ||
} | ||
}); | ||
|
||
app.listen(3000, () => { | ||
console.log('listening on port 3000'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "knock-knock", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"express": "^4.17.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<style> | ||
* { | ||
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, | ||
'Helvetica Neue', sans-serif; | ||
box-sizing: border-box; | ||
} | ||
|
||
html, | ||
body { | ||
margin: 0; | ||
} | ||
|
||
.container { | ||
padding: 2rem; | ||
width: 90%; | ||
max-width: 900px; | ||
margin: auto; | ||
} | ||
|
||
input:not([type='submit']) { | ||
width: 100%; | ||
padding: 8px; | ||
margin: 8px 0; | ||
} | ||
|
||
textarea { | ||
width: 100%; | ||
padding: 8px; | ||
margin: 8px 0; | ||
resize: vertical; | ||
font-family: monospace; | ||
} | ||
|
||
input[type='submit'] { | ||
margin-bottom: 16px; | ||
} | ||
</style> | ||
|
||
<div class="container"> | ||
<h1>Create Paste</h1> | ||
<form method="POST" action="/create"> | ||
<textarea name="data"></textarea> | ||
<input type="submit" value="Create" /> | ||
</form> | ||
</div> |
Oops, something went wrong.