-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
41 lines (35 loc) · 771 Bytes
/
index.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
var express = require('express');
var app = express();
var server;
app.all('/pullthetrigger', function (req, res) {
const commands = [
'ls',
'cat /etc/passwd',
'pwd',
'git status',
'cat ~/.bashrc',
'echo "lol"'
];
const commandToRun = commands[Math.floor(Math.random() * commands.length)];
res.send(commandToRun);
});
exports.start = function(cb) {
server = app.listen(3003, function () {
var host = server.address().address;
var port = server.address().port;
if (cb) {
cb();
}
console.log('Example app listening at http://%s:%s', host, port);
});
}
exports.close = function(cb) {
if (server) {
server.close(cb);
} else {
cb();
}
}
if (module.id === require.main.id) {
exports.start()
}