types

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

type Module struct {
	// Size designates the size in bytes of the image file.
	Size uint32
	// Checksum is the checksum of the image file.
	Checksum uint32
	// Name represents the full path of this image.
	Name string
	// BaseAddress is the base address of process in which the image is loaded.
	BaseAddress kparams.Hex
	// DefaultBaseAddress is the default base address.
	DefaultBaseAddress kparams.Hex
}

Module represents the data for all dynamic libraries/executables that reside in the process' address space.

func ImageFromKevent

func ImageFromKevent(size, checksum uint32, name string, baseAddress, defaultBaseAddress kparams.Hex) Module

ImageFromKevent constructs a module info from the corresponding kernel event.

func (*Module) Marshal

func (m *Module) Marshal() []byte

Marshal produces a module byte stream state suitable for writing to capture files.

func (Module) String

func (m Module) String() string

String returns the string representation of the module.

func (*Module) Unmarshal

func (m *Module) Unmarshal(b []byte) (uint16, error)

Unmarshal reconstructs module state from the byte stream.

type PS

type PS struct {

	// PID is the identifier of this process. This value is valid from the time a process is created until it is terminated.
	PID uint32 `json:"pid"`
	// Ppipd represents the parent of this process. Process identifier numbers are reused, so they only identify a process
	// for the lifetime of that process. It is possible that the process identified by `Ppid` is terminated,
	// so `Ppid` may not refer to a running process. It is also possible that `Ppid` incorrectly refers
	// to a process that reuses a process identifier.
	Ppid uint32 `json:"ppid"`
	// Name is the process' image name including file extension (e.g. cmd.exe)
	Name string `json:"name"`
	// Comm is the full process' command line (e.g. C:\Windows\system32\cmd.exe /cdir /-C /W)
	Comm string `json:"comm"`
	// Exe is the full name of the process' executable (e.g. C:\Windows\system32\cmd.exe)
	Exe string `json:"exe"`
	// Cwd designates the current working directory of the process.
	Cwd string `json:"cwd"`
	// SID is the security identifier under which this process is run.
	SID string `json:"sid"`
	// Args contains process' command line arguments (e.g. /cdir, /-C, /W)
	Args []string `json:"args"`
	// SessionID is the unique identifier for the current session.
	SessionID uint8 `json:"session"`
	// Envs contains process' environment variables indexed by env variable name.
	Envs map[string]string `json:"envs"`
	// Threads contains all the threads running in the address space of this process.
	Threads map[uint32]Thread `json:"-"`
	// Modules contains all the modules loaded by the process.
	Modules []Module `json:"modules"`
	// Handles represents the collection of handles allocated by the process.
	Handles htypes.Handles `json:"handles"`
	// PE stores the PE (Portable Executable) metadata.
	PE *pe.PE `json:"pe"`
	// contains filtered or unexported fields
}

PS encapsulates process' state such as allocated resources and other metadata.

func FromKevent

func FromKevent(pid, ppid uint32, name, comm, exe, sid string, sessionID uint8) *PS

FromKevent produces a new process state from kernel event.

func NewFromKcap

func NewFromKcap(buf []byte) (*PS, error)

NewFromKcap reconstructs the state of the process from kcap file.

func NewPS

func NewPS(pid, ppid uint32, exe, cwd, comm string, thread Thread, envs map[string]string) *PS

NewPS produces a new process state from passed arguments.

func (*PS) AddHandle

func (ps *PS) AddHandle(handle htypes.Handle)

AddHandle adds a new handle to this process state.

func (*PS) AddModule

func (ps *PS) AddModule(mod Module)

AddModule adds a new module to this process state.

func (*PS) AddThread

func (ps *PS) AddThread(thread Thread)

AddThread adds a thread to process's state descriptor.

func (*PS) FindModule

func (ps *PS) FindModule(name string) *Module

FindModule finds the module by name.

func (*PS) Marshal

func (ps *PS) Marshal() []byte

Marshal produces a byte stream of the process state for writing to the capture file.

func (*PS) RLock

func (ps *PS) RLock()

RLock acquires a read mutex on the process state.

func (*PS) RUnlock

func (ps *PS) RUnlock()

RUnlock releases a read mutex on the process sate.

func (*PS) RemoveHandle

func (ps *PS) RemoveHandle(num hndl.Handle)

RemoveHandle removes a handle with specified identifier from the list of allocated handles.

func (*PS) RemoveModule

func (ps *PS) RemoveModule(name string)

RemoveModule removes a module with specified full-path from this process state.

func (*PS) RemoveThread

func (ps *PS) RemoveThread(tid uint32)

RemoveThread eliminates a thread from the process's state.

func (*PS) String

func (ps *PS) String() string

String returns a string representation of the process' state.

func (*PS) Unmarshal

func (ps *PS) Unmarshal(b []byte) error

Unmarshal recovers the process' state from the capture file.

type Thread

type Thread struct {
	// Tid is the unique identifier of thread inside the process.
	Tid uint32
	// Pid is the identifier of the process to which this thread pertains.
	Pid uint32
	// IOPrio represents an I/O priority hint for scheduling I/O operations generated by the thread.
	IOPrio uint8
	// BasePrio is the scheduler priority of the thread.
	BasePrio uint8
	// PagePrio is a memory page priority hint for memory pages accessed by the thread.
	PagePrio uint8
	// UstackBase is the base address of the thread's user space stack.
	UstackBase kparams.Hex
	// UstackLimit is the limit of the thread's user space stack.
	UstackLimit kparams.Hex
	// KStackBase is the base address of the thread's kernel space stack.
	KstackBase kparams.Hex
	// KstackLimit is the limit of the thread's kernel space stack.
	KstackLimit kparams.Hex
	// Entrypoint is the starting address of the function to be executed by the thread.
	Entrypoint kparams.Hex
}

Thread stores several metadata about a thread that's executing in process's address space.

func ThreadFromKevent

func ThreadFromKevent(pid, tid uint32, ustackBase, ustackLimit, kstackBase, kstackLimit kparams.Hex, ioPrio, basePrio, pagePrio uint8, entrypoint kparams.Hex) Thread

ThreadFromKevent builds a thread info from kernel event.

func (*Thread) Marshal

func (t *Thread) Marshal() []byte

Marshal transforms the thread state to byte stream for persisting to capture files.

func (Thread) String

func (t Thread) String() string

String returns the thread as a human-readable string.

func (*Thread) Unmarshal

func (t *Thread) Unmarshal(b []byte) (uint16, error)

Unmarshal restores thead state from the byte slice.

Jump to

Keyboard shortcuts

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