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

client

import "github.com/TheManticoreProject/Manticore/network/cifs/client"

Index

type Client

Client represents an SMB v1.0 client

type Client struct {
    // Transport is the transport layer for the client
    Transport transport.Transport

    // TreeConnect is the tree connect for the client
    TreeConnect *TreeConnect

    // Session is the session for the client
    Session *Session

    // Connection is the connection for the client
    Connection *Connection
}

func NewClientUsingNBTTransport

func NewClientUsingNBTTransport(host net.IP, port int) *Client

NewClientUsingNBTTransport creates a new SMB v1.0 client using NBT transport

Returns:

  • A pointer to the initialized SMB client
  • An error if the client initialization fails

func (*Client) Connect

func (c *Client) Connect(ipaddr net.IP, port int) error

Connect establishes a connection to an SMB server

Returns:

  • An error if the connection fails

func (*Client) GetHost

func (c *Client) GetHost() net.IP

GetHost returns the current host IP address of the SMB client

func (*Client) GetPort

func (c *Client) GetPort() int

GetPort returns the current port number of the SMB client

func (*Client) GetRemoteServerTime

func (c *Client) GetRemoteServerTime() (time.Time, error)

GetRemoteServerTime retrieves the current time from the remote server.

This function sends an SMB_COM_QUERY_TIME_REQUEST message to the server and receives the server’s current time in UTC.

The query process: 1. Creates and sends an SMB_COM_NEGOTIATE_REQUEST message 2. Receives the SMB_COM_NEGOTIATE_RESPONSE from the server 3. Validates the response command type 4. Processes server capabilities and configuration

Returns:

  • nil if negotiation is successful
  • An error if any step in the negotiation process fails (connection issues, message creation/marshalling errors, transport errors, or unexpected responses)

func (*Client) Negotiate

func (c *Client) Negotiate() error

Negotiate initiates the SMB protocol negotiation with the server.

This function performs the SMB_COM_NEGOTIATE exchange, which is the first step in establishing an SMB session. It sends a list of dialects supported by the client and receives the server’s preferred dialect along with server capabilities.

The negotiation process: 1. Creates and sends an SMB_COM_NEGOTIATE_REQUEST message 2. Receives the SMB_COM_NEGOTIATE_RESPONSE from the server 3. Validates the response command type 4. Processes server capabilities and configuration

Returns:

  • nil if negotiation is successful
  • An error if any step in the negotiation process fails (connection issues, message creation/marshalling errors, transport errors, or unexpected responses)

func (*Client) SessionSetup

func (c *Client) SessionSetup() error

func (*Client) SetHost

func (c *Client) SetHost(host net.IP)

SetHost sets the host IP address for the SMB client

func (*Client) SetPort

func (c *Client) SetPort(port int)

SetPort sets the port number for the SMB client

type Connection

Connection represents an established SMB connection between the client and server

type Connection struct {
    Server *Server

    // ClientNextSendSequenceNumber is the sequence number for the next signed request being sent
    ClientNextSendSequenceNumber uint32

    // ClientResponseSequenceNumber is the expected sequence numbers for responses of outstanding signed requests, indexed by PID and MID
    ClientResponseSequenceNumber map[uint32]uint32

    // ConnectionlessSessionID is the SMB Connection identifier for connectionless transport
    ConnectionlessSessionID uint32

    // IsSigningActive indicates whether message signing is active
    IsSigningActive bool

    // NegotiateSent indicates whether an SMB_COM_NEGOTIATE request has been sent
    NegotiateSent bool

    // NTLMChallenge is the cryptographic challenge received from the server during negotiation
    NTLMChallenge []byte

    // OpenTable is the list of Opens, allowing lookups based on FID
    OpenTable map[uint16]interface{}

    // PIDMIDList is the list of outstanding SMB commands
    PIDMIDList []interface{}

    // SearchOpenTable is the list of SearchOpens representing open file searches
    SearchOpenTable []interface{}

    // SelectedDialect is the SMB Protocol dialect selected for this connection
    SelectedDialect string

    // MaxMpxCount is the maximum number of commands permitted to be outstanding
    MaxMpxCount uint16

    // SessionTable is the list of authenticated sessions established on this connection
    SessionTable map[uint16]*Session

    // ShareLevelAccessControl indicates whether the server requires share passwords instead of user accounts
    ShareLevelAccessControl bool

    // SigningChallengeResponse is the challenge response used for signing
    SigningChallengeResponse []byte

    // SigningSessionKey is the session key used for signing packets
    SigningSessionKey []byte

    // TreeConnectTable is the list of tree connects over this SMB connection
    TreeConnectTable map[uint16]interface{}
}

type Server

Server represents the server for the client

type Server struct {
    // Host is the IP address of the server
    Host net.IP

    // Port is the port number of the server
    Port int

    // Name is the name of the server
    Name string

    // SecurityMode is the security mode of the server
    SecurityMode securitymode.SecurityMode

    // SigningState is the signing policy of the server (Disabled, Enabled, or Required)
    SigningState string

    // Capabilities is the capabilities of the server
    Capabilities capabilities.Capabilities

    // MaxBufferSize is the negotiated maximum size for SMB messages sent to server
    MaxBufferSize uint32

    // ChallengeResponse indicates whether server supports challenge/response authentication
    ChallengeResponse bool

    // SessionKey is the session key value returned by the server in negotiate response
    SessionKey uint32

    // SystemTime is the system time of the server
    SystemTime types.SMB_TIME

    // TimeZone is the time zone of the server
    TimeZone int16

    // DomainName is the domain name of the server
    DomainName string
}

type Session

Session represents an established session between the client and server

type Session struct {
    // The SMB connection associated with this session
    Connection *Client

    // The cryptographic session key associated with this session
    SessionKey []byte

    // The 2-byte UID for this session
    SessionUID uint16

    // Opaque implementation-specific entity that identifies the credentials
    UserCredentials interface{}
}

type TreeConnect

TreeConnect represents an established tree connect between the client and share on the server

type TreeConnect struct {
    Connection *Connection // The SMB connection associated with this tree connect
    ShareName  string      // The share name corresponding to this tree connect
    TreeID     uint16      // The TreeID (TID) that identifies this tree connect
    Session    *Session    // A reference to the session on which this tree connect was established
    IsDfsShare bool        // A Boolean that, if set, indicates that the tree connect was established to a DFS share
}