Land #9962, tab-complete target options
commit
b79b53c438
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue