Home page logo

nmap-dev logo Nmap Development mailing list archives

[PATCH] [Ncat] Fix EOF handling
From: Daniel Roethlisberger <daniel () roe ch>
Date: Sat, 18 Apr 2009 20:10:23 +0200

Ncat currently doesn't handle EOF events in a very intuitive way.
Usability for scripting mainly depends on the ability to pipe
into and out of Ncat:

me () server $ ncat -l 1234 | tar xvf -
me () client $ tar cvf - somedir | ncat server 1234

Currently, this does not work as expected, neither in the client
nor in the server.

In connect mode, EOF on standard input does not cause Ncat to
exit.  `cat file | ncat somewhere 1234' will keep running forever
until Ncat receives a SIGINT.  To be suitable for scripting, Ncat
must exit after EOF on stdin.

In listen mode, closing the TCP connection on the client side
does not cause Ncat to flush stdout and exit, because Ncat is
waiting for other connections.  SIGINT does not help here,
because Ncat will not write the remaining buffered bytes to
stdout in that case, so a received file will have some missing
bytes at the end.

Cince this behaviour can be considered a feature, the attached
patch adds a `-k' option, modelled after the *BSD nc(1) option of
the same name.  `-l -k' gives current behaviour, while just `-l'
gives the expected, scriptable single-shot behaviour which is
default for all netcat variants I am aware of (which is why I'd
propose to make it the default).

The attached patches fix EOF handling in both connect and listen
mode as I'd expect Ncat to handle EOF.  Comments?

Daniel Roethlisberger

Attachment: ncat.eof-fix-connect.diff

Attachment: ncat.eof-fix-listen.diff

Sent through the nmap-dev mailing list
Archived at http://SecLists.Org

  By Date           By Thread  

Current thread:
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]