Documentation ¶
Overview ¶
Package smbnego facilitates SMB version 2 protocol negotiation.
Index ¶
- Constants
- type Context
- func (c Context) CompressionCaps() smbcompression.Capabilities
- func (c Context) Data() []byte
- func (c Context) EncryptionCaps() smbencryption.Capabilities
- func (c Context) Length() uint16
- func (c Context) NetName() Name
- func (c Context) PreauthIntegrityCaps() smbintegrity.Capabilities
- func (c Context) Type() ContextType
- type ContextList
- type ContextOffset
- type ContextType
- type Name
- type Request
- func (r Request) Capabilities() smbcap.Flags
- func (r Request) ClientID() (id smbid.ID)
- func (r Request) ContextCount() uint16
- func (r Request) ContextList() ContextList
- func (r Request) ContextOffset() uint32
- func (r Request) DialectCount() uint16
- func (r Request) Dialects() smbdialect.List
- func (r Request) SecurityMode() smbsecmode.Flags
- func (r Request) SetCapabilities(flags smbcap.Flags)
- func (r Request) SetClientID(id smbid.ID)
- func (r Request) SetContextCount(count uint16)
- func (r Request) SetContextOffset(size uint32)
- func (r Request) SetDialectCount(count uint16)
- func (r Request) SetSecurityMode(flags smbsecmode.Flags)
- func (r Request) SetSize(size uint16)
- func (r Request) Size() uint16
- func (r Request) Summary() string
- func (r Request) Valid() bool
- type Response
- func (r Response) Capabilities() smbcap.Flags
- func (r Response) ContextCount() uint16
- func (r Response) ContextList() ContextList
- func (r Response) ContextOffset() uint32
- func (r Response) DialectRevision() smbdialect.Revision
- func (r Response) MaxReadSize() uint32
- func (r Response) MaxTransactSize() uint32
- func (r Response) MaxWriteSize() uint32
- func (r Response) SecurityBuffer() []byte
- func (r Response) SecurityBufferLength() uint16
- func (r Response) SecurityBufferOffset() uint16
- func (r Response) SecurityMode() smbsecmode.Flags
- func (r Response) ServerID() (id smbid.ID)
- func (r Response) ServerStartTime() time.Time
- func (r Response) SetCapabilities(flags smbcap.Flags)
- func (r Response) SetContextCount(size uint16)
- func (r Response) SetContextOffset(size uint32)
- func (r Response) SetDialectRevision(revision smbdialect.Revision)
- func (r Response) SetMaxReadSize(size uint32)
- func (r Response) SetMaxTransactSize(size uint32)
- func (r Response) SetMaxWriteSize(size uint32)
- func (r Response) SetSecurityBuffer(v []byte)
- func (r Response) SetSecurityBufferLength(length uint16)
- func (r Response) SetSecurityBufferOffset(offset uint16)
- func (r Response) SetSecurityMode(flags smbsecmode.Flags)
- func (r Response) SetServerID(id smbid.ID)
- func (r Response) SetServerStartTime(t time.Time)
- func (r Response) SetSize(size uint16)
- func (r Response) SetSystemTime(t time.Time)
- func (r Response) Size() uint16
- func (r Response) Summary() string
- func (r Response) SystemTime() time.Time
- func (r Response) Valid() bool
Constants ¶
const ( PreauthIntegrityCaps = 0x0001 // SMB2_PREAUTH_INTEGRITY_CAPABILITIES EncryptionCaps = 0x0002 // SMB2_ENCRYPTION_CAPABILITIES CompressionCaps = 0x0003 // SMB2_COMPRESSION_CAPABILITIES NetnameID = 0x0004 // SMB2_NETNAME_NEGOTIATE_CONTEXT_ID )
SMB negotiation context types.
const ContextHeaderLength = 8
ContextHeaderLength is the number of bytes required for a valid negotiation context header.
const MaxSecurityBuffer = 65535
MaxSecurityBuffer is the maximum length of the security buffer for a negotiation packet.
const RequestSize = 36
RequestSize is the number of bytes required for the fixed portion an SMB negotiation request.
const ResponseSize = 64
ResponseSize is the number of bytes required for the fixed portion an SMB negotiation response.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context []byte
Context interprets a slice of bytes as an SMB negotiation context during SMB 3.1.1 protocol negotiation.
func (Context) CompressionCaps ¶
func (c Context) CompressionCaps() smbcompression.Capabilities
CompressionCaps interprets the context's data as a set of compression capabilities.
func (Context) EncryptionCaps ¶
func (c Context) EncryptionCaps() smbencryption.Capabilities
EncryptionCaps interprets the context's data as a set of encryption capabilities.
func (Context) NetName ¶
NetName interprets the context's data as the name of the server the client wishes to connect to.
func (Context) PreauthIntegrityCaps ¶
func (c Context) PreauthIntegrityCaps() smbintegrity.Capabilities
PreauthIntegrityCaps interprets the context's data as a set of preauthentication integrity capabilities.
type ContextList ¶
type ContextList []byte
ContextList interprets a slice of bytes as an SMB negotiation context list.
func (ContextList) Member ¶
func (k ContextList) Member(offset ContextOffset) Context
Member returns the context at the given offset within the list.
func (ContextList) Next ¶
func (k ContextList) Next(last ContextOffset) (next ContextOffset)
Next returns the offset of the next member within the list after last.
func (ContextList) Valid ¶
func (k ContextList) Valid(count uint16) bool
Valid returns true if the negotiation context list has the expected number of valid contexts.
type ContextOffset ¶
type ContextOffset uint
ContextOffset defines the offset of a context within a negotiation context list.
type ContextType ¶
type ContextType uint16
ContextType identifies a type of negotiation context during SMB 3.1.1 protocol negotiation.
func (ContextType) String ¶
func (t ContextType) String() string
String returns a string representation of the context type.
type Name ¶
type Name []byte
Name interprets a slice of bytes as an SMB server name encoded as utf16.
type Request ¶
type Request []byte
Request interprets a slice of bytes as an SMB negotiation request packet.
func (Request) Capabilities ¶
Capabilities returns the capability flags of the request.
func (Request) ContextCount ¶
ContextCount returns the negotiation context count of the request.
This field is only valid in the SMB 3.1.1 dialect.
func (Request) ContextList ¶
func (r Request) ContextList() ContextList
ContextList returns the negotiation context list from the request.
If r is valid the returned list is guaranteed to be valid.
This field is only valid in the SMB 3.1.1 dialect.
func (Request) ContextOffset ¶
ContextOffset returns the offset of the first negotiation context in the request.
This field is only valid in the SMB 3.1.1 dialect.
func (Request) DialectCount ¶
DialectCount returns the dialect count of the request.
func (Request) Dialects ¶
func (r Request) Dialects() smbdialect.List
Dialects returns the dialect list from the request.
func (Request) SecurityMode ¶
func (r Request) SecurityMode() smbsecmode.Flags
SecurityMode returns the security mode of the request.
func (Request) SetCapabilities ¶
SetCapabilities sets the capability flags of the request.
func (Request) SetClientID ¶
SetClientID sets the client identifier of the request.
func (Request) SetContextCount ¶
SetContextCount sets the negotiation context count of the request.
This field is only valid in the SMB 3.1.1 dialect.
func (Request) SetContextOffset ¶
SetContextOffset sets the offset of the first negotiation context in the request.
This field is only valid in the SMB 3.1.1 dialect.
func (Request) SetDialectCount ¶
SetDialectCount sets the dialect count of the request.
func (Request) SetSecurityMode ¶
func (r Request) SetSecurityMode(flags smbsecmode.Flags)
SetSecurityMode sets the security mode of the request.
func (Request) Size ¶
Size returns the structure size of the request. The specification requires that this be 36, regardless of the number of dialects or negotiation contexts.
type Response ¶
type Response []byte
Response interprets a slice of bytes as an SMB negotiation response packet.
func (Response) Capabilities ¶
Capabilities returns the capability flags of the response.
func (Response) ContextCount ¶
ContextCount returns the context count of the response.
This field is only valid in the SMB 3.1.1 dialect.
func (Response) ContextList ¶
func (r Response) ContextList() ContextList
ContextList returns the negotiation context list from the response.
If r is valid the returned list is guaranteed to be valid.
This field is only valid in the SMB 3.1.1 dialect.
func (Response) ContextOffset ¶
ContextOffset returns the offset of the first negotiate context in bytes from the start of the packet header.
This field is only valid in the SMB 3.1.1 dialect.
func (Response) DialectRevision ¶
func (r Response) DialectRevision() smbdialect.Revision
DialectRevision returns the dialect revision of the response.
func (Response) MaxReadSize ¶
MaxReadSize returns the maximum read size of the response.
func (Response) MaxTransactSize ¶
MaxTransactSize returns the maximum transaction size of the response.
func (Response) MaxWriteSize ¶
MaxWriteSize returns the maximum write size of the response.
func (Response) SecurityBuffer ¶
SecurityBuffer returns the bytes of the security buffer from the response.
func (Response) SecurityBufferLength ¶
SecurityBufferLength returns the length of the security buffer within the response.
func (Response) SecurityBufferOffset ¶
SecurityBufferOffset returns the offset of the security buffer in bytes from the start of the packet header.
func (Response) SecurityMode ¶
func (r Response) SecurityMode() smbsecmode.Flags
SecurityMode returns the security mode of the response.
func (Response) ServerStartTime ¶
ServerStartTime returns the server start time of the response.
func (Response) SetCapabilities ¶
SetCapabilities sets the capability flags of the response.
func (Response) SetContextCount ¶
SetContextCount sets the context count of the response.
This field is only valid in the SMB 3.1.1 dialect.
func (Response) SetContextOffset ¶
SetContextOffset sets the offset of the first negotiate context in bytes from the start of the packet header.
This field is only valid in the SMB 3.1.1 dialect.
func (Response) SetDialectRevision ¶
func (r Response) SetDialectRevision(revision smbdialect.Revision)
SetDialectRevision sets the dialect revision of the response.
func (Response) SetMaxReadSize ¶
SetMaxReadSize sets the maximum read size of the response.
func (Response) SetMaxTransactSize ¶
SetMaxTransactSize sets the maximum transaction size of the response.
func (Response) SetMaxWriteSize ¶
SetMaxWriteSize sets the maximum write size of the response.
func (Response) SetSecurityBuffer ¶
SetSecurityBuffer sets the bytes of the security buffer within the response. It also updates the security buffer offset and length automatically.
If len(v) exceeds MaxSecurityBuffer the call will panic.
If the response is too small to hold all of v the call will panic.
func (Response) SetSecurityBufferLength ¶
SetSecurityBufferLength sets the length of the security buffer within the response.
func (Response) SetSecurityBufferOffset ¶
SetSecurityBufferOffset sets the offset of the security buffer in bytes from the start of the packet header.
func (Response) SetSecurityMode ¶
func (r Response) SetSecurityMode(flags smbsecmode.Flags)
SetSecurityMode sets the security mode of the response.
func (Response) SetServerID ¶
SetServerID sets the server identifier of the response.
func (Response) SetServerStartTime ¶
SetServerStartTime sets the server start time of the response.
func (Response) SetSystemTime ¶
SetSystemTime sets the system time of the response.
func (Response) Size ¶
Size returns the structure size of the response. The specification requires that this be 65, regardless of the size of the security buffer or the number of negotiation contexts.
func (Response) SystemTime ¶
SystemTime returns the system time of the response.