Nmap Development mailing list archives

[PATCH] Ncat: Implementation of idle timeout option for listen mode


From: Tomas Hozza <thozza () redhat com>
Date: Wed, 05 Jun 2013 16:43:42 +0200

On 01/15/2013 12:25 AM, David Fifield wrote:
On Mon, Jan 14, 2013 at 02:53:11PM +0100, Michal Hlavinka wrote:
I just found that ncat does not behave the way I'd expect.

Make it listen for udp connection:
ncat -l -u 1234 </dev/null

and send "Hello":
echo "Hello" | ncat -u localhost 1234

The result is that listening ncat waits for the "Hello" message and
when it comes, it terminates and prints nothing.

In ncat_listen_dgram it select()s change on socket descriptor and
after a few checks it goes to
"""/* stdin -> socket and socket -> stdout */""""
while loop. Where it checks stdin first and finding it closed, it
terminates. I'm not sure what is intended behaviour, but I guess it
should print the message since it's waiting for it.

I think this behavior is right. Arguably the program should quit
immediately upon startup since its input is closed. I would accept a
patch to do that.

And another question. Our QA engineers use netcat in their tests and
one use case is to wait for connection for some time and then
terminate.

In old netcat there's -w option which has the same behaviour like
the -i in ncat. Unfortunately, -i can't be used together with -l (it
prints error message). Why is it that way? Is it just that nobody
wrote the code or is there any other reason why it can't be used
together?

My guess is that it is just not implemented.

David Fifield

Hello.

I implemented the idle timeout "-i" option for ncat's listen mode.
Previously it was available only for connection mode.

I also added tests for idle timeout option when used in listen mode
into the ncat-test.pl test-suite.

Patches are attached.

I want to point out that when using ncat in listen mode with UDP, the
server is unaware of the connected client until it sends some message to
the server. This behaviour differs from connection oriented protocols
such as TCP and SCTP.

That's why I added separate tests for connection oriented protocols
and UDP in the test-suite.


Regards,

Tomas Hozza

Attachment: 0001-Ncat-Implement-idle-timeout-option-for-listen-mode.patch
Description:

Attachment: 0002-Ncat-Add-tests-for-idle-timeout-in-listen-mode.patch
Description:

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

Current thread: