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

tcp

import "github.com/TheManticoreProject/Manticore/network/dcerpc/v5/transport/tcp"

Package tcp implements the DCE/RPC ncacn_ip_tcp protocol sequence: DCE/RPC directly over a TCP connection.

Unlike ncacn_np (network/dcerpc/v5/transport/smb), which carries PDUs as SMB named pipe writes and reads, ncacn_ip_tcp has no intermediate framing: each PDU is written straight to the socket and the receive side is driven by the common header’s frag_length. This transport therefore implements Send as a single socket write of a complete PDU and Recv as a single socket read; reassembling fragments across reads is the DCE/RPC client’s responsibility (its fragmentReader buffers by frag_length).

The endpoint is an explicit host and port. The endpoint mapper (ept) on TCP port 135 resolves the dynamic port a service listens on; see the epm interface (network/dcerpc/interfaces/…) for that lookup.

References:

Index

Constants

Default fragment sizes proposed at Bind time. 5840 (0x16D0) is the classic Windows default for RPC over TCP. Callers that want different fragments can override via SetMaxFrag before Connect.

const (
    DefaultMaxXmitFrag uint16 = 5840
    DefaultMaxRecvFrag uint16 = 5840
)

EndpointMapperPort is the well-known TCP port of the endpoint mapper (ept), used to resolve the dynamic port of a service before connecting to it.

const EndpointMapperPort = 135

type TCPTransport

TCPTransport is a DCE/RPC transport over a TCP connection (ncacn_ip_tcp).

type TCPTransport struct {
    // contains filtered or unexported fields
}

func New

func New(host string, port int) *TCPTransport

New creates a TCP transport that will connect to the given host and port. host may be an IPv4 address, IPv6 address, or hostname; the port is the explicit RPC endpoint (use EndpointMapperPort to talk to the endpoint mapper).

func (*TCPTransport) Close

func (t *TCPTransport) Close() error

Close tears down the TCP connection. It is idempotent.

func (*TCPTransport) Connect

func (t *TCPTransport) Connect() error

Connect opens the TCP connection. It is idempotent.

func (*TCPTransport) MaxRecvFrag

func (t *TCPTransport) MaxRecvFrag() uint16

MaxRecvFrag returns the proposed maximum receive fragment size.

func (*TCPTransport) MaxXmitFrag

func (t *TCPTransport) MaxXmitFrag() uint16

MaxXmitFrag returns the proposed maximum transmit fragment size.

func (*TCPTransport) Recv

func (t *TCPTransport) Recv() ([]byte, error)

Recv reads up to MaxRecvFrag bytes from the socket and returns them. The result may hold part of a PDU, exactly one PDU, or several PDUs; the caller reassembles by frag_length. A read that returns no data before the peer closes the connection is reported as an error.

func (*TCPTransport) Send

func (t *TCPTransport) Send(pdu []byte) error

Send writes a complete PDU to the socket. A net.Conn write returns a non-nil error whenever fewer than len(pdu) bytes are written, so a single Write suffices.

func (*TCPTransport) SetMaxFrag

func (t *TCPTransport) SetMaxFrag(xmit, recv uint16)

SetMaxFrag overrides the transmit and receive fragment sizes proposed at Bind time. It must be called before Connect to take effect.

func (*TCPTransport) SetTimeout

func (t *TCPTransport) SetTimeout(d time.Duration)

SetTimeout bounds Connect and each subsequent Recv: Connect fails if the connection cannot be established within d, and Recv fails if no data arrives within d. A non-positive d removes the bound (blocking I/O). It must be called before Connect to affect the dial.