Skip to content

Commit 9b16cdf

Browse files
committed
Land rapid7#7845, Fix Msf::Exploit::EXE shellcode/template mismatch
2 parents 981f318 + d8da7c6 commit 9b16cdf

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/msf/core/exploit/exe.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ def exe_init_options(opts)
164164
:sub_method => datastore['EXE::OldMethod']
165165
})
166166

167+
# NOTE: If code and platform/arch are supplied, we use those values and skip initialization.
168+
#
167169
# This part is kind of tricky so we need to explain the logic behind the following load order.
168170
# First off, platform can be seen from different sources:
169171
#
@@ -180,7 +182,7 @@ def exe_init_options(opts)
180182
#
181183
# Architecture shares the same load order.
182184

183-
unless opts[:platform]
185+
unless opts[:code] && opts[:platform]
184186
if self.respond_to?(:payload_instance) && payload_instance.platform.platforms != [Msf::Module::Platform]
185187
opts[:platform] = payload_instance.platform
186188
elsif self.respond_to? :target_platform
@@ -190,11 +192,10 @@ def exe_init_options(opts)
190192
end
191193
end
192194

193-
unless opts[:arch]
195+
unless opts[:code] && opts[:arch]
194196
if self.respond_to? :payload_instance
195197
opts[:arch] = payload_instance.arch
196198
elsif self.respond_to? :target_arch
197-
$stderr.puts "target specific arch"
198199
opts[:arch] = target_arch
199200
elsif self.respond_to? :arch
200201
opts[:arch] = arch

0 commit comments

Comments
 (0)