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