From 5cfe5b4567fe4dccff046ef6811b92cd957ba460 Mon Sep 17 00:00:00 2001 From: Tim W Date: Thu, 14 Mar 2019 23:33:27 +0800 Subject: [PATCH] add JavaMeterpreterDebug option --- lib/msf/core/payload/java/bind_tcp.rb | 11 +++---- lib/msf/core/payload/java/payload_options.rb | 32 ++++++++++++++++++++ lib/msf/core/payload/java/reverse_http.rb | 6 ++-- lib/msf/core/payload/java/reverse_tcp.rb | 12 ++++---- 4 files changed, 46 insertions(+), 15 deletions(-) create mode 100644 lib/msf/core/payload/java/payload_options.rb diff --git a/lib/msf/core/payload/java/bind_tcp.rb b/lib/msf/core/payload/java/bind_tcp.rb index 25e9b9379b..bf12896f08 100644 --- a/lib/msf/core/payload/java/bind_tcp.rb +++ b/lib/msf/core/payload/java/bind_tcp.rb @@ -3,6 +3,7 @@ require 'msf/core' require 'msf/core/payload/transport_config' require 'msf/core/payload/uuid/options' +require 'msf/core/payload/java/payload_options' module Msf @@ -17,15 +18,15 @@ module Payload::Java::BindTcp include Msf::Payload::TransportConfig include Msf::Payload::Java include Msf::Payload::UUID::Options + include Msf::Payload::Java::PayloadOptions # - # Register Java reverse_http specific options + # Register Java bind_tcp specific options # def initialize(*args) super register_advanced_options([ Msf::OptString.new('AESPassword', [false, "Password for encrypting communication", '']), - Msf::OptInt.new('Spawn', [true, "Number of subprocesses to spawn", 2]) ]) end @@ -37,7 +38,7 @@ module Payload::Java::BindTcp end def include_send_uuid - false + false end # @@ -45,9 +46,7 @@ module Payload::Java::BindTcp # def stager_config(opts={}) ds = opts[:datastore] || datastore - spawn = ds["Spawn"] || 2 - c = "" - c << "Spawn=#{spawn}\n" + c = super pass = ds["AESPassword"] || '' if pass != "" c << "AESPassword=#{pass}\n" diff --git a/lib/msf/core/payload/java/payload_options.rb b/lib/msf/core/payload/java/payload_options.rb new file mode 100644 index 0000000000..9a71eaa7f4 --- /dev/null +++ b/lib/msf/core/payload/java/payload_options.rb @@ -0,0 +1,32 @@ +# -*- coding: binary -*- + +require 'msf/core' + +module Msf::Payload::Java::PayloadOptions + + def initialize(info = {}) + super(info) + register_advanced_options( + [ + Msf::OptBool.new('JavaMeterpreterDebug', [ false, "Run the payload in debug mode, with logging enabled" ]), + Msf::OptInt.new('Spawn', [true, "Number of subprocesses to spawn", 2]) + ] + ) + end + + # + # Generate default configuration that is to be included in the stager. + # + def stager_config(opts={}) + ds = opts[:datastore] || datastore + spawn = ds["Spawn"] || 2 + c = "" + if ds["JavaMeterpreterDebug"] + spawn = 0 + c << "StageParameters=NoRedirect\n" + end + c << "Spawn=#{spawn}\n" + c + end + +end diff --git a/lib/msf/core/payload/java/reverse_http.rb b/lib/msf/core/payload/java/reverse_http.rb index a454191032..f25eb970d7 100644 --- a/lib/msf/core/payload/java/reverse_http.rb +++ b/lib/msf/core/payload/java/reverse_http.rb @@ -3,6 +3,7 @@ require 'msf/core' require 'msf/core/payload/transport_config' require 'msf/core/payload/uuid/options' +require 'msf/core/payload/java/payload_options' module Msf @@ -17,6 +18,7 @@ module Payload::Java::ReverseHttp include Msf::Payload::TransportConfig include Msf::Payload::Java include Msf::Payload::UUID::Options + include Msf::Payload::Java::PayloadOptions # # Register Java reverse_http specific options @@ -25,7 +27,6 @@ module Payload::Java::ReverseHttp super register_advanced_options( [ - OptInt.new('Spawn', [true, 'Number of subprocesses to spawn', 2]), OptInt.new('StagerURILength', [false, 'The URI length for the stager (at least 5 bytes)']), ] + Msf::Opt::http_header_options @@ -64,9 +65,8 @@ module Payload::Java::ReverseHttp def stager_config(opts={}) uri = generate_uri(opts) ds = opts[:datastore] || datastore + c = super - c = '' - c << "Spawn=#{ds["Spawn"] || 2}\n" c << "HeaderUser-Agent=#{ds["HttpUserAgent"]}\n" if ds["HttpUserAgent"] c << "HeaderHost=#{ds["HttpHostHeader"]}\n" if ds["HttpHostHeader"] c << "HeaderReferer=#{ds["HttpReferer"]}\n" if ds["HttpReferer"] diff --git a/lib/msf/core/payload/java/reverse_tcp.rb b/lib/msf/core/payload/java/reverse_tcp.rb index 6dd329e30d..92af852135 100644 --- a/lib/msf/core/payload/java/reverse_tcp.rb +++ b/lib/msf/core/payload/java/reverse_tcp.rb @@ -3,6 +3,7 @@ require 'msf/core' require 'msf/core/payload/transport_config' require 'msf/core/payload/uuid/options' +require 'msf/core/payload/java/payload_options' module Msf @@ -17,15 +18,15 @@ module Payload::Java::ReverseTcp include Msf::Payload::TransportConfig include Msf::Payload::Java include Msf::Payload::UUID::Options + include Msf::Payload::Java::PayloadOptions # - # Register Java reverse_http specific options + # Register Java reverse_tcp specific options # def initialize(*args) super register_advanced_options([ Msf::OptString.new('AESPassword', [false, "Password for encrypting communication", '']), - Msf::OptInt.new('Spawn', [true, "Number of subprocesses to spawn", 2]) ]) end @@ -37,17 +38,16 @@ module Payload::Java::ReverseTcp end def include_send_uuid - false + false end + # # Generate configuration that is to be included in the stager. # def stager_config(opts={}) + c = super ds = opts[:datastore] || datastore - spawn = ds["Spawn"] || 2 - c = "" - c << "Spawn=#{spawn}\n" pass = ds["AESPassword"] || '' if pass != "" c << "AESPassword=#{pass}\n"