Home page logo
/

nmap-dev logo Nmap Development mailing list archives

Re: [PATCH] Fix IPv6 scanning against link-local addresses
From: Kris Katterjohn <katterjohn () gmail com>
Date: Tue, 20 May 2008 00:26:02 -0500

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kris Katterjohn wrote:
I had a hunch that the struct sockaddr_in6 sin6_scope_id member was the
way to handle this, and it certainly seems to be.  If the zone ID passed
to Nmap is numeric, that number is just stored in that member.  If the
ID is not fully numeric, it is assumed to be an interface name.  I added
the ifindex member to struct interface_info and I look it up with
getInterfaceByName().


D'oh!  It turns out that this is already taken care of by getaddrinfo(),
so that makes it a lot simpler.  I was right about sin6_scope_id, but I
didn't need to do the parsing and interface index lookups.

Since it is so simple, I went ahead and committed the fix.  I've
attached a copy of the patch for review and the curious.

I've tested it on Windows XP and Linux.  Both numeric indexes and
interface names still work on Linux.

Thanks,
Kris Katterjohn

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQIVAwUBSDJg5v9K37xXYl36AQLWWQ//TaA7mnhzB/MqaDldN55sknof86E2xLXk
Sncz2UEYm0uBnNYObQiawbrygPjK3W0Jk2ikE5Kj7rzrBdqg4zXOhrxKqpUyP4CR
kHmBXFOxXBHdoPBvk+K5FCY0+2VmiCwogwqHtDz+j9T83vMD/i9AO8ypjeqgwvfN
U2C8bsW8hoEGF83H3AIGK3FDKW0tr05VFNiy6yhIiA6In+Ag3S/DRmcToOzOg4mv
t+nqbJx5f0/g4vJHz/khTzux68gewWVc11T7WXBRfmIQzPXoI/v8129TgCDAnk4q
dIUIxasCF0t7A/TF9Wl80obe2wbKttobxiw6EezTHZCVhsvuKf4iscpwB+JSajzB
rzzE3S1o1SKOHC1OAlSqH+tY8vDcTzYVN99RwP9OfYkVPFpAB7v+1TEWQs85c5vM
m/3Gt+JljupyjNDR+S0lI2Vzc8EQhR9jhIYuJunSPXMb/oJbvH0ItR/MHmbegVD4
YuLIgP3M7N9vifpdLz+dHFK5nR1rvbxWB6EWZ3UEmSjrWbVyWBjbPzc1dHij+d2e
jwmdpAd9v1cYbx7vavg4zln1PPAzKE/RBYWrKj4+psFXbx2VNhuisehWyJ2kWZKA
fi521GVQQgOimrGyZdxTN6VqjaTDUFj/wAwMpJhwa1BFgNHkUuJ3+66k6MRYs/jC
22muYfloYCI=
=DSbo
-----END PGP SIGNATURE-----
Index: TargetGroup.cc
===================================================================
--- TargetGroup.cc      (revision 7549)
+++ TargetGroup.cc      (revision 7550)
@@ -296,7 +296,7 @@
     }
     assert(result->ai_addrlen == sizeof(struct sockaddr_in6));
     struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) result->ai_addr;
-    memcpy(ip6.s6_addr, sin6->sin6_addr.s6_addr, 16);
+    memcpy(&ip6, sin6, sizeof(struct sockaddr_in6));
     ipsleft = 1;
     freeaddrinfo(result);
 #else // HAVE_IPV6
@@ -443,7 +443,8 @@
 #ifdef SIN_LEN
     sin6->sin6_len = *sslen;
 #endif /* SIN_LEN */
-    memcpy(sin6->sin6_addr.s6_addr, ip6.s6_addr, 16);
+    memcpy(sin6->sin6_addr.s6_addr, ip6.sin6_addr.s6_addr, 16);
+    sin6->sin6_scope_id = ip6.sin6_scope_id;
 #else
     fatal("IPV6 not supported on this platform");
 #endif // HAVE_IPV6
Index: TargetGroup.h
===================================================================
--- TargetGroup.h       (revision 7549)
+++ TargetGroup.h       (revision 7550)
@@ -143,7 +143,7 @@
   void Initialize();
 
 #if HAVE_IPV6
-  struct in6_addr ip6;
+  struct sockaddr_in6 ip6;
 #endif
 
   /* These 4 are used for the '/mask' style of specifying target 

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org

  By Date           By Thread  

Current thread:
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]
AlienVault