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

344 Commits

Author SHA1 Message Date
d33tah
6355a1bebe Revert my unfinished refactoring commit I pushed by mistake. 2014-07-23 14:43:12 +00:00
d33tah
308d924415 Remove an unneeded duplicate variable assignment. 2014-07-23 14:37:16 +00:00
dmiller
5ce61b556e Make a more descriptive error when raw sockets fail.
Doesn't happen often, but as the message says, certain Solaris zones can
cause problems here. This message is more informative than the previous
"socket troubles in Init"
2014-07-11 04:00:26 +00:00
dmiller
e603da4a4f Remove some minor changes to timing updates in connect scans
This change restores the control flow of handling connect() return and
error values. This shouldn't result in any real changes, but makes it
simpler to see the differences introduced in r33185.
2014-07-10 14:21:30 +00:00
dmiller
12004b5d41 Detect self-connected TCP connect probes
Recent discussion here: http://seclists.org/nmap-dev/2014/q1/136
2014-07-08 16:09:15 +00:00
dmiller
567e344ad7 Fix assertion failure in do_one_select_round
Since the refactor in r33185, getting a good response for a host during
a ping scan can remove all outstanding probes for that host, since we
already know the host is up. This broke the existing iteration in some
cases. I could force the crash with: nmap -sn -PS80-89 scanme.nmap.org

Now we check explicitly for an empty list each time through the loop.
2014-07-08 15:17:12 +00:00
dmiller
65c50eb695 re-apply r33185
Consolidate connect-scan status and errno checking

    Previously, the return value and socket errors from the connect() call
    were checked in two different places: immediately after the call, and
    then later as the sockets were select()ed over. This led to a divergence
    of logic, so the immediate checking failed to set state reasons or
    contribute to timing. This commit puts all such checking into a single
    function, handleConnectResult, so further improvements will not diverge
    again.
2014-07-08 15:17:10 +00:00
d33tah
2cc8da210a Revert "Consolidate connect-scan status and errno checking". 2014-07-08 14:23:51 +00:00
dmiller
ae4cae1c6e Consolidate connect-scan status and errno checking
Previously, the return value and socket errors from the connect() call
were checked in two different places: immediately after the call, and
then later as the sockets were select()ed over. This led to a divergence
of logic, so the immediate checking failed to set state reasons or
contribute to timing. This commit puts all such checking into a single
function, handleConnectResult, so further improvements will not diverge
again.
2014-07-08 02:59:15 +00:00
dmiller
cfd1c5fe65 Set reasons when connect() comes back immediately
In sendConnectScanProbe, the usual method is to start a non-blocking
connect() and then do select() on the sockets until we get a result. On
some platforms and in some circumstances, connect() either blocks or
comes back immediately. We handled this by setting the port state
appropriately, but we didn't set the reason, yielding results like "Host
is up, received no-response" and "80/tcp  open  http  no-response"
2014-07-02 15:35:12 +00:00
d33tah
a80c90608c sed -i 's/if ( /if (/g' *.cc *.h; sed -i 's/for ( /for (/g' *.cc *.h; sed -i 's/( /(/g' nmap_amigaos.h tcpip.h service_scan.cc
There's still quite a lot of code like this, nse_openssl.cc being most
messy IMHO. Also, I left out "if( something )" syntax.
2014-06-25 15:40:54 +00:00
d33tah
421176fc00 Get rid of double newline at the EOF I accidentally introduced in the
last commit.
2014-06-18 11:30:02 +00:00
d33tah
e3d1c178e3 Add newlines at the EOF in conformance to Daniel's coding standards
proposal. This only affects Nmap's root directory. We might also need to
modify the code which autogenerates Nmap's source code files such as IPv6
fingerprinting code.
2014-06-18 10:18:58 +00:00
jay
b6a994ea40 Correct the Target MAC Address in Nmap's ARP discovery to conform to what IP stacks in currently popular operating systems use. 2014-05-31 11:03:44 +00:00
dmiller
b5e53fc1d8 Silence libc++ warnings, via Olli Hauer 2014-04-17 21:58:39 +00:00
dmiller
3f0d0c16f9 Spellcheck on Nmap, Nsock, Nbase source files 2014-02-20 18:44:12 +00:00
dmiller
c9714990c7 Remove trailing whitespace from C/C++ files
https://secwiki.org/w/Nmap/Code_Standards
2014-02-12 20:25:51 +00:00
henri
64fb5b3482 Added safe fd_set operations.
Only FD_SET and FD_CLR were available. Added a FD_ISSET equivalent.
Implemented them as static inline instead of macros for consistency.

These functions abort() if the FD number is higher than FD_SETSIZE
(except on windows where no check is performed).
2014-01-30 19:02:57 +00:00
d33tah
e35d0a0c23 Add a comment to explain numIncompleteHostsLessThan. 2014-01-27 00:44:16 +00:00
d33tah
4816358475 Replace all tab characters at the beginnings of lines with 8 spaces.
Mixed indentation annoyed my vim.
2014-01-05 19:14:26 +00:00
d33tah
36fc84ab31 Fix coding style - only run begin_sniffer in case of a raw scan. 2013-12-30 18:56:43 +00:00
dmiller
228f0bec77 Fix ICMPv6 assertion failure: http://seclists.org/nmap-dev/2013/q4/290 2013-12-17 14:10:49 +00:00
dmiller
26665465c6 Refactor ftp bounce scan into nmap_ftp.{h,cc}
By factoring this code out, we make it easier to convert to NSE.
http://seclists.org/nmap-dev/2013/q4/255
2013-12-11 02:23:58 +00:00
jah
d0a95fe03e determineScanGroupSize could cause a higher number of randomly generated hosts
to be scanned than was requested with -iR N (for 0 < N < 16) because it didn't
account for max_ips_to_scan.
2013-11-26 00:11:09 +00:00
dmiller
ff7a0ea10d Avoid runtime undefinedness due to integer overflow
Using TIMEVAL_MSEC_SUBTRACT can lead to integer overflow when the times
are far apart (such as epoch (0) or uninitialized timeval and "now").
Instead, calculate the "deadline" and use TIMEVAL_AFTER to test.
2013-11-25 18:35:48 +00:00
dmiller
c1c659568e Fix divide-by-zero in scan_engine.cc 2013-11-21 23:30:03 +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
262c147308 Match icmpid in icmp_probe_match.
Remainder of Chris Johnson's patch from
http://seclists.org/nmap-dev/2013/q3/296.

Previously, Nmap could match replies that came in response to an
original probe, with one of the retransmissions of the probe. One effect
was that latency would be measured to be smaller than it should. Chris
Johnson summarized the problem and showed how to reproduce it at
http://seclists.org/nmap-dev/2013/q3/113.
2013-08-17 02:18:09 +00:00
david
4b47eae996 Store ICMP ID in ICMP probes.
Part of Chris Johnson's patch from
http://seclists.org/nmap-dev/2013/q3/296.
2013-08-17 02:18:07 +00:00
david
f49e3435f8 Factor out icmp_probe_match.
Part of Chris Johnson's patch from
http://seclists.org/nmap-dev/2013/q3/296.
2013-08-17 02:18:05 +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
5ab1b23bf0 Fix address matching in -PY ping.
Patch by Marin Maržić.
http://seclists.org/nmap-dev/2013/q2/297
2013-05-17 07:56:51 +00:00
dmiller
43f5db6ce4 Handle ICMP Time Exceeded messages in scan engine
DiabloHorn on #nmap noticed that Nmap was ignoring ICMP Time Exceeded
messages while trying to map firewall rules using --ttl.
get_pcap_result() was handling ICMP type 3 (Destination Unreachable),
but not type 11 (Time Exceeded). Now ports that elicit this response
will be marked filtered (to be consistent with existing Connect scan
behavior) and will report time-exceeded from (IP) for the reason.

This was not a common issue, since host discovery already accounted for
it. Port scans would only be affected when skipping host discovery.
2013-03-28 21:11:45 +00:00
david
785855e3ac Limit maxSocketsAllowed to FD_SETSIZE.
At high scan rates, there was nothing to prevent trying to set or clear
socket descriptors above FD_SETSIZE, which is usually around 1024. I got
a reliable assertion failures with the command
	nmap -sT -p- --min-rate 100000 scanme.nmap.org
The problem only affected -sT scans. A similar protection was added to
Nsock in r15808.
2013-02-22 01:14:32 +00:00
david
630a6db051 Break up the maxSocketsAllowed assignment. 2013-02-22 01:14:32 +00:00
david
719017b003 Use CHECKED_FD_SET and CHECKED_FD_CLR in ultra_scan. 2013-02-22 00:45:58 +00:00
david
fd7cabf7db Remove some old Linux compatibility code from connect scan.
This code was quite old (dating from r854 in 2000) and may not serve a
purpose anymore. Let's try removing it.

Apart from being obsolete, the code had a race condition where the
connection could be closed with a RST before getpeername was called,
leading to a fatal error message.
2013-02-05 04:55:29 +00:00
david
51c7dc5b7f Increase the number of slack file descriptors in connect scan. 2013-01-21 04:36:03 +00:00
david
2a1abf7b84 Make some return values less confusing. 2013-01-20 12:12:29 +00:00
david
b1c4f7f012 Localize struct pingtech in scan_engine.cc. 2013-01-18 00:33:03 +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
7b18ea1bc0 Move win32_fatal_raw_sockets out of nmap_raw_socket.
For the same reason and with the same exception (nse_dnet.cc) as in
r30159.
2012-10-31 17:00:55 +00:00
david
03946ba2f5 Return -1 instead of calling pfatal in nmap_raw_socket.
There was one case where we previously didn't fatal, in nse_dnet.cc.
Move the fatal calls out of nmap_raw_socket and into the calling scope,
with the exception of the one in nse_dnet.cc.

The problem was reported by Rob Nicholls.
http://seclists.org/nmap-dev/2012/q4/186
2012-10-31 16:09:47 +00:00
david
03d4b03d2c Get rid of "using namespace std".
Importing the whole std namespace caused a problem with Clang and the
punning of bind and std::bind.

http://seclists.org/nmap-dev/2012/q4/58

The Web's opinion of "using namespace std" also seems to be more against
than for.
2012-10-11 04:45:50 +00:00
david
c5faae4b26 Call socket_bindtodevice for -sT scan. 2012-10-03 15:43:24 +00:00
david
a53e00afa1 Factor out an nmap_raw_socket function.
This does the common setup of a raw socket that we use everywhere.
2012-10-03 15:43:21 +00:00
david
832f815d33 Use smartly chosen destination ports instead of o.magic_port in -sO.
Using o.magic_port, which is usually used for our source address, or
otherwise is somewhat randomly generated, doesn't make sense here.
Instead, use the same destination ports that we use for host discovery:
80 for TCP and SCTP, and 40125 for UDP.

http://seclists.org/nmap-dev/2012/q3/663
2012-09-02 22:47:45 +00:00
david
f45f2f394e Ignore supposed replies with nonsense pingseq/tryno.
If we get a reply that doesn't pass the simple comparison using the
current value of USI->seqmask, then ignore it. Previously we emitted the
message "Bad Sequence number from host %s.\n" and allowed the reply to
match any probe. This only matters when using -g because otherwise we
encode that information in the source port. I think we have addressed
what was mentioned in the TODO comment in r15986. Allowing promiscuous
matching, as was done before, causes the same spurious closed port issue
that was addressed in r29686.
2012-08-28 14:29:23 +00:00