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

Unexpected error in NSE_TYPE_READ callback #2140

Closed
lynnewu opened this issue Oct 6, 2020 · 3 comments · Fixed by res0nat0r/nmap#1
Closed

Unexpected error in NSE_TYPE_READ callback #2140

lynnewu opened this issue Oct 6, 2020 · 3 comments · Fixed by res0nat0r/nmap#1
Labels

Comments

@lynnewu
Copy link

lynnewu commented Oct 6, 2020

Describe the bug

Scan terminates unexpectedly with the message:
"Unexpected error in NSE_TYPE_READ callback. Error code: 1234 (No service is operating at the destination network endpoint on the remote system. )

QUITTING!"

To Reproduce
nmap -sS -sU -sV -T3 -v --version-all --script banner --top-ports 50 192.168.57-58.0-255
Expected behavior
Scan should run to completion

Version info (please complete the following information):

  • OS: [e.g. Linux 4.15, Windows 10 1909]
    Windows Server 2019 Standard 1809 build 17763.1397

  • Output of nmap --version:
    Nmap version 7.90 ( https://nmap.org )
    Platform: i686-pc-windows-windows
    Compiled with: nmap-liblua-5.3.5 openssl-1.1.1h nmap-libssh2-1.9.0 nmap-libz-1.2.11 nmap-libpcre-7.6 Npcap-1.00 nmap-libdnet-1.12 ipv6
    Compiled without:
    Available nsock engines: iocp poll select

  • Output of nmap --iflist
    Starting Nmap 7.90 ( https://nmap.org ) at 2020-10-06 10:37 Central Daylight Time
    INTERFACES
    DEV (SHORT) IP/MASK TYPE UP MTU MAC
    eth0 (eth0) 192.168.53.223/22 ethernet up 1500 00:50:56:86:0D:4E
    eth1 (eth1) 192.168.6.223/23 ethernet up 1500 00:50:56:86:74:AE
    eth2 (eth2) 192.168.57.223/24 ethernet up 1500 00:50:56:86:C9:EE
    eth3 (eth3) 192.168.59.223/24 ethernet up 1500 00:50:56:86:7F:C2
    lo0 (lo0) ::1/128 loopback up -1
    lo0 (lo0) 127.0.0.1/8 loopback up -1

DEV WINDEVICE
eth0 \Device\NPF_{6D2BE5DA-D4D7-4EE7-A94D-8068D2780B85}
eth1 \Device\NPF_{41567334-FCDA-4ACF-B927-76E8410D2DA5}
eth2 \Device\NPF_{84E1F408-49C7-4BA7-8EEC-41F1A0800541}
eth3 \Device\NPF_{4EDDACC8-DD7F-40AC-AC29-FB998BB18A08}
lo0 \Device\NPF_Loopback
lo0 \Device\NPF_Loopback
\Device\NPF_{0675240A-CE03-47AE-BBBD-0E468557FA72}
\Device\NPF_{D60D66D5-866A-4639-BC03-712D91BBCD9B}
\Device\NPF_{70686BF5-C31D-4160-9C09-997E61DC700C}

ROUTES
DST/MASK DEV METRIC GATEWAY
192.168.57.255/32 eth2 271
192.168.57.223/32 eth2 271
255.255.255.255/32 eth0 271
255.255.255.255/32 eth1 271
255.255.255.255/32 eth3 271
255.255.255.255/32 eth2 271
192.168.55.255/32 eth0 271
192.168.59.255/32 eth3 271
192.168.6.223/32 eth1 271
192.168.7.255/32 eth1 271
192.168.59.223/32 eth3 271
192.168.53.223/32 eth0 271
127.255.255.255/32 lo0 331
127.0.0.1/32 lo0 331
255.255.255.255/32 lo0 331
192.168.57.0/24 eth2 271
192.168.59.0/24 eth3 271
192.168.6.0/23 eth1 271
192.168.52.0/22 eth0 271
127.0.0.0/8 lo0 331
224.0.0.0/4 eth2 271
224.0.0.0/4 eth3 271
224.0.0.0/4 eth1 271
224.0.0.0/4 eth0 271
224.0.0.0/4 lo0 331
0.0.0.0/0 eth1 15 192.168.6.1
0.0.0.0/0 eth3 271 192.168.59.1
0.0.0.0/0 eth0 271 192.168.52.1
0.0.0.0/0 eth2 271 192.168.57.1
::1/128 lo0 331
ff00::/8 lo0 331

Additional context
Add any other context about the problem here, such as special network type.

@lynnewu lynnewu added the Nmap label Oct 6, 2020
@lynnewu
Copy link
Author

lynnewu commented Oct 6, 2020

Was able to narrow things down a bit. The error is not specific to port 67, but it's the only port where I can consistently get 100% failure, regardless of host.

The hosts in question don't have anything running on port 67 (TCP or UDP).

Using: nmap -sS -sU -sV -p 67 -T3 -d4 -v -v -v --version-all --script banner 192.168.57.22

Starting probes against new service: 192.168.57.22:67 (udp)
Service scan sending probe RPCCheck to 192.168.57.22:67 (udp)
Service scan sending probe DNSVersionBindReq to 192.168.57.22:67 (udp)
event #306 (type READ)
NSOCK DEBUG [0.7510s] event_delete(): event_delete (IOD #19) (EID #306)
NSOCK INFO [0.7510s] nsock_iod_delete(): nsock_iod_delete (IOD #20)
NSOCK INFO [0.7510s] nevent_delete(): nevent_delete on event #322 (type READ)
NSOCK DEBUG [0.7510s] event_delete(): event_delete (IOD #20) (EID #322)
NSOCK DEBUG [0.7510s] event_delete(): event_delete (IOD #1) (EID #18)
NSOCK DEBUG [1.0670s] nsock_set_log_function(): Registered external logging function: D897E0
NSOCK DEBUG [1.0670s] nsock_set_loglevel(): Set log level to DEBUG
NSOCK INFO [1.0670s] nsock_iod_new2(): nsock_iod_new (IOD #1)
NSOCK DEBUG [1.0670s] event_new(): event_new (IOD #1) (EID #8)
NSOCK INFO [1.0670s] nsock_connect_udp(): UDP connection requested to 192.168.57.22:67 (IOD #1) EID 8
NSOCK DEBUG [1.0670s] nsock_pool_add_event(): NSE #8: Adding event (timeout in 22503502ms)
NSOCK DEBUG [1.0670s] nsock_loop(): nsock_loop() started (no timeout). 1 events pending
NSOCK INFO [1.0670s] nsock_trace_handler_callback(): Callback: CONNECT SUCCESS for EID 8 [192.168.57.22:67]
NSOCK DEBUG [1.0670s] event_new(): event_new (IOD #1) (EID #19)
NSOCK INFO [1.0670s] nsock_write(): Write request for 40 bytes to IOD #1 EID 19 [192.168.57.22:67]
NSOCK DEBUG [1.0670s] nsock_pool_add_event(): NSE #19: Adding event (timeout in 5000ms)
NSOCK DEBUG [1.0670s] event_new(): event_new (IOD #1) (EID #26)
NSOCK INFO [1.0670s] nsock_read(): Read request from IOD #1 [192.168.57.22:67] (timeout: 5000ms) EID 26
NSOCK DEBUG [1.0670s] nsock_pool_add_event(): NSE #26: Adding event (timeout in 5000ms)
NSOCK DEBUG [1.0670s] event_delete(): event_delete (IOD #1) (EID #8)
NSOCK INFO [1.0670s] nsock_trace_handler_callback(): Callback: WRITE SUCCESS for EID 19 [192.168.57.22:67]
NSOCK DEBUG [1.0670s] event_delete(): event_delete (IOD #1) (EID #19)
NSOCK INFO [6.0790s] nsock_trace_handler_callback(): Callback: READ TIMEOUT for EID 26 [192.168.57.22:67]
NSOCK DEBUG [6.0790s] event_new(): event_new (IOD #1) (EID #35)
NSOCK INFO [6.0790s] nsock_write(): Write request for 30 bytes to IOD #1 EID 35 [192.168.57.22:67]
NSOCK DEBUG [6.0790s] nsock_pool_add_event(): NSE #35: Adding event (timeout in 5000ms)
NSOCK DEBUG [6.0790s] event_new(): event_new (IOD #1) (EID #42)
NSOCK INFO [6.0790s] nsock_read(): Read request from IOD #1 [192.168.57.22:67] (timeout: 5000ms) EID 42
NSOCK DEBUG [6.0790s] nsock_pool_add_event(): NSE #42: Adding event (timeout in 5000ms)
NSOCK DEBUG [6.0790s] event_delete(): event_delete (IOD #1) (EID #26)
NSOCK INFO [6.0790s] nsock_trace_handler_callback(): Callback: WRITE SUCCESS for EID 35 [192.168.57.22:67]
NSOCK DEBUG [6.0790s] event_delete(): event_delete (IOD #1) (EID #35)
NSOCK INFO [6.0790s] nsock_trace_handler_callback(): Callback: READ ERROR [No service is operating at the destination network endpoint on the remote system. (1234)] for EID 42 [192.168.57.22:67]
Unexpected error in NSE_TYPE_READ callback. Error code: 1234 (No service is operating at the destination network endpoint on the remote system. )
QUITTING!

@dmiller-nmap
Copy link

Thanks for this report! Apparently, WSARecvFrom() can return ERROR_PORT_UNREACHABLE instead of a more recognizable Winsock error code when an ICMP error packet is received. I just pushed a change to translate this to ECONNREFUSED which should do the right thing.

res0nat0r added a commit to res0nat0r/nmap that referenced this issue Oct 7, 2020
* Implement Ncat proxy creds via environment variable. Fixes nmap#2060, closes nmap#2073

* Fix --resume from IPv6 scans

* Use correct default buffer position. Closes nmap#2084

* Clarify upper boundary for variable-length numerical fields

* Make maximize_fdlimit return rlim_t on appropriate platforms. Closes nmap#2085. Fixes nmap#2079

* Credential object is creds.Account, not brute.Account. See nmap#2086

* Clarify location of the Error object

* Use correct default buffer position. Closes nmap#2086

* Minor optimization of url.parse_query()

* Output of matched fingerprints in http-default-accounts. Fixes nmap#2077

* Document that --open implies --defeat-rst-ratelimit since 7.40

* SNMP scripts are enabled on non-standard ports. See nmap#1473

* Increases SQL Server version resolution

* Eliminate reflection false positives in http-shellshock. Closes nmap#2089

* Unify AFP pathname serialization

* Correct AFP name extraction from responses. Closes nmap#2091
FPGetFileDirParms and FPEnumerateExt2 could crash due to unpacking from
out-of-bounds positions. This latent issue got exposed by converting from
bin.unpack to more stringent string.unpack

* Clarified parsing of the volume list in AFP FPGetSrvrParms

* Add cross references between the 2 whois scripts

* Streamline Boolean expressions

* Centralize AFP timestamp conversion to string

* Fix a word-wrapping issue

* Prevent SSH2 KEX confusion. Fixes nmap#2105

* Add ssh2.fetch_host_key() support for group 16

* Handle case of corrupted TCP options with length 0. Fixes nmap#2104

* Add iDRAC9 fingerprint to http-default-accounts. Closes nmap#2096

* fix license url: http -> https

* Implementation of TLS SNI override in Ncat
Closes nmap#2087, closes nmap#1928, fixes nmap#1927, fixes nmap#1974

* Fix off-by-one issue in last change. Fixes nmap#2107

* Be more strict with TCP options parsing, avoid reading off the end of TCP options. See nmap#2107

* Remove nmap-update

This feature was never publicly released, and has not been distributed
in our binary builds for a couple versions now. It needed to be removed
in order to reduce the number of places Nmap looks for data files. See nmap#2051

* If fetchfile didn't find the XSL, use a relative path on all platforms.

* Do not search NMAPDATADIR on Windows as it is not defined. See nmap#2051

* Remove an unused variable

* Require trailing '/' to match a directory name with --script. See nmap#2051

* Stop using Shellshock in header name. Fixes nmap#1983

* Fix line wrapping

* Speed improvement for script afp-ls. Closes nmap#2098

* New option --discovery-ignore-rst. Closes nmap#1616

* Nbase is needed for __attribute__ on Windows

* include string_pool in Windows build

* Use larger buffer size for socket errors (WSAETIMEDOUT was longer).

* Allow multiple UDP payloads per port. Closes nmap#1859 (payloads to be committed later)

* New UDP payloads. Closes nmap#1860

* Use ASCII chars for some payload data where it makes sense

* Pass error along instead of printing (link error)

* OpenSSL 1.1.X renamed libs: libeay32->libcrypto ssleay32->libssl

* More OpenSSL DLL name changes

* One last libeay32->libcrypto name change

* Fix loopback detection on Windows with new Npcap

* Add some popular favicon hashes

* Update nmap-mac-prefixes

* Update nmap-services from IANA

* Handle too-short response in s7-info. See nmap#2117

* Remove a todo item that is done (--resolve-all)

* Update dated 'class' network terms to CIDR. Closes nmap#2054

* Call superclass's init method from derived class

* Use signed value for tcp header offset and option lengths to detect underflow

* Correctly check for unsigned subtraction underflow.

* Add some missing changelog entries

* Tell LGTM to use the correct version of Python (2)

* Process new Linux and OpenBSD fingerprints

* Only get SSL options if we use them, currently for NO_SSLv2

* Process a few service fingerprint submissions

* Add a requested feature

* Try to make sure enough data is present before parsing. See nmap#2117

* Replace hyphens in the client SSH banner
Hyphen is not allowed in the software version string (RFC 4253, section 4.2)

* Update the SSH protocol flow. Closes nmap#1460
Allows the server to start the key exchange before the protocol version
exchange (banner exchange) is completed

* Silence static analysis warning

LGTM points out that since comparison with sizeof(buf) coerces n to
unsigned, all negative values become very large values, which are
necessarily larger than sizeof(buf), so the test is redundant. We still
want the test in our code to be explicit that we are checking for it, so
reordering the comparisons should silence the warning. A good optimizing
compiler should be able to combine the two conditions anyway.

See github/codeql#4249

* Be explicit about truncating division (timeout is in whole milliseconds)

* Improve docs on -Pn and host discovery

"Host discovery" is the preferred term over "ping scan" because of
confusion with ICMP Echo Request, a.k.a. "ping" as used by the "ping"
utility. Warn when users use -Pn because it has negative impact on scan
times since ultrascan timing parameters fall back to slow initial
defaults.

* Fix a config issue with LGTM (libverbs not linked in libpcap)

* Update IPv6 classifier based on new submissions through 2020-09-14

* Fix a meaningless error message when parsing IPv6 extension headers.

* Allow %F date format to mean YYYY-mm-dd like GNU date

* Remove duplicate test conditionals already tested in enclosing block

* Properly handle pcap reads in iocp engine. Fixes nmap#2126

Still has an odd code smell, but this fixes my test case with Nping.

* Add missing prototype

* Make IOCP the default Nsock engine on Windows. See nmap#2126

* Update macosx build to OpenSSL 1.1.1h, use jhbuild for all build steps

* Default rule base for script mysql-audit. See nmap#2125

* Avoid masked use of date before 1/1/1970 UTC. Fixes nmap#2136, closes nmap#2137

* Fix a CHANGELOG typo

* Reintegrate Nmap 7.90 release branch

* Bump version and regen docs for 7.90SVN post-release

* Only warn about protocol specs in port list with -p. Fixes nmap#2135

* Handle a weird IOCP error for UDP sockets. Fixes nmap#2140

Co-authored-by: nnposter <nnposter@e0a8ed71-7df4-0310-8962-fdc924857419>
Co-authored-by: dmiller <dmiller@e0a8ed71-7df4-0310-8962-fdc924857419>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@lynnewu @dmiller-nmap and others