1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-09 14:11:29 +00:00
Commit Graph

170 Commits

Author SHA1 Message Date
david
293a073c92 pcap sockets appear not to be selectable on Solaris. 2011-09-29 22:23:15 +00:00
david
c87da9aa8b Avoid using parameter names that are #defined on AIX.
AIX defines various things like ip_id as some implementation-dependent
submember of struct ip.
2011-09-21 07:31:37 +00:00
david
75f753b441 Rearrange include for AIX. 2011-09-21 07:31:35 +00:00
david
9bf2ec3884 Merge from /nmap-exp/luis/nmap-os6.
svn merge --ignore-ancestry svn://svn.insecure.org/nmap@26621 svn://svn.insecure.org/nmap-exp/luis/nmap-os6

This is the IPv6 OS detection branch. "nmap -6 -O" works now, though at
this point it only prints fingerprints and not OS guesses, because we
need to collect more submissions.
2011-09-19 18:31:46 +00:00
david
f41753c4e9 Add a sockaddr dst argument to send_ip function that use raw sockets.
Heretofore we have always extracted teh destination address directly
from the packet contents. But the raw packet bytes do not contain enough
information in one case: IPv6 link-local addresses. For those we really
need the scope ID, and for that we must pass this information all the
way down.

Before this, I got "no route to host" on OS link-local addresses. I
think that it was working on Linux only on accident, by the OS picking a
default interface or something.
2011-09-19 16:13:35 +00:00
david
d91b131da0 Make various accessors and parameters const. 2011-09-19 16:13:33 +00:00
david
5898afd06b Canonicalize interface addresses returned from libdnet.
Mac OS X appears to have a new address convention that I can't find
documented. The link-local address fe80:4::X:X:X:X stands for
fe80::X:X:X:X%en0, if en0 is the interface with index 4. (I.e., it would
be fe80::X:X:X:X%4 on Windows.) The number 4 could be different numbers.

The interface addresses seem to be stored with these pseudo-zone IDs at
a low level, because they appear that way when they come from libdnet.
This is what "nmap --iflist" shows:

lo0  (lo0)   fe80:1::1/64                   loopback    up   16384
en0  (en0)   fe80:4::xxxx:xxxx:xxxx:xxxx/64 ethernet    up   1500  XX:XX:XX:XX:XX:XX

The OS X network tools seem to hide this. This is what "ifconfig" and
"netstat -rn -f inet6" show:

lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
en0: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
        inet6 fe80::xxxx:xxxx:xxxx:xxxx%en0 prefixlen 64 scopeid 0x4

fe80::1%lo0                             link#1                          UHLI            lo0
fe80::xxxx:xxxx:xxxx:xxxx%en0           XX:XX:XX:XX:XX:XX               UHLI            lo0

(Not the "scopeid 0x4".) Also, if you use one of these addresses, it
magically transforms into one without the pseudo-ID (getaddrinfo does
this):

$ ping6 fe80:4::1234
PING6(56=40+8+8 bytes) fe80::xxxx:xxxx:xxxx:xxxx%en0 --> fe80::1234%en0
$ ping6 fe80:1::1234
PING6(56=40+8+8 bytes) fe80::1%lo0 --> fe80::1234%lo0

This translation is messing up our netmask comparisons for the purpose
of routing. If you use a normal link-local address starting with fe80:0,
then it doesn't compare equal with the fe80:4/64 interface address. If
you try to use the 4, then getaddrinfo turns it into fe80:0 anyway, and
the comparison still fails.

So for this reason I added a canonicalize_address function, which calls
getnameinfo on an address, then calls getaddrinfo on the returned
string, to mangle an address the same way the OS would do it. One would
hope this is a no-op in cases other than the one I have described.

Now "nmap --iflist" shows:
lo0  (lo0)   fe80::1/64                   loopback    up   16384
en0  (en0)   fe80::xxxx:xxxx:xxxx:xxxx/64 ethernet    up   1500  XX:XX:XX:XX:XX:XX
2011-09-18 23:49:34 +00:00
david
1887aef067 Allow setting certain extension headers as ancillary data in send_ipv6_ip. 2011-09-18 23:46:54 +00:00
david
66cf4fbe4a Define __APPLE_USE_RFC_3542.
Since OS X 10.7, we must declare whether we want the IPv6 sockets API to
work like RFC 2292 or RFC 3542. As far as I know, we are compatible with
both, so just pick the more recent one, which Apple says will become the
default in the future.
2011-09-18 05:11:25 +00:00
david
a13313ad2f Don't double-count RTA_LENGTH in netlink messages.
For each rtattr we add to the netlink message, we were adding
RTA_LENGTH(rtattr->rta_len) to the length of the netlink message. But
rtattr->rta_len was already calculated as RTA_LENGTH of something, and
doing RTA_LENGTH twice made the length 4 bytes longer than it should be.
This caused a log in dmesg:
	netlink: 4 bytes leftover after parsing attributes.
or
	netlink: 8 bytes leftover after parsing attributes.
if there was an IPv6 scope ID (because that causes two rtattrs instead
of one).

The new code is consistent with the rtnetlink(3) man page, which does
	rta->rta_len = sizeof(unsigned int);
	req.n.nlmsg_len = NLMSG_ALIGN(req.n.nlmsg_len) + RTA_LENGTH(sizeof(unsigned int));
We do the equivalent
	rta->rta_len = sizeof(unsigned int);
	req.n.nlmsg_len = NLMSG_ALIGN(req.n.nlmsg_len) + rta->rta_len;
2011-09-03 17:22:07 +00:00
david
1ef0db4b33 Define CMSG_ALIGN, CMSG_SPACE, and CMSG_LEN for old Solaris.
This was reported by Dagobert Michelsen and comes from
http://wiki.opencsw.org/porting-faq#toc10.
2011-09-03 01:51:35 +00:00
david
77204b9d43 Add an ifindex member to interface_info.
This is a copy of intf_index from libdnet.
2011-08-30 23:55:08 +00:00
david
31be04c93c Factor out a function to get an interface name from an index. 2011-08-30 23:55:05 +00:00
david
44e5b39fa2 Don't fatal when failing to find an interface by index. 2011-08-30 19:19:34 +00:00
david
43422f9344 Show a hint about an IPv6 zone ID suffix when get_srcaddr fails. 2011-08-30 18:32:35 +00:00
david
d1a518e08d Don't fatal when get_srcaddr can't connect the socket.
Let it be handled by a higher layer.
2011-08-30 18:32:34 +00:00
david
d759b485ea Honor sin6_scope_id in route_dst_generic.
This is set nonzero when there is a scope identifier at the end of
an IPv6 address, like fe80::a8bb:ccff:fedd:eeff%eth0 or
fe80::a8bb:ccff:fedd:eeff%1 on Windows. When this happens, we look up
the interface by index and then act as if it was the interface given by
-e. (But -e always has precedence over this.)
2011-08-30 17:01:51 +00:00
david
c5afa5b57b Temporarily revert r26242.
if_indextoname doesn't work the same way on Windows.
2011-08-30 14:33:20 +00:00
david
053154e5c3 Honor sin6_scope_id in route_dst_generic.
This is set nonzero when there is a scope identifier at the end of
an IPv6 address, like fe80::a8bb:ccff:fedd:eeff%eth0. When this
happens, we look up the interface by index and then act as if it was the
interface given by -e. (But -e always has precedence over this.)
2011-08-30 04:18:58 +00:00
david
d7302d7608 Use if_indextoname instead of our own intf_name function. 2011-08-30 04:18:57 +00:00
david
96a785e67d Honor sin6_scope_id in route_dst_netlink.
This is set nonzero when there is a scope identifier at the end of an
IPv6 address, like fe80::a8bb:ccff:fedd:eeff%eth0. When this happens, we
add an rtattr with type RTA_OIF to request a particular outgoing
interface.

