Skip to content

Commit

Permalink
Fix several bugs running non-scanner aux modules
Browse files Browse the repository at this point in the history
This fixes a couple of bugs in rapid7#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.
  • Loading branch information
busterb committed Feb 25, 2019
1 parent d78a997 commit e9e2958
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions lib/msf/ui/console/command_dispatcher/auxiliary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def name
#
# Launches an auxiliary module for single attempt.
#
def run_single(mod, opts)
def run_single(mod, action, opts)
begin
mod.run_simple(
'Action' => action,
Expand Down Expand Up @@ -123,23 +123,25 @@ def cmd_run(*args)
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
Expand Down

0 comments on commit e9e2958

Please sign in to comment.