herestring causing netcat to hang?

0

I have netcat bound to a socket, listening on tcp port 5555:

Server

nc -vvlp 5555 -e /bin/bash

An incoming connection from a remote host, with a herestring:

Client

nc $server_ip 5555 <<<'ls'

As expected the ls command is executed on the server, and the result is displayed to the client, but the connection just seems to hang there. It no longer respond to input.
Note: If ncat is used instead of nc, the stdin appears to go unparsed, and the connection is dropped altogether.


The question is why; typing the command manually doesn't cause it to hang or sever the connection, so why is the herestring any different? If the herestring isn't compatible, what's an effective way to automate the same task?

voices

Posted 2019-11-02T02:04:41.873

Reputation: 2 053

No answers