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

Ensure DNS command config loading does not crash msfconsole #18760

Conversation

adfoster-r7
Copy link
Contributor

@adfoster-r7 adfoster-r7 commented Jan 29, 2024

Closes #18756
Continuation of #18662

When starting termux (which isn't supported) msfconsole crashes due to failing to load /etc/resolv.conf:

image

However this could theoretically happen on other OS versions too so I've put in a naive rescue for now

Notes:

  • This functionality should be behind a feature flag still
  • We shouldn't crash
  • For termux we should be reading a different file location: /data/data/com.termux/files/usr/etc/resolv.conf
  • We probably want better fallback behavior, should we use cloudflare DNS or similar in the error scenario?

Verification

List the steps needed to make sure this thing works

  • Ensure termux no longer crashes on bootup
  • Ensure that a missing config file no longer crashes msfconsole on bootup, I changed this config manually:
      Defaults = {
        :config_file => "/etc/resolv.conf",

@adfoster-r7 adfoster-r7 mentioned this pull request Jan 29, 2024
@adfoster-r7 adfoster-r7 force-pushed the ensure-dns-command-does-not-crash-msfconsole branch from 9cb3c0e to 7ce1310 Compare January 29, 2024 13:23
@dwelch-r7
Copy link
Contributor

Changes seem good to me, working locally after changing the default config

Before:

$ ./msfconsole                                                                                                                                                                                                                                ‹ruby-3.0.5@metasploit-framework›
Metasploit tip: Search can apply complex filters such as search cve:2009
type:exploit, see all the filters with help search
/Users/dwelch/dev/metasploit-framework/lib/net/dns/resolver.rb:1087:in `foreach': No such file or directory @ rb_sysopen - /etc/garbage/resolv.conf (Errno::ENOENT)
	from /Users/dwelch/dev/metasploit-framework/lib/net/dns/resolver.rb:1087:in `parse_config_file'
	from /Users/dwelch/dev/metasploit-framework/lib/rex/proto/dns/resolver.rb:66:in `initialize'
	from /Users/dwelch/dev/metasploit-framework/lib/rex/proto/dns/cached_resolver.rb:25:in `initialize'
	from /Users/dwelch/dev/metasploit-framework/lib/msf/ui/console/driver.rb:83:in `new'
	from /Users/dwelch/dev/metasploit-framework/lib/msf/ui/console/driver.rb:83:in `initialize'
	from /Users/dwelch/dev/metasploit-framework/lib/metasploit/framework/command/console.rb:66:in `new'
	from /Users/dwelch/dev/metasploit-framework/lib/metasploit/framework/command/console.rb:66:in `driver'
	from /Users/dwelch/dev/metasploit-framework/lib/metasploit/framework/command/console.rb:54:in `start'
	from /Users/dwelch/dev/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'
	from ./msfconsole:23:in `<main>'

After:

$ ./msfconsole                                                                                                                                                                                                                                ‹ruby-3.0.5@metasploit-framework›
Metasploit tip: After running db_nmap, be sure to check out the result
of hosts and services


      .:okOOOkdc'           'cdkOOOko:.
    .xOOOOOOOOOOOOc       cOOOOOOOOOOOOx.
   :OOOOOOOOOOOOOOOk,   ,kOOOOOOOOOOOOOOO:
  'OOOOOOOOOkkkkOOOOO: :OOOOOOOOOOOOOOOOOO'
  oOOOOOOOO.    .oOOOOoOOOOl.    ,OOOOOOOOo
  dOOOOOOOO.      .cOOOOOc.      ,OOOOOOOOx
  lOOOOOOOO.         ;d;         ,OOOOOOOOl
  .OOOOOOOO.   .;           ;    ,OOOOOOOO.
   cOOOOOOO.   .OOc.     'oOO.   ,OOOOOOOc
    oOOOOOO.   .OOOO.   :OOOO.   ,OOOOOOo
     lOOOOO.   .OOOO.   :OOOO.   ,OOOOOl
      ;OOOO'   .OOOO.   :OOOO.   ;OOOO;
       .dOOo   .OOOOocccxOOOO.   xOOd.
         ,kOl  .OOOOOOOOOOOOO. .dOk,
           :kk;.OOOOOOOOOOOOO.cOk:
             ;kOOOOOOOOOOOOOOOk:
               ,xOOOOOOOOOOOx,
                 .lOOOOOOOl.
                    ,dOd,
                      .

       =[ metasploit v6.3.54-dev-7ce13101df               ]
+ -- --=[ 2393 exploits - 1235 auxiliary - 421 post       ]
+ -- --=[ 1388 payloads - 46 encoders - 11 nops           ]
+ -- --=[ 9 evasion                                       ]

Metasploit Documentation: https://docs.metasploit.com/

msf6 auxiliary(scanner/smb/smb_enumshares) >

@dwelch-r7 dwelch-r7 merged commit e5f96bd into rapid7:master Jan 29, 2024
34 checks passed
@dwelch-r7 dwelch-r7 added the rn-fix release notes fix label Jan 29, 2024
@dwelch-r7
Copy link
Contributor

Release Notes

Fixes an issue where Metasploit fails to start when resolv.conf cannot be found

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.

Msfconsole error
2 participants