Fix/msf host info cidr filtering#21448
Open
kx7m2qd wants to merge 7 commits into
Open
Conversation
Uses Rex::Arch.from_uname to map uname -m output to ARCH_ constants for non-meterpreter Linux/BSD shell sessions. References rapid7/rex-arch#13 Fixes rapid7#21403
Added documentation for the get_os_architecture method to clarify its purpose and return value.
Co-authored-by: Spencer McIntyre <58950994+smcintyre-r7@users.noreply.github.com>
The addresses parameter was passed directly to db_hosts which does exact string matching, so CIDR ranges like 192.168.159.0/24 never matched any host address and returned 0 results. Fix: detect CIDR notation and filter using IPAddr in Ruby after fetching all hosts, instead of passing the CIDR to the API. Exact IP addresses continue to be passed to the API as before. Fixes rapid7#21405
The addresses parameter was passed directly to db_hosts which does exact string matching, so CIDR ranges like 192.168.159.0/24 never matched any host address and returned 0 results. Fix: detect CIDR notation and filter using IPAddr in Ruby after fetching all hosts, instead of passing the CIDR to the API. Exact IP addresses continue to be passed to the API as before. Fixes rapid7#21405
The addresses parameter was passed directly to db_hosts which does exact string matching, so CIDR ranges like 192.168.159.0/24 never matched any host address and returned 0 results. Fix: detect CIDR notation and filter using IPAddr in Ruby after fetching all hosts, instead of passing the CIDR to the API. Exact IP addresses continue to be passed to the API as before. Fixes rapid7#21405
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
Fixes #21405
The
msf_host_infoMCP tool was not honoring CIDR range filters. When a CIDRlike
192.168.159.0/24was passed as theaddressesparameter, it was forwardeddirectly to
db_hostswhich does exact string matching — so no hosts were everreturned.
The fix detects CIDR notation (presence of
/) and performs the filtering in Rubyusing
IPAddrafter fetching all hosts, instead of passing the CIDR to the API.Exact IP addresses continue to be passed to the API as before.
Verification
./msfconsole --mcp-transport http192.168.159.0/24and some outside it)192.168.159.10— verify only that host is returned192.168.159.0/24— verify only hosts in that subnet are returnedonly_up=true— verify results are filtered correctly