Skip to content

Commit 9791288

Browse files
committed
Adjustments for POSIX meterpreter patching
1 parent eb7155d commit 9791288

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

lib/rex/post/meterpreter/client_core.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ def generate_windows_stub(process)
659659
# This should be done by the reflective loader payloads
660660
#else
661661
# # Just patch the timeouts, which are consistent on each of the payloads.
662-
# Rex::Payloads::Meterpreter::Patch.patch_passive_service!(blob,
662+
# Rex::Payloads::Meterpreter::Patch.patch_timeouts!(blob,
663663
# :expiration => self.client.expiration,
664664
# :comm_timeout => self.client.comm_timeout,
665665
# :retry_total => self.client.retry_total,
@@ -675,6 +675,12 @@ def generate_linux_stub
675675
f.read(f.stat.size)
676676
}
677677

678+
Rex::Payloads::Meterpreter::Patch.patch_timeouts!(blob,
679+
:expiration => self.client.expiration,
680+
:comm_timeout => self.client.comm_timeout,
681+
:retry_total => self.client.retry_total,
682+
:retry_wait => self.client.retry_wait)
683+
678684
blob
679685
end
680686

modules/payloads/stages/linux/x86/meterpreter.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
require 'msf/base/sessions/meterpreter_options'
99
require 'rex/elfparsey'
1010

11+
# Provides methods to patch options into the metsrv stager.
12+
require 'rex/payloads/meterpreter/patch'
13+
1114
module Metasploit3
1215
include Msf::Sessions::MeterpreterOptions
1316

@@ -100,10 +103,16 @@ def generate_stage
100103
#file = File.join(Msf::Config.data_directory, "msflinker_linux_x86.elf")
101104
file = File.join(Msf::Config.data_directory, "meterpreter", "msflinker_linux_x86.bin")
102105

103-
met = File.open(file, "rb") {|f|
106+
blob = File.open(file, "rb") {|f|
104107
f.read(f.stat.size)
105108
}
106109

107-
return met
110+
Rex::Payloads::Meterpreter::Patch.patch_timeouts!(blob,
111+
:expiration => datastore['SessionExpirationTimeout'].to_i,
112+
:comm_timeout => datastore['SessionCommunicationTimeout'].to_i,
113+
:retry_total => datastore['SessionRetryTotal'].to_i,
114+
:retry_wait => datastore['SessionRetryWait'].to_i)
115+
116+
return blob
108117
end
109118
end

0 commit comments

Comments
 (0)