smbnego

package
v0.0.0-...-c8c792b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package smbnego facilitates SMB version 2 protocol negotiation.

Index

Constants

View Source
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.

View Source
const ContextHeaderLength = 8

ContextHeaderLength is the number of bytes required for a valid negotiation context header.

View Source
const MaxSecurityBuffer = 65535

MaxSecurityBuffer is the maximum length of the security buffer for a negotiation packet.

View Source
const RequestSize = 36

RequestSize is the number of bytes required for the fixed portion an SMB negotiation request.

View Source
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.

https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/15332256-522e-4a53-8cd7-0bd17678a2f7

func (Context) CompressionCaps

func (c Context) CompressionCaps() smbcompression.Capabilities

CompressionCaps interprets the context's data as a set of compression capabilities.

func (Context) Data

func (c Context) Data() []byte

Data returns the context's data as a slice of bytes.

func (Context) EncryptionCaps

func (c Context) EncryptionCaps() smbencryption.Capabilities

EncryptionCaps interprets the context's data as a set of encryption capabilities.

func (Context) Length

func (c Context) Length() uint16

Length returns the length of the context data in bytes.

func (Context) NetName

func (c Context) NetName() Name

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.

func (Context) Type

func (c Context) Type() ContextType

Type returns the type of the context.

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.

https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/15332256-522e-4a53-8cd7-0bd17678a2f7

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.

func (Name) String

func (n Name) String() string

String returns a string representation of the name.

type Request

type Request []byte

Request interprets a slice of bytes as an SMB negotiation request packet.

https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/e14db7ff-763a-4263-8b10-0c3944f52fc5

func (Request) Capabilities

func (r Request) Capabilities() smbcap.Flags

Capabilities returns the capability flags of the request.

func (Request) ClientID

func (r Request) ClientID() (id smbid.ID)

ClientID returns the client identifier of the request.

func (Request) ContextCount

func (r Request) ContextCount() uint16

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

func (r Request) ContextOffset() uint32

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

func (r Request) DialectCount() uint16

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

func (r Request) SetCapabilities(flags smbcap.Flags)

SetCapabilities sets the capability flags of the request.

func (Request) SetClientID

func (r Request) SetClientID(id smbid.ID)

SetClientID sets the client identifier of the request.

func (Request) SetContextCount

func (r Request) SetContextCount(count uint16)

SetContextCount sets the negotiation context count of the request.

This field is only valid in the SMB 3.1.1 dialect.

func (Request) SetContextOffset

func (r Request) SetContextOffset(size uint32)

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

func (r Request) SetDialectCount(count uint16)

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) SetSize

func (r Request) SetSize(size uint16)

SetSize sets the structure size of the request.

func (Request) Size

func (r Request) Size() uint16

Size returns the structure size of the request. The specification requires that this be 36, regardless of the number of dialects or negotiation contexts.

func (Request) Summary

func (r Request) Summary() string

Summary returns a multi-line string representation of the request.

func (Request) Valid

func (r Request) Valid() bool

Valid returns true if the request is valid.

type Response

type Response []byte

Response interprets a slice of bytes as an SMB negotiation response packet.

https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/63abf97c-0d09-47e2-88d6-6bfa552949a5

func (Response) Capabilities

func (r Response) Capabilities() smbcap.Flags

Capabilities returns the capability flags of the response.

func (Response) ContextCount

func (r Response) ContextCount() uint16

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

func (r Response) ContextOffset() uint32

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

func (r Response) MaxReadSize() uint32

MaxReadSize returns the maximum read size of the response.

func (Response) MaxTransactSize

func (r Response) MaxTransactSize() uint32

MaxTransactSize returns the maximum transaction size of the response.

func (Response) MaxWriteSize

func (r Response) MaxWriteSize() uint32

MaxWriteSize returns the maximum write size of the response.

func (Response) SecurityBuffer

func (r Response) SecurityBuffer() []byte

SecurityBuffer returns the bytes of the security buffer from the response.

func (Response) SecurityBufferLength

func (r Response) SecurityBufferLength() uint16

SecurityBufferLength returns the length of the security buffer within the response.

func (Response) SecurityBufferOffset

func (r Response) SecurityBufferOffset() uint16

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) ServerID

func (r Response) ServerID() (id smbid.ID)

ServerID returns the server identifier of the response.

func (Response) ServerStartTime

func (r Response) ServerStartTime() time.Time

ServerStartTime returns the server start time of the response.

func (Response) SetCapabilities

func (r Response) SetCapabilities(flags smbcap.Flags)

SetCapabilities sets the capability flags of the response.

func (Response) SetContextCount

func (r Response) SetContextCount(size uint16)

SetContextCount sets the context count of the response.

This field is only valid in the SMB 3.1.1 dialect.

func (Response) SetContextOffset

func (r Response) SetContextOffset(size uint32)

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

func (r Response) SetMaxReadSize(size uint32)

SetMaxReadSize sets the maximum read size of the response.

func (Response) SetMaxTransactSize

func (r Response) SetMaxTransactSize(size uint32)

SetMaxTransactSize sets the maximum transaction size of the response.

func (Response) SetMaxWriteSize

func (r Response) SetMaxWriteSize(size uint32)

SetMaxWriteSize sets the maximum write size of the response.

func (Response) SetSecurityBuffer

func (r Response) SetSecurityBuffer(v []byte)

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

func (r Response) SetSecurityBufferLength(length uint16)

SetSecurityBufferLength sets the length of the security buffer within the response.

func (Response) SetSecurityBufferOffset

func (r Response) SetSecurityBufferOffset(offset uint16)

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

func (r Response) SetServerID(id smbid.ID)

SetServerID sets the server identifier of the response.

func (Response) SetServerStartTime

func (r Response) SetServerStartTime(t time.Time)

SetServerStartTime sets the server start time of the response.

func (Response) SetSize

func (r Response) SetSize(size uint16)

SetSize sets the structure size of the response.

func (Response) SetSystemTime

func (r Response) SetSystemTime(t time.Time)

SetSystemTime sets the system time of the response.

func (Response) Size

func (r Response) Size() uint16

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) Summary

func (r Response) Summary() string

Summary returns a multi-line string representation of the response.

func (Response) SystemTime

func (r Response) SystemTime() time.Time

SystemTime returns the system time of the response.

func (Response) Valid

func (r Response) Valid() bool

Valid returns true if the response is valid.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL