From 92e0522524b21c4946533443d5100a887cc1eeec Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 10 Aug 2020 16:31:11 +0100 Subject: [PATCH] Fixes for bug #13956 --- lib/msf/core/exploit/dns/enumeration.rb | 6 ++++++ modules/auxiliary/gather/enum_dns.rb | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/msf/core/exploit/dns/enumeration.rb b/lib/msf/core/exploit/dns/enumeration.rb index f8e84639f1..bca1e22bee 100644 --- a/lib/msf/core/exploit/dns/enumeration.rb +++ b/lib/msf/core/exploit/dns/enumeration.rb @@ -51,8 +51,14 @@ module Enumeration dns.nameservers -= dns.nameservers dns.nameservers = ns_a_records zone = dns.axfr(domain) + + # Original set of exceptions which were deliberately caught but were missing some + # situations. Leaving these in as they may want to be treated differently + # to other, maybe more generic, exceptions. rescue ResolverArgumentError, Errno::ECONNREFUSED, Errno::ETIMEDOUT, ::NoResponseError, ::Timeout::Error => e print_error("Query #{domain} DNS AXFR - exception: #{e}") + rescue => e + print_error("Query #{domain} DNS AXFR - exception: #{e}") end next if zone.blank? records << zone diff --git a/modules/auxiliary/gather/enum_dns.rb b/modules/auxiliary/gather/enum_dns.rb index 71ef39a983..0f4f5c5c9c 100644 --- a/modules/auxiliary/gather/enum_dns.rb +++ b/modules/auxiliary/gather/enum_dns.rb @@ -65,7 +65,13 @@ class MetasploitModule < Msf::Auxiliary domain = datastore['DOMAIN'] is_wildcard = dns_wildcard_enabled?(domain) - dns_axfr(domain) if datastore['ENUM_AXFR'] + # All exceptions should be being handled by the library + # but catching here as well, just in case. + begin + dns_axfr(domain) if datastore['ENUM_AXFR'] + rescue => e + print_error("AXFR failed: #{e}") + end dns_get_a(domain) if datastore['ENUM_A'] dns_get_cname(domain) if datastore['ENUM_CNAME'] dns_get_ns(domain) if datastore['ENUM_NS']