Fix several bugs running non-scanner aux modules

This fixes a couple of bugs in #11176:

 - RHOSTS is not always used in Aux modules, don't enforce it unless it's used.
 - Be sure to pass the action to the run stub, since it's not a standard option.
GSoC/Meterpreter_Web_Console
Brent Cook 2019-02-25 16:19:57 -06:00
parent d78a9978e0
commit e9e29580a7
1 changed files with 12 additions and 10 deletions

View File

@ -62,7 +62,7 @@ class Auxiliary
#
# Launches an auxiliary module for single attempt.
#
def run_single(mod, opts)
def run_single(mod, action, opts)
begin
mod.run_simple(
'Action' => action,
@ -123,23 +123,25 @@ class Auxiliary
jobify = true
end
rhosts_range = Rex::Socket::RangeWalker.new(mod.datastore['RHOSTS'])
unless rhosts_range && rhosts_range.length
print_error("Auxiliary failed: option RHOSTS failed to validate.")
return false
unless mod.datastore['RHOSTS'].nil?
rhosts_range = Rex::Socket::RangeWalker.new(mod.datastore['RHOSTS'])
unless rhosts_range && rhosts_range.length
print_error("Auxiliary failed: option RHOSTS failed to validate.")
return false
end
end
begin
# Check whether run a scanner module.
if mod.class.included_modules.include?(Msf::Auxiliary::Scanner)
run_single(mod, opts)
# For multi target attempts.
# Check if this is a scanner module.
if mod.class.included_modules.include?(Msf::Auxiliary::Scanner) || rhosts_range.nil?
run_single(mod, action, opts)
else
# For multi target attempts.
rhosts_range.each do |rhost|
nmod = mod.replicant
nmod.datastore['RHOST'] = rhost
vprint_status("Running module against #{rhost}")
run_single(nmod, opts)
run_single(nmod, action, opts)
end
end
rescue ::Timeout::Error