Generated from Manticore v1.1.5 • 201 packages. View on pkg.go.dev

createcontext

import "github.com/TheManticoreProject/Manticore/network/smb/smb_v20/createcontext"

Package createcontext implements the SMB2_CREATE_CONTEXT structure carried in the variable buffer of SMB2 CREATE requests and responses. A create context is a tagged name/data pair (durable-handle request, lease request, query maximal-access, allocation size, …); CREATE carries a chained list of them.

The SMB2 CREATE command bodies keep the context list as a raw []byte (CreateRequest.CreateContexts / CreateResponse.CreateContexts); this package builds and parses that buffer into typed contexts.

[MS-SMB2] 2.2.13.2 SMB2_CREATE_CONTEXT Request Values: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/93a3d702-90a0-4c8a-86c4-12dfa9230f5f

Index

Variables

Well-known SMB2_CREATE_CONTEXT name tags (MS-SMB2 2.2.13.2). The name is the ASCII tag the server matches against; most are 4 bytes.

var (
    NameExtendedAttributes = []byte("ExtA") // SMB2_CREATE_EA_BUFFER
    NameSecurityDescriptor = []byte("SecD") // SMB2_CREATE_SD_BUFFER
    NameDurableHandleReq   = []byte("DHnQ") // SMB2_CREATE_DURABLE_HANDLE_REQUEST
    NameDurableHandleRecon = []byte("DHnC") // SMB2_CREATE_DURABLE_HANDLE_RECONNECT
    NameAllocationSize     = []byte("AlSi") // SMB2_CREATE_ALLOCATION_SIZE
    NameQueryMaximalAccess = []byte("MxAc") // SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST
    NameTimewarpToken      = []byte("TWrp") // SMB2_CREATE_TIMEWARP_TOKEN
    NameQueryOnDiskID      = []byte("QFid") // SMB2_CREATE_QUERY_ON_DISK_ID
    NameRequestLease       = []byte("RqLs") // SMB2_CREATE_REQUEST_LEASE
)

func Marshal

func Marshal(contexts []CreateContext) ([]byte, error)

Marshal encodes a list of create contexts into the chained, 8-byte-aligned buffer carried by CreateRequest/CreateResponse.CreateContexts. Each context’s Name is placed immediately after the 16-byte header; its Data (when present) follows on the next 8-byte boundary. Every context except the last is padded so the next begins on an 8-byte boundary, and its Next field is set accordingly.

type CreateContext

CreateContext is a single SMB2_CREATE_CONTEXT: a name tag and its associated data buffer (either may drive the create behavior; Data is empty for contexts that carry only a name).

type CreateContext struct {
    Name []byte
    Data []byte
}

func Parse

func Parse(buf []byte) ([]CreateContext, error)

Parse decodes a chained SMB2_CREATE_CONTEXT buffer into its contexts. All offsets and lengths are validated against the buffer, so a malformed (server-controlled) list is rejected rather than indexing out of range.