-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvunerable-app.js
41 lines (31 loc) · 938 Bytes
/
vunerable-app.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
33
34
35
36
37
38
39
40
41
const express = require("express");
const { exec } = require("child_process");
const PORT = process.env.PORT || 3000;
const app = express();
app.set("view engine", "ejs");
app.use(express.urlencoded({ extended: false }));
app.get("/", (req, res) => {
res.render("index", {
filepath: null,
stdout: null,
error: null
});
});
app.post("/execute", (req, res) => {
const filepath = req.body.filepath;
exec(`ls /home/kali/acme-ftp-server${filepath}`, (err, stdout, stderr) => {
let error = null;
stdout = stdout.split("\n").filter(n => n.length > 1);
if(err || stderr) {
error = "Something went wrong, please try again later"
}
res.render("index", {
filepath,
stdout,
error
});
});
});
app.listen(PORT, () => {
console.log(`Express is listening on port:${PORT}`);
});