From e70402a130330d6fc73ce752a9a36d77d5fa2d26 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Mon, 15 Aug 2016 23:50:57 -0500 Subject: [PATCH] use the platform string verbatim on windows meterpreter --- lib/msf/base/sessions/meterpreter.rb | 45 ++++++++++++++++++---------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/lib/msf/base/sessions/meterpreter.rb b/lib/msf/base/sessions/meterpreter.rb index d721524399..13db99c151 100644 --- a/lib/msf/base/sessions/meterpreter.rb +++ b/lib/msf/base/sessions/meterpreter.rb @@ -325,25 +325,38 @@ class Meterpreter < Rex::Post::Meterpreter::Client def update_session_info username = self.sys.config.getuid sysinfo = self.sys.config.sysinfo + tuple = self.platform.split('/') - self.platform = self.platform.split('/')[0] + '/' + - case self.sys.config.sysinfo['OS'] - when /windows/i - Msf::Module::Platform::Windows - when /darwin/i - Msf::Module::Platform::OSX - when /freebsd/i - Msf::Module::Platform::FreeBSD - when /netbsd/i - Msf::Module::Platform::NetBSD - when /openbsd/i - Msf::Module::Platform::OpenBSD - when /sunos/i - Msf::Module::Platform::Solaris - else - Msf::Module::Platform::Linux + # + # Windows meterpreter currently needs 'win32' or 'win64' to be in the + # second half of the platform tuple, in order for various modules and + # library code match on that specific string. + # + if self.platform !~ /win32|win64/ + + platform = case self.sys.config.sysinfo['OS'] + when /windows/i + Msf::Module::Platform::Windows + when /darwin/i + Msf::Module::Platform::OSX + when /freebsd/i + Msf::Module::Platform::FreeBSD + when /netbsd/i + Msf::Module::Platform::NetBSD + when /openbsd/i + Msf::Module::Platform::OpenBSD + when /sunos/i + Msf::Module::Platform::Solaris + else + Msf::Module::Platform::Linux end.realname.downcase + # + # This normalizes the platform from 'python/python' to 'python/linux' + # + self.platform = "#{tuple[0]}/#{platform}" + end + safe_info = "#{username} @ #{sysinfo['Computer']}" safe_info.force_encoding("ASCII-8BIT") if safe_info.respond_to?(:force_encoding)