In my tests, this does the right thing when the address is in fact the
assigned address of the interface; the interface becomes lo instead of
the physical interface name.
2011-08-30 04:18:56 +00:00
djalal
fc79deba75 Made getInterfaceByName() return IPv6 interface information. 2011-08-10 22:56:34 +00:00
weilin
1dcf652410 Added ND ping for local IPv6 nets, merging from /nmap-exp/weilin/nmap-nd. 2011-07-19 02:31:54 +00:00
david
f5fe8fb6e9 Use the proper length in get_srcaddr, not sizeof(sockaddr_in6).
This was a bug in r24413. The size needs to vary with the address family
on some platforms including OS X. This was noticed by Chris Clements.
2011-06-28 00:35:01 +00:00
david
fd259a2422 Use getsockname to get source addresses.
This was previously gotten by setting the source address to be the same
of the interface address of the matching route. However this can be
wrong; when making a normal socket connection the source address is
chosen differently. We create a SOCK_DGRAM socket, connect it, and read
the local address with getsockname.
2011-06-27 18:05:39 +00:00
shinnok
e06012af5a Type conversion safety fixes that remove compiler warnings too. 2011-06-23 20:48:06 +00:00
shinnok
68bdff3e54 Minor cosmetic fix. 2011-06-23 11:14:42 +00:00
david
e748e46d9e Add ipv6_get_data_any and ip_get_data_any.
These version allow returning an extension header or other
non–upper-layer protocol if it is the final header before the end of the
packet. This is used to parse the broken packets sent as part of
protocol scan.
2011-06-17 05:47:33 +00:00
david
c32e8c5513 Fix socket leak in intf_name. This was reported by Brandon. 2011-06-15 08:34:33 +00:00
david
d1aae42962 Whitespace in ippackethdrinfo. 2011-06-15 00:22:59 +00:00
david
8737c0ab72 Remove unused local. 2011-06-15 00:22:58 +00:00
david
3382faa75e Update a comment. 2011-06-14 21:06:35 +00:00
david
bbf70e7f69 Fix printing of UDP and SCTP IPv6 packets.
Unlike other protocols, these assumed an IP header length of
sizeof(struct ip).
2011-06-14 19:46:46 +00:00
david
35d920cda9 Rename do_arp_cache to do_mac_cache.
It is no longer specific to ARP; it also caches IPv6 ND results.
2011-06-14 00:42:39 +00:00
david
fdef8d7663 Remove IPv4-only comments from do_arp_cache. 2011-06-14 00:42:38 +00:00
david
dc7f62ffa9 Continue to consider a target directly connected if its gateway is equal
to its own address.
2011-06-08 05:15:20 +00:00
david
4aa4a154f9 Merge from /nmap-exp/david/nmap-ipv6.
This is raw IPv6 packet support for most port and ping scans, Neighbor
Discovery, and traceroute.
2011-06-08 01:24:48 +00:00
david
b08c07339a Make netutil_fatal return void. 2011-06-07 16:18:51 +00:00
david
04e2cc9936 Add __attribute__((noreturn)) to netutil_fatal. 2011-06-07 04:59:26 +00:00
kris
4effcc8418 trivial comment typo 2011-05-07 03:17:52 +00:00
kris
71ec39d01a remove an outdated comment of mine 2011-05-07 02:55:09 +00:00
david
afce65a3a8 Rename tcpudp_cksum to ipv4_pseudoheader_cksum. Partial merge of r21278
from /nmap-exp/david/nmap-ipv6.
2011-04-26 15:38:44 +00:00
david
58e9346684 Split apart the calls to inet_ntoa from r22818; we can't call it twice
in the same statement or the static buffer is overwritten.
2011-03-30 21:07:37 +00:00
david
61e8dfc660 Improve the message "WARNING: Unable to find appropriate interface for
system route to..." to include the destination and netmask, not only the
gateway.
2011-03-30 20:53:30 +00:00
kris
740318cee9 Updating ip_is_reserved(): the last IPv4 address blocks (102-104/8, 179/8 and
185/8) have been allocated to the RIRs
2011-02-04 03:06:57 +00:00
kris
c95e5d797b updating ip_is_reserved(): 39/8 and 106/8 allocated today 2011-02-01 00:19:56 +00:00
fyodor
86e59a8c4e Update copyright statements from 2010 to 2011 2011-01-21 00:04:16 +00:00
kris
39ac0e4eda relatively large ip_is_reserved() update: 5/8, 23/8, 37/8 and 100/8 allocated 2010-12-04 00:16:38 +00:00
kris
2e838599c3 updating ip_is_reserved(): 105/8 allocated 2010-11-16 04:54:35 +00:00
david
7653cf7d4a Move COPYING.OpenSSL to OpenSSL.txt, update copyright notices to match. 2010-10-30 03:01:50 +00:00