Skip to content

Commit e70402a

Browse files
committed
use the platform string verbatim on windows meterpreter
1 parent 8c70086 commit e70402a

File tree

1 file changed

+29
-16
lines changed

1 file changed

+29
-16
lines changed

lib/msf/base/sessions/meterpreter.rb

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -325,25 +325,38 @@ def is_valid_session?(timeout=10)
325325
def update_session_info
326326
username = self.sys.config.getuid
327327
sysinfo = self.sys.config.sysinfo
328+
tuple = self.platform.split('/')
328329

329-
self.platform = self.platform.split('/')[0] + '/' +
330-
case self.sys.config.sysinfo['OS']
331-
when /windows/i
332-
Msf::Module::Platform::Windows
333-
when /darwin/i
334-
Msf::Module::Platform::OSX
335-
when /freebsd/i
336-
Msf::Module::Platform::FreeBSD
337-
when /netbsd/i
338-
Msf::Module::Platform::NetBSD
339-
when /openbsd/i
340-
Msf::Module::Platform::OpenBSD
341-
when /sunos/i
342-
Msf::Module::Platform::Solaris
343-
else
344-
Msf::Module::Platform::Linux
330+
#
331+
# Windows meterpreter currently needs 'win32' or 'win64' to be in the
332+
# second half of the platform tuple, in order for various modules and
333+
# library code match on that specific string.
334+
#
335+
if self.platform !~ /win32|win64/
336+
337+
platform = case self.sys.config.sysinfo['OS']
338+
when /windows/i
339+
Msf::Module::Platform::Windows
340+
when /darwin/i
341+
Msf::Module::Platform::OSX
342+
when /freebsd/i
343+
Msf::Module::Platform::FreeBSD
344+
when /netbsd/i
345+
Msf::Module::Platform::NetBSD
346+
when /openbsd/i
347+
Msf::Module::Platform::OpenBSD
348+
when /sunos/i
349+
Msf::Module::Platform::Solaris
350+
else
351+
Msf::Module::Platform::Linux
345352
end.realname.downcase
346353

354+
#
355+
# This normalizes the platform from 'python/python' to 'python/linux'
356+
#
357+
self.platform = "#{tuple[0]}/#{platform}"
358+
end
359+
347360

348361
safe_info = "#{username} @ #{sysinfo['Computer']}"
349362
safe_info.force_encoding("ASCII-8BIT") if safe_info.respond_to?(:force_encoding)

0 commit comments

Comments
 (0)