-
Notifications
You must be signed in to change notification settings - Fork 14k
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
Support checks in relay modules #19639
base: master
Are you sure you want to change the base?
Changes from all commits
179c992
ec01052
01ff9d0
4738032
0d2a9e1
85f62a8
2e4bc2c
6097a68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*- coding: binary -*- | ||
|
||
module Msf | ||
|
||
### | ||
# | ||
# This module provides methods for modules which intend to handle multiple hosts | ||
# themselves through some means, e.g. scanners. This circumvents the typical | ||
# RHOSTS -> RHOST logic offered by the framework. | ||
# | ||
### | ||
|
||
module Auxiliary::MultipleTargetHosts | ||
|
||
def has_check? | ||
respond_to?(:check_host) | ||
end | ||
|
||
def check | ||
nmod = replicant | ||
begin | ||
nmod.check_host(datastore['RHOST']) | ||
rescue NoMethodError | ||
Exploit::CheckCode::Unsupported | ||
end | ||
end | ||
|
||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -187,9 +187,17 @@ def set_via(opts) | |
# exploit instance. Store references from and to the exploit module. | ||
# | ||
def set_from_exploit(m) | ||
target_host = nil | ||
unless m.target_host.blank? | ||
# only propagate the target_host value if it's exactly 1 host | ||
if (rw = Rex::Socket::RangeWalker.new(m.target_host)).length == 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because RHOSTS wasn't being split any more, RHOST was still a range. This caused |
||
target_host = rw.next_ip | ||
end | ||
end | ||
|
||
self.via = { 'Exploit' => m.fullname } | ||
self.via['Payload'] = ('payload/' + m.datastore['PAYLOAD'].to_s) if m.datastore['PAYLOAD'] | ||
self.target_host = Rex::Socket.getaddress(m.target_host) if (m.target_host.to_s.strip.length > 0) | ||
self.target_host = target_host | ||
self.target_port = m.target_port if (m.target_port.to_i != 0) | ||
self.workspace = m.workspace | ||
self.username = m.owner | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check for a space does not account for all of the different ways RangeWalker can handle multiple hosts. Instead, we should actually use RangeWalker to count how many hosts were targeted and only report it if there's a single target. Because this calculation is too expensive to run each time a message is printed, we cache the value.
The comment implies that this was always the intention.