Nmap Development mailing list archives

ncat: perform half-duplex shutdown upon EOF


From: James Stanley <james () incoherency co uk>
Date: Wed, 24 Aug 2022 20:32:39 +0100

I have submitted a pull request on github: https://github.com/nmap/nmap/pull/2510

The summary is:

Previously, |netexec()| would cease all communication as soon as it read EOF
from either the child proces *or* the remote side. This meant (for example)
when the other end of the TCP socket calls |shutdown(fd, SHUT_WR)|, the child process doesn't get a chance to send any more response, drain its buffers, etc.

The new behaviour is to propagate EOF onwards from the child process to the
remote, and vice versa, and keep a flag variable for each side to say whether
we still want to be reading from that side.

------------------------------------------------------------------------

With the new version, if you do something like:

|server$ ncat -l 10000 -e /bin/cat client$ ncat localhost 10000 <file1 >file2 |

Then it will now do what you expect: copy |file1| to |file2|. Previously ncat would stop reading from |/bin/cat| as soon as it got the half-duplex shutdown from the remote side, which means unless |cat|'s buffer is empty at the time ncat receives the shutdown, |file2| ends up shorter than |file1| because of the data stuck inside |cat| that never got transmitted over the network. Hope that makes sense.

Regards,

James Stanley
_______________________________________________
Sent through the dev mailing list
https://nmap.org/mailman/listinfo/dev
Archived at https://seclists.org/nmap-dev/

Current thread: