Merged
Conversation
Fixes #8. smbclient's interactive shell now supports list_snapshots, which enumerates VSS shadow copies on the currently selected share via FSCTL_SRV_ENUMERATE_SNAPSHOTS. Matches Impacket smbclient.py's list_snapshots output format. The response follows MS-SMB2 2.2.32 and requires a two-call size probe: the first ioctl uses a 16-byte output buffer to read the SRV_SNAPSHOT_ARRAY header (SnapShotArraySize tells us how large the second buffer needs to be), then a second ioctl asks for the full payload and parses the UTF-16LE NUL-separated @GMT-... tokens. Changes: - pkg/third_party/smb2/client.go: add an exported Ioctl method on *File as a thin wrapper over the internal ioctl helper, so FSCTL operations beyond FSCTL_PIPE_TRANSCEIVE don't need their own dedicated method in the vendored library. - pkg/smb/client.go: EnumerateSnapshots() method on *Client. Handles the size-probe dance, parses the UTF-16LE token list via pkg/utf16le, returns []string. Empty slice when no snapshots exist. - tools/smbclient/main.go: wire list_snapshots into the shell's command switch and help text. Unblocks the VSS-based NTDS extraction path: use c$ list_snapshots # get @GMT-YYYY.MM.DD-HH.MM.SS get @GMT-...\Windows\NTDS\ntds.dit secretsdump -ntds ntds.dit -system SYSTEM
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
Fixes #8. Adds
list_snapshotstosmbclient's interactive shell, which enumerates VSS shadow copies on the currently selected share viaFSCTL_SRV_ENUMERATE_SNAPSHOTS. Output format matches Impacket'ssmbclient.py:Unblocks the VSS-based NTDS extraction workflow (enumerate snapshot,
get @GMT-...\Windows\NTDS\ntds.dit, parse offline withsecretsdump -ntds).Protocol
MS-SMB2 2.2.32 requires a two-call size probe: the first ioctl uses a 16-byte output buffer to read the
SRV_SNAPSHOT_ARRAYheader (SnapShotArraySizetells us how large the second buffer needs to be), then a second ioctl asks for the full payload. The body is a sequence of UTF-16LE NUL-terminated@GMT-YYYY.MM.DD-HH.MM.SSstrings followed by a final UTF-16LE NUL.Changes
pkg/third_party/smb2/client.go: export anIoctl(ctlCode, input, maxOutput)method on*Fileas a thin wrapper over the internal ioctl helper, so FSCTL operations beyondFSCTL_PIPE_TRANSCEIVEdon't need their own dedicated method in the vendored library.pkg/smb/client.go: newEnumerateSnapshots() ([]string, error)method. Handles the size-probe dance, parses UTF-16LE tokens viapkg/utf16le, returns an empty slice when no snapshots exist.tools/smbclient/main.go: wirelist_snapshotsinto the shell's command switch and help text.Test plan
go build ./...cleango vet ./...cleanGOOS=windows CGO_ENABLED=0 go build ./...cleango test ./pkg/transport/passesvssadmin create shadow /for=C:. Confirmed output: