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

message

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

Index

func MarshalCompound

func MarshalCompound(messages []*Message) ([]byte, error)

MarshalCompound serializes a sequence of SMB2 messages into a single compounded request/response.

Each message contributes a 64-byte header followed by its command body. Every segment except the last is padded with zero bytes so that the following header starts on an 8-byte boundary, and each non-last header’s NextCommand is set to the offset, in bytes, from the start of that header to the start of the next header. The last header’s NextCommand is 0.

Source: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/fb188936-5050-48d3-b350-dc43059638a4

type Message

Message is a single SMB2 message: a 64-byte header followed by one command body. Compounded messages (several header+body segments chained via the header NextCommand field) are handled by MarshalCompound / UnmarshalCompound; each segment is itself a Message.

type Message struct {
    Header  *header.Header
    Command command_interface.CommandInterface
}

func NewMessage

func NewMessage() *Message

NewMessage creates an empty SMB2 message with a default header and no command.

func UnmarshalCompound

func UnmarshalCompound(data []byte) ([]*Message, error)

UnmarshalCompound parses a compounded SMB2 message into its constituent messages by following each header’s NextCommand offset. A single (non-compounded) message parses into a one-element slice.

func (*Message) Marshal

func (m *Message) Marshal() ([]byte, error)

Marshal serializes a single (non-compounded) SMB2 message: the header followed by the command body. NextCommand is forced to 0. Use MarshalCompound to chain several messages.

func (*Message) SetCommand

func (m *Message) SetCommand(command command_interface.CommandInterface)

SetCommand attaches a command to the message and copies its command code into the header.

func (*Message) Unmarshal

func (m *Message) Unmarshal(data []byte) (int, error)

Unmarshal deserializes a single SMB2 message from the start of data. The command body runs from the end of the header to the header’s NextCommand offset when set (a compounded segment), or to the end of data otherwise.

Returns the number of bytes consumed: the NextCommand offset when set, or the full length of data otherwise.

Subpackages