From 97912882ca250c739b69838ead2217602030dbcf Mon Sep 17 00:00:00 2001 From: OJ Date: Fri, 17 Apr 2015 19:53:05 +1000 Subject: [PATCH] Adjustments for POSIX meterpreter patching --- lib/rex/post/meterpreter/client_core.rb | 8 +++++++- modules/payloads/stages/linux/x86/meterpreter.rb | 13 +++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/rex/post/meterpreter/client_core.rb b/lib/rex/post/meterpreter/client_core.rb index 8df0daa153..96d98f6398 100644 --- a/lib/rex/post/meterpreter/client_core.rb +++ b/lib/rex/post/meterpreter/client_core.rb @@ -659,7 +659,7 @@ class ClientCore < Extension # This should be done by the reflective loader payloads #else # # Just patch the timeouts, which are consistent on each of the payloads. - # Rex::Payloads::Meterpreter::Patch.patch_passive_service!(blob, + # Rex::Payloads::Meterpreter::Patch.patch_timeouts!(blob, # :expiration => self.client.expiration, # :comm_timeout => self.client.comm_timeout, # :retry_total => self.client.retry_total, @@ -675,6 +675,12 @@ class ClientCore < Extension f.read(f.stat.size) } + Rex::Payloads::Meterpreter::Patch.patch_timeouts!(blob, + :expiration => self.client.expiration, + :comm_timeout => self.client.comm_timeout, + :retry_total => self.client.retry_total, + :retry_wait => self.client.retry_wait) + blob end diff --git a/modules/payloads/stages/linux/x86/meterpreter.rb b/modules/payloads/stages/linux/x86/meterpreter.rb index 2ee655a5de..cd85b395cb 100644 --- a/modules/payloads/stages/linux/x86/meterpreter.rb +++ b/modules/payloads/stages/linux/x86/meterpreter.rb @@ -8,6 +8,9 @@ require 'msf/base/sessions/meterpreter_x86_linux' require 'msf/base/sessions/meterpreter_options' require 'rex/elfparsey' +# Provides methods to patch options into the metsrv stager. +require 'rex/payloads/meterpreter/patch' + module Metasploit3 include Msf::Sessions::MeterpreterOptions @@ -100,10 +103,16 @@ module Metasploit3 #file = File.join(Msf::Config.data_directory, "msflinker_linux_x86.elf") file = File.join(Msf::Config.data_directory, "meterpreter", "msflinker_linux_x86.bin") - met = File.open(file, "rb") {|f| + blob = File.open(file, "rb") {|f| f.read(f.stat.size) } - return met + Rex::Payloads::Meterpreter::Patch.patch_timeouts!(blob, + :expiration => datastore['SessionExpirationTimeout'].to_i, + :comm_timeout => datastore['SessionCommunicationTimeout'].to_i, + :retry_total => datastore['SessionRetryTotal'].to_i, + :retry_wait => datastore['SessionRetryWait'].to_i) + + return blob end end