1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-14 19:59:02 +00:00
Commit Graph

120 Commits

Author SHA1 Message Date
david
11b76a55e2 Route tables rework to libdnet-stripped/NMAP_MODIFICATIONS. 2012-09-30 00:01:20 +00:00
david
049208898b Set intf_name in route-bsd.c, the parts used by OS X.
There are some other #ifdefs that are used on other platforms, in which
code intf_name might nto be set but will continue to be an empty string
as before.
2012-09-30 00:01:17 +00:00
david
0ed5d26bc3 Set intf_name in route-win32.c. 2012-09-30 00:01:16 +00:00
david
98aa8fbe80 Set intf_name in route-linux.c. 2012-09-30 00:01:12 +00:00
david
5bbe36af7a Add intf_name to the route_entry struct.
This is set to an empty string in all functions yielding routes,
particularly route_loop. The code to get the interface pertaining to a
route is different on different platforms, so must be added one by one.
The code setting the intf_name to an empty string is only tested on
Linux.
2012-09-30 00:01:10 +00:00
david
bfea61a51e Put the sscanf count check right after the call to sscanf. 2012-09-27 03:10:28 +00:00
david
06dcb1c138 Check ipv6 route flags and sscanf count as well. 2012-09-27 03:06:22 +00:00
david
95b634d28c We are reading 11, not 10, fields from /proc/net/route. 2012-09-27 02:58:27 +00:00
david
645e0d213f We can only read n - 1 bytes of interface name; sscanf doesn't include
the terminator.

Noticed by Djalal.
2012-09-27 02:58:26 +00:00
djalal
af495cdc49 Fixed a bug that prevented Nmap from finding any interfaces when one
of them had the type ARPHDR_INFINIBAND; this was the case for
IP-over-InfiniBand interfaces. However, This support is not complete
since IPoIB interfaces use 20 bytes for the hardware address, and
currently we only report and handle 6 bytes.
Nmap IP level scans should work without any problem, please refer to
the '--send-ip' switch and to the following thread:
http://seclists.org/nmap-dev/2012/q3/642

This bug was reported by starlight.2012q3.
2012-09-26 09:24:00 +00:00
djalal
e017b7c290 Fixed a bug that prevented Nmap from finding any interfaces when one
of them had the type ARPHDR_IEEE80211; this was the case for wireless
interfaces operating in access point mode. This bug was reported by
Sebastiaan Vileijn.

http://seclists.org/nmap-dev/2012/q3/986
2012-09-26 08:49:22 +00:00
david
0674925f73 Skip over entire ifreq struct in NEXTIFR.
On platforms supporting sa_len, NEXTIFR would skip over sa_len bytes
starting at the beginning of ifr_addr, and assume that was the end of
the struct. (The idea being that a large address such as a sockaddr_in6
could overflow the nominal struct boundary.) This logic was wrong when
there was something else in the union bigger than sa_len; we would
increment into somewhere in the middle of the same struct.

This exhibited itself on NetBSD, where struct ifreq has a
sockaddr_storage member in its internal union:
struct	ifreq {
	char	ifr_name[IFNAMSIZ];		/* if name, e.g. "en0" */
	union {
		struct	sockaddr ifru_addr;
		struct	sockaddr ifru_dstaddr;
		struct	sockaddr ifru_broadaddr;
		struct	sockaddr_storage ifru_space;

No, we skip over sa_len bytes, or to the nominal end of the struct,
whichever is larger.

Unix Network Programming gets this wrong too; in figure 17.8 they do
ptr += sizeof(ifr->ifr_name) + max(sizeof(struct sockaddr), ifr->ifr_addr.sa_len);
2012-09-10 01:17:28 +00:00
david
f7873c0089 Resolve strict-aliasing problems in ip6_ntop.
addr-util.c:191:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
2012-09-01 03:29:39 +00:00
david
7a9e7c502e Add a missing IFF_IPMP #ifdef guard. 2012-08-26 20:44:32 +00:00
david
48ff61a710 Handle ARPHRD_VOID in addr_ston.
This type is used by OpenVZ venet interfaces. We "handle" such an
address type just by blanking the MAC address field.

Lack of support for this type of interface was preventing Nmap from
working on certain systems.

http://seclists.org/nmap-dev/2012/q2/763

An earlier message about this same type of interface is

http://seclists.org/nmap-dev/2009/q3/303
2012-07-21 07:35:41 +00:00
djalal
8e7edbd008 o Fixed a bug that caused Nmap to fail to find any network interface when
at least one of them is in the monitor mode. The fix was to define the
  ARP_HRD_IEEE80211_RADIOTAP 802.11 radiotap header identifier in the
  libdnet-stripped code. Network interfaces that are in this mode are used
  by radiotap for 802.11 frame injection and reception. The bug was
  reported by Tom Eichstaedt and Henri Doreau.
  http://seclists.org/nmap-dev/2012/q2/449
  http://seclists.org/nmap-dev/2012/q2/478
  [Djalal Harouni, Henri Doreau]
2012-06-02 19:35:08 +00:00
david
ae2f887af1 Ignore IPMP interfaces in SIOCGLIFCONF intf_loop.
This is a (hopefully temporary) workaround for these virtual interfaces
on Solaris. They don't work for Nmap because they don't allow packet
sniffing, but you can use one of the physical interfaces they're
composed of.
2012-05-24 02:56:08 +00:00
david
4c5022b100 Fix the fd6 condition for SIOCGLIFFLAGS. 2012-05-13 01:20:56 +00:00
david
7cfee5944c Don't let Solaris IPMP devices appear as Ethernet. 2012-05-12 23:27:49 +00:00
david
25fdaf95f3 Use a large initial buffer in the call to GetAdaptersAddresses.
GetAdaptersAddresses is supposed to return ERROR_BUFFER_OVERFLOW and set
len to the required size when len is too small. So normally we would
call the function once with a small len, and then again with the longer
len. But, on Windows 2003, apparently you only get ERROR_BUFFER_OVERFLOW
the *first* time you call the function with a too-small len--the next
time you get ERROR_INVALID_PARAMETER. So this function would fail the
second and later times it is called.

So, make the first call using a large len. On Windows 2003, this will
work the first time as long as there are not too many adapters. (It will
still fail with ERROR_INVALID_PARAMETER if there are too many adapters,
but this will happen infrequently because of the large buffer.) Other
systems that always return ERROR_BUFFER_OVERFLOW when appropriate will
enlarge the buffer if the initial len is too short.
2012-05-10 21:29:54 +00:00
david
cc0f2e1e54 Don't use LIFC_UNDER_IPMP if it's not defined. 2012-05-10 20:45:30 +00:00
david
49aafa4a38 Use LIFC_UNDER_IPMP when enumerating Solaris interfaces.
An IPMP interface is a special kind of interface made up of other
interfaces. The other interfaces are hidden by default unless this flag
is passed to ioctl(SIOCGLIFCONF). This allows me to scan over an IPMP
interface in a simple setup.
2012-05-07 21:41:57 +00:00
david
e819beaaae Make changes for IPv6-only interfaces on Solaris.
First try SIOCGLIFFLAGS with an IPv4 socket, then again with an IPv6 socket if that fails. Use that same socket for the other ioctl queries.

Avoid adding an IPv6 alias address that is the same as an IPv6 primary address. This is the same as an existing check in the IPv4 case.

Fix a loop exit boundary condition check.
2012-04-22 02:13:16 +00:00
david
7cd9a0f2d2 Make some #ifdef guards actually use the symbol they're guarding. 2012-04-20 23:57:43 +00:00
david
b5c1e83471 Substitute on-link routes' gateways with an all-zero address.
On OS X, the code in route_loop in route-bsd.c can get a gateway
sockaddr_dl that looks like this:

$1 = {
  sdl_len = 20 '\024',
  sdl_family = 18 '\022',
  sdl_index = 4,
  sdl_type = 6 '\006',
  sdl_nlen = 0 '\0',
  sdl_alen = 0 '\0',
  sdl_slen = 0 '\0',
  sdl_data = '\0' <repeats 11 times>
}

route_loop would throw these out because there's no hardward address
there. This is a routing table entry that indicates that there is no
gateway, and that packets for this particular destination need to go on
interface #4. It corresponds to this type of line from netstat output:

Destination        Gateway            Flags        Refs      Use   Netif Expire
192.168.0          link#4             UCS             2        0     en0

I've changed it so that instead of throwing out the entry, it creates an
all-zero address of the same type as the destination address, which is a
convention used (by Nmap at least) to indicate an on-link route.
2012-03-26 22:24:55 +00:00
david
d7af8ff3d0 Better factoring and comments in route-bsd.c route_loop. 2012-03-26 22:24:54 +00:00
david
2c7e3f31de Try /dev/net/<iface> after /dev/<iface> with DLPI.
This appears to be a new place on Solaris 11. WIthout this, I get a MAC address of 00:00:00:00:00:00 from --iflist for example.
2012-03-17 12:06:27 +00:00
david
dbf79dafaa SIOCGLIFCONF-based implementation of intf_loop for Solaris 10.
The SIOCG*L*IFCONF interface is mostly like SIOCGIFCONF except that it
uses a sockaddr_storage-based structure that allows handling IPv6 interfaces.
2011-09-30 00:42:45 +00:00
david
399942d759 Add an MIB2_IP6 in addition to the MIB2_IP loop.
This gets IPv6 routes.
2011-09-29 22:23:16 +00:00
david
ddb4829b2b Use SIOCGIFNETMASK6 to get IPv6 interface netmasks.
This is used when SIOCGIFNETMASK_IN6 isn't available.
2011-09-28 06:55:48 +00:00
david
31f12a071c Check for <netinet/in6_var.h>.
This contains the SIOCGIFNETMASK6 ioctl definition on AIX.
2011-09-28 06:55:47 +00:00
david
8d964ad4e9 Consider IFF_LOOPBACK before IFF_BROADCAST.
The IPv6 loopback interface on AIX has both IFF_BROADCAST and IFF_LOOPBACK set. Checking IFF_BROADCAST first erroneously makes it appear as an Ethernet device.
2011-09-26 22:26:50 +00:00
david
032caee6ac o Made the interface gathering loop work on Linux when an interface
index is more than two digits in /proc/sys/if_inet6. Joe McEachern
  tracked down the problem and provided the fix.
2011-09-25 19:14:33 +00:00
david
0bce585dec Use getkerninfo to get routing information on AIX. 2011-09-21 07:31:34 +00:00
david
70d2105b9f Use if_nametoindex instead of SIOCGIFINDEX.
The latter isn't available on OS X.
2011-09-17 06:40:41 +00:00
david
4f454a29d2 Add the intf_entry.intf_index member.
This is the operating system's interface index, as used by
if_indextoname and sockaddr_sin6.sin6_scope_id.
2011-08-30 23:55:07 +00:00
david
12f4742f0f Add intf_get_index to libdnet-stripped.
This function gets an interface from an internal interface number, such
as a sockaddr_in6.sin6_scope_id.
2011-08-30 17:01:50 +00:00
david
c32d196ce2 Remove the nonexistent include/config.h from the build configuration.
With this present, the project always appeared out of date. Visual C++
would always prompt to rebuild the project when starting to debug, for
example.
2011-07-20 07:16:05 +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
shinnok
9562171e86 Remove unreferenced local variable. 2011-06-22 18:35:56 +00:00
david
5f8b19c700 Add ICMPv6 Parameter Problem defines. 2011-06-14 19:46:49 +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
7f7c78ad96 Fix a bug in Windows interface matching. The code was supposed to check if a
MAC address matched the expected address, and if so, take that as a preliminary
match before checking the description string for a stronger match. But if
retrieving the the MAC address failed completely, it was still being accepted
as a preliminary match, and would prevent later matches with only the MAC
address from being accepted.
2011-02-10 05:52:22 +00:00
david
33f3645ecd Don't define HAVE_SYS_SOCKET_H in dnet_winconfig.h. That it was wrongly
defined was noticed by Gisle Vanem. It makes no difference because this
macro isn't used in any source files for Windows (or any platform).
2010-11-29 20:30:52 +00:00
david
fa320a9c16 Change the name of the "dnet" project to "libdnet-stripped". This was only a
warning, not a build failure, but now it better matches the other projects
whose name matches their directory name.
2010-11-04 20:27:30 +00:00
david
6ce7c2e34d Upgrade the Windows build files using the Visual C++ 2010 Express conversion
wizard. At this point the solution doesn't build.
2010-11-04 18:16:40 +00:00
david
dba101df69 Update NMAP_MODIFICATIONS to reflect upstream code merges by Jay Fink. 2010-10-11 18:17:23 +00:00
david
f664110479 Update NMAP_MODIFICATIONS for fixed ip6_pack_hdr. 2010-10-07 21:54:19 +00:00
david
6112cb9a43 Fix bugs in ip6_pack_hdr so that the traffic class and flow label are
set correctly.

1. Shift the low-order bits of fc by 20 bits, not 28, because fl is a
   20-bit field.
2. Use a mask in host byte order to mask fl, which is also provided in
   host byte order.
3. Swap | and & in combining fc and fl.
2010-10-07 21:51:28 +00:00
david
a2b84bf74f o Changed the name of libdnet's sctp_chunkhdr to avoid a conflict with
a struct of the same name in <netinet/sctp.h>. This caused a
  compiliation error when Nmap was compiled with an OpenSSL that had
  SCTP support. [Olli Hauer, Daniel Roethlisberger]
2010-09-05 03:40:31 +00:00