diff --git a/web/samplehub/samplehub.tar.xz b/web/samplehub/samplehub.tar.xz new file mode 100644 index 0000000..8cdf407 Binary files /dev/null and b/web/samplehub/samplehub.tar.xz differ diff --git a/web/samplehub/samplehub/.flag.txt b/web/samplehub/samplehub/.flag.txt new file mode 100644 index 0000000..508ddf5 --- /dev/null +++ b/web/samplehub/samplehub/.flag.txt @@ -0,0 +1 @@ +HERO{FAKE_FLAG} \ No newline at end of file diff --git a/web/samplehub/samplehub/Dockerfile b/web/samplehub/samplehub/Dockerfile new file mode 100644 index 0000000..1e187f4 --- /dev/null +++ b/web/samplehub/samplehub/Dockerfile @@ -0,0 +1,10 @@ +FROM alpine:3.20.3 + +WORKDIR /usr/app +COPY ./src/ . +COPY ./.flag.txt /.flag.txt +RUN apk add --update --no-cache nodejs npm && \ + npm install + +USER guest +CMD ["/usr/bin/node", "/usr/app/app.js"] diff --git a/web/samplehub/samplehub/docker-compose.yml b/web/samplehub/samplehub/docker-compose.yml new file mode 100644 index 0000000..26380ec --- /dev/null +++ b/web/samplehub/samplehub/docker-compose.yml @@ -0,0 +1,16 @@ +version: '3.8' + +services: + web: + build: . + ports: + - "3000:3000" + read_only: true + restart: unless-stopped + cap_drop: + - all + deploy: + resources: + limits: + cpus: "0.5" + memory: 1G diff --git a/web/samplehub/samplehub/src/app.js b/web/samplehub/samplehub/src/app.js new file mode 100644 index 0000000..3d4ce53 --- /dev/null +++ b/web/samplehub/samplehub/src/app.js @@ -0,0 +1,28 @@ +const express = require("express"); +const path = require("path"); + +const app = express(); +const PORT = 3000; + +app.use(express.static(path.join(__dirname, "public"))); +app.set("view engine", "ejs"); +app.set("views", path.join(__dirname, "views")); + +app.get("/", (req, res) => { + res.render("index"); +}); + +process.chdir(path.join(__dirname, "samples")); +app.get("/download/:file", (req, res) => { + const file = path.basename(req.params.file); + res.download(file, req.query.filename || "sample.png", (err) => { + if (err) { + res.status(404).send(`File "${file}" not found`); + } + }); +}); + + +app.listen(PORT, () => { + console.log(`Server is running on http://localhost:${PORT}`); +}); diff --git a/web/samplehub/samplehub/src/package.json b/web/samplehub/samplehub/src/package.json new file mode 100644 index 0000000..c37c102 --- /dev/null +++ b/web/samplehub/samplehub/src/package.json @@ -0,0 +1,6 @@ +{ + "dependencies": { + "ejs": "^3.1.10", + "express": "^4.21.1" + } +} diff --git a/web/samplehub/samplehub/src/public/samples.json b/web/samplehub/samplehub/src/public/samples.json new file mode 100644 index 0000000..2d8dd55 --- /dev/null +++ b/web/samplehub/samplehub/src/public/samples.json @@ -0,0 +1,9 @@ +[ + { "filename": "sample.png", "extension": ".png", "description": "A Portable Network Graphics file that supports lossless data compression. Commonly used for web images and graphics." }, + { "filename": "sample.jpg", "extension": ".jpg", "description": "A JPEG image file, widely used for digital photos and web graphics. It employs lossy compression to reduce file size." }, + { "filename": "sample.pdf", "extension": ".pdf", "description": "A Portable Document Format file used for sharing documents while preserving formatting. It is viewable on any platform using a PDF reader." }, + { "filename": "sample.doc", "extension": ".doc", "description": "A Microsoft Word document file format used for text documents. It supports rich formatting and can include images, tables, and other elements." }, + { "filename": "sample.xls", "extension": ".xls", "description": "A Microsoft Excel spreadsheet file format that supports data analysis and calculation. It allows for complex formulas and data visualization." }, + { "filename": "sample.mp3", "extension": ".mp3", "description": "An audio file format that uses lossy compression to reduce file size. It's commonly used for music and audio streaming." }, + { "filename": "sample.mp4", "extension": ".mp4", "description": "A digital multimedia format commonly used for video files. It supports a wide range of codecs and is ideal for streaming." } +] diff --git a/web/samplehub/samplehub/src/samples/sample.doc b/web/samplehub/samplehub/src/samples/sample.doc new file mode 100644 index 0000000..7e12e3d Binary files /dev/null and b/web/samplehub/samplehub/src/samples/sample.doc differ diff --git a/web/samplehub/samplehub/src/samples/sample.jpg b/web/samplehub/samplehub/src/samples/sample.jpg new file mode 100644 index 0000000..c0eeef0 Binary files /dev/null and b/web/samplehub/samplehub/src/samples/sample.jpg differ diff --git a/web/samplehub/samplehub/src/samples/sample.mp3 b/web/samplehub/samplehub/src/samples/sample.mp3 new file mode 100644 index 0000000..ab94045 Binary files /dev/null and b/web/samplehub/samplehub/src/samples/sample.mp3 differ diff --git a/web/samplehub/samplehub/src/samples/sample.mp4 b/web/samplehub/samplehub/src/samples/sample.mp4 new file mode 100644 index 0000000..b11552f Binary files /dev/null and b/web/samplehub/samplehub/src/samples/sample.mp4 differ diff --git a/web/samplehub/samplehub/src/samples/sample.pdf b/web/samplehub/samplehub/src/samples/sample.pdf new file mode 100644 index 0000000..c01805e Binary files /dev/null and b/web/samplehub/samplehub/src/samples/sample.pdf differ diff --git a/web/samplehub/samplehub/src/samples/sample.png b/web/samplehub/samplehub/src/samples/sample.png new file mode 100644 index 0000000..0218b6e Binary files /dev/null and b/web/samplehub/samplehub/src/samples/sample.png differ diff --git a/web/samplehub/samplehub/src/samples/sample.xls b/web/samplehub/samplehub/src/samples/sample.xls new file mode 100644 index 0000000..1464ee1 Binary files /dev/null and b/web/samplehub/samplehub/src/samples/sample.xls differ diff --git a/web/samplehub/samplehub/src/views/index.ejs b/web/samplehub/samplehub/src/views/index.ejs new file mode 100644 index 0000000..2d94d5d --- /dev/null +++ b/web/samplehub/samplehub/src/views/index.ejs @@ -0,0 +1,65 @@ + + + + + + Samples + + + +
+

File Samples

+
+ +
+
+
+ + + +