1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00
Commit Graph

251 Commits

Author SHA1 Message Date
fyodor
684f42c4ad One more adjustment to the license text. Notes that Zenmap, Ncat, and Nping use this license. Note that contributions made directly in the src repository are treated the same as those in the mailing list. 2012-03-01 06:53:35 +00:00
fyodor
e96a7b7b24 Update the headers for each code file. This updates code copyright dates to 2012, notes the awesome NSE in the list of technology, and slightly rewords the derivative works clarification 2012-03-01 06:32:23 +00:00
henri
63f3fc4954 Fixed comments that referred to an incorrect location. 2012-01-26 09:25:05 +00:00
david
06b69fa9a3 Make some args const. 2011-10-29 19:40:15 +00:00
david
91b7aa2d5f Don't use strict inequality with MAX_LINK_HEADERSZ.
DLT_IPNET is equal to this.
2011-09-29 22:23:14 +00:00
david
f0d97d0e9a Add offset for DLT_IPNET (seen on Solaris). 2011-09-29 22:23:13 +00:00
david
fee764a5d8 Use a special struct_ip.h to include <netinet/ip.h> and accoutrements.
The comment in struct_ip.h explains the reasoning for this. The AIX C library
uses #defines that change the names of members of struct ip, and conflict with
some existing code. (Notably struct ip_hdr in libdnet and IPv4Header::h in
libnetutil.) We can still use the AIX files if we include <netinet/ip.h> after
this other code has been preprocessed. That's hard to enforce when
<netinet/ip.h> is included from another header file; this new file allows
including it always late, and only where needed.
2011-09-21 07:31:38 +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
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
8b01344caf In build_{icmp,igmp}_raw, fill with zeros when data is NULL.
This restores the previous behavior of these functions, which was broken
in r24127, which itself was fixing another bug.

r24127 solved the problem of --data-length appending zeroes, not random
data, to ICMP and IGMP packets. But in doing so, it added a check that
the data argument is not NULL. OS detection uses a data argument of
NULL, expecting these functions to fill in zeroes in this case. The
result of this was that the IE probes were being sent with empty
payloads instead of 120 and 150 bytes.
2011-09-15 17:57:00 +00:00
david
f86f2dec67 Assign scope id in nmap_route_dst.
This is done for all IPv6 addresses when the -e option is used.
2011-08-30 23:55:09 +00:00
david
9932429abd Whitespace. 2011-08-30 23:55:06 +00:00
david
6cf428d8c6 Fix some "and" -> "&&". 2011-07-19 23:42:33 +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
21cbe8ffba Use a big enough buffer in traceND. Same as r24365 in
/nmap-exp/weiling/nmap-nd.
2011-06-28 21:58:54 +00:00
shinnok
3240e10bb0 Fix MSVC compiler noreturn related warnings and add extra
safety asserts to the functions that do not return on all
control paths.
2011-06-23 23:59:52 +00:00
shinnok
e8bd001619 Fix build_icmp_raw and build_igmp_raw filling the packet data payload with
zeroes instead of the supplied random data, when nmap is invoked with --data-length.
2011-06-18 11:20:54 +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
381bb03d70 Rename readip_pcap -> readipv4_pcap and readip46_pcap to readip_pcap.
We should have the multiprotocol version be the main version, with
IPv4-only code being a noted exception. Also these functions are almost
the same so one can call the other.
2011-06-08 23:46:21 +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
0183cde860 Finish r23021 (rename of tcpudp_cksum to ipv4_pseudoheader_cksum). I
accidentally left tcpip.cc out of the commit.
2011-04-26 23:00:49 +00:00
david
650ede916a Remove unused send_ip_raw function. 2011-04-01 21:17:01 +00:00
david
7453ec34d0 Change o.TimeSinceStartMS returning milliseconds to o.TimeSinceStart
returning floating-point seconds. Everywhere o.TimeSinceStartMS was
called, the return value was being divided by 1000.0, which had the same
effect but would overflow when the difference exceeded about 25 days
(2^31 milliseconds). This patch is by Daniel Miller.
2011-03-28 20:34:32 +00:00
david
bf99fb231b Check that the argument to freeaddrinfo is not NULL. The behavior may be
unspecified and causes a segmentation fault on Android Bionic libc.
Vlatko fixed the bug in his Android binaries and it was first reported
by @alexismm2.
2011-02-15 08:19:58 +00:00
fyodor
86e59a8c4e Update copyright statements from 2010 to 2011 2011-01-21 00:04:16 +00:00
david
bc55d41b9a Add a comment explaining why we can unconditionally set the id and seq
fields in build_icmp_raw, even though not all ICMP types have them. All
the types handled by the function do have them, and in the same place.
2010-12-02 22:46:56 +00:00
david
7653cf7d4a Move COPYING.OpenSSL to OpenSSL.txt, update copyright notices to match. 2010-10-30 03:01:50 +00:00
luis
d0a4d0ad50 Moved function max_sd() to libnetutil. Also, two new helper functions have been added. 2010-10-20 15:57:50 +00:00
kris
75580c850b Don't fragment IP packets with DF set, even if o.fragscan is set. If a
packet is built to explicitly avoid fragmentation, honor it.
2010-08-02 07:53:40 +00:00
kris
886015d72c don't log (trace) an IP packet if the send failed 2010-07-31 07:57:10 +00:00
luis
da126c8b78 Merged nmap-dedup branch from nmap-exp/luis/nmap-dedup. This completes the Nmap/Nping code de-duplication phase. 2010-06-22 17:24:34 +00:00
david
d90b7b15a7 Make a new function called resolve_all in tcpip.cc, which is like
resolve except that it returns all resolved addresses. Use this new
function to resolve IPv4 addresses instead of gethostbyname in
TargetGroup.cc. The gethostbyname code assumed that only IPv4 addresses
would be returned. If the resolver returned IPv6 addresses, TargetGroup
would blindly copy the first four bytes of the IPv6 address into the
IPv4 struct. This was first reported by Mats Erik Andersson at
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=584301; he also
suggested the fix.
2010-06-19 00:13:44 +00:00
luis
0c8dd438e1 Added a few common protocols to proto2ascii(). Some ifdef directives were included, to avoid breaking compilation if the protos are not defined in some systems. 2010-06-09 17:37:52 +00:00
david
198282a9c3 Remove some Windows-only function prototypes that are obsolete. There are not
defined anywhere.

