1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-10 08:51:36 +00:00
Commit Graph

145 Commits

Author SHA1 Message Date
dmiller
27c2a64a17 Remove 6/8, 7/8, and 55/8 from ip_is_reserved. http://seclists.org/nmap-dev/2016/q1/11 2016-02-11 05:52:35 +00:00
dmiller
f9a7123aed sys/uio.h needed for struct iovec on OpenBSD 2016-01-13 20:53:38 +00:00
dmiller
a205e0c4d4 Fix for OpenBSD packet loss. Fixes #274 2016-01-12 19:38:06 +00:00
dmiller
2450dee71e Extend libnetutil's isipprivate function to check for 169.254/16 2015-12-19 20:44:55 +00:00
dmiller
e73053c457 Fix FreeBSD version check for raw socket byte order. Fixes #217. See #196, #50 2015-10-28 03:21:15 +00:00
dmiller
3d9e348832 Use a mutex on Windows to avoid a hang when accessing WinPCAP driver
Reported by multiple users on Windows 8.1 and Windows Server 2012 R2.
Seems to hang when the WinPCAP driver is accessed via OpenServiceA by
multiple processes at once. Users report that this change, which uses a
mutex to avoid concurrent access, fixes the hang.
2015-09-20 19:06:11 +00:00
dmiller
9ab82ecedf Fix raw packet sending on FreeBSD 10.0 and later.
See https://svnweb.freebsd.org/base?view=revision&revision=241913 for
the change. Closes #196. Fixes #50.
2015-08-06 21:10:36 +00:00
dmiller
68409b2226 Update copyright date to 2015 2015-06-03 13:01:29 +00:00
dmiller
5d6fe15fec Cache dnet names not found in addition to found names. http://seclists.org/nmap-dev/2015/q1/251 2015-06-01 03:51:31 +00:00
dmiller
c7e5ad67b5 Do optimization of pcap filters via set_pcap_filter
Optimizing reduces BPF instructions from 45 to 10 for large-scan case.

Also use PCAP_NETMASK_UNKNOWN instead of 0 since we don't provide a
netmask.
2014-10-29 05:31:08 +00:00
dmiller
5adfb3b1de Update copyright notice to 2014 2014-08-16 01:52:33 +00:00
jay
8d5ec9e310 Reapply r33420, r33421. Fix a missing right parenthesis. https://xkcd.com/859/ 2014-08-15 12:09:22 +00:00
fyodor
f6f59a7cd7 Auto regeneration with latest template files, etc. 2014-08-13 22:57:43 +00:00
jay
d4cf544df6 Fix a missing bracket at the end of the IMPORTANT NMAP LICENSE TERMS part in each file 2014-08-02 19:29:50 +00:00
dmiller
795ca1b64f Fix assert fail on FreeBSD in libdnet 2013-11-07 19:32:33 +00:00
dmiller
77f1429a56 Fix UDP checksum generation (0 -> 0xffff)
See changelog and http://seclists.org/nmap-dev/2013/q4/122
2013-11-06 02:46:20 +00:00
david
5df0e13ee2 Use 32-bit values, not 16, for IP ID values.
IP ID fields are overloaded to include the flow label of IPv6 packets.
In particular, abstract_ip_hdr is no longer limited to 16 bits.
2013-10-27 06:33:45 +00:00
d33tah
ccd0c02a4c Add a lacking space in the license comment. The command I used to do this is:
for file in `grep "* including the terms and conditions of this license text as well.       \*" * -r --files-with-match `; do sed "s/\* including the terms and conditions of this license text as well.       \*/* including the terms and conditions of this license text as well.        */g" -i $file; done
2013-09-11 19:06:20 +00:00
david
1f372aa911 Make format string specifiers better match types.
Suggested by Gisle Vanem.
http://seclists.org/nmap-dev/2013/q3/269
2013-08-15 08:07:26 +00:00
david
4961ebf047 8-byte display for SCTP checksum. 2013-08-15 08:07:24 +00:00
david
ed237e8e19 Use %lu instead of %ul.
Discovered by Gisle Vanem.
http://seclists.org/nmap-dev/2013/q3/269
2013-08-15 08:07:21 +00:00
david
784b1ef4e8 Swap SCTP vtag and csum in HIGH_DETAIL output.
Discovered by Gisle Vanem.
http://seclists.org/nmap-dev/2013/q3/269
2013-08-15 08:07:14 +00:00
fyodor
6e01ecd452 Update an email address, fix a typo, and slightly reword a sentence. 2013-07-30 00:02:00 +00:00
fyodor
83fb10ec56 Update the Nmap copyright/license files. This isn't the new Nmap Public Source License we've been discussing on the list, but rather just a 'quick patch' to hopefully prevent some of the abuse we've been seeing from companies lately. More details on the changes will be posted to the dev list. Also, the copyright year was updated to 2013 (which is the only change to Nsock license statements). 2013-07-28 22:05:05 +00:00
david
9ac1bffad2 Ignore down interfaces at route_dst time, not when building routing table.
The previous code to ignore down interfaces didn't account for implicit
routes that come from interface addresses and netmasks. You can force
the use of a route using a down interface with -e.
2013-07-01 02:06:09 +00:00
david
b415564df9 Sort routes first by netmask, then by metric.
Metric is used to break ties between routes with the same size netmask.
2013-06-30 17:38:15 +00:00
david
9ea60a9f1f Consider IPPROTO_NONE (59) an upper-layer protocol for IPv6.
"Upper-layer" here simply means that there are no extension headers
following, which is the case here.
2013-06-06 14:50:09 +00:00
david
ce98c0ad1e Don't consider NOARP devices as Ethernet devices.
NStorm reported a failure of ARP ping scan on OpenVZ venet devices,
which don't have a MAC address and can't do ARP. We don't keep interface
flags such as NOARP at the target level, so check whether the interfaces
returned by libdnet are both INTF_TYPE_ETH and don't have
INTF_FLAG_NOARP set; otherwise call them "other" interfaces.

http://seclists.org/nmap-dev/2013/q1/349
http://openvz.org/Virtual_network_device
2013-05-13 05:38:33 +00:00
david
39687a80b1 Set source and destination interfaces as rtattrs.
Scans using the -e option could use the correct interface but the wrong
source address.

Thanks to Taburiss S for the report and John Bond for help debugging.
http://seclists.org/nmap-dev/2013/q1/269
http://seclists.org/nmap-dev/2013/q1/327
2013-03-08 05:35:07 +00:00
david
96d9d6fc51 Fix some socket leaks in get_srcaddr. 2013-03-08 05:35:05 +00:00
david
66bd9d1993 Enforce device name only after choosing loopback in route_dst_generic.
Nping calls route_dst at least twice: once with a NULL device, and again
with the device learned from the first time. This interfered with the
code that automatically chooses a loopback interface for dests that are
the same as an interface address. For example, if you are 192.168.0.1,
and you are scanning 192.168.0.1, route_dst will tell you to use
interface "lo0" even though the interface of 192.168.0.1 may be "eth0".
route_dst was returning failure because the device name check was being
done before "eth0" got changed to "lo0".

This problem didn't show up on Linux because Linux uses
route_dst_netlink, which delegates the work to the kernel. But I could
reproduce on Linux by forcing the use of route_dst_generic.
2013-02-09 18:55:46 +00:00
david
5ab6c9fa93 Sort by metric. 2013-02-01 05:01:59 +00:00
david
e2387e4693 Add metric to struct sys_route. 2013-02-01 05:01:57 +00:00
david
41b397200b Show ICMP ID and seqno in packet trace by default.
This was previously limited to ippackethdrinfo's medium detail and
above, which required -v in Nping and -d2 in Nmap.
2013-01-28 22:34:37 +00:00
david
50a4817671 Remove dynamically allocated fakeargv.
This used to be used to hold the original argv before quashing with -q.
Now that -q is gone, it was just a copy of argv.

fakeargv was also causing Valgrind to complain about leaked memory. it
wasn't a real leak, but now it's out of the report anyway.
2013-01-25 06:26:21 +00:00
david
e1fba2d663 Merge r30416:30527 from /nmap-exp/david/ipv6-ranges.
This is a refactoring of target parsing that stores different types of
target specifications as different classes. The eventual intention is to
allow easy iteration over each specification for the purpose of IPv6
multicast host discovery.
2013-01-22 00:01:08 +00:00
fyodor
6a42ef47c0 Update the Nmap and Nsock source code headers to note new Nmap dev mailing list email address and a better URL for Nmap license. 2012-12-06 01:21:42 +00:00
david
3029747902 Actually use the interface address when get_srcaddr fails.
There was an embarrasing bug here added in r28874. In the second of
three calls to get_srcaddr, the interface was being indexed by an index
variable that, in this place, was actually an index into the routes
table. This would in general produce a nonsensical source address or
out-of-bounds access.

The symptom of this problem was the following error messages:
	get_srcaddr: can't connect socket: The requested address is not valid in its context.
	Failed to convert source address to presentation format!?!  Error: Unknown error
The first showed that get_srcaddr failed, and the second was caused by
the bogus source address.

http://seclists.org/nmap-dev/2012/q3/859
http://seclists.org/nmap-dev/2012/q4/59
2012-10-11 03:11:53 +00:00
david
ac606d846f Fallback check for an AF_UNSPEC interface in route_dst_netlink.
When an interface doesn't have an address set, getInterfaceByName can
fail because it checks the address family. The fatal error message would
be something like
	route_dst_netlink: can't find interface "tap0"
If we can't find an interface with a specific address family, fall back
with an AF_UNSPEC search.

http://seclists.org/nmap-dev/2012/q4/12
2012-10-03 21:06:43 +00:00
david
22d49bd5c9 Match against both destination and gateway in sysroutes_dnet_find_interfaces.
This commit fixes two different bugs:

(1) First in some situations Nmap will only see routes that are attached
to the device that handles the default route.

(2) On boxes without a default route, Nmap will not see any route.

These two bugs are caused by sysroutes_dnet_find_interfaces() logic
which will use only the geteway to match interface addresses.

To fix this, first check the current route and see if the gateway was set
otherwise use the destination address to match the address of an
interface.
2012-09-30 00:01:14 +00:00
david
6c8b5c7dd9 Assign sys_route interfaces immediately when iface names come from libdnet. 2012-09-30 00:01:13 +00:00
david
d319f8bf56 Uniformity and style in resolve functions. 2012-09-15 17:56:16 +00:00
david
113e0b975f Break out resolve and resolve_numeric.
Besides the confusingness of the nodns argument being negatively
phrased, it had the value 0 in every existing call. Split out the nodns
special case into a separate function resolve_numeric.

This also has the side effect of changing the number of parameters to
the resolve function, which will cause a compile error for any calls I
might have missed changing when I changed the return code meaning in the
previous commit.

Ncat has its own copy of resolve, which obeys the global o.nodns rather
than a parameter. I'm leaving that alone for now. But give it the same
resolve_internal function, and make resolve call it with different flags
depending on the value of o.nodns.
2012-09-15 17:56:11 +00:00
david
0e738370ee Make resolve return a getaddrinfo error code.
The only error we can have apart from a getaddrinfo error is a list of
zero addresses; return EAI_NONAME in that case.

This unfortunately inverts the truth value of the return code of
resolve; 0 now means success.
2012-09-15 17:56:08 +00:00
david
e2d17adf9f Fix add_rtattr_addr.
The second argument to RTA_NEXT was missing a dereference, so it was
changing the pointer rather than the integer pointed to. I got this
assertion failure with an IPv6 link-local address:

nmap: netutil.cc:3048: void add_rtattr_addr(nlmsghdr*, rtattr**, unsigned int*, unsigned char, const sockaddr_storage*): Assertion `((*len) >= (int)sizeof(struct rtattr) && (*rtattr)->rta_len >= sizeof(struct rtattr) && (*rtattr)->rta_len <= (*len))' failed.
2012-09-15 17:17:59 +00:00
david
3fb047e237 Don't assign any routes to interfaces that are not up. 2012-09-14 15:51:12 +00:00
david
b5b558f162 Don't use the clobbered rtmsg->rtm_family to look up interfaces.
This value gets clobbered after the netlink recvmsg. It was giving me a
bogus address family (234), which caused the call to getInterfaceByName
to fail:
Could not find interface wlan0 which was specified by -e

This seems to have been exposed by r29754. Specifying a source address
that is not on any actual route seems to result in a netlink query
result with 0 entries, and the changed value of rtm_family. (The fact
that there are no routes returned is not a problem, because we bail out
early when -e is given, now that getInterfaceByName works again.)
2012-09-11 23:50:21 +00:00
david
5b8c1090e5 Add specifiers for source address and interface in route_dst_netlink.
We previously restricted by destination address; do it for source
address as well. This can matter in some configurations.

http://seclists.org/nmap-dev/2012/q3/831

There still seems to be a problem with the wrong route being chosen with
--send-ip, but this patch is reported to work with --send-eth.
2012-09-11 18:39:42 +00:00
david
be636dacaf Factor out a add_rtattr_addr function to add a source or destination spec.
This is used to restrict what routes the Netlink layer will return to
us.
2012-09-11 18:39:40 +00:00
david
f4e06ca3d7 Ignore RTN_UNREACHABLE routes in route_dst_netlink.
According to rtnetlink(7), such routes are "an unreachable destination."
I get such a route when I ifdown my he-ipv6 interface:

$ /sbin/route -n -A inet6
Kernel IPv6 routing table
Destination                    Next Hop                   Flag Met Ref Use If
::/0                           ::                         !n   -1  1 26122 lo

The problem with not ignoring such routes is that Nmap will think that
the interface to use is lo, and consequently that all the targets are
localhost addresses. Ping scan will succeed with a localhost-response,
but trying to send any packets will fail with "destination unreachable."

Maybe we should do the same thing for these additional values of
rtm_type?

              RTN_BLACKHOLE     a packet dropping route
              RTN_PROHIBIT      a packet rejection route
2012-07-24 00:24:11 +00:00