evtx

package module
v0.0.0-...-bbcbd99 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2022 License: Apache-2.0 Imports: 15 Imported by: 2

README

A Golang EVTX Parser

This parser is based on code by https://github.com/KasperskyLab/ForensicsTools

Documentation

Overview

Copyright 2018 Velocidex Innovations

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	EVTX_HEADER_MAGIC       = "ElfFile\x00"
	EVTX_CHUNK_HEADER_MAGIC = "ElfChnk\x00"
	EVTX_CHUNK_HEADER_SIZE  = 0x200

	EVTX_CHUNK_SIZE = 0x10000

	EVTX_EVENT_RECORD_MAGIC = "\x2a\x2a\x00\x00"
	EVTX_EVENT_RECORD_SIZE  = 24
)

Variables

This section is empty.

Functions

func Debug

func Debug(arg interface{})

func ExpandMessage

func ExpandMessage(
	event *ordereddict.Dict, resolver MessageResolver) string

func GenerateEvents

func GenerateEvents(fd io.ReadSeeker) (chan GeneratedEvent, func(), error)

func NormalizeEventData

func NormalizeEventData(expanded interface{})

func ParseAttributes

func ParseAttributes(ctx *ParseContext) bool

func ParseBinXML

func ParseBinXML(ctx *ParseContext)

func ParseCloseElement

func ParseCloseElement(ctx *ParseContext) bool

Represents a closing element (i.e. </Element>)

func ParseCloseStartElement

func ParseCloseStartElement(ctx *ParseContext) bool

Represents a close of the start element ('>' in <Element>)

func ParseFile

func ParseFile(fd io.ReadSeeker) (*ordereddict.Dict, error)

func ParseOpenStartElement

func ParseOpenStartElement(ctx *ParseContext, has_attr bool) bool

This is called when we open a new XML Tag. e.g. "<EventData".

func ParseOptionalSubstitution

func ParseOptionalSubstitution(ctx *ParseContext) bool

func ParseTemplateInstance

func ParseTemplateInstance(ctx *ParseContext) bool

func ParseValueText

func ParseValueText(ctx *ParseContext) bool

func ReadName

func ReadName(ctx *ParseContext) string

func ReadPrefixedUnicodeString

func ReadPrefixedUnicodeString(ctx *ParseContext, is_null_terminated bool) string

func UTF16LEToUTF8

func UTF16LEToUTF8(data []byte) []byte

Types

type Chunk

type Chunk struct {
	Header ChunkHeader
	Offset int64
	Fd     io.ReadSeeker
}

func GetChunks

func GetChunks(fd io.ReadSeeker) ([]*Chunk, error)

Get all the chunks in the file.

func NewChunk

func NewChunk(fd io.ReadSeeker, offset int64) (*Chunk, error)

func (*Chunk) Parse

func (self *Chunk) Parse(start_record_id int) ([]*EventRecord, error)

type ChunkHeader

type ChunkHeader struct {
	Magic               [8]byte
	FirstEventRecNumber uint64
	LastEventRecNumber  uint64
	FirstEventRecID     uint64
	LastEventRecID      uint64
	HeaderSize          uint32
}

type DBResolver

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

func NewDBResolver

func NewDBResolver(message_file string) (*DBResolver, error)

func (*DBResolver) Close

func (self *DBResolver) Close()

func (*DBResolver) GetMessage

func (self *DBResolver) GetMessage(
	provider, channel string, event_id int) string

TODO: What is happening with the channel here?

func (*DBResolver) GetParameter

func (self *DBResolver) GetParameter(provider, channel string, parameter_id int) string

type EVTXHeader

type EVTXHeader struct {
	Magic           [8]byte
	Firstchunk      uint64
	LastChunk       uint64
	NextRecordID    uint64
	HeaderSize      uint32
	MinorVersion    uint16
	MajorVersion    uint16
	HeaderBlockSize uint16

	FileFlags uint32
	CheckSum  uint32
	// contains filtered or unexported fields
}

type EventRecord

type EventRecord struct {
	Header EventRecordHeader
	Event  interface{}
}

func NewEventRecord

func NewEventRecord(ctx *ParseContext, chunk *Chunk) (*EventRecord, error)

func (*EventRecord) Parse

func (self *EventRecord) Parse(ctx *ParseContext)

type EventRecordHeader

type EventRecordHeader struct {
	Magic    [4]byte
	Size     uint32
	RecordID uint64
	FileTime uint64
}

