1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-07 13:11:28 +00:00
Commit Graph

407 Commits

Author SHA1 Message Date
david
223d45c435 Isolate the test for valid encapsulated ICMPv6 data to those protocols
that need it.

We need to accept invalid encapsulated data for protocol scan responses.
2011-06-14 19:46:51 +00:00
david
a67eca0555 Allow sending -6 -sO probes. 2011-06-14 19:46:48 +00:00
david
af7da5f72d Don't consider any more probes after finding one of our own to localhost.
There is a special test that uses IP IDs to check if a presumed reply
from localhost is actually one of our own probes. However the test
didn't bail out ofter finding one of these matches, so a retransmission
(with a different IP ID) could match and look like a protocol reply from
localhost.
2011-06-14 19:46:47 +00:00
david
0793852c90 Fix the setting of ipid in setIP. 2011-06-14 19:46:44 +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
colin
5d3e0e688c Portreasons Restructuring. icmpt_to_reason added. 2011-05-26 19:46:29 +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
523c4f7104 Remove -sR o.rpcscan handling; make -sR an alias for -sV. 2011-03-12 18:20:09 +00:00
fyodor
86e59a8c4e Update copyright statements from 2010 to 2011 2011-01-21 00:04:16 +00:00
david
c822f62d84 Typo fix. 2010-12-03 21:29:59 +00:00
david
7653cf7d4a Move COPYING.OpenSSL to OpenSSL.txt, update copyright notices to match. 2010-10-30 03:01:50 +00:00
kris
380cfaba2c For generating ICMP IDs to send, use modulus and addition on a single random
number to guarantee it's nonzero (which some target hosts require) rather
than looping for new random numbers.  

* ICMP ID values are unimportant, as long as they are nonzero
* The original code to get random numbers was exactly duplicated (new variable,
  comment, loop, even whitespace) in the same function, so using a single
  variable set initially (albeit differently) simplifies duplication
2010-10-01 22:45:23 +00:00
david
fc9d35fed9 Add a symbolic constant for INITIAL_ARP_RTT_TIMEOUT. 2010-09-17 16:46:09 +00:00
david
c8106e0ef3 Let --min-rtt-timeout be a lower bound on the initial timeout for ARP
scan. ARP scan had a hardcoded initial timeout of 100 ms, which could be
lower than the minimum requested. The default minimum timeout is also
100 ms, so this has no effect if --min-rtt-timeout is not used.
2010-09-17 16:35:01 +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
david
852ad9440d Improve indentation and comments in init_socket. 2010-08-11 14:39:42 +00:00
david
c78dcce4d3 Move init_socket from nmap.cc to scan_engine.cc, because it is only used
in the latter file.
2010-08-11 14:34:54 +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
fyodor
6ac6e2fad5 loosen the requirements for a split-handshake syn detection to allow the likes of SYN|PSH. See this thread: http://seclists.org/nmap-dev/2010/q2/739 2010-06-11 06:17:52 +00:00
jah
a17609e6b4 Ports are now considered open during a SYN scan if a SYN packet (without the ACK
flag) is received in response. This can be due to an extremely rare TCP feature
known as a simultaneous open or split handshake connection.
see http://nmap.org/misc/split-handshake.pdf
Added a reason code: ER_SYN and associated reason string: "split-handshake-syn".
2010-06-08 01:50:45 +00:00
david
994da96f9c Merge Jay Fink's patch that puts UDP payloads in an external data file
instead of being hard-coded in payloads.cc. This is the patch from
http://seclists.org/nmap-dev/2010/q2/497.
2010-05-25 17:38:23 +00:00
kris
0be83cf063 Move around a few gettimeofday() calls, including where port scan timing
comparisons would be affected by debugging level:

http://seclists.org/nmap-dev/2010/q2/373
2010-05-11 03:22:42 +00:00
kris
0cf74cdfdd comment fix 2010-05-04 04:32:12 +00:00
fyodor
1aecac420f Update copyright year from 2009 to 2010 2010-05-03 21:20:25 +00:00
david
e72ecb11ac Fix spelling neccessary -> necessary. 2010-03-20 03:59:31 +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
david
9fee7968f9 Make a slight change to the order in which ping probes are sent to match
research. -PY should come after, not before -PU. -PM should be the last
one.
2010-03-05 19:45:58 +00:00
david
549dc85ad3 Change PortList::getPortState to return the default port state if the
port is unknown, instead of -1. This makes it a better fit with the
other accessor functions. For those callers that need to know whether a
port is in the default state or not, add PortList::portIsDefault.

Having getPortState return -1 for ports in the default state would cause
the slightly wrong

Discovered unknown port 88/udp on 192.168.0.190 is actually open

to be printed instead of

Discovered open|filtered port 88/udp on 192.168.0.190 is actually open
2010-01-26 20:46:26 +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
735c767a71 Set the reason_id to no-response when probes time out during ping scan.
This was mistakenly removed in the merge from nmap-mem.
2009-12-21 19:57:00 +00:00
david
7db7da0007 Merge again from /nmap-exp/david/nmap-mem; this fixes a couple of bugs. 2009-12-20 03:22:19 +00:00
david
1c6030709b Revert r16307:16309, the merge from nmap-mem. I just found a
segmentation fault which I am investigating.
2009-12-19 22:49:16 +00:00
david
b838242e01 Merge from /nmap-exp/david/nmap-mem. This brings in two memory-reducing
changes. The first is that Port objects don't allocate memory for
service and RPC results unless that information is set. This reduces the
size of a bare Port from 92 to 40 bytes on my machine. The second change
is that PortList now has the notion of a "default port state," which is
the state of any ports that didn't receive a response. These ports don't
need an allocated Port object, which saves a lot of memory in scans
where most ports didn't get a response.
2009-12-19 21:26:14 +00:00
david
e2315ae075 Remove the unused Port::owner member. 2009-11-20 20:17:33 +00:00
david
3c0a38d281 Print the "Warning: giving up on port because retransmission cap hit"
message once per host, not one per hostgroup. Include the IP address and
tryno in the message. It now looks like

Warning: 64.13.134.52 giving up on port because retransmission cap hit (0).

This was suggested by Chris Clements.
2009-11-16 17:33:12 +00:00
david
e22ebd5580 Reset ss.numqueries_outstanding to 0 when giving up on an RPC port
because of a lack of responses. Otherwise there is no way for that
number to decrease after moving on to the next port, leading to an
infinite loop. Lionel Cons reported the problem and provided a debug log
at http://seclists.org/nmap-dev/2009/q4/364.
2009-11-11 17:49:31 +00:00
david
b0976983bc Remove the allow_ipid_match checking from scan_engine.cc. This was a
test that was applied to packets returned in ICMP error messages.
Because some operating systems modify the IP ID outside of Nmap's
control, the apply_ipid_match function had a built-in heuristic whereby
it would deactivate itself (always return true) if this seemed to be
happening. What this meant in practice was that every time a successful
match was made, a counter was incremented, and if the ratio of
successful matches to successful matches was over 80%, IP ID matching
was enforced.

The matching and heuristic could cause relevant probes to be dropped in
some cases. See http://seclists.org/nmap-dev/2009/q2/665 for an example
of this and discussion. The IP ID match was always done in combination
with other tests; so even without it we are still dealing with a
relevant probe. The IP ID distinction could at best distinguish between
retransmissions of the same probe, and it was not necessary for that in
every case, such as with most TCP probes where we can use the SEQ field.
I thought this small benefit was not worth the risk of potentially
losing replies that we care about.
2009-11-05 02:19:19 +00:00
david
2db9068013 Combine some common tests. 2009-11-04 22:29:32 +00:00
david
5cc0f838b2 Add SCTP vtag matching for ping probe replies too. 2009-11-04 22:16:13 +00:00
david
a38d7db2cf Merge r15998 from /nmap-exp/david/nmap-token, SCTP vtag matching. 2009-11-04 22:12:27 +00:00
david
8f6485bbcc Combine a lot of similar loops in the matching of ICMP replies for ping
probes, the same way as is done for normal probes.
2009-11-04 22:09:55 +00:00
david
7399cd7fec Do the same thing as r16000 (IP ID matching only after other tests pass)
for ping probe replies too.
2009-11-04 21:37:02 +00:00
david
af8f151972 Move the IP ID test after the tests for source ports, etc., because
every false attempt degrades the IP ID filter. We only want to to call
it when we're pretty sure we have a match.
2009-11-04 21:33:53 +00:00
david
1a87380b44 Merge the difference between this branch at r15954 and
/nmap-exp/david/nmap-token. This brings in the following changes:

Use a strict tryno equality test in check_tryno_pingseq. This appears to
have no effect in the current code, because the way we traverse the
probe list backwards ensures that probes with a higher tryno are tried
first. However this protects against matching the wrong tryno if that
behavior is ever changed.

Factor out the code that checks for a match of a TCP packet.

Add some extra checks when matching up TCP probes, to avoid confusing
responses to SYN and ACK probes when they are sent to the same host on
the same port, with the same tryno and pingseq, in a ping scan that
includes both -PS and -PA. I think this is the only case where there can
be confusion. The new rules are: A SYN/ACK can only be matched to a SYN
probe. A RST/ACK can only be matched to a SYN or FIN. A bare RST cannot
be matched to a SYN or FIN.

Make an important change in the way the tryno and pingseq are encoded
for TCP probes with the ACK flag set when --source-port is in effect.
According to RFC 793, responses to ACK packets on an unestablished
connection (CLOSED and LISTEN states in particular) should send a RST
response with a SEQ value the same as the received ACK value. So for
example, if it's in the CLOSED state and wants to send a RST, it sends
        <SEQ=0><ACK=SEG.SEQ+SEG.LEN><CTL=RST,ACK>
if the received packet does not have the ACK flag set, but
        <SEQ=SEG.ACK><CTL=RST>

This caused a problem because in the second case, the response does not
reflect our sent SEQ value, which is where the tryno and pingseq are
encoded. The response's acknowledgement number, while not valid because
the ACK flag is not set, is typically 0. Decoding this with seq32_decode
would result in a decoding error, leading to a
        Bad Sequence number from host
message. In this case the probe was allowed to match any TCP probe with
the same ports and address, even though the pingseq and tryno might be
off or the probe is a different kind of probe entirely (like a SYN
probe).

Here's a summary of what has changed, with <tryno,pingseq> standing for
an encoded tryno and pingseq.
Before:
        Non-ACK probes sent with SEQ=<tryno,pingseq>, ACK=0.
        ACK probes sent with SEQ=<tryno,pingseq>, ACK=random
        Probes matched against ACK and ACK - 1.
Now:
        Non-ACK probes sent with SEQ=<tryno,pingseq>, ACK=0.
        ACK probes sent with SEQ=0, ACK=<tryno,pingseq>.
        Probes matched against ACK, ACK - 1, and SEQ.

Matching against the SEQ field may also help in some other weird cases.
In the LISTEN state, the receiving TCP is supposed to check that "the
security/compartment on the incoming segment does not exactly match the
security/compartment in the TCB," and if it doesn't, return
        <SEQ=SEG.ACK><CTL=RST>
just like in the ACK case. I don't know how common that sort of thing is.
2009-11-04 01:52:59 +00:00
david
18fb4bdf64 Tiny whitespace changes. 2009-10-14 16:07:47 +00:00
david
e7afd943f0 Remove the ununsed UltraProbe::internalProbe member. 2009-10-02 22:52:10 +00:00
batrick
9044a42c6b Fixed a format specifier warning (expected "long unsigned int"). 2009-08-29 01:14:33 +00:00
luis
a5ca31db9e Replaced nmap's hex dump functions with new hexdump() included in nbase. Before
Nmap used two functions: one of them, hdump(), just printed raw hex bytes 
(no ASCII equivalents) and the other one, lamont_hdump() had a bug when 
printing buffers where bufflen%16==3. A new function has been implemented 
from scratch, that basically produces the same output as Wireshark. 
Output looks like this:

0000   e8 60 65 86 d7 86 6d 30  35 97 54 87 ff 67 05 9e  .`e...m05.T..g..
0010   07 5a 98 c0 ea ad 50 d2  62 4f 7b ff e1 34 f8 fc  .Z....P.bO{..4..
0020   c4 84 0a 6a 39 ad 3c 10  63 b2 22 c4 24 40 f4 b1  ...j9.<.c.".$@..

Changes:

- The new hexdump() function has been added to nbase.
- Old hdump() and lamont_dump() have been removed from nmap's code.
- A wrapper to the new hexdump(), called nmap_hexdump(), has been added
  to nmap's utils.cc. The wrapper basically prints the buffer returned 
  by hexdump() using nmap's log_write() function.
2009-08-25 18:09:19 +00:00