1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-14 11:49:01 +00:00
Commit Graph

49 Commits

Author SHA1 Message Date
henri
e2fb7301de Avoid sending error message to stdout 2012-10-10 18:59:13 +00:00
david
3e9f862ce3 Add nsock_setdevice function.
This function allows setting the device that will be used in
SO_BINDTODEVICE setsockopt calls for all new sockets.
2012-10-03 15:43:16 +00:00
david
2f2e826487 Remove OpenSSL directory, moved to /nmap-mswin32-aux. 2012-10-02 00:53:12 +00:00
henri
e60ba1b617 Use nse_errorcode() to get the actual errors. 2012-09-21 09:08:24 +00:00
henri
b4607a5071 Style fixes.
indent -nut -i2 -kr -br -brs -brf -l0 -bad -npcs -nprs -ncs <files> and manual adjustments.
2012-09-21 09:05:59 +00:00
david
7e5c9a8914 Regen with Autoconf 2.68 and aclocal 1.11.6.
for DIR in . nbase ncat nsock/src nping;
	do (echo $DIR; cd $DIR && aclocal --force && autoconf --force);
done
2012-09-19 16:41:35 +00:00
henri
a1d5763563 Fixed filename in header. 2012-09-10 21:03:17 +00:00
david
5ab8e37be6 Recognize WSAEADDRINUSE in handle_connect_result.
This happens on Windows when two sockets bind to the same local port and
connect to the same remote port on a remote host. I tried this on Linux;
Linux prevents the second bind from succeeding.

http://seclists.org/nmap-dev/2012/q2/513
2012-09-06 20:11:08 +00:00
david
66c296e27f Use socket_strerror in Nsock callback traces.
Otherwise WinSock error numbers are not understood; you get "Unknown
error" instead of "Only one usage of each socket address
(protocol/network address/port) is normally permitted." for example.
2012-09-06 20:11:04 +00:00
david
640714f63d Use a more sophisticated configure check for epoll.
This is from the GNU Autoconf archive.

http://www.gnu.org/software/autoconf-archive/ax_have_epoll.html

http://seclists.org/nmap-dev/2012/q3/598
http://seclists.org/nmap-dev/2012/q3/657
2012-09-02 22:47:09 +00:00
henri
89537773ce Removed extra '\n', another one being added by the function. 2012-07-30 19:54:11 +00:00
henri
a111b5bcdc [NSOCK] Sandwitched pcap_read_on_nonselect() statements between #ifndef
PCAP_CAN_DO_SELECT guards to prevent them from being executed on systems that
actually provide selectable pcap descriptors.
2012-07-17 16:38:15 +00:00
henri
a2f308a8f8 Removed duplicate declaration of a msiod *nsi variable.
It's used two times, in two separate blocks of the function. Therefore it was
declared twice (once per block), then got moved toplevel but the second
declaration was forgotten somehow.

This doesn't actually change anything (identical objdump -d diff) but makes code
nicer.
2012-07-13 21:18:03 +00:00
henri
87fcddad2b Fixed a couple nsock problems described in
http://seclists.org/nmap-dev/2012/q3/56.  r29134 already addressed the issue but
was incomplete.

This replaces r29134 with an engine-agnostic approach, and additionally enforces
the reset of IOD flags before use or re-use.
2012-07-09 16:45:49 +00:00
henri
9baacdf9e3 [NSOCK] Fixed an epoll-engine-specific bug. The engine didn't recognized FDs
that were internally closed and replaced by other ones. This happened during
reconnect attempts.

--

When reconnecting with SSL_OP_NO_SSLv2 (nsock_core.c:472), the libary closes the
fd of the current IOD, and replaces it by a new one.

The man page for epoll_ctl states that a close() on a fd makes it removed from
any epoll set it was in. Therefore, if epoll_ctl(EPOLL_CTL_MOD, ...) returns
ENOENT, we retry with EPOLL_CTL_ADD.
2012-07-05 14:35:51 +00:00
henri
d86d3f68c2 Made nsock messages more consistent.
- Always format function name without parens at the beginning of a message.
  - Added a nsi_new notification message.
  - Only trace the first call to nsi_delete() of a given IOD (i.e. don't log the
    calls issued from the resulting callbacks).
2012-07-05 14:22:26 +00:00
henri
f7ba1847cf Enforce proper variable initialization. 2012-07-03 12:19:24 +00:00
david
7f5d53184c Uniform handling of makefile.dep in makefiles.
"make clean" keeps makefile.dep and "make distclean" deletes it. This
patch is by Michael McTiernan.

http://seclists.org/nmap-dev/2012/q2/827
2012-06-19 14:06:49 +00:00
david
685f5fa4c3 Define SOLARIS_BPF_PCAP_CAPTURE for Solaris 11.
Solaris 11 uses BPF packet capture rather than DLPI, which requires
different handling in many cases. The new preprocessor symbol tells when
this is the case; it is additional granularity on top of SOLARIS.
2012-04-07 08:07:41 +00:00
david
05c713d22a Don't try to do FD_ISSET on a nonselectable pcap descriptor.
The Nsock select engine stores readiness information in a mask instead
of doing an FD_ISSET against the descriptor every time. This is a good
idea, but it removed a special case in the pre-engines code: in case
PCAP_CAN_DO_SELECT is not defined, we can't do FD_ISSET on the
descriptor because it is -1. Here we check for that occurrence and set
EV_READ in the mask so that a non-blocking pcap read can happen every
iteration.
2012-04-05 03:30:09 +00:00
david
4a541fc367 Add an assert that I am currently able to make fail. 2012-04-05 01:37:59 +00:00
david
b1583a66e6 Centralize nsock_tod updates in msevent_new.
This was being done manually for various types of events, and not doing
it in every case was causing hard-to-find bugs. See the log messages for
r19970 in /nsock and r28292 in /nmap.
2012-03-29 17:43:35 +00:00
david
9cd1ef697b Update nsock_tod before creating a timer.
nsock_tod is Nsock's idea of the current time. It is updated when an
nsock_pool is initialized, on each iteration of nsock_loop, and in a few
other places. What could go wrong, with respect to timers, is a sequence
like this:
	nsp_new
	[... some long delay ...]
	nsock_create_timer(timeout)
	nsock_loop
The time elapsed after the creatino of the timer until it fires would
not be timeout, but rather timeout - delay. If the delay was long
enough, the timer would fire as loop as nsock_loop was entered.

This showed itself in IPv6 OS detection. We schedule 6 timers
immediately, 100 ms apart. If the pcap_open or anything else took too
long, then the timers would fire all at once. This messed up the
calculation of the TCP_ISR feature.

Perhaps we should do this when any new event is created? It is already
done manually at the beginning of each of the connect functions.
2012-03-16 20:02:57 +00:00
henri
b1086ac340 Added a --nsock-engine option to nmap, nping and ncat to enforce use of a
given nsock IO engine. [Henri]
2012-03-01 09:05:02 +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
dbda99204b Extreme nitpicking: added missing closing parentheses in comments. 2012-02-23 18:22:37 +00:00
henri
889a4711ba Changed variable name from camel case to all lowercase for consistency with the naming convention. 2012-02-19 15:29:23 +00:00
henri
5f49844390 Simple comment fixes. 2012-02-02 09:52:19 +00:00
henri
2ff581affa Fixed event set masking, only ev_inc was modified. Error introduced in r27949.
This was noticed and fixed by Brian Gottreu.
2012-01-30 21:53:34 +00:00
henri
e1c71046fe Changed update_events() to make it directly filter out events that belong to
both event sets (events to add and events to remove).

This removes the need callers had to do that filtering, it is safer and makes code
easier to read and maintain.

This section of code is described in a nmap-dev thread, that led to the
development of this patch: http://seclists.org/nmap-dev/2012/q1/243
2012-01-29 15:30:59 +00:00
henri
9cf2fa8854 Apply the correct event type against evclr in X_EV. 2012-01-27 20:44:28 +00:00
henri
255c2a0a9b Fixed an assertion failure which could occur when connecting to an SSL server:
nsock_core.c:186: update_events: Assertion `(ev_inc & ev_dec) == 0' failed.

Thanks to Ron for reporting the bug and testing.
See: http://seclists.org/nmap-dev/2012/q1/235
2012-01-27 15:46:32 +00:00
henri
63f3fc4954 Fixed comments that referred to an incorrect location. 2012-01-26 09:25:05 +00:00
henri
10d1f17509 Fixed two minor typos that escaped previous checks. 2012-01-26 09:16:58 +00:00
henri
444667943f Fixed SVN properties for consistency, so that src files now have the following
ones:

  svn:keywords: Author Date Id Revision
  svn:eol-style: native
2012-01-26 09:10:18 +00:00
henri
9c7f72108b More code cleaning: whitespace and indentation fixes. 2012-01-20 08:26:14 +00:00
david
8dd5bc49ca Fold EACCES and WSAEACCES cases together.
Otherwise this causes a duplicate case error on Windows.
2012-01-20 02:28:44 +00:00
david
df3b01e5d8 Use the right errno in handle_connect_result catch-all assert.
We call getsockopt(SO_ERROR) to get the socket error, but then we were
calling perror, which uses the global errno instead.
2012-01-19 00:03:40 +00:00
david
47ee706a4a Handle EACCES in handle_connect_result.
This specific connect error is already handled by ultra_scan. A comment
there says it can result from ICMPv6 destination-unreachable
admin-prohibited messages.
2012-01-19 00:03:39 +00:00
henri
2cdd7e63f0 Minor wrapping and whitespace fixes. 2012-01-13 12:59:18 +00:00
henri
520ff94839 Fixed HAVE_PCAP=0 case. 2012-01-13 12:56:20 +00:00
henri
48fea78cb4 Fill epoll_event structures with zeros before use. 2012-01-11 11:17:58 +00:00
henri
d0a17f430f Fixed more typos. 2012-01-09 13:47:58 +00:00
henri
fe566432c7 Minor rewordings, fixed typos. 2012-01-09 13:33:38 +00:00
henri
42c7c15c3f Fixed typos. 2012-01-09 13:20:13 +00:00
henri
659ed2ac89 Check for the presence of EPOLLRDHUP in the nsock epoll(7)-based engine as this
flag isn't available on every epoll-compatible systems.
2012-01-08 20:17:38 +00:00
henri
856cd00a17 Merged nsock-engines from nmap-exp. This rewrite of the nsock library adds
support for system-specific scalable IO notification facilities without breaking
portability. This initial version comes with an epoll(7)-based engine for Linux
and a select(2)-based fallback engine for all other operating systems.

This required an important refactoring of the library but the external API was
preserved.

The rewrite also tries to bring the coding standards of nmap to nsock.

See http://labs.unix-junkies.org/nsock_engines.html for the details.
2012-01-05 01:08:16 +00:00
henri
15f74d395f Fix pcap_gc() crash after failed attempts to open pcap readers from NSE. Patch
by Djalal.

See http://seclists.org/nmap-dev/2012/q1/43
2012-01-05 00:44:48 +00:00
david
ed2ba4e168 Copy nping, nsock, nbase, zenmap, ncat from their homes in /.
If you have trouble updating after this revision you need to follow
these instructions. You have probably just seen an error like this:

svn: URL 'svn://svn.insecure.org/nping' of existing directory 'nping'
does not match expected URL 'svn://svn.insecure.org/nmap/nping'

This is caused by the replacement of SVN externals.

Here's what you need to do. First, save any local changes you might have
in the nping, nsock, nbase, ncat, and zenmap directories. (For example
by running "cd nping; svn diff > ../nping.diff".) If you don't have any
local changes you can skip this step.

Then run these commands:

rm -rf nping/ nsock/ nbase/ ncat/ zenmap/
svn update
svn cleanup

If all else fails, you can just delete your whole working directory and
check out anew:

svn co --username guest --password "" svn://svn.insecure.org/nmap

There may be further discussion in the mailing list thread at
http://seclists.org/nmap-dev/2011/q4/303.
2011-11-16 21:49:44 +00:00