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

Resolve host mixin #19854

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

cgranleese-r7
Copy link
Contributor

@cgranleese-r7 cgranleese-r7 commented Feb 3, 2025

Note

TODO: Update tests to not resolve against google.com
This PR builds on a previous PR, specifically this comment thread.

This new mixin allows for DNS resolution for modules with multiple session types. E.g. modules/post/windows/gather/enum_computers.rb supports multiple sessions:

'SessionTypes' => %w[meterpreter powershell shell]

However the resolution across these session requires different logic. Meterpreter will now make use of the new Meterpreter API changes that will NEED to be landed before this PR can land.

metasploit-payloads PR - rapid7/metasploit-payloads#681
metasploit-framework PR - #18499

The mixin will check if we have a Meterpreter session with access to the net library and use the new Meterpreter API if so, otherwise fallback to nslookup if not.

Note

A rescue was added to the enum_computers module to allow for instances when the DNS isn't able to be resolved via the meterpreter API. This is due to inconsistent resolving methods in the runtime languages.

With no errors

image

With every entry returning an error

image

Mixed results

image

Verification

List the steps needed to make sure this thing works

  • Start msfconsole
  • use post/windows/gather/enum_computers.rb
  • Target a machine with multiple computers available
  • Get a Meterpreter session
  • Verify the module now list all expected computers as part of that domain
    Example:
List of identified Hosts.
=========================

 Domain  Hostname  IPs
 ------  --------  ---
 VB      DC1       192.168.175.201, 192.168.175.200, 192.168.175.135

@cgranleese-r7 cgranleese-r7 added enhancement rn-enhancement release notes enhancement labels Feb 3, 2025
@cgranleese-r7 cgranleese-r7 marked this pull request as draft February 3, 2025 15:56
@cgranleese-r7 cgranleese-r7 force-pushed the resolve-host-mixin branch 3 times, most recently from bf48a18 to a57ccc3 Compare February 4, 2025 12:54
resolved_host.reject { |k, _v| k == :ip }
else
ips = []
data = cmd_exec("nslookup #{host}")
Copy link
Contributor

Choose a reason for hiding this comment

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

nslookup is Windows-specific, yet the resolve_host method doesn't seem to be platform-specific

modules/post/windows/gather/enum_computers.rb Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement rn-enhancement release notes enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants