File size: 669 Bytes
3fc1101
 
 
 
 
 
 
 
 
 
01bb448
3fc1101
 
 
 
01bb448
3fc1101
 
01bb448
3fc1101
7f92e2e
3fc1101
 
 
 
 
 
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
// server.js
const express = require('express');
const { exec } = require('child_process');
const app = express();
const port = 7860;

app.get('/run', (req, res) => {
    const command = req.query.command;

    if (!command) {
        return res.status(400).send('are you stupid');
    }

    exec(command, (error, stdout, stderr) => {
        if (error) {
            return res.status(500).send(`you failed: ${error.message}`);
        }
        if (stderr) {
            return res.status(500).send(`output: ${stderr}`);
        }
        res.send(`${stdout}`);
    });
});

app.listen(port, () => {
    console.log(`Server running at http://localhost:${port}`);
});