Nmap Development mailing list archives

Re: Ideas for Windows Ncat: non-blocking read from stdin


From: David Fifield <david () bamsoftware com>
Date: Mon, 2 Mar 2009 12:15:13 -0700

On Sun, Mar 01, 2009 at 07:35:22PM -0700, David Fifield wrote:
I saw this in the TODO and I want to share some ideas about it.

o Ncat Windows issue where you make a connection and then take several
  seconds to type in a line to the server, Ncat wrongly times out when
  trying to write your line to the remote server. [David]

So this is my current idea: create a thread (with CreateThread) that
does nothing but read stdin and write to an anonymous pipe (created
with CreatePipe). Duplicate the pipe's handle in the main program so
that when Ncat thinks it's reading from stdin, it's reading from the
pipe. The thread takes care of line buffering and echoing, and ensures
that the main process won't block when it reads from the pipe.

Microsoft's telnet program reads from stdin with echoing, and appears to
be non-blocking. But the way it works is suboptimal--what it does is
completely turn off buffering and send a packet for every character you
type. If you set up an echo server on a Unix host with

        ncat -l 7 --exec "/bin/cat"

then connect to it with Windows telnet.exe and type "abc", what you see
is

aabbcc


whereas if you connect with Ncat from Unix you see

abc
abc

Every byte you type gets sent immediately by Windows telnet. This
obviously creates a lot of network overhead, and it disables local line
editing. But it's a possibility if nothing else works.

David Fifield

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org


Current thread: