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

343 Commits

Author SHA1 Message Date
dmiller
5b52e7a3f2 Build fixes 2025-04-10 19:24:22 +00:00
dmiller
5f6bc69983 Account for VLAN header in pcap packets if needed. 2025-04-10 19:00:50 +00:00
dmiller
6db5c9cb85 Bump copyright date 2025-02-26 17:44:43 +00:00
dmiller
4f712b76a3 Avoid printing (null):-1 for STDIN in Nsock debug output 2024-12-09 20:03:48 +00:00
dmiller
8bb1334a87 Avoid printing junk timeouts in Nsock debug output 2024-12-06 20:44:28 +00:00
dmiller
92d5b6a310 Correctly process satisfied request from pending SSL data 2024-11-25 22:09:08 +00:00
dmiller
1264a6e472 Increment first, then decrement; avoid clearing desired bit 2024-11-25 22:09:07 +00:00
dmiller
3a0db5dc51 Try an SSL_read() immediately to get the correct ssl_desire 2024-11-21 20:11:38 +00:00
dmiller
38823b5cd1 Handle SSL_read()/SSL_write() returning 0 when not EOF.
OpenSSL docs say, "Old documentation indicated a difference between 0
and -1, and that -1 was retryable. You should instead call
SSL_get_error() to find out if it's retryable."
2024-11-21 20:11:38 +00:00
dmiller
ff1df7a80c Zero IOD in nsock_iod_new2. Was reusing old peer info 2024-11-18 23:02:48 +00:00
dmiller
4efe456e0b Nsock iocp: pass immediate errors on to process_event() 2024-11-18 21:19:46 +00:00
dmiller
b1f6f9b088 Track EOF at IOD level also 2024-11-18 20:26:28 +00:00
dmiller
1f6e8d9fe3 Handle EWOULDBLOCK as well as EAGAIN 2024-11-18 20:26:27 +00:00
dmiller
cffc94e845 Consolidate event list management to nevent_unref()
Removes duplicate logic for PCAP_BSD_SELECT_HACK. May address accounting
problems that led to issues like #187 (macOS) and #2912 (Windows).
2024-11-13 19:15:12 +00:00
dmiller
222add87a6 Paranoid gh_list check: node is in list before removal 2024-11-13 19:15:11 +00:00
dmiller
3f64103cf0 Move some prototypes to nsock_internal.h 2024-11-13 19:15:10 +00:00
dmiller
379b56b582 Include timeout info in debug output for all nsock reads/connects 2024-11-12 20:05:56 +00:00
dmiller
1e8c1ab3cd Let all nsock engines use STDIN on Windows! 2024-11-06 16:48:29 +00:00
dmiller
635cc50011 Nsock iocp: fix IPv6 connect 2024-11-06 16:06:32 +00:00
dmiller
411b186576 Simplify nevent_delete for PCAP_BSD_SELECT_HACK mode 2024-11-01 18:40:09 +00:00
dmiller
2ca95ad6b4 Nsock select engine: don't process if sd is -1 (nonselectable) 2024-11-01 18:40:08 +00:00
dmiller
931c13cd21 Fixes for IOCP engine build 2024-10-15 20:37:11 +00:00
dmiller
7703b045e5 Nsock poll engine: efficient use of pollfds array
Using socket descriptor as an index works okay for UNIX, though it
wastes the first several indices which are assigned to STDIN/STDOUT,
files, etc. However, for Windows it is really bad, since descriptors are
large, nonconsecutive numbers. Using a little overhead to track each
iod's index and the next empty space is worth it.
2024-10-11 20:59:35 +00:00
dmiller
b94ae785ba Fix handling of non-select()-able pcap handles
1. pcap_get_selectable_fd() may return -1 for some devices, even if the
   platform as a whole supports select() on these handles. Check for
   this condition throughout.
2. The various backend system calls (kevent, poll, epoll, etc.) do not
   sleep for the timeout period if no valid handles are registered,
   unlike select on UNIX. This leads to busy wait, looping continuously.
   Instead, we call usleep() in those cases.
2024-10-11 20:59:34 +00:00
dmiller
6186767cd1 Move a useful function to nsock_core.c 2024-10-11 20:59:33 +00:00
dmiller
532938f49c Do a non-blocking check for events when pcap data is available
For platforms without selectable pcap handles (e.g. Windows), the
arrival of data for a pcap read would previously skip checking for any
triggered non-pcap events in that loop iteration. This is not usually a
problem because the next loop will be triggered immediately, picking up
the non-pcap events before any further pcap data arrives. However,
excessive pcap data on a handle in immediate mode might prevent the
engine loop from checking for non-pcap events for long enough to result
in timeouts. Instead, do a non-blocking check for triggered events in
this case and handle those in the same loop iteration.
2024-10-09 17:40:10 +00:00
dmiller
167fafe65c Correctly handle all cases for canceling IO in iocp engine 2024-10-08 21:14:43 +00:00
dmiller
f765af4070 IOCP engine: further checks against duplicating eovs 2024-10-08 21:14:42 +00:00
dmiller
30bc184e0f Fix iocp engine when calling nsock_read on unconnected socket
When the IOD isn't connected, iod->peerlen is 0, which means WSARecvFrom
returns WSAEFAULT because the lpFrom parameter is not NULL, and 0 bytes
is not enough space to fit any sockaddr.
2024-10-08 21:14:42 +00:00
dmiller
cb483ec503 Properly handle SSL connect events. Fixes #2139
SSL_WANT_READ and SSL_WANT_WRITE conditions modify the watched events during
NSE_TYPE_CONNECT_SSL, which was causing the IOCP engine to re-post the same
completion packet multiple times. Adding a status field to the
extended_overlapped struct resolves this.

Additionally, canceled and timed-out events risked the same extended_overlapped
being freed multiple times, which caused the gh_heap corruption in the original
issue report.
2024-10-07 18:30:28 +00:00
dmiller
a86e86913b Ensure events are updated if SSL connect times out 2024-10-06 22:19:30 +00:00
dmiller
dde9c509ed Allow nsock_iod_get_communication_info() to get latest UDP peer 2024-07-01 16:17:42 +00:00
dmiller
dcb4ba569e Avoid multiple expansions of TIMEVAL_MSEC_SUBTRACT macro within MAX macro 2024-06-27 19:36:04 +00:00
dmiller
98c6ec85af Don't test for SSL_set_alpn_protos, present in all supported OpenSSL versions 2024-04-02 21:32:24 +00:00
dmiller
ba26cc78f2 Replace check for DTLS_client_method with OPENSSL_NO_DTLS 2024-04-02 21:32:23 +00:00
dmiller
c1c9fcca4a Avoid checking for SSL_set_tlsext_host_name, present in all supported OpenSSL versions 2024-04-02 21:32:22 +00:00
dmiller
f999182d0f Bump date and reapply header templates 2024-02-28 18:46:45 +00:00
dmiller
0876310c2a Fix leaking compiled pcap filter. Fixes #2609 2023-08-23 15:07:56 +00:00
dmiller
6f6b2de214 Apply new license templates, bump copyright date 2023-04-14 17:11:46 +00:00
dmiller
9d0e5ac2b9 Avoid warning about missing legacy provider unless debugging. Fixes #2532 2022-09-29 22:19:27 +00:00
dmiller
a3fb546708 Fix proxy parsing to fail on empty string. Fixes #177 2022-09-20 23:37:29 +00:00
dmiller
0afb05b155 Add tests for nsock proxy parsing 2022-09-20 23:37:28 +00:00
dmiller
7eda670f4b Fix socks4 proxy parsing when target resolves to IPv6 2022-09-20 23:37:28 +00:00
dmiller
c236ade401 Increase stress level of tests for nsock 2022-09-20 23:37:26 +00:00
dmiller
d6bea8dcde Build based on OpenSSL version, not API level. Fixes #2516 2022-09-06 22:39:34 +00:00
dmiller
1f50e82dd2 Fix a preprocessor condition 2022-08-25 22:32:35 +00:00
dmiller
d43df98ab1 Nsock: Use separate SSL_CTX for SSL vs DTLS 2022-08-25 16:29:49 +00:00
dmiller
49005f99a2 Clarify Nsock SSL cleanup state. 2022-08-25 16:29:48 +00:00
dmiller
5f88cbac30 Avoid double-free of SSL_CTX in some cases. See #2482 2022-08-25 15:38:31 +00:00
dmiller
140dd72415 Fix build with OpenSSL 3.0
Updated all OpenSSL code to OpenSSL 3.0 API with no deprecated functions. Some
NSE functions were changed:
* openssl.rc4_options and openssl.rc4 were removed in favor of openssl.encrypt
* openssl.bignum_pseudo_rand is now an alias for openssl.bignum_rand
* openssl.bignum_is_prime and openssl.bignum_is_safe_prime will now ignore the
  nchecks parameter, using a secure default instead.
2022-08-25 14:51:59 +00:00