Apparently SCTP can't have the same kind of half-open sockets that TCP
has. When one direction is closed, we can't do anything further with the
socket.
http://seclists.org/nmap-dev/2013/q1/227
This eliminates the ambiguity that could exist when, say, both o.udp and
o.sctp were both set. The code would use whichever it happened to test
first. This also makes TCP mode explicit with IPPROTO_TCP.
The existing tests here didn't make much sense, and didn't cover all the
situations we care about. The 8 tests now check each of
client !--send-only EOF on stdin
client --send-only EOF on stdin
server !--send-only EOF on stdin
server --send-only EOF on stdin
client !--recv-only EOF on socket
client --recv-only EOF on socket
server !--recv-only EOF on socket
server --recv-only EOF on socket
The other thing we care about is whether the client/server keeps running
after the EOF. That is now checked in each of the tests too.
ncat_assert is safe because it cannot be disabled. <assert.h> assert is
also safe because we make sure that NDEBUG remains defined. Doing this
helps avoid potential bad effects of something changing in the future.
Resolves these Parfait reports
(http://seclists.org/nmap-dev/2012/q4/412).
Error: Null pointer dereference (CWE 476)
Read from null pointer 'fdn'
at line 328 of components/nmap/build/amd64/ncat/ncat_core.c in function 'blocking_fdinfo_send'.
Function 'get_fdinfo' may return constant 'NULL' at line 615, called at line 366 in function 'ncat_broadcast'.
Constant 'NULL' passed into function 'blocking_fdinfo_send', argument 'fdn', from call at line 367.
Null pointer introduced at line 615 of components/nmap/build/amd64/ncat/util.c in function 'get_fdinfo'.
at line 330 of components/nmap/build/amd64/ncat/ncat_core.c in function 'blocking_fdinfo_send'.
Function 'get_fdinfo' may return constant 'NULL' at line 615, called at line 366 in function 'ncat_broadcast'.
Constant 'NULL' passed into function 'blocking_fdinfo_send', argument 'fdn', from call at line 367.
Null pointer introduced at line 615 of components/nmap/build/amd64/ncat/util.c in function 'get_fdinfo'.
Error: Null pointer dereference (CWE 476)
Read from null pointer 'fdn'
at line 946 of components/nmap/build/amd64/ncat/ncat_listen.c in function 'shutdown_sockets'.
Function 'get_fdinfo' may return constant 'NULL' at line 615, called at line 945.
Null pointer introduced at line 615 of components/nmap/build/amd64/ncat/util.c in function 'get_fdinfo'.
This is simple IPv6 unicast ranges. For example,
nmap -6 en.wikipedia.org/120 -sn
The other, more complicated part of this overall change is automatic
multicast scanning of large local subnets. That part isn't done yet.
Reworked the logging infrastructure to make it more flexible
and consistent.
Updated nmap, nping and ncat accordingly. Nsock log level can
now be adjusted at runtime by pressing d/D in nmap.
compatibility between systems and use cases. [Henri Doreau]
There were known issues with the following cases:
* epoll and regular files
* kqueue and regular files
* WSAPoll and stdin
The --nsock-engine=<ENGINE> can still be used to bypass this
default choice.
See: http://seclists.org/nmap-dev/2012/q4/173
This code was not always properly cleaning up automatically generated
sockets; for example in the case of "Connection refused". It would
delete sockets even if you gave one manually with --source; it's not
clear that's the right behavior.
Added tests for UNIX domain sockets to the ncat_test.pl
script. Added tests for:
1. listening on and connecting to UNIX STREAM socket.
2. listening on and connecting to (client with random
socket) UNIX DGRAM socket.
3. connecting to UNIX DGRAM socket with given source
socket (with "-s").
o.af is AF_UNSPEC at this point in the common case that neither -4 nor
-6 was given. The code was falling through to the "else" IPv6 case. I
think we were getting luck with this because the port number happens to
be in the same place in sockaddr_in and sockaddr_in6.
Since r29743, ncat closes connection after reading EOF. This patch first
introduces a new test to verify it, and also updates two existing tests
to prevent them from closing STDIN too early.