Skip to content

Commit

Permalink
(web): Added restart the robots
Browse files Browse the repository at this point in the history
  • Loading branch information
saintbarber committed Jul 1, 2024
1 parent 6fb9e90 commit fd921c5
Show file tree
Hide file tree
Showing 16 changed files with 9,489 additions and 0 deletions.
Empty file.
26 changes: 26 additions & 0 deletions web/restart_the_robots/challenge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Restart the Robots"
author: "sAINT_barber"
category: web

description: |
Where do directories go when they want to hide from robots?
value: 500
type: dynamic_docker
extra:
initial: 500
minimum: 100
decay: 25
redirect_type: http
compose_stack: !filecontents docker-compose.yml


flags:
- GTBQ{ch3ck_r0b0ts_4_h1dd3n_d1r3ct0r13s}

tags:
- beginner


state: visible
version: "0.1"
9 changes: 9 additions & 0 deletions web/restart_the_robots/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:

app:
image: ghcr.io/cybermouflons/gt-beginner-quest-2024/restart_the_robots:latest
build: ./setup/
ports:
- 3000:3000
environment:
flag: GTBQ{ch3ck_r0b0ts_4_h1dd3n_d1r3ct0r13s}
Empty file.
2 changes: 2 additions & 0 deletions web/restart_the_robots/setup/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
Dockerfile
15 changes: 15 additions & 0 deletions web/restart_the_robots/setup/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:20

WORKDIR /app

COPY package*.json ./

COPY routes/ routes/
COPY static/ static/
COPY views/ views/
COPY server.js server.js

RUN npm install

EXPOSE 3000
CMD ["npm", "run", "start"]
17 changes: 17 additions & 0 deletions web/restart_the_robots/setup/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "web_template",
"version": "1.0.0",
"description": "Web challenge template for GT's beginners quest",
"main": "server.js",
"scripts": {
"dev": "nodemon -e html,js server.js",
"start": "node server.js"
},
"author": "sAINT_barber",
"license": "ISC",
"dependencies": {
"express": "^4.19.2",
"nodemon": "^3.1.4",
"nunjucks": "^3.2.4"
}
}
21 changes: 21 additions & 0 deletions web/restart_the_robots/setup/routes/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const express = require('express')
const router = express.Router({ caseSensitive: true });

router.get('/', async (req, res) => {


return res.render('index.html');
});

router.get('/the_robots_will_never_find_me_now', async (req, res) => {

flag = process.env.flag

return res.render('flag.html', {flag: flag});
});


module.exports = () => {
return router;
};

39 changes: 39 additions & 0 deletions web/restart_the_robots/setup/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const express = require('express');
const nunjucks = require('nunjucks');
const bodyParser = require('body-parser');
const http = require('http');


app = express();

var httpServer = http.createServer(app);
const routes = require('./routes');

app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.json());

nunjucks.configure('views', {
autoescape: true,
express: app
});

app.set('view engine', 'nunjucks');

app.set('views', './views');
app.use(express.static('./static'));


app.use(routes());

app.use(function(err, req, res, next) {
console.log(err)
res.status(500).json({ message: 'You broke me :(' });
});

(async() => {

httpServer.listen(3000, () => {
console.log(`Server running at http://0.0.0.0:3000/`);
});

})();
Loading

0 comments on commit fd921c5

Please sign in to comment.