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

Fix/dns/dot suffixed names #19012

Merged
merged 2 commits into from Mar 25, 2024

Conversation

zeroSteiner
Copy link
Contributor

This fixes an issue that was reported where msfconsole will fail to start if the /etc/hosts file contains a name ending in a . such as bad..

The core of the fix is to upgrade rex-socket from 0.1.56 to 0.1.57, which pulls in the changes from rapid7/rex-socket#66. In addition to that, the #initialize method was updated to ignore errors that may occur when parsing the hosts file so any other issues that occur with it will not prevent msfconsole from starting.

Testing

On a Linux system:

  • Edit /etc/hosts and add a new line containing 127.1.1.1 bad.
  • Start msfconsole, see that it starts
  • Run dns reset-config, see the bad. hostname is defined.

self.static_hostnames = StaticHostnames.new(hostnames: static_hosts)
self.static_hostnames.parse_hosts_file
begin
self.static_hostnames.parse_hosts_file
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to ignore the individual entries that break? 👀

i.e. If an invalid entry is the first line of the /etc/hosts file, we could ignore that individual host and continue to parse the rest of the file with 127.0.0.1 localhost etc

begin
self.static_hostnames.parse_hosts_file
rescue StandardError => e
@logger.error 'Failed to parse the hosts file, ignoring it'
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like the default @logger is /dev/null:

[11] pry(#<Rex::Proto::DNS::CachedResolver>)> @config[:log_file]
=> "/dev/null"

Which in this scenario might not be useful if folk want to debug issues/report framework issues; Is it possible to wire it up to the framework logging

Copy link
Contributor

@adfoster-r7 adfoster-r7 left a comment

Choose a reason for hiding this comment

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

Looks good to me to fix the current issues; My comments aren't a blocker/can be circled back to at a future point in time - looks good to merge now - will hand over the reins to you for that 💯

@adfoster-r7 adfoster-r7 merged commit 30093ea into rapid7:master Mar 25, 2024
51 checks passed
@adfoster-r7 adfoster-r7 added the rn-fix release notes fix label Mar 25, 2024
@adfoster-r7
Copy link
Contributor

Release Notes

This fixes an issue that was reported where msfconsole will fail to start if the user's /etc/hosts file contained a host name ending in a . or containing _ characters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rn-fix release notes fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants