Fix SAPDIAG probe: extract SID, hostname and kernel from DIAG port#6
Open
kloris wants to merge 1 commit into
Open
Fix SAPDIAG probe: extract SID, hostname and kernel from DIAG port#6kloris wants to merge 1 commit into
kloris wants to merge 1 commit into
Conversation
…2XX)
The existing SAPDIAG softmatch regex never matched because the header
anchor pattern (\x00\x00\x11) does not appear in actual SAP Dispatcher
responses. The response starts with a plain NI header (\x00\x00..),
followed directly by DIAG items — no \x11 byte at offset 4.
This was confirmed against SAP S/4HANA (kernel 793) where the probe
successfully returns the full login screen (~4KB), but the softmatch
silently fails and nmap falls through to the SAPDISP probe which only
reports "SAP ABAP Dispatcher" without SID, hostname, or version info.
Changes:
- Fix header anchor to match actual NI response format (^\x00\x00.{2})
- Promote softmatch to match (this is a definitive service identification)
- Rename "DB name" to "SID" in the info string for clarity
- Add fallback match for login screens without kernel version item
- Add match for DIAG error responses that leak SID in the error text
("invalid gui connect data (location <host>_<SID>_<inst>-<wp>)")
- Add comments documenting the probe and ST_R3INFO item structure
Tested with nmap 7.91 against SAP S/4HANA kernel 793 on port 3201:
3201/tcp open sapdiag SAP ABAP Dispatcher kernel 7930, patch level 100,
database release 758 (SID S4D)
Service Info: Host: srv03s4d1
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
softmatchregex on the SAPDIAG probe — the header anchor pattern\x00\x00\x11does not appear in actual SAP Dispatcher responses (actual:\x00\x00NI header), so SID/hostname/kernel were never extractedmatch(definitive service identification) and rename "DB name" → "SID" for claritySIDin the error textProblem
The existing SAPDIAG probe successfully sends a TERM_INI packet and receives the full login screen (~4KB) containing
ST_R3INFOitems with SID, hostname, and kernel version. However, thesoftmatchregex never fires because it expects\x00\x00\x11at byte offset 4, while the actual response has\x00\x00\x00(plain NI header with no DP header in the response).As a result, nmap falls through to the
SAPDISPprobe which only reports:...with no SID, hostname, or version information.
After this fix
Match rules added
\x10\x06\x29item"location <host>_<SID>_<NR>")Test plan
SAPDISPfallback probe still works for basic detection🤖 Generated with Claude Code