-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
ncat: nsock_loop error 10038 #978
Comments
Regression seems to have appeared with version 7.60; 7.50 works fine for me on Windows 7.
|
Confirmed. The reason is that --- a/nbase/nbase_misc.c 2017-06-20 17:16:33
+++ b/nbase/nbase_misc.c 2017-08-29 15:53:50
@@ -502,6 +502,8 @@
if (emaster)
eset = *emaster;
+ FD_CLR(STDIN_FILENO, &eset);
+
fds_ready = 0;
/* selecting on anything other than stdin? */
if (s > 1) |
Can someone try git-bisect on this? I unfortunately do not have access to a windows machine but may be able to advise if this is a nsock issue. Knowing the faulty commit would help a lot. |
I was able to narrow it down to r36816 (2065d75) |
You could also try the secret option
|
I think that @gvanem is right. Windows does not allow selecting on non-sockets. You can try the suggested patch (please move the new FD_CLR statement right below the existing one on line 479 though). Can you check that it does not introduce regression WRT the bug that r36816 was attempting to fix (see http://seclists.org/nmap-dev/2017/q1/220)? Can you also check with a regular file as stdin: 'ncat host < file.input'? Using alternative engines with ncat "works" but is discouraged on windows because of this kind of issues. We have no fpoll() wrapper and I am unsure how iocp behaves on stdin. I would be happy to know it though! :) |
This helps with making the connection but the same error pops up again at the end of the session. I have put together a band-aid patch below, which gets rid of the error (including at the session end) but :
--- a/nbase/nbase_misc.c
+++ b/nbase/nbase_misc.c
@@ -428,6 +428,8 @@
int iter = -1, i;
struct timeval stv;
fd_set rset, wset, eset;
+ int r_stdin = rmaster != NULL && FD_ISSET(STDIN_FILENO, rmaster);
+ int e_stdin = emaster != NULL && FD_ISSET(STDIN_FILENO, emaster);
/* Figure out whether there are any FDs in the sets, as @$@!$# Windows
returns WSAINVAL (10022) if you call a select() with no FDs, even though
@@ -441,8 +443,8 @@
s--;
}
- /* Handle the case where stdin is not being read from. */
- if (rmaster == NULL || !FD_ISSET(STDIN_FILENO, rmaster)) {
+ /* Handle the case where stdin is not in scope. */
+ if (!(r_stdin || e_stdin)) {
if (s > 0) {
/* Do a normal select. */
return select(s, rmaster, wmaster, emaster, tv);
@@ -476,7 +478,10 @@
stdin_thread_started = 1;
}
- FD_CLR(STDIN_FILENO, rmaster);
+ if (r_stdin)
+ FD_CLR(STDIN_FILENO, rmaster);
+ if (e_stdin)
+ FD_CLR(STDIN_FILENO, emaster);
if (tv) {
int usecs = (tv->tv_sec * 1000000) + tv->tv_usec;
@@ -509,7 +514,7 @@
else
usleep(stv.tv_sec * 1000000UL + stv.tv_usec);
- if (fds_ready > -1 && win_stdin_ready()) {
+ if (fds_ready > -1 && r_stdin && win_stdin_ready()) {
FD_SET(STDIN_FILENO, &rset);
fds_ready++;
} |
@nnposter That patch looks good to me. I looked over the MSDN docs and there shouldn't be any sort of "exceptional condition" for STDIN; that's for URG/OOB traffic, generally. I applied it and will be doing some more testing to be sure. I should have been running |
On 1/11/18 7:53 AM, CapitanShinChan wrote:
I have the same issue. There is any place where I can get the previous
ncat version compiled for Windows?
Patch r37036, committed on 9/30/17, has hopefully resolved the issue so
you can just compile ncat from the master branch.
Otherwise you can grab older installers from
https://nmap.org/dist/?C=M&O=D
Cheers,
nnposter
|
Windows 10 Version 10.0.16299.125
|
Also:
The second attempt caused a crash! |
Synopsis:
Ncat 7.60 on Windows is unable to perform a simple client TCP connect. The same problem is not observed on Linux. A nine-months old version of ncat also works fine.
The key error message is
There was no recent change in routine
select_loop()
innsock/src/engine_select.c
to provide an obvious explanation.Details:
The following is observed on Windows 8 with stock ncat 7.60 (and also on Windows 7 with close-enough ncat r36949):
The same version of ncat (r36949) on Ubuntu does not have the problem:
An older version of ncat (r36483) on the same Windows 8 and Windows 7 also works fine:
The text was updated successfully, but these errors were encountered: