rpc

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

A minimal implementation of MS-RPC protocol

Index

Constants

View Source
const (
	PACKET_TYPE_REQUEST                = 0x00
	PACKET_TYPE_RESPONSE               = 0x02
	PACKET_TYPE_FAULT                  = 0x03
	PACKET_TYPE_BIND                   = 0x0b
	PACKET_TYPE_BIND_ACK               = 0x0c
	PACKET_TYPE_BIND_NAK               = 0x0d
	PACKET_TYPE_ALTER_CONTEXT          = 0x0e
	PACKET_TYPE_ALTER_CONTEXT_RESPONSE = 0x0f
	PACKET_TYPE_AUTH3                  = 0x10
	PACKET_TYPE_SHUTDOWN               = 0x11
	PACKET_TYPE_CANCEL                 = 0x12
	PACKET_TYPE_ORPHANED               = 0x13
)
View Source
const (
	PFC_FIRST_FRAG          = 0x01
	PFC_LAST_FRAG           = 0x02
	PFC_PENDING_CANCEL      = 0x04
	PFC_SUPPORT_HEADER_SIGN = 0x04
	PFC_CONC_MPX            = 0x10
	PFC_DID_NOT_EXECUTE     = 0x20
	PFC_MAYBE               = 0x40
	PFC_OBJECT_UUID         = 0x80
)
View Source
const (
	LSA_CLOSE         = 0x0000
	LSA_LOOKUP_NAMES  = 0x000e
	LSA_OPEN_POLICY_2 = 0x002c
	LSA_GET_USER_NAME = 0x002d

	NET_SHARE_GET_INFO = 0x0010
	NET_SHARE_ENUM_ALL = 0x000f

	MDS_OPEN = 0x0000
)
View Source
const (
	STYPE_DISKTREE   = 0x00000000
	STYPE_IPC_HIDDEN = 0x80000003
)
View Source
const (
	HeaderSize = 16
)

Variables

View Source
var (
	NDR32 = []byte{
		0x04, 0x5d, 0x88, 0x8a, 0xeb, 0x1c, 0xc9, 0x11,
		0x9f, 0xe8, 0x08, 0x00, 0x2b, 0x10, 0x48, 0x60,
	}

	NDR64 = []byte{
		0x33, 0x05, 0x71, 0x71, 0xba, 0xbe, 0x37, 0x49,
		0x83, 0x19, 0xb5, 0xdb, 0xef, 0x9c, 0xcc, 0x36,
	}

	BIND_TIME_FEATURES = []byte{
		0x2c, 0x1c, 0xb7, 0x6c, 0x12, 0x98, 0x40, 0x45,
		0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	}
)

Functions

This section is empty.

Types

type Bind

type Bind struct {
	MaxXmitFrag  uint16
	MaxRecvFrag  uint16
	AssocGroupID uint32
	ContextList  []*Context
}

func (*Bind) Decode

func (b *Bind) Decode(r io.Reader)

func (*Bind) Encode

func (b *Bind) Encode(w io.Writer)

type BindAck

type BindAck struct {
	MaxXmitFrag  uint16
	MaxRecvFrag  uint16
	AssocGroupID uint32
	PortSpec     string
	ResultList   []*Result
}

func (*BindAck) Decode

func (ba *BindAck) Decode(r io.Reader)

func (*BindAck) Encode

func (ba *BindAck) Encode(w io.Writer)

type Context

type Context struct {
	ContextID        uint16
	AbstractSyntax   *SyntaxID
	TransferSyntaxes []*SyntaxID
}

func (*Context) Decode

func (c *Context) Decode(r io.Reader)

func (*Context) Encode

func (c *Context) Encode(w io.Writer)

type Decoder

type Decoder interface {
	Decode(r io.Reader)
}

type Encoder

type Encoder interface {
	Encode(w io.Writer)
}

type Frame

type Frame struct {
	Handle          lsarpc.Handle
	SecurityContext ntlm.SecurityContext
}
type Header struct {
	RPCVersionMajor    uint8
	RPCVersionMinor    uint8
	PacketType         uint8
	PacketFlags        uint8
	DataRepresentation uint32
	FragLength         uint16
	AuthLength         uint16
	CallID             uint32
}

func NewHeader

func NewHeader(pt uint8, pf uint8, callID uint32) *Header

func (*Header) Decode

func (h *Header) Decode(r io.Reader)

func (*Header) Encode

func (h *Header) Encode(w io.Writer)

type InboundPacket

type InboundPacket struct {
	Header  *Header
	Body    Decoder
	Payload []byte
}

func (*InboundPacket) Read

func (ip *InboundPacket) Read(r io.Reader)

type MdsOpenRequest

type MdsOpenRequest struct {
	DeviceID       uint32
	Unkn2          uint32
	Unkn3          uint32
	ShareMountPath string
	ShareName      string
	MaxCount       uint32
}

func (*MdsOpenRequest) Unmarshal

func (req *MdsOpenRequest) Unmarshal(buf []byte)

type MdsOpenResponse

type MdsOpenResponse struct {
	DeviceID     uint32
	Unkn2        uint32
	Unkn3        uint32
	SharePath    string
	PolicyHandle [20]byte
	MaxCount     uint32
}

func (*MdsOpenResponse) MarshalNDR

func (resp *MdsOpenResponse) MarshalNDR(ctx context.Context, w ndr.Writer) error

type NetShareEnumAllRequest

type NetShareEnumAllRequest struct {
	Server    string
	Level     uint32
	MaxBuffer uint32
}

func (*NetShareEnumAllRequest) Unmarshal

func (req *NetShareEnumAllRequest) Unmarshal(buf []byte)

type NetShareEnumAllResponse

type NetShareEnumAllResponse struct {
	Shares []NetShareInfo1
	Result uint32
}

func (*NetShareEnumAllResponse) MarshalNDR

func (resp *NetShareEnumAllResponse) MarshalNDR(ctx context.Context, w ndr.Writer) error

type NetShareGetInfoRequest

type NetShareGetInfoRequest struct {
	Server string
	Share  string
	Level  uint32
}

func (*NetShareGetInfoRequest) Unmarshal

func (req *NetShareGetInfoRequest) Unmarshal(buf []byte)

type NetShareInfo1

type NetShareInfo1 struct {
	Share   string
	Type    uint32
	Comment string
}

type NetShareInfo1Response

type NetShareInfo1Response struct {
	NetShareInfo1
	Result uint32
}

func (*NetShareInfo1Response) MarshalNDR

func (resp *NetShareInfo1Response) MarshalNDR(ctx context.Context, w ndr.Writer) error

type OutboundPacket

type OutboundPacket struct {
	Header *Header
	Body   Encoder
}

func NewBindAck

func NewBindAck(callID uint32, addr string, contexts []*Context) *OutboundPacket

func NewCloseResponse

func NewCloseResponse(callID uint32, status uint32) *OutboundPacket

func NewGetUserNameResponse

func NewGetUserNameResponse(callID uint32, accountName, authorityName string, status uint32) *OutboundPacket

func NewLookupNamesResponse

func NewLookupNamesResponse(callID uint32, ctx ntlm.SecurityContext, status uint32) *OutboundPacket

func NewMdsOpenResponse

func NewMdsOpenResponse(callID uint32, req MdsOpenRequest, path string, status uint32) *OutboundPacket

func NewNetShareEnumAllResponse

func NewNetShareEnumAllResponse(callID uint32, shares []NetShareInfo1, status uint32) *OutboundPacket

func NewNetShareGetInfo1Response

func NewNetShareGetInfo1Response(callID uint32, share, remark string, status uint32) *OutboundPacket

func NewOpenPolicy2Response

func NewOpenPolicy2Response(callID uint32, frame *Frame, status uint32) *OutboundPacket

func (*OutboundPacket) Write

func (op *OutboundPacket) Write(w io.Writer)

type Request

type Request struct {
	AllocHint  uint32
	ContextID  uint16
	OpNum      uint16
	ObjectUUID []byte
}

func (*Request) Decode

func (req *Request) Decode(r io.Reader)

func (*Request) Encode

func (req *Request) Encode(w io.Writer)

type Response

type Response struct {
	AllocHint   uint32
	ContextID   uint16
	CancelCount uint16
}

func (*Response) Decode

func (resp *Response) Decode(r io.Reader)

func (*Response) Encode

func (resp *Response) Encode(w io.Writer)

type ResponseBody

type ResponseBody struct {
	Header  Response
	Payload ndr.Marshaler
}

func (*ResponseBody) Encode

func (rb *ResponseBody) Encode(w io.Writer)

type Result

type Result struct {
	DefResult      uint16
	ProviderReason uint16
	TransferSyntax *SyntaxID
}

func (*Result) Decode

func (res *Result) Decode(r io.Reader)

func (*Result) Encode

func (res *Result) Encode(w io.Writer)

type SyntaxID

type SyntaxID struct {
	IfUUID         [16]byte
	IfVersionMajor uint16
	IfVersionMinor uint16
}

func (*SyntaxID) Decode

func (sid *SyntaxID) Decode(r io.Reader)

func (*SyntaxID) Encode

func (sid *SyntaxID) Encode(w io.Writer)

Jump to

Keyboard shortcuts

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