Skip to content

Add RAP fallback to smb_enumshares for legacy SMB hosts#21123

Open
Z6543 wants to merge 1 commit intorapid7:masterfrom
Z6543:smb-enumshares-rap-fallback
Open

Add RAP fallback to smb_enumshares for legacy SMB hosts#21123
Z6543 wants to merge 1 commit intorapid7:masterfrom
Z6543:smb-enumshares-rap-fallback

Conversation

@Z6543
Copy link

@Z6543 Z6543 commented Mar 16, 2026

Depends on: rapid7/ruby_smb#294 (must be merged first)

Summary

  • Add RAP (Remote Administration Protocol) fallback to smb_enumshares when SRVSVC share enumeration fails, enabling share enumeration on Windows 95/98/ME and other legacy SMB hosts that don't support DCERPC
  • Map RAP integer share types (0=DISK, 1=PRINTER, etc.) to the string format the module expects, so filtering, spidering, and reporting work unchanged
  • Add direct: false to the SMB1 connect call on port 139 to ensure proper NetBIOS session setup

Verification

  • Against a modern SMB host: SRVSVC succeeds as before, RAP path is never reached
  • Against a legacy Win9x/ME host on port 139: SRVSVC fails with UnexpectedStatusCode/InvalidPacket, module falls back to RAP and enumerates shares successfully
  • Share option filtering works with both SRVSVC and RAP results

Depends on: rapid7/ruby_smb#294 (must be merged first)

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants