Nmap Development mailing list archives

Re: ncat exec or sending a one-shot login string


From: Daniel Miller <bonsaiviking () gmail com>
Date: Mon, 14 Dec 2015 14:03:41 -0600

Brian,

We've fixed a lot of these socket, pipe, and stdin EOF handling issues in
recent versions. Most recently in version 7.00, we added an option that
some folks needed for cron scripts, --no-shutdown, which prevents Ncat from
closing the network connection when it receives EOF on STDIN. Other
relevant options (which may or may not help your particular situation) are:

-k or --keep-open, accept multiple connections in listen mode
--send-only, only send data, ignoring received; quit on EOF
--recv-only, Only receive data, never send anything

Finally, sometimes you need to give Ncat some extra time to receive a
reply, especially with UDP communication. For example this will fail:

echo -ne '\0\x06\x01\0\0\x01\0\0\0\0\0\0\x07version\x04bind\0\0\x10\0\x03'
| ncat -u 192.168.1.1 53

But this will succeed:

(echo -ne
'\0\x06\x01\0\0\x01\0\0\0\0\0\0\x07version\x04bind\0\0\x10\0\x03'; sleep 5)
| ncat -u 192.168.1.1 53

We don't yet have a command option for that, but a subshell+sleep works
pretty well.

Dan

On Sun, Dec 13, 2015 at 9:02 AM, Brian Franklin <brian.is.still () gmail com>
wrote:

Hi there!  I'm a big fan of ncat, particularly the ssl support.  Well done!

Recently, I'm trying to use it from within cron.  I can't seem to get it
to work.  Basically, I connect as a client and then pass a login string to
a remote server, and then it streams some data to me, which I then pipe to
another process.  I use something like:

cat "login" - | ncat -C --ssl [server] [port] | [some other script]

This works perfectly from the command line (it always does...) but the
cron job won't work.  Turning up the verbosity provides some interesting
clues, but I don't know how to interpret most of it.  I've applied all my
standard "tricks" for debugging a cron job, but I'm getting nowhere.  The
closest I've come is that it might be related to my use of 'cat' and it's
reliance on stdin to 'hold' the pipe open?

If I remove the last pipe, and just collect the ncat output using the MTA
from cron, then it reports a successful connection, but it just seems to
quit after that.

What I'm trying to achieve is this:

1.  Connect to remote server
2.  Send login string (really just an identity)
3.  Receive data
4.  Pipe data to another script for processing

Sending the login string is a one-shot deal; after that it's all
uni-directional communication and I don't send anything back.  I have no
control over the remote server.

Using ncat 6.40 on Ubuntu 14.04.

Can anyone point me in the right direction?

Thanks,

Brian

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

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

Current thread: