diff --git a/lib/rex/proto/dns/resolver.rb b/lib/rex/proto/dns/resolver.rb index 9b79712df2ad..6aa1345e6ace 100644 --- a/lib/rex/proto/dns/resolver.rb +++ b/lib/rex/proto/dns/resolver.rb @@ -84,8 +84,15 @@ def initialize(config = {}) raise ResolverArgumentError, "Option #{key} not valid" end end + self.static_hostnames = StaticHostnames.new(hostnames: static_hosts) - self.static_hostnames.parse_hosts_file + begin + self.static_hostnames.parse_hosts_file + rescue StandardError => e + @logger.error 'Failed to parse the hosts file, ignoring it' + # if the hosts file is corrupted, just use a default instance with any specified hostnames + self.static_hostnames = StaticHostnames.new(hostnames: static_hosts) + end end # # Provides current proxy setting if configured