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

13096 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
82586d6327 Remove unused functions from snmp.lua 2024-11-12 20:05:58 +00:00
dmiller
fdf5a2d7e9 Configurable retries for snmp.lua 2024-11-12 20:05:57 +00:00
dmiller
10321be656 snmp.lua: add configurable timeout 2024-11-12 20:05:57 +00:00
dmiller
379b56b582 Include timeout info in debug output for all nsock reads/connects 2024-11-12 20:05:56 +00:00
dmiller
2d43280b16 NSE libssh2 bindings: allow exec without pty 2024-11-11 21:07:01 +00:00
dmiller
e2ccdb8074 Fix a typo in ssh-run 2024-11-11 21:07:01 +00:00
dmiller
33bfd251b4 Macro for common idiom in nse_libssh2 2024-11-11 21:07:00 +00:00
dmiller
5d14851aaa Fix error in ldap-brute: 'no string output' 2024-11-11 21:06:59 +00:00
dmiller
bfba1352e4 Fix UDP listen on Windows: recvfrom behaves differently. 2024-11-07 23:43:26 +00:00
dmiller
1e8c1ab3cd Let all nsock engines use STDIN on Windows! 2024-11-06 16:48:29 +00:00
dmiller
1c3fc17d2f Ncat: handle overlapped stdin socket from nbase's fselect 2024-11-06 16:47:25 +00:00
dmiller
6b2df74ef2 Nbase: use a static SOCKET for STDIN 2024-11-06 16:46:32 +00:00
dmiller
635cc50011 Nsock iocp: fix IPv6 connect 2024-11-06 16:06:32 +00:00
dmiller
f9b9434044 nbase: win32 build fix 2024-11-06 16:05:03 +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
0e3a51c992 Set timeouts for Windows connect scan. Fixes #2113 2024-10-30 19:02:09 +00:00
dmiller
f1559fbc22 Use a socket, not pipe, for STDIN emulation in fselect
Using a TCP connected socket allows us to use a single select call instead of
interrupting it every 125ms to poll the stdin-pipe.
2024-10-30 18:55:39 +00:00
dmiller
fef9f592b0 POSIX usleep() returns an int. 2024-10-28 23:17:05 +00:00
dmiller
f0c022b25f Avoid infinite loop on systems where select doesn't update timeout 2024-10-28 23:11:53 +00:00
dmiller
191aadf142 Record current time for connect probes, not an old time 2024-10-28 23:11:52 +00:00
dmiller
cf718f2071 Avoid a few extra gettimeofday calls 2024-10-28 23:11:52 +00:00
dmiller
df1604ab19 Simplify pcap_select, remove timeval form 2024-10-28 23:11:51 +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
14142ce874 Use nbase's usleep, not select, for delay timer in Ncat 2024-10-11 20:59:34 +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
f8d4531b1f Make some broadcast scripts 'safe' category 2024-10-08 21:14:40 +00:00
dmiller
0bae611494 Don't use 1ms timeout for writes. Actual time can be >100ms because of NSE overhead 2024-10-08 21:14:40 +00:00
dmiller
a751509b0b Use u32 for s_addr; in_addr_t not defined on Windows 2024-10-07 18:31:14 +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
f1325d7c6f Handle libssh2 errors on connect. Closes #2616. Fixes #1014 2024-10-04 18:21:25 +00:00
dmiller
b507356091 Fix typoed index in latest libssh2 publickey change 2024-10-04 18:21:24 +00:00
dmiller
79b35dcb04 Add binding for libssh2_userauth_publickey_frommemory 2024-10-03 19:18:13 +00:00
dmiller
f8b7e5c860 Fix libssh2.channel_read_stderr, was reading stream 0 2024-10-03 19:18:13 +00:00
dmiller
325a4f680c http.lua parse_redirect support URL params 2024-10-03 19:18:12 +00:00
dmiller
e263e64820 Don't bail on PCRE2 match errors. Better debug info. 2024-09-27 19:20:42 +00:00
dmiller
01ccce00c0 Define service buffer lengths in one place only 2024-09-27 19:20:41 +00:00
dmiller
2184f98858 Consolidate cases: arpping is used for both IPv4 and IPv6 2024-09-27 19:20:40 +00:00
dmiller
f43fdaa1d7 Use no-route instead of unknown-response for ARP failure 2024-09-20 17:25:59 +00:00