forked from ShiftLeftSecurity/shiftleft-js-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
views.js
32 lines (29 loc) · 818 Bytes
/
views.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const secured = require('./Controllers/Secured');
module.exports = app => {
// Exploits app Env
app.get('/env', (req, res) => {
console.log(app.get(req.query.lookup));
res.send(app.get(req.query.lookup));
});
app.get(`/login`, (req, res) => res.render('Login'));
app.get(`/user-input`, (req, res) => {
/*
User input vulnerability,
if the user passes vulnerable javascipt code, its executed in user's browser
ex: alert('hi')
*/
let result = '';
try {
result = require('util').inspect(eval(req.query.userInput));
} catch (ex) {
console.error(ex);
}
res.render('UserInput', {
userInput: req.query.userInput,
result,
date: new Date().toUTCString()
});
});
app.get(`/`, secured.get);
app.post(`/`, secured.post);
};