Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further improve / fix RHOSTS support for aux modules #11493

Merged
merged 1 commit into from
Feb 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions lib/msf/ui/console/command_dispatcher/auxiliary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,24 +123,24 @@ def cmd_run(*args)
jobify = true
end

if mod.datastore['RHOSTS']
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

rhosts = datastore['RHOSTS']
begin
# Check if this is a scanner module.
if mod.class.included_modules.include?(Msf::Auxiliary::Scanner) || rhosts_range.nil?
# Check if this is a scanner module or doesn't target remote hosts
if rhosts.blank? || mod.class.included_modules.include?(Msf::Auxiliary::Scanner)
run_single(mod, action, opts)
# For multi target attempts with non-scanner modules.
else
# For multi target attempts.
rhosts_opt = Msf::OptAddressRange.new('RHOSTS')
if !rhosts_opt.valid?(rhosts)
print_error("Auxiliary failed: option RHOSTS failed to validate.")
return false
end

rhosts_range = Rex::Socket::RangeWalker.new(rhosts_opt.normalize(rhosts))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the normalize call here extracts the hosts back from the file

rhosts_range.each do |rhost|
nmod = mod.replicant
nmod.datastore['RHOST'] = rhost
vprint_status("Running module against #{rhost}")
print_status("Running module against #{rhost}")
Copy link
Member Author

@busterb busterb Feb 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed this to non-verbose like other usage in MSF. Otherwise it's completely silent out of the box.

run_single(nmod, action, opts)
end
end
Expand Down