-
Notifications
You must be signed in to change notification settings - Fork 440
Expand file tree
/
Copy pathviews.js
More file actions
38 lines (33 loc) · 1 KB
/
views.js
File metadata and controls
38 lines (33 loc) · 1 KB
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
33
34
35
36
37
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) => {
const sanitizeHtml = require('sanitize-html');
(req, res) => {
/*
User input vulnerability,
if the user passes vulnerable javascipt code, its executed in user's browser
ex: alert('hi')
*/
let result = '';
try {
// Sanitize user input to prevent code injection
const sanitizedInput = sanitizeHtml(req.query.userInput);
result = require('util').inspect(eval(sanitizedInput));
} catch (ex) {
console.error(ex);
}
res.render('UserInput', {
userInput: sanitizedInput, // Use sanitized input in the view
result,
date: new Date().toUTCString()
});
}
app.get(`/`, secured.get);
app.post(`/`, secured.post);
};