From f4befda59b77f3723d601c67952531c863196192 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Fri, 17 Feb 2017 15:50:45 -0600 Subject: [PATCH] inherit the options from the default target so we can autocomplete before the rhost resolution occurs --- lib/msf/core/exploit.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/msf/core/exploit.rb b/lib/msf/core/exploit.rb index 25fa8f2823..0d6eb6de08 100644 --- a/lib/msf/core/exploit.rb +++ b/lib/msf/core/exploit.rb @@ -287,15 +287,17 @@ class Exploit < Msf::Module # to the information hash. super(info) + self.default_target = info['DefaultTarget'] || 0 + # Skip this whole routine if there are no targets - unless info['Targets'].nil? + if self.default_target == 0 && info['Targets'] # Add an Automatic Target to the Exploit if it doesn't have one - unless has_auto_target?(info['Targets']) + if !has_auto_target?(info['Targets']) # Don't add the automatic target unless there's already more than one target to pick from if info['Targets'].count > 1 # Finally, only add the target if there is a remote host option if self.respond_to?(:rhost) && self.respond_to?(:auto_targeted_index) - auto = ["Automatic", { 'AutoGenerated' => true}] + auto = ["Automatic", {'AutoGenerated' => true}.merge(info['Targets'][self.default_target][1])] info['Targets'].unshift(auto) end end @@ -304,7 +306,6 @@ class Exploit < Msf::Module self.targets = Rex::Transformer.transform(info['Targets'], Array, [ Target ], 'Targets') - self.default_target = info['DefaultTarget'] || 0 self.payload_info = info['Payload'] || {} self.successful = false self.session_count = 0