@@ -325,25 +325,38 @@ def is_valid_session?(timeout=10)
325
325
def update_session_info
326
326
username = self . sys . config . getuid
327
327
sysinfo = self . sys . config . sysinfo
328
+ tuple = self . platform . split ( '/' )
328
329
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
345
352
end . realname . downcase
346
353
354
+ #
355
+ # This normalizes the platform from 'python/python' to 'python/linux'
356
+ #
357
+ self . platform = "#{ tuple [ 0 ] } /#{ platform } "
358
+ end
359
+
347
360
348
361
safe_info = "#{ username } @ #{ sysinfo [ 'Computer' ] } "
349
362
safe_info . force_encoding ( "ASCII-8BIT" ) if safe_info . respond_to? ( :force_encoding )
0 commit comments