metasploit-framework icon indicating copy to clipboard operation
metasploit-framework copied to clipboard

Metasploit crashes on bad hosts entry

Open LongWayHomie opened this issue 10 months ago • 1 comments

Steps to reproduce

How'd you do it?

  1. Update msf to latest version (v6.4.0-dev)
  2. Add bad host line in /etc/hosts (ex. 127.0.0.1 badhost.host. - with dot at the end)
  3. Run msfconsole

Done on rolling kali release.
Here's stacktrace:

root@kali:~# msfconsole
Metasploit tip: View all productivity tips with the tips command
/usr/share/metasploit-framework/lib/rex/proto/dns/static_hostnames.rb:84:in `add': Invalid hostname: intelligence.htb. (ArgumentError)
        from /usr/share/metasploit-framework/lib/rex/proto/dns/static_hostnames.rb:48:in 'block (2 levels) in parse_hosts_file'
        from /usr/share/metasploit-framework/lib/rex/proto/dns/static_hostnames.rb:47:in 'each'
        from /usr/share/metasploit-framework/lib/rex/proto/dns/static_hostnames.rb:47:in 'block in parse_hosts_file'
        from /usr/share/metasploit-framework/lib/rex/proto/dns/static_hostnames.rb:42:in 'foreach'
        from /usr/share/metasploit-framework/lib/rex/proto/dns/static_hostnames.rb:42:in 'parse_hosts_file'
        from /usr/share/metasploit-framework/lib/rex/proto/dns/resolver.rb:88:in 'initialize'
        from /usr/share/metasploit-framework/lib/rex/proto/dns/cached_resolver.rb:25:in 'initialize'
        from /usr/share/metasploit-framework/lib/msf/ui/console/driver.rb:86:in 'new'
        from /usr/share/metasploit-framework/lib/msf/ui/console/driver.rb:86:in 'initialize'
        from /usr/share/metasploit-framework/lib/metasploit/framework/command/console.rb:66:in 'new'
        from /usr/share/metasploit-framework/lib/metasploit/framework/command/console.rb:66:in 'driver'
        from /usr/share/metasploit-framework/lib/metasploit/framework/command/console.rb:54:in 'start'
        from /usr/share/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in 'start'
        from /usr/bin/msfconsole:23:in '<main>'

Changed only some quote marks in dump to correctly show it here. The solution is to remove this "bad" hosts entry.

Were you following a specific guide/tutorial or reading documentation?

No

Expected behavior

Metasploit Framework should start

Current behavior

Because of bad hosts entry, msf won't start

Metasploit version

Framework: 6.4.0-dev Console : 6.4.0-dev

Additional Information

LongWayHomie avatar Mar 29 '24 21:03 LongWayHomie