Land #9962, tab-complete target options

This commit is contained in:
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.
#
def target_index
target_idx = datastore['TARGET']
target_idx = Integer(datastore['TARGET']) rescue datastore['TARGET']
default_idx = default_target || 0
# Use the default target if one was not supplied.
if (target_idx == nil and default_idx and default_idx >= 0)
target_idx = default_idx
elsif target_idx.is_a?(String)
target_idx = targets.index { |target| target.name == target_idx }
end
return (target_idx) ? target_idx.to_i : nil
end

View File

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

View File

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