Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not read from STDIN option #142

Closed
techwolf359 opened this issue May 29, 2015 · 5 comments
Closed

Do not read from STDIN option #142

techwolf359 opened this issue May 29, 2015 · 5 comments
Labels

Comments

@techwolf359
Copy link

Upgraded from CentOS 6 to 7 and nc was replaced with ncat. nc has an option, -d, which won't try to read from STDIN. -d in ncat, is a delay flag. Changing option flags would be perfectly okay if there was a corresponding option. The main problem is that when I run a bash script non-interactively that has ncat listen, it immediately exits "NCAT DEBUG: EOF on stdin". I've been unsuccessful in a workaround short of building the older nc for CentOS 7.

@techwolf359
Copy link
Author

For what it's worth, I did get a workaround using script. Example:

script -c "nc -l $port | tar xvf -"

I still think to keep compatibility, ncat should have a flag to accomplish this.

@dmiller-nmap
Copy link

Does --recv-only do what you want in this case?

@techwolf359
Copy link
Author

Negative, same results.

@dmiller-nmap
Copy link

Please include the output of nc --version so we can determine if this is an already-solved issue.

Additionally, the output (stderr) from your command with the addition of -vvv will provide useful debugging information.

Finally, can you clarify what you mean by "non-interactively"? Do you have the same problem with nc -l $port </dev/null | tar xvf - ? Or do you mean closing stdin with <&-? I just filed a bug for a separate issue in that case: #143.

@techwolf359
Copy link
Author

Receiving side: Ncat: Version 6.40 ( http://nmap.org/ncat )
Sending side: nc-1.84-22.el6.x86_64

Reproduced with: nc -vvv -l $port </dev/null | tar xvf -

Ncat: Version 6.40 ( http://nmap.org/ncat )
NCAT DEBUG: Initialized fdlist with 103 maxfds
Ncat: Listening on :::9999
NCAT DEBUG: Added fd 3 to list, nfds 1, maxfd 3
Ncat: Listening on 0.0.0.0:9999
NCAT DEBUG: Added fd 4 to list, nfds 2, maxfd 4
NCAT DEBUG: Added fd 0 to list, nfds 3, maxfd 4
NCAT DEBUG: Initialized fdlist with 100 maxfds
NCAT DEBUG: selecting, fdmax 4
NCAT DEBUG: select returned 1 fds ready
NCAT DEBUG: fd 4 is ready
Ncat: Connection from $IP.
NCAT DEBUG: Swapping fd[0] (3) with fd[2] (0)
NCAT DEBUG: Removed fd 3 from list, nfds 2, maxfd 4
NCAT DEBUG: Swapping fd[1] (4) with fd[1] (4)
NCAT DEBUG: Removed fd 4 from list, nfds 1, maxfd 0
Ncat: Connection from $IP:32840.
NCAT DEBUG: Added fd 5 to list, nfds 2, maxfd 5
NCAT DEBUG: Added fd 5 to list, nfds 1, maxfd 5
NCAT DEBUG: selecting, fdmax 5
NCAT DEBUG: select returned 1 fds ready
NCAT DEBUG: fd 0 is ready
NCAT DEBUG: EOF on stdin
NCAT DEBUG: selecting, fdmax 5
NCAT DEBUG: select returned 1 fds ready
NCAT DEBUG: fd 5 is ready
NCAT DEBUG: Closing connection.
NCAT DEBUG: Swapping fd[1] (5) with fd[1] (5)
NCAT DEBUG: Removed fd 5 from list, nfds 1, maxfd 0
NCAT DEBUG: Swapping fd[0] (5) with fd[0] (5)
NCAT DEBUG: Removed fd 5 from list, nfds 0, maxfd -1
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors

adsr added a commit to adsr/nmap that referenced this issue Jun 4, 2015
This option solves issue nmap#142. It prevents Ncat from putting the connection in
half-duplex mode after seeing EOF on stdin. This emulates the behavior of
OpenBSD-netcat's `-d` option. The `-d` option itself prevents a bug affecting
some versions of that program in which the sender closes the connection
prematurely upon receiving a FIN packet from a receiver.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants