rpchttp

package
v2.0.18+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2017 License: CC0-1.0 Imports: 12 Imported by: 3

Documentation

Index

Constants

View Source
const (
	PFC_FIRST_FRAG          = 0x01
	PFC_LAST_FRAG           = 0x02
	PFC_PENDING_CANCEL      = 0x04
	PFC_SUPPORT_HEADER_SIGN = 0x04
	PFC_RESERVED_1          = 0x08
	PFC_CONC_MPX            = 0x10
	PFC_DID_NOT_EXECUTE     = 0x20
	PFC_MAYBE               = 0x40
	PFC_OBJECT_UUID         = 0x80
)
View Source
const (
	DCERPC_PKT_REQUEST    = 0x00
	DCERPC_PKT_PING       = 0x01
	DCERPC_PKT_RESPONSE   = 0x02
	DCERPC_PKT_FAULT      = 0x03
	DCERPC_PKT_WORKING    = 0x04
	DCERPC_PKT_NOCALL     = 0x05
	DCERPC_PKT_REJECT     = 0x06
	DCERPC_PKT_ACK        = 0x07
	DCERPC_PKT_CL_CANCEL  = 0x08
	DCERPC_PKT_FACK       = 0x09
	DCERPC_PKT_CANCEL_ACK = 0x0A
	DCERPC_PKT_BIND       = 0x0B
	DCERPC_PKT_BIND_ACK   = 0x0C
	DCERPC_PKT_BIND_NAK   = 0x0D
	DCERPC_PKT_ALTER      = 0x0E
	DCERPC_PKT_ALTER_RESP = 0x0F
	DCERPC_PKT_AUTH_3     = 0x10
	DCERPC_PKT_SHUTDOWN   = 0x11
	DCERPC_PKT_CO_CANCEL  = 0x12
	DCERPC_PKT_ORPHANED   = 0x13
	DCERPC_PKT_RTS        = 0x14
)

as defined in dcerpc.idl

View Source
const (
	RTS_FLAG_NONE            = 0x00
	RTS_FLAG_PING            = 0x01
	RTS_FLAG_OTHER_CMD       = 0x02
	RTS_FLAG_RECYCLE_CHANNEL = 0x04
	RTS_FLAG_IN_CHANNEL      = 0x08
	RTS_FLAG_OUT_CHANNEL     = 0x10
	RTS_FLAG_EOF             = 0x20
	RTS_FLAG_ECHO            = 0x40
)

RTS Flags

View Source
const (
	RTS_CMD_RECEIVE_WINDOW_SIZE      = 0
	RTS_CMD_FLOW_CONTROL_ACK         = 1
	RTS_CMD_CONNECTION_TIMEOUT       = 2
	RTS_CMD_COOKIE                   = 3
	RTS_CMD_CHANNEL_LIFETIME         = 4
	RTS_CMD_CLIENT_KEEPALIVE         = 5
	RTS_CMD_VERSION                  = 6
	RTS_CMD_EMPTY                    = 7
	RTS_CMD_PADDING                  = 8
	RTS_CMD_NEGATIVE_ANCE            = 9
	RTS_CMD_ANCE                     = 10
	RTS_CMD_CLIENT_ADDRESS           = 11
	RTS_CMD_ASSOCIATION_GROUP_ID     = 12
	RTS_CMD_DESTINATION              = 13
	RTS_CMD_PING_TRAFFIC_SENT_NOTIFY = 14
	RTS_CMD_CUSTOM_OUT               = 15
)

RTS CMD

View Source
const (
	RPC_C_AUTHN_NONE                = 0x0
	RPC_C_AUTHN_GSS_NEGOTIATE       = 0x9  // SPNEGO
	RPC_C_AUTHN_WINNT               = 0xa  // NTLM
	RPC_C_AUTHN_GSS_SCHANNEL        = 0xe  // TLS
	RPC_C_AUTHN_GSS_KERBEROS        = 0x10 // Kerberos
	RPC_C_AUTHN_NETLOGON            = 0x44 // Netlogon
	RPC_C_AUTHN_DEFAULT             = 0xff // (NTLM)
	RPC_C_AUTHN_LEVEL_DEFAULT       = 0
	RPC_C_AUTHN_LEVEL_NONE          = 1
	RPC_C_AUTHN_LEVEL_CONNECT       = 2
	RPC_C_AUTHN_LEVEL_CALL          = 3
	RPC_C_AUTHN_LEVEL_PKT           = 4
	RPC_C_AUTHN_LEVEL_PKT_INTEGRITY = 5
	RPC_C_AUTHN_LEVEL_PKT_PRIVACY   = 6
)

Variables

View Source
var AuthSession *utils.Session

AuthSession Keep track of session data

Functions

func CookieGen

func CookieGen() []byte

CookieGen creates a 16byte UUID

func DoConnectExRequest

func DoConnectExRequest(MAPI []byte, auxLen uint32) ([]byte, error)

DoConnectExRequest makes our connection request. After this we can use EcDoRPCExt2 to make our MAPI requests

func EcDoRPCAbk

func EcDoRPCAbk(MAPI []byte, l int) ([]byte, error)

func EcDoRPCExt2

func EcDoRPCExt2(MAPI []byte, auxLen uint32) ([]byte, error)

EcDoRPCExt2 does our actual RPC request returns the mapi data

func RPCBind

func RPCBind() error

RPCBind function establishes our session

func RPCDisconnect

func RPCDisconnect()

RPCDisconnect fucntion

func RPCDummy

func RPCDummy()

RPCDummy is used to check if we can communicate with the server

func RPCOpen

func RPCOpen(URL string, readySignal chan bool, errOccurred chan error) (err error)

RPCOpen opens HTTP for RPC_IN_DATA and RPC_OUT_DATA

func RPCOpenOut

func RPCOpenOut(URL string, readySignal chan bool, errOccurred chan error) (err error)

RPCOpenOut function opens the RPC_OUT_DATA channel starts our listening "loop" which scans for new responses and pushes these to our list of recieved responses

func RPCOutWrite

func RPCOutWrite(data []byte)

RPCOutWrite function writes to the RPC_OUT_DATA channel, this should only happen once, for ConnA1

func RPCPing

func RPCPing()

RPCPing fucntion

func RPCWrite

func RPCWrite(data []byte)

RPCWrite function writes to our RPC_IN_DATA channel

func RPCWriteN

func RPCWriteN(MAPI []byte, auxlen uint32, opnum byte)

RPCWriteN function writes to our RPC_IN_DATA channel

func SplitData

func SplitData(data []byte, atEOF bool) (advance int, token []byte, err error)

SplitData is used to scan through the input stream and split data into individual responses

Types

type AUXBuffer

type AUXBuffer struct {
	RPCHeader RPCHeader
	Buff      []AuxInfo
}

AUXBuffer struct

func (AUXBuffer) Marshal

func (auxbuf AUXBuffer) Marshal() []byte

Marshal AuxBuffer

type AUXClientConnectionInfo

type AUXClientConnectionInfo struct {
	Header                      AUXHeader
	ConnectionGUID              []byte
	OffsetConnectionContextInfo uint16
	Reserved                    uint16
	ConnectionAttempts          uint32
	ConnectionFlags             uint32
	ConnectionContextInfo       []byte
}

AUXClientConnectionInfo used for aux info

func (AUXClientConnectionInfo) Marshal

func (auxbuf AUXClientConnectionInfo) Marshal() []byte

Marshal AUXClientConnectionInfo

type AUXHeader

type AUXHeader struct {
	Size    uint16 //
	Version uint8
	Type    uint8
}

AUXHeader struct

type AUXPerfAccountInfo

type AUXPerfAccountInfo struct {
	Header   AUXHeader
	ClientID uint16
	Reserved uint16
	Account  []byte
}

AUXPerfAccountInfo used for aux info

func (AUXPerfAccountInfo) Marshal

func (auxbuf AUXPerfAccountInfo) Marshal() []byte

Marshal AUXPerfAccountInfo

type AUXPerfClientInfo

type AUXPerfClientInfo struct {
	Header             AUXHeader
	AdapterSpeed       uint32
	ClientID           uint16
	MachineNameOffset  uint16
	UserNameOffset     uint16
	ClientIPSize       uint16
	ClientIPOffset     uint16
	ClientIPMaskSize   uint16
	ClientIPMaskOffset uint16
	AdapterNameOffset  uint16
	MacAddressSize     uint16
	MacAddressOffset   uint16
	ClientMode         uint16
	Reserved           uint16
	MachineName        []byte
	UserName           []byte
	ClientIP           []byte
	ClientIPMask       []byte
	AdapterName        []byte
	MacAddress         []byte
}

AUXPerfClientInfo used for aux info

func (AUXPerfClientInfo) Marshal

func (auxbuf AUXPerfClientInfo) Marshal() []byte

Marshal AUXPerfClientInfo

type AUXPerfGCSuccess

type AUXPerfGCSuccess struct {
	Header                AUXHeader
	ClientID              uint16
	ServerID              uint16
	Reserved              uint16
	TimeSinceRequest      uint32
	TimeToCompleteRequest uint32
	RequestOperation      uint8
	Reserved2             []byte
}

AUXPerfGCSuccess used for aux info

func (AUXPerfGCSuccess) Marshal

func (auxbuf AUXPerfGCSuccess) Marshal() []byte

Marshal AUXPerfGCSuccess

type AUXTPerfMDBSuccess

type AUXTPerfMDBSuccess struct {
	Header                AUXHeader
	ClientID              uint16
	ServerID              uint16
	SessionID             uint16
	RequestID             uint16
	TimeSinceRequest      uint32
	TimeToCompleteRequest uint32
}

AUXTPerfMDBSuccess used for aux info

func (AUXTPerfMDBSuccess) Marshal

func (auxbuf AUXTPerfMDBSuccess) Marshal() []byte

Marshal AUXTPerfMDBSuccess

type AUXTypePerfProcessInfo

type AUXTypePerfProcessInfo struct {
	Header            AUXHeader
	ProcessID         uint16
	Reserved          uint16
	ProcessGUID       []byte
	ProcessNameOffset uint16
	Reserved2         uint16
	ProcessName       []byte
}

AUXTypePerfProcessInfo used for aux info

func (AUXTypePerfProcessInfo) Marshal

func (auxbuf AUXTypePerfProcessInfo) Marshal() []byte

Marshal AUXTypePerfProcessInfo

type AUXTypePerfRequestID

type AUXTypePerfRequestID struct {
	Header    AUXHeader
	SessionID uint16
	RequestID uint16
}

AUXTypePerfRequestID used for aux info

func (AUXTypePerfRequestID) Marshal

func (auxbuf AUXTypePerfRequestID) Marshal() []byte

Marshal AUXTypePerfRequestID

type AUXTypePerfSessionInfo

type AUXTypePerfSessionInfo struct {
	Header       AUXHeader
	SessionID    uint16
	Reserved     uint16
	SessionGUID  []byte
	ConnectionID uint32
}

AUXTypePerfSessionInfo used for aux info

func (AUXTypePerfSessionInfo) Marshal

func (auxbuf AUXTypePerfSessionInfo) Marshal() []byte

Marshal AUXTypePerfSessionInfo

type AssociationGroupID

type AssociationGroupID struct {
	CommandType        uint32
	AssociationGroupID []byte //16 byte
}

AssociationGroupID used to hold the group id

type Auth3Request

type Auth3Request struct {
	Header      RTSHeader
	MaxFrag     uint16
	MaxRecvFrag uint16
	//Pad         uint32
	SecTrailer []byte
	AuthData   []byte
}

Auth3Request struct

func Auth3

func Auth3(authLevel, authType uint8, authData []byte) Auth3Request

func (Auth3Request) Marshal

func (authBind Auth3Request) Marshal() []byte

Marshal turn Auth3Request into Bytes

type AuxInfo

type AuxInfo interface {
	Marshal() []byte
}

AuxInfo interface to make Aux buffers generic

type BindPDU

type BindPDU struct {
	Header             RTSHeader
	MaxFrag            uint16
	MaxRecvFrag        uint16
	AssociationGroupID uint32
	CtxNum             uint32 //2
	CtxItems           []byte
	SecTrailer         []byte
	AuthData           []byte
}

BindPDU struct

func Bind

func Bind() BindPDU

Bind function Creates a Bind Packet

func SecureBind

func SecureBind(authLevel, authType uint8, session *ntlm.ClientSession) BindPDU

func (BindPDU) Marshal

func (rtsBind BindPDU) Marshal() []byte

Marshal turn Bind into Bytes

type CONNA1

type CONNA1 struct {
	Header               RTSHeader
	Flags                uint16
	NumberOfCommands     uint16
	Version              []byte //8 bytes
	VirtualConnectCookie Cookie
	OutChannelCookie     Cookie
	ReceiveWindowSize    []byte //8 bytes
}

CONNA1 struct for initial connection

func ConnA1

func ConnA1(channelCookie []byte) CONNA1

ConnA1 sent from the client to create the input channel

func (CONNA1) Marshal

func (connA1Request CONNA1) Marshal() []byte

Marshal connA1

type CONNB1

type CONNB1 struct {
	Header               RTSHeader
	Flags                uint16
	NumberOfCommands     uint16
	Version              []byte //8 bytes
	VirtualConnectCookie Cookie
	InChannelCookie      Cookie
	ChannelLifetime      ChannelLifetime
	ClientKeepAlive      ClientKeepalive
	AssociatonGroupID    AssociationGroupID
}

CONNB1 struct for initial connection

func ConnB1

func ConnB1() CONNB1

ConnB1 sent from the client to create the output channel

func (CONNB1) Marshal

func (connB1Request CONNB1) Marshal() []byte

Marshal connB1

type CTX

type CTX struct {
	ContextID      uint16
	TransItems     uint8
	Pad            uint8
	AbstractSyntax []byte //20 bytes
	TransferSyntax []byte //20 bytes
}

CTX item used in Bind

func (CTX) Marshal

func (ctx CTX) Marshal() []byte

Marshal CTX

type ChannelLifetime

type ChannelLifetime struct {
	CommandType     uint32 //always 04
	ChannelLifetime uint32 //range of 128kb to 2 Gb
}

ChannelLifetime holds lifetime of channel

type ClientKeepalive

type ClientKeepalive struct {
	CommandType     uint32 //always 05
	ClientKeepalive uint32 //range of 128kb to 2 Gb
}

ClientKeepalive specifies how long the channel is kept open

type ConnectExRequest

type ConnectExRequest struct {
	Header        RTSHeader
	MaxFrag       uint16
	MaxRecv       uint16
	Version       []byte //8-byte
	ContextHandle []byte //16-byte cookie
	Data          []byte //our MAPI request goes here
	AuxBufLen     uint32
	RgbAuxIn      []byte
	CbAuxIn       uint32
	AuxOut        uint32
}

ConnectExRequest our connection request

func (ConnectExRequest) Marshal

func (rtsRequest ConnectExRequest) Marshal() []byte

Marshal ConnectExRequest into bytes

type Cookie struct {
	CommandType uint32 //always going to be 03
	Cookie      []byte //16 byte
}

Cookie used the connection/channel cookie

type PDUData

type PDUData struct {
	ContextHandle []byte //16-byte cookie
	Data          []byte
	CbAuxIn       uint32
	AuxOut        uint32
}

func (PDUData) Marshal

func (pdu PDUData) Marshal() []byte

Marshal turn PDUData into Bytes

type RPCHeader

type RPCHeader struct {
	Version    uint16 //always 0x0000
	Flags      uint16 //0x0001 Compressed, 0x0002 XorMagic, 0x0004 Last
	Size       uint16
	SizeActual uint16 //Compressed size (if 0x0001 set)
}

RPCHeader common fields

type RPCResponse

type RPCResponse struct {
	Header     RTSHeader
	PDU        []byte
	SecTrailer []byte
	Body       []byte
	AutData    []byte
}

RPCResponse to hold the data from our response

func RPCRead

func RPCRead(callID int) (RPCResponse, error)

RPCRead function takes a call ID and searches for the response in our list of received responses. Blocks until it finds a response

func (*RPCResponse) Unmarshal

func (response *RPCResponse) Unmarshal(raw []byte) (int, error)

Unmarshal RPCResponse

type RTSHeader

type RTSHeader struct {
	Version      uint8 //05
	VersionMinor uint8 //00
	Type         uint8
	PFCFlags     uint8
	PackedDrep   uint32
	FragLen      uint16
	AuthLen      uint16
	CallID       uint32
}

RTSHeader structure for unmarshal

type RTSPing

type RTSPing struct {
	Header RTSHeader
	Sec    RTSSec
}

RTSPing an RTSPing message keeping the channel alive

func Ping

func Ping() RTSPing

Ping function creates a Ping Packet

func (RTSPing) Marshal

func (rtsPing RTSPing) Marshal() []byte

Marshal turn RTSPing into Bytes

type RTSRequest

type RTSRequest struct {
	Header  RTSHeader
	MaxFrag uint16
	MaxRecv uint16
	Command []byte //8-byte
	PduData []byte //PDUData
	//	ContextHandle []byte //16-byte cookie
	//	Data          []byte //our MAPI request goes here
	//RPC Parts
	//	CbAuxIn uint32
	//	AuxOut  uint32
	SecTrailer []byte
	AuthData   []byte
}

RTSRequest an RTSRequest

func (RTSRequest) Marshal

func (rtsRequest RTSRequest) Marshal() []byte

Marshal turn RTSRequest into Bytes

type RTSSec

type RTSSec struct {
	AuthType   uint8
	AuthLevel  uint8
	AuthPadLen uint8
	AuthRsvrd  uint8
	AuthCTX    uint32
}

RTSSec the security trailer this is going to be 0x00000010 for all of our requests

func (RTSSec) Marshal

func (sec RTSSec) Marshal() []byte

Marshal RTSSec

func (*RTSSec) Unmarshal

func (sec *RTSSec) Unmarshal(raw []byte, ln int) (int, error)

Unmarshal the SecTrailer

Jump to

Keyboard shortcuts

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