void nmapwin_init();
void nmapwin_cleanup();
void nmapwin_list_interfaces();
int if2nameindex(int ifi);
2010-06-07 18:42:17 +00:00
luis
ac860ca961 Corrected trivial typo 2010-05-17 17:56:29 +00:00
david
5cf726d259 Fix up indentation in collect_dnet_interfaces. 2010-05-12 16:34:25 +00:00
fyodor
1aecac420f Update copyright year from 2009 to 2010 2010-05-03 21:20:25 +00:00
david
b7387894f5 Fix comment typos. 2010-04-30 18:14:52 +00:00
david
8bc5135d93 When iterating over the interface list on systems that have sa_len, only
allow the sa_len to increase the size of the current structure, not
decrease it below sizeof(struct ifreq). Doing it this way makes it work
on NetBSD. This technique more or less matches that used in Unix Network
Programming, 3rd Edition, section 17.6. The old implementation was
likely incorrect, though it happened to work on FreeBSD.
2010-03-26 22:11:30 +00:00
david
bc132b963c Make read_arp_reply_pcap work with a libpcap datalink type of
DLT_LINUX_SLL, as well as the DLT_EN10MB that was formerly supported.
This type is used on some interfaces where Linux doesn't reliably retain
the link-layer header, and when capturing on the "any" device. On such
interfaces, you would get the error

read_arp_reply_pcap called on interfaces that is datatype 113 rather than DLT_EN10MB (1)

For more on this datalink type, see

pcap-linktype(7)
http://wiki.wireshark.org/SLL

I tested this by hacking scan_engine.cc to use the "any" device:

--- scan_engine.cc      (revision 16972)
+++ scan_engine.cc      (working copy)
@@ -4882,7 +4882,7 @@
     }
   }

-  USI->pd = my_pcap_open_live(Targets[0]->deviceName(), 100,  (o.spoofsource)? 1 : 0, pcap_selectable_fd_valid()? 200 : 2);
+  USI->pd = my_pcap_open_live("any" /*Targets[0]->deviceName()*/, 100,  (o.spoofsource)? 1 : 0, pcap_selectable_fd_valid()? 200 : 2);
   if (USI->ping_scan_arp){
     /* Some OSs including Windows 7 and Solaris 10 have been seen to send their
        ARP replies to the broadcast address, not to the (unicast) address that

I had to use a newer version of libpcap from git. The 1.0.0 that we ship
has a bug that keeps "any" from working. You would get SIOCGIFHWADDR: No
such device.
2010-03-12 05:23:50 +00:00
david
d109ff13d8 Consider an address directly connected if the gateway of its matching routing
table is exactly the same as the address. This is how it appears to work on Mac
OS X. Now there are three ways for an address to be directly connected:

1. Gateway address is 0.0.0.0 (Linux).
2. Gateway address is the same as local interface address (Windows).
3. Gateway address is the same as the destination address (Mac OS X).
2010-03-12 00:45:11 +00:00
david
02b1a00bf9 Change the way route_dst works to allow static routes to override
interface addresses and netmasks.

Before, route_dst worked like this:
  1) Check destination address against all interfaces, with special-case
     handling for local addresses.
  2) Check destination address against routing table.

Now it works like this:
  1) Check destination address against local addresses.
  2) Check destination address against routing table.
  3) Check destination address against all interfaces.

This allows a routing table entry to override an interface, for example
in this configuration:

  ************************INTERFACES************************
  DEV  (SHORT) IP/MASK         TYPE     UP MAC
  eth0 (eth0)  192.168.0.21/24 ethernet up 00:00:00:00:00:00

  **************************ROUTES**************************
  DST/MASK       DEV  GATEWAY
  192.168.0.3/32 eth0 192.168.0.1
  192.168.0.0/24 eth0

192.168.0.3 will not be considered directly connected, but will have its
traffic routed through 192.168.0.1.

The logic for determining when an address is directly connected has
changed. Instead of considering an address directly connected whenever
it matches an interface netmask, we consider it so when the gateway
address is 0.0.0.0 or when the gateway address is exactly equal to the
interface address. The proper way to do this would be to look at the "G"
flag from the routing table, but libdnet doesn't retain that.
2010-03-11 20:04:21 +00:00
david
0f048bb0f4 Compare addresses if netmasks are equal in the qsort comparison function
for routes, to ensure that routes keep their same relative order. This
idea is from http://www.gnu.org/s/libc/manual/html_node/Array-Sort-Function.html.
2010-03-11 18:03:01 +00:00
david
48654df805 Switch to -sn and -Pn as the new preferred synonyms for -sP and -P0.
This establishes a more regular syntax for some options that disable
phases of a scan:
	-n  no reverse DNS
	-Pn no host discovery
	-sn no port scan
Also, the -sP was possibly misleading because the 'P' suggests "ping
scan," when you can now do more than just pinging when you disable port
scanning. For example, -sC -sn and -sn -Pn --traceroute make sense.
2010-03-11 01:16:06 +00:00
david
9a31e8b830 Change PacketTrace::traceArp not to take the Ethernet header. It wasn't
being used, and this leaves the door open for non-Ethernet encapsulation
of ARP packets, in particular the Linux "cooked" socket encapsulation
that can in some cases be used by libpcap.
2010-03-10 16:58:24 +00:00
kris
a42ea72a97 Merge through r16884 from /nmap-exp/kris/nse-rawip plus the following changelog
entries:

o [NSE] Raw packet sending at the IP layer is now supported, in addition to
  the Ethernet sending functionality.  Packets to send start with an IPv4
  header and can be sent to arbitrary hosts. [Kris]

o [NSE] Added the ipidseq script to classify a host's IP ID sequence numbers
  in the same way Nmap does.  This can be used to test hosts' suitability for
  Nmap's Idle Scan (-sI), i.e. check if a host is an idle zombie.  This is
  the first script to use the new raw IP sending functionality in NSE. [Kris]

o [NSE] Added the function nmap.is_privileged() to tell a script if, as far
  as Nmap's concerned, it can do privileged operations.  For instance, this
  can be used to see if a script should be able to open a raw socket or
  Ethernet interface. [Kris]

o [NSE] Added the function nmap.get_ports() to allow a script to iterate
  over a host's port tables matching a certain protocol and state. [Kris,
  Patrick]
2010-02-26 20:42:10 +00:00
david
f21a07cfde Revert r16464. 2010-01-15 03:55:23 +00:00
david
c73b250615 Factor out a function that reports the failure to open an Ethernet
device and exits. On Windows, print a hint about "net start npf" to
start the NPF service.
2010-01-15 00:37:39 +00:00
david
577fc127f7 Use socket_strerror, not plain strerror, to report the result of non-blocking
connections in tcpip.cc. socket_strerror works with Winsock error codes whereas
plain strerror returns "Unknown error".

However, the error string for what is probably the most common error code,
WSAEWOULDBLOCK, is the big ugly "A non-blocking socket operation could not be
completed immediately.". Add a special case to use "Operation now in progress"
for that specific error.
2010-01-13 19:22:41 +00:00