Skip to content

Fix SMB share type reporting in SRVS responses - #2280

Open
gabrielg5 wants to merge 1 commit into
masterfrom
fix/issue-2271-smb-share-type
Open

gabrielg5 wants to merge 1 commit into
masterfrom
fix/issue-2271-smb-share-type

Conversation

@gabrielg5

Copy link
Copy Markdown
Collaborator

Fixes #2271

Convert configured SMB share types to integers before assigning them to the SRVS SHARE_INFO_1 response fields.

Share types are stored as strings by ConfigParser. Passing those strings directly to the NDR DWORD field caused every share to be reported as STYPE_DISKTREE (0).

Regression tests now verify disk, printer, and IPC share types.

@anadrianmanrique anadrianmanrique self-assigned this Sep 10, 2026
@anadrianmanrique anadrianmanrique added the enhancement Implemented features can be improved or revised label Sep 10, 2026
godylockz pushed a commit to godylockz/impacket that referenced this pull request Nov 11, 2026
@qianeric-backup

Copy link
Copy Markdown
Contributor

I had opened #2355 for the same two lines before noticing this one, and closed it as a duplicate. Copying the verification here in case it saves you a step -- the change is correct and I don't want the data to go to waste.

Three shares configured with shareType 0 / 1 / 3, queried with smbclient:

before                          after
Sharename   Type                Sharename   Type
IPC$        Disk                IPC$        IPC
DISK        Disk                DISK        Disk
PRINTER     Disk                PRINTER     Printer

Two observations that may be useful for the review:

This aligns SMB2 with SMB1, it doesn't invent a convention. The SMB1 handlers already coerce in both places (MSRPC_UUID_SRVS_NETR_SHARE_ENUM and _GET_INFO both do int(shares[i]['share type'])), so the missing int() in the SMB2 path is an inconsistency rather than a design choice.

int() will raise on a non-numeric value. ConfigParser returns whatever was written, so shareType = printer gives ValueError inside the RPC handler. That is pre-existing and SMB1 has exactly the same exposure, so I don't think it belongs in this PR -- just noting it so it isn't a surprise later.

One nit on the test, take it or leave it: it asserts the value round-trips as an int, which it will. Asserting the specific STYPE_* constants for the three cases would also catch a future change that coerces correctly but to the wrong value.

godylockz pushed a commit to godylockz/impacket that referenced this pull request Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Implemented features can be improved or revised

Projects

None yet

Development

Successfully merging this pull request may close these issues.

All SMB shares report type of Disk

3 participants