Nmap Development mailing list archives
Re: -6 and mass_dns and dns.lua
From: jah <jah () zadkiel plus com>
Date: Mon, 06 Oct 2008 21:04:06 +0100
Hi again, Attached is a patch which enables l_get_dns_servers() to return dns servers to NSE when nmap_mass_rdns() is called with no targets and o.mass_dns is false. It does the job, but the problem is that the --system-dns option is not respected, making the patch a non-starter - I attach it in the hope that someone knows or can think of another approach. To illustrate the problem, a scan such as: nmap -6 -p80 -PN -d --script ASN ipv6.google.com would yield SCRIPT ENGINE DEBUG: AS Numbers Failed to send dns query. Response from dns.query(): 9 whereas the same scan with the patch applied would result in the expected script output: Host script results: | AS Numbers: | BGP: 2001:4860::/32 | Country: US |_ Origin AS: 15169 - GOOGLE - Google Inc. You could also see the effect of the patch with an IPv4 target: nmap -p80 -PN -d --script ASN --system-dns www.google.com So does anyone have any bright ideas? Regards, jah
--- nmap_dns.cc.orig 2008-10-06 20:55:34.062500000 +0100 +++ nmap_dns.cc 2008-10-06 19:33:30.875000000 +0100 @@ -1129,7 +1129,7 @@ bool lasttrace = false; char spmobuf[1024]; - if (o.mass_dns == false) { + if (o.mass_dns == false && num_targets) { Target *currenths; struct sockaddr_storage ss; size_t sslen; @@ -1175,7 +1175,7 @@ if (servs.size() == 0 && firstrun) error("mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers"); } - + if (!num_targets) return; // If necessary, set up the /etc/hosts hashtable etchosts_init(); @@ -1332,8 +1332,11 @@ std::list<std::string> get_dns_servers() { // if, for example, run with -n, list is not initialized, // run empty nmap_mass_rdns to do so - if(servs.size() == 0 && firstrun) { + static int firstNoTargets=1; + + if(servs.size() == 0 && (firstrun || firstNoTargets)) { nmap_mass_rdns(NULL, 0); + firstNoTargets = 0; } std::list<dns_server *>::iterator servI; std::list<std::string> serverList;
_______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- -6 and mass_dns and dns.lua jah (Oct 05)
- Re: -6 and mass_dns and dns.lua jah (Oct 06)
- Re: -6 and mass_dns and dns.lua jah (Oct 07)
- Re: -6 and mass_dns and dns.lua David Fifield (Oct 19)
- Re: -6 and mass_dns and dns.lua jah (Oct 20)
- Re: -6 and mass_dns and dns.lua David Fifield (Oct 30)
- Re: -6 and mass_dns and dns.lua jah (Oct 30)
- Re: -6 and mass_dns and dns.lua David Fifield (Oct 31)
- Re: -6 and mass_dns and dns.lua jah (Oct 31)
- Re: -6 and mass_dns and dns.lua jah (Oct 07)
- Re: -6 and mass_dns and dns.lua jah (Oct 06)