type EvtxGUID

type EvtxGUID struct {
	D  uint32
	W1 uint16
	W2 uint16
	B  [8]uint8
}

func (*EvtxGUID) ToString

func (self *EvtxGUID) ToString() string

type GeneratedEvent

type GeneratedEvent struct {
	Event map[string]interface{}
	Err   error
}

type MessageResolver

type MessageResolver interface {
	GetMessage(provider, channel string, event_id int) string
	GetParameter(provider, channel string, parameter_id int) string
	Close()
}

func GetNativeResolver

func GetNativeResolver() (MessageResolver, error)

type NullResolver

type NullResolver struct{}

func (NullResolver) Close

func (self NullResolver) Close()

func (NullResolver) GetMessage

func (self NullResolver) GetMessage(provider, channel string, event_id int) string

func (NullResolver) GetParameter

func (self NullResolver) GetParameter(provider, channel string, parameter_id int) string

type ParseContext

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

func NewParseContext

func NewParseContext(chunk *Chunk) *ParseContext

func (*ParseContext) ConsumeBytes

func (self *ParseContext) ConsumeBytes(size int) []byte

func (*ParseContext) ConsumeInt32

func (self *ParseContext) ConsumeInt32() (ret int32)

func (*ParseContext) ConsumeInt64

func (self *ParseContext) ConsumeInt64() (ret int64)

func (*ParseContext) ConsumeInt64hexArray

func (self *ParseContext) ConsumeInt64hexArray(size int) []string

func (*ParseContext) ConsumeReal32

func (self *ParseContext) ConsumeReal32() (ret float32)

func (*ParseContext) ConsumeReal64

func (self *ParseContext) ConsumeReal64() (ret float64)

func (*ParseContext) ConsumeSysTime

func (self *ParseContext) ConsumeSysTime(size int) string

func (*ParseContext) ConsumeUint16

func (self *ParseContext) ConsumeUint16() uint16

func (*ParseContext) ConsumeUint32

func (self *ParseContext) ConsumeUint32() uint32

func (*ParseContext) ConsumeUint64

func (self *ParseContext) ConsumeUint64() uint64

func (*ParseContext) ConsumeUint8

func (self *ParseContext) ConsumeUint8() uint8

func (*ParseContext) ConsumeUnit16Array

func (self *ParseContext) ConsumeUnit16Array(size int) []uint16

func (*ParseContext) ConsumeUnit64Array

func (self *ParseContext) ConsumeUnit64Array(size int) []uint64

func (ParseContext) Copy

func (self ParseContext) Copy() *ParseContext

Make a copy of the context. This new copy can be used to continue parsing without disturbing the state of this parser context.

func (*ParseContext) CurrentKey

func (self *ParseContext) CurrentKey() string

func (*ParseContext) CurrentTemplate

func (self *ParseContext) CurrentTemplate() *TemplateNode

func (*ParseContext) GetTemplateByID

func (self *ParseContext) GetTemplateByID(id int) (*TemplateNode, bool)

func (*ParseContext) NewTemplate

func (self *ParseContext) NewTemplate(id int) *TemplateNode

func (*ParseContext) Offset

func (self *ParseContext) Offset() int

func (*ParseContext) PopTemplate

func (self *ParseContext) PopTemplate()

func (*ParseContext) PushTemplate

func (self *ParseContext) PushTemplate(key string, template *TemplateNode)

func (*ParseContext) SetOffset

func (self *ParseContext) SetOffset(offset int)

func (*ParseContext) SkipBytes

func (self *ParseContext) SkipBytes(count int)

type TemplateNode

type TemplateNode struct {
	Id          uint32
	Type        uint32
	Literal     interface{}
	NestedArray []*TemplateNode
	NestedDict  *ordereddict.Dict //map[string]*TemplateNode

	CurrentKey string
}

func NewTemplate

func NewTemplate(id int) *TemplateNode

func (*TemplateNode) Expand

func (self *TemplateNode) Expand(args map[int]interface{}) interface{}

func (*TemplateNode) SetExpansion

func (self *TemplateNode) SetExpansion(key string, id, type_id uint32)

func (*TemplateNode) SetLiteral

func (self *TemplateNode) SetLiteral(key string, literal interface{})

func (*TemplateNode) SetNested

func (self *TemplateNode) SetNested(key string, nested *TemplateNode)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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