Wednesday, 22 May 2019

Open up shell on server via http request

I have this:

const http = require('http');
const cp = require('child_process');

const server = http.createServer((req,res) => {

  const bash = cp.spawn('bash');
  req.pipe(bash.stdin, {end:false);
  bash.stdout.pipe(res);
  bash.stderr.pipe(res);

});

server.listen('4004');

when I hit the server with:

curl localhost:4004

and I type bash commands, nothing gets outputed to my console, anybody know why?

Note: Obviously there are security concerns, but one thing way to address that is to run this in a docker container and implement authentication (any recommendations on auth schemes lmk).



from Open up shell on server via http request

No comments:

Post a Comment