Generated from Manticore v1.1.6 • 388 packages. View on pkg.go.dev

transport

import "github.com/TheManticoreProject/Manticore/network/smb/common/transport"

Index

Constants

Default SMB listening ports: 445 carries SMB directly over TCP, while 139 carries it inside a NetBIOS session (RFC 1002).

const (
    DefaultDirectTCPPort = "445"
    DefaultNBTPort       = "139"
)

type Listener

Listener is the accept side of the SMB transport layer, the counterpart of Transport’s Connect. Accept yields a Transport that is already connected and whose transport-level handshake, if the transport has one, is already complete, so a server above it can treat both transports identically.

type Listener interface {
    // Accept blocks until a client connects and returns it as a Transport
    // together with its remote address. A connection whose transport-level
    // handshake fails is discarded rather than returned, so Accept only ever
    // yields a Transport ready to carry SMB messages.
    Accept() (Transport, net.Addr, error)

    // Close stops listening. It does not close the connections already handed
    // out by Accept; those are owned by their callers.
    Close() error

    // Addr returns the address the listener is bound to, which is how a caller
    // discovers the port when it asked for port 0.
    Addr() net.Addr
}

func ListenNBT

func ListenNBT(addr string, acceptedNames []string) (Listener, error)

ListenNBT listens for NetBIOS-over-TCP SMB connections on addr, completing the RFC 1002 4.3 session handshake on each accepted connection before returning it. An addr with no port (including the empty string) is bound on DefaultNBTPort.

acceptedNames are the CALLED NetBIOS names this endpoint answers to; an empty list answers to any name, and the “*SMBSERVER” wildcard is always answered.

Parameters:

  • addr: the address to bind, e.g. “0.0.0.0:139”, “:139”, "" or “127.0.0.1:0”
  • acceptedNames: the CALLED names to serve, or nil to serve any

Returns:

  • A Listener yielding NetBIOS over TCP transports
  • An error if the address cannot be bound

func ListenTCP

func ListenTCP(addr string) (Listener, error)

ListenTCP listens for Direct TCP SMB connections on addr. An addr with no port (including the empty string) is bound on DefaultDirectTCPPort.

Parameters:

  • addr: the address to bind, e.g. “0.0.0.0:445”, “:445”, "" or “127.0.0.1:0”

Returns:

  • A Listener yielding Direct TCP transports
  • An error if the address cannot be bound

type Transport

type Transport interface {
    Connect(ipaddr net.IP, port int) error

    Close() error

    Send(data []byte) (int, error)

    Receive() ([]byte, error)

    IsConnected() bool

    // SetTimeout bounds Connect and each subsequent Receive: Connect fails if
    // the connection cannot be established within d, and Receive fails if a
    // frame does not arrive within d. A non-positive d removes the bound
    // (blocking I/O), which is the initial state of every transport.
    SetTimeout(d time.Duration)
}

func NewTransport

func NewTransport(transportType string) Transport