From cf2403e9d77d4964b91573e158bae51a3d7aaf5e Mon Sep 17 00:00:00 2001 From: dmiller Date: Fri, 9 May 2025 22:47:05 +0000 Subject: [PATCH] Fall back to system resolution if we get NXDOMAIN and the name is non-ascii --- nmap_dns.cc | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/nmap_dns.cc b/nmap_dns.cc index 9a0304dd5..c560cb367 100644 --- a/nmap_dns.cc +++ b/nmap_dns.cc @@ -783,15 +783,31 @@ static void read_evt_handler(nsock_pool nsp, nsock_event evt, void *) { return; } info &reqinfo = infoI->second; + DNS::Request *reqt = reqinfo.tpreq->targ; + bool processing_successful = false; if (DNS_HAS_ERR(f, DNS::ERR_NAME) || p.answers.empty()) { - process_request(ACTION_FINISHED, reqinfo); - if (o.debugging >= TRACE_DEBUG_LEVEL) - log_write(LOG_STDOUT, "mass_dns: NXDOMAIN \n", p.id); - output_summary(); - stat_nx++; + // Check if this was a nonstandard name; + if (reqt->type != DNS::PTR) { + for (std::string::const_iterator it=reqt->name.begin(); it < reqt->name.end(); it++) { + if (*it < '0') { // signed char comparison; non-ascii are < 0 + // system resolver might be able to do better with things like AI_IDN + process_request(ACTION_SYSTEM_RESOLVE, reqinfo); + processing_successful = true; + break; + } + } + } + if (!processing_successful) { + process_request(ACTION_FINISHED, reqinfo); + if (o.debugging >= TRACE_DEBUG_LEVEL) + log_write(LOG_STDOUT, "mass_dns: NXDOMAIN \n", p.id); + stat_nx++; + } + + output_summary(); return; } @@ -805,12 +821,9 @@ static void read_evt_handler(nsock_pool nsp, nsock_event evt, void *) { return; } - bool processing_successful = false; - sockaddr_storage ip; ip.ss_family = AF_UNSPEC; std::string alias; - DNS::Request *reqt = reqinfo.tpreq->targ; for(std::list::const_iterator it = p.answers.begin(); it != p.answers.end(); ++it )