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

Assert in nsock_pcap.c with iocp engine #535

Open
gvanem opened this issue Aug 31, 2016 · 5 comments
Open

Assert in nsock_pcap.c with iocp engine #535

gvanem opened this issue Aug 31, 2016 · 5 comments

Comments

@gvanem
Copy link

gvanem commented Aug 31, 2016

With a command like:

nmap -p20-80 -sV --nsock-engine=iocp 10.0.0.1

I always get an assert-error in nsock/src/engine_ioc.p.c at line 237:

Assertion failed: result, file engine_iocp.c, line 237

Further studying shows CreateIoCompletionPort() returns 0 with GetLastError() == 87.
Which is ERROR_INVALID_PARAMETER. Not sure why, but is iod->sd a legal value for a HANDLE?

This is on Win-10, latest Nmap built using MSVC-2015, 32-bit.

@dmiller-nmap
Copy link

HANDLE is typedef'd PVOID, and iod->sd is an int. Generally those will be compatible in terms of storage size, but I can see how it might be a stretch to cast one to the other. Hopefully @Tudor-Coman or @bmenrigh can comment.

@gvanem
Copy link
Author

gvanem commented Sep 1, 2016

Further tracing shows it correctly uses the socket-value of 1216 from WSASocketA(). So maybe another parameter it to blame?

I can also see there are 2 completion-ports used at the same time; iocp_init() is called twice. Doesn't look right. It's also strange to me that a command:

nmap -p20-80 -sT --nsock-engine=iocp 10.0.0.1

doesn't involve IOCP (only select() is used).

@gvanem
Copy link
Author

gvanem commented Sep 1, 2016

My bad, I hadn't got the updated nbase_misc.c with the overlapped flag:

return WSASocket(af, style, protocol, NULL, 0, WSA_FLAG_OVERLAPPED);

Hence it's working now. I'll close the issue.

@gvanem gvanem closed this as completed Sep 2, 2016
@gvanem
Copy link
Author

gvanem commented Jun 1, 2017

There is still a bug regarding this. Now with a different assert() in nsock_pcap.c:

Starting Nping 0.7.40SVN ( https://nmap.org/nping ) at 2017-06-01 04:39 PDT
SENT (0.3125s) TCP 10.0.0.10:22594 > 10.0.0.1:80 S ttl=64 id=44422 iplen=40  seq=2582998811 win=1480
Assertion failed: fs_length(&(nse->iobuf)) == 0, file nsock_pcap.c, line 392

From a command like nping --tcp --nsock-engine=iocp 10.0.0.1.
And the call-stack:

ucrtbase!_wassert+0x16
nping!do_actual_pcap_read(struct nevent * nse = 0x04838cb0)+0x89
nping!pcap_read_on_nonselect(struct npool * nsp = 0x015ae110)+0x1c
nping!iocp_loop(struct npool * nsp = 0x015ae110, int msec_timeout = 0n986)+0x10a
nping!nsock_engine_loop+0xa
nping!nsock_loop(struct npool * nsp = 0x015ae110, int msec_timeout = 0n1001)+0x175

nping!ProbeMode::start(void)+0x7c6
nping!main(int argc = 0n4, char ** argv = 0x03ccfaf8)+0x236

PS. It would be nice if the available engines was listed in nping --help or nping --version.

PS2. I see there is an insane amount of WSAEINVAL returned from WSAPoll() when using a
command like nping --nsock-engine=poll 10.0.0.1.

@gvanem gvanem reopened this Jun 1, 2017
@gvanem
Copy link
Author

gvanem commented Jun 1, 2017

Just removing the assert() in nsock_pcap.c, line 392, all seems to work on Windows too.
I've no idea what this means, but the nse->iobuf contains some junk at that point.

@dmiller-nmap dmiller-nmap changed the title Assert in engine_iocp.c Assert in nsock_pcap.c with iocp engine Oct 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants