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

Comments

Projects
None yet
2 participants
@techwolf359

techwolf359 commented May 29, 2015

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

This comment has been minimized.

Show comment
Hide comment
@techwolf359

techwolf359 May 29, 2015

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.

techwolf359 commented May 29, 2015

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

This comment has been minimized.

Show comment
Hide comment
@dmiller-nmap

dmiller-nmap May 29, 2015

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

dmiller-nmap commented May 29, 2015

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

@dmiller-nmap dmiller-nmap added the Ncat label May 29, 2015

@techwolf359

This comment has been minimized.

Show comment
Hide comment
@techwolf359

techwolf359 May 29, 2015

Negative, same results.

techwolf359 commented May 29, 2015

Negative, same results.

@dmiller-nmap

This comment has been minimized.

Show comment
Hide comment
@dmiller-nmap

dmiller-nmap May 29, 2015

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.

dmiller-nmap commented May 29, 2015

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

This comment has been minimized.

Show comment
Hide comment
@techwolf359

techwolf359 Jun 3, 2015

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

techwolf359 commented Jun 3, 2015

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

Add `--no-shutdown` option.
This option solves issue #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.

@nmap-bot nmap-bot closed this in 1b4c4a9 Nov 10, 2015

qha added a commit to qha/nmap that referenced this issue Dec 16, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment