-1

I was wondering if it is possible to execute linux commands from a localhosted webpage to a local linux server and get the output send back to the webpage. If so, how would I be able to achieve this.

Migilinio
  • 3
  • 2
  • 2
    Possible duplicate of [Execute a command line binary with Node.js](https://stackoverflow.com/questions/20643470/execute-a-command-line-binary-with-node-js) – Romeo Sierra May 09 '18 at 13:55
  • What is the back-end coding language ? Php, java, JavaScript, ... ? – benjarobin May 09 '18 at 13:56
  • Yes it's possible. What are you trying to execute? Lot depends on the command you are trying to execute and the server. – bansi May 09 '18 at 13:56
  • I am trying to execute aircrack-ng commands, I am trying to make a web gui for a schoolproject to use Aircrack-ng commands used for deauthentication from local machines. the (server) is at this point default kali linux but that can change. – Migilinio May 09 '18 at 14:00

1 Answers1

-1

In Node (which I assume you're using), you can asynchronously call to the shell using the provided child_process.exec command. exec() provides a callback which provides Streams for stdout and stderr. These can be piped to your response:

const { exec } = require('child_process');

// Or whatever function runs when responding to requests
app.use(function(req, res) => {
    // Pipe the output of the command to 
    exec("<command>", (err, stdout, stderr) => stderr.pipe(res))
})
bren
  • 4,176
  • 3
  • 28
  • 43