Add RAP fallback to smb_enumshares for legacy SMB hosts#21123
Open
Z6543 wants to merge 1 commit intorapid7:masterfrom
Open
Add RAP fallback to smb_enumshares for legacy SMB hosts#21123Z6543 wants to merge 1 commit intorapid7:masterfrom
Z6543 wants to merge 1 commit intorapid7:masterfrom
Conversation
The smb_enumshares module uses DCERPC/SRVSVC (net_share_enum_all) to enumerate shares. Windows 95/98/ME and other legacy SMB hosts do not support DCERPC and return DBG_CONTINUE, causing the module to fail with no results. Fall back to the RAP (Remote Administration Protocol) method net_share_enum_rap when SRVSVC raises UnexpectedStatusCode or InvalidPacket. RAP sends a NetShareEnum request over \PIPE\LANMAN, which is the only share-enumeration method these hosts support. RAP returns integer share types (0=DISK, 1=PRINTER, 2=DEVICE, 3=IPC) rather than the string labels SRVSVC uses. A RAP_SHARE_TYPES constant maps these integers to the same string format the rest of the module expects, so share filtering, spidering, and reporting all work unchanged. Co-Authored-By: Claude Opus 4.6 <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.
Depends on: rapid7/ruby_smb#294 (must be merged first)
Summary
smb_enumshareswhen SRVSVC share enumeration fails, enabling share enumeration on Windows 95/98/ME and other legacy SMB hosts that don't support DCERPCdirect: falseto the SMB1 connect call on port 139 to ensure proper NetBIOS session setupVerification
UnexpectedStatusCode/InvalidPacket, module falls back to RAP and enumerates shares successfullyShareoption filtering works with both SRVSVC and RAP resultsDepends on: rapid7/ruby_smb#294 (must be merged first)