1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-03 13:19:04 +00:00
Commit Graph

394 Commits

Author SHA1 Message Date
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
d42dd7eed9 Additional tests and checks for gh_heap validity 2024-10-08 21:14:41 +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
9fc9e6e081 Fix a typo in nsock tests 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
ed5fb3e248 Restore HAVE_OPENSSL definition for nsock on Windows, previously removed from nbase 2024-04-02 21:32:21 +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
758b6d1792 Remove unimplemented function prototype 2022-09-21 01:53:19 +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
1bc5302911 Restore log handler after log tests 2022-09-20 23:37:27 +00:00
dmiller
c236ade401 Increase stress level of tests for nsock 2022-09-20 23:37:26 +00:00
dmiller
e9f3b12e07 Move a useful function to nbase 2022-09-20 23:37:25 +00:00
dmiller
5ae6b75bf4 Note correct order of nsock function calls for proxychains. Fixes #176 2022-09-20 23:37:25 +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
dmiller
2f6be3a30b Remove incorrect recvfrom: unread data is lost per MS docs 2022-08-15 16:23:36 +00:00
dmiller
9a1ba979b0 Ensure gh_heap node addresses are NULL when invalid. 2022-07-29 15:21:14 +00:00
dmiller
1c9e1ddbcb Improve assertions in gh_heap
* Assert index matches any time a node is accessed by index, subsuming
  the assertion from #2139.
* Ensure all removed nodes are invalidated, so double-removes will
  trigger assertion failure. Added a test for this.
2022-07-29 15:21:13 +00:00
dmiller
dd690b3e0b Bump copyright date and update some links [ci skip] 2022-02-18 17:38:46 +00:00
dmiller
3e08021083 Don't rely on -1 return value from SSL_read, just check SSL_get_error() directly 2021-12-14 18:36:55 +00:00
fyodor
3aec3f3a07 Update to latest copyright templates. Main change is that Insecure.Com LLC is now Nmap Software LLC 2021-11-23 16:04:37 +00:00