utils

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: 18

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Trace    *log.Logger
	Info     *log.Logger
	Question *log.Logger
	Fail     *log.Logger
	Warning  *log.Logger
	Error    *log.Logger
	Clear    *log.Logger
)
View Source
var (

	//EncBase64 wrapper for encoding to base64
	EncBase64 = base64.StdEncoding.EncodeToString
	//DecBase64 wrapper for decoding from base64
	DecBase64 = base64.StdEncoding.DecodeString
)

Functions

func BodyToBytes

func BodyToBytes(DataStruct interface{}) []byte

BodyToBytes func

func DecodeUint16

func DecodeUint16(num []byte) uint16

DecodeUint16 decode 2 byte value into uint16

func DecodeUint32

func DecodeUint32(num []byte) uint32

DecodeUint32 decode 4 byte value into uint32

func DecodeUint8

func DecodeUint8(num []byte) uint8

DecodeUint8 decode 1 byte value into uint8

func EncodeNum

func EncodeNum(v interface{}) []byte

EncodeNum encode a number as a byte array

func FromUnicode

func FromUnicode(uni []byte) string

FromUnicode read unicode and convert to byte array

func Hash

func Hash(s string) uint32

Hash Calculate a 32byte hash

func Init

func Init(
	traceHandle io.Writer,
	infoHandle io.Writer,
	warningHandle io.Writer,
	errorHandle io.Writer)

Init the logging function

func Obfuscate

func Obfuscate(data []byte) []byte

Obfuscate traffic using XOR and the magic byte as specified in RPC docs

func ReadASCIIString

func ReadASCIIString(pos int, buff []byte) ([]byte, int)

ReadASCIIString returns a string as ascii

func ReadByte

func ReadByte(pos int, buff []byte) (byte, int)

ReadByte read and return a single byte

func ReadBytes

func ReadBytes(pos, count int, buff []byte) ([]byte, int)

ReadBytes read and return count number o bytes

func ReadTypedString

func ReadTypedString(pos int, buff []byte) ([]byte, int)

ReadTypedString reads a string as either Unicode or ASCII depending on type value

func ReadUint16

func ReadUint16(pos int, buff []byte) (uint16, int)

ReadUint16 read 2 bytes and return as uint16

func ReadUint32

func ReadUint32(pos int, buff []byte) (uint32, int)

ReadUint32 read 4 bytes and return as uint32

func ReadUint8

func ReadUint8(pos int, buff []byte) (uint8, int)

ReadUint8 read 1 byte and return as uint8

func ReadUnicodeString

func ReadUnicodeString(pos int, buff []byte) ([]byte, int)

ReadUnicodeString read and return a unicode string

func UTF16BE

func UTF16BE(str string, trail int) []byte

UTF16BE func to encode strings for the CRuleElement

func UniString

func UniString(str string) []byte

UniString converts a string into a unicode string byte array

Types

type Account

type Account struct {
	AccountType     string
	Action          string
	RedirectAddr    string
	MicrosoftOnline bool
	Protocol        []*Protocol
}

Account structure for unmarshal

type AddressBook

type AddressBook struct {
	InternalUrl string
	ExternalUrl string
}

AddressBook structure for unmarshal

type AutoError

type AutoError struct {
	ErrorCode string
	Message   string
	DebugData string
}

AutoError structure for unmarshal

type AutodiscoverResp

type AutodiscoverResp struct {
	Response Response
}

AutodiscoverResp structure for unmarshal

func (*AutodiscoverResp) Unmarshal

func (autodiscresp *AutodiscoverResp) Unmarshal(resp []byte) error

Unmarshal returns the XML response as golang structs

type Config

type Config struct {
	Domain   string
	User     string
	Pass     string
	Email    string
	Basic    bool
	Insecure bool
	Verbose  bool
	Admin    bool
}

Config containing the session variables

type MailStore

type MailStore struct {
	InternalUrl string
	ExternalUrl string
}

MailStore structure for unmarshal

type ProtoInternal

type ProtoInternal struct {
	OWAUrl   string
	Protocol *Protocol
}

ProtoInternal strucuture for unmarshal

type Protocol

type Protocol struct {
	Type                    string
	TypeAttr                string `xml:"Type,attr"`
	Server                  string
	TTL                     string
	ServerDN                string
	ServerVersion           string
	MdbDN                   string
	PublicFolderServer      string
	Port                    string
	DirectoryPort           string
	ReferralPort            string
	ASUrl                   string
	EWSUrl                  string
	EMWSUrl                 string
	SharingURL              string
	ECPUrl                  string
	OOFUrl                  string
	UMUrl                   string
	OABUrl                  string
	EwsPartnerURL           string
	LoginName               string
	DomainRequired          string
	DomainName              string
	SPA                     string
	AuthPackage             string
	CertPrincipleName       string
	SSL                     string
	AuthRequired            string
	UsePOPAuth              string
	SMTPLast                string
	NetworkRequirements     string
	MailStore               *MailStore
	AddressBook             *AddressBook
	Internal                *ProtoInternal
	External                *ProtoInternal
	PublicFolderInformation *PublicFolderInformation
}

Protocol structure for unmarshal

type PublicFolderInformation

type PublicFolderInformation struct {
	SMTPAddress string
}

PublicFolderInformation structure for unmarshal

type Response

type Response struct {
	User    User
	Account Account
	Error   AutoError
}

Response structure for unmarshal

type Session

type Session struct {
	User          string
	Pass          string
	Email         string
	Domain        string
	Basic         bool
	Insecure      bool
	Verbose       bool
	Admin         bool
	LID           string
	URL           *url.URL
	ABKURL        *url.URL //URL for the AddressBook Provider
	Host          string   //used for TCP
	ReqCounter    int
	Transport     int
	CookieJar     *cookiejar.Jar
	Client        http.Client
	ClientSet     bool
	LogonID       byte
	Authenticated bool
	Folderids     [][]byte
	RulesHandle   []byte
	NTHash        []byte
	NTLMAuth      string
	BasicAuth     string

	RPCSet              bool
	ContextHandle       []byte //16-byte cookie for the RPC session
	RPCURL              string
	UserDN              []byte
	Trigger             string
	RPCMailbox          string
	RPCEncrypt          bool
	RPCNetworkAuthLevel uint8
	RPCNetworkAuthType  uint8
	RPCNtlmSessionKey   []byte
}

Session stores authentication cookies ect

type User

type User struct {
	DisplayName             string
	LegacyDN                string
	DeploymentID            string
	AutoDiscoverSMTPAddress string
}

User structure for unmarshal

Jump to

Keyboard shortcuts

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