Nmap Development mailing list archives

Re: -6 and mass_dns and dns.lua


From: jah <jah () zadkiel plus com>
Date: Tue, 07 Oct 2008 16:05:03 +0100

Hi folks,

The attached patches nmapOps.cc and nmap_dns.cc:

o.mass_dns is not set to false for IPv6 targets.

system dns resolution is skipped for IPv6 targets when nmap_mass_rdns()
is called with zero num_targets allowing dns servers to be obtained from
the windows registry or /etc/resolv.conf if the dns servers aren't
already known (servs.size() is zero).  After doing this the function
returns immediately and without proceeding to /etc/hosts lookup etc.

--system-dns is respected.

Regards,

jah


diff -urNb nmap-4.76/NmapOps.cc nmap-4.76-working_copy/NmapOps.cc
--- nmap-4.76/NmapOps.cc        2008-09-30 02:20:17.734375000 +0100
+++ nmap-4.76-working_copy/NmapOps.cc   2008-10-07 14:38:55.546875000 +0100
@@ -488,7 +488,7 @@
     fatal("Sorry -- IPv6 support is currently only available for connect() scan (-sT), ping scan (-sP), and list scan 
(-sL).  OS detection and decoys are also not supported with IPv6.  Further support is under consideration.");
   }
 
-  if (af() != AF_INET) mass_dns = false;
+  if (af() != AF_INET && af() != AF_INET6) mass_dns = false;
 
   /* Prevent performance values from getting out of whack */
   if (min_parallelism > max_parallelism)
diff -urNb nmap-4.76/nmap_dns.cc nmap-4.76-working_copy/nmap_dns.cc
--- nmap-4.76/nmap_dns.cc       2008-10-07 15:06:42.312500000 +0100
+++ nmap-4.76-working_copy/nmap_dns.cc  2008-10-07 14:51:10.296875000 +0100
@@ -1129,7 +1129,7 @@
   bool lasttrace = false;
   char spmobuf[1024];
 
-  if (o.mass_dns == false) {
+  if (o.mass_dns == false || (o.af() == AF_INET6 && num_targets)) {
     Target *currenths;
     struct sockaddr_storage ss;
     size_t sslen;
@@ -1175,6 +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 (o.af() == AF_INET6 && !num_targets) return;
 
   // If necessary, set up the /etc/hosts hashtable
   etchosts_init();
@@ -1306,7 +1307,7 @@
 
   if (stat_actual > 0) {
     if (o.debugging || o.verbose >= 3) {
-      if (o.mass_dns) {
+      if (o.mass_dns && o.af() != AF_INET6) {
        // #:  Number of DNS servers used
        // OK: Number of fully reverse resolved queries
        // NX: Number of confirmations of 'No such reverse domain eXists'
@@ -1332,8 +1333,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: