Land #9962, tab-complete target options

GSoC/Meterpreter_Web_Console
Brent Cook 2018-05-15 16:41:55 -05:00
commit b79b53c438
No known key found for this signature in database
GPG Key ID: 1FFAA0B24B708F96
3 changed files with 7 additions and 3 deletions

View File

@ -674,13 +674,16 @@ class Exploit < Msf::Module
# The target index that has been selected. # The target index that has been selected.
# #
def target_index def target_index
target_idx = datastore['TARGET'] target_idx = Integer(datastore['TARGET']) rescue datastore['TARGET']
default_idx = default_target || 0 default_idx = default_target || 0
# Use the default target if one was not supplied. # Use the default target if one was not supplied.
if (target_idx == nil and default_idx and default_idx >= 0) if (target_idx == nil and default_idx and default_idx >= 0)
target_idx = default_idx target_idx = default_idx
elsif target_idx.is_a?(String)
target_idx = targets.index { |target| target.name == target_idx }
end end
return (target_idx) ? target_idx.to_i : nil return (target_idx) ? target_idx.to_i : nil
end end

View File

@ -9,7 +9,7 @@ module Msf
# #
# @return [Boolean] whether or not to use our automatic targeting routine # @return [Boolean] whether or not to use our automatic targeting routine
def auto_target? def auto_target?
selected_target = targets[target_index] selected_target = targets[target_index] if target_index
return false if selected_target.nil? return false if selected_target.nil?
if selected_target.name =~ /Automatic/ && selected_target['AutoGenerated'] == true && auto_target_host if selected_target.name =~ /Automatic/ && selected_target['AutoGenerated'] == true && auto_target_host
true true

View File

@ -2286,6 +2286,7 @@ class Core
res = [] res = []
if (active_module.targets) if (active_module.targets)
1.upto(active_module.targets.length) { |i| res << (i-1).to_s } 1.upto(active_module.targets.length) { |i| res << (i-1).to_s }
res += active_module.targets.map(&:name)
end end
return res return res
end end