1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 12:41:29 +00:00

Change Ncat default behavior to avoid TCP half-closed connections

This commit is contained in:
dmiller
2024-11-25 22:09:10 +00:00
parent b805bcf71d
commit dd4a7906d6
3 changed files with 11 additions and 5 deletions

View File

@@ -1,5 +1,10 @@
#Nmap Changelog ($Id$); -*-text-*- #Nmap Changelog ($Id$); -*-text-*-
o [Ncat] Ncat in connect mode no longer defaults to half-closed TCP
connections. This makes it more compatible with other netcats. The -k option
will enable the old behavior. See https://seclists.org/nmap-dev/2013/q1/188
[Daniel Miller]
o [Nsock][GH#2788] Fix an issue affecting Ncat where unread bytes in the SSL o [Nsock][GH#2788] Fix an issue affecting Ncat where unread bytes in the SSL
layer's buffer could not be read until more data arrived on the socket, which layer's buffer could not be read until more data arrived on the socket, which
could lead to deadlock. [Daniel Miller] could lead to deadlock. [Daniel Miller]

View File

@@ -1331,9 +1331,10 @@ static void read_socket_handler(nsock_pool nsp, nsock_event evt, void *data)
#else #else
Close(STDOUT_FILENO); Close(STDOUT_FILENO);
#endif #endif
/* In --recv-only mode or non-TCP mode, exit after EOF on the socket. */ /* For TCP, --keep-open means don't quit unless --recv-only */
if (o.proto != IPPROTO_TCP || (o.proto == IPPROTO_TCP && o.recvonly)) if (!o.keepopen || o.proto != IPPROTO_TCP || o.recvonly) {
nsock_loop_quit(nsp); nsock_loop_quit(nsp);
}
return; return;
} else if (status == NSE_STATUS_ERROR) { } else if (status == NSE_STATUS_ERROR) {
if (!o.zerobyte||o.verbose) if (!o.zerobyte||o.verbose)

View File

@@ -1017,8 +1017,8 @@ static int ncat_connect_mode(void)
if (o.chat) if (o.chat)
bye("Invalid option combination: `--chat' with connect."); bye("Invalid option combination: `--chat' with connect.");
if (o.keepopen) if (o.keepopen && o.proto != IPPROTO_TCP)
bye("Invalid option combination: `--keep-open' with connect."); bye("Invalid option combination: `--keep-open' with non-TCP protocol.");
return ncat_connect(); return ncat_connect();
} }