Documentation ¶
Overview ¶
Package process fetches process and socket information from the operating system. It can find the process owning a network connection.
Index ¶
- Variables
- func All() map[int]*Process
- func CleanProcessStorage(activePIDs map[int]struct{})
- func GetActiveConnectionIDs() []string
- func GetPidByEndpoints(localIP net.IP, localPort uint16, remoteIP net.IP, remotePort uint16, ...) (pid int, direction bool, err error)
- func GetPidByPacket(pkt packet.Packet) (pid int, direction bool, err error)
- func SetDBController(controller *database.Controller)
- type Process
- func GetOrFindPrimaryProcess(ctx context.Context, pid int) (*Process, error)
- func GetOrFindProcess(ctx context.Context, pid int) (*Process, error)
- func GetProcessByEndpoints(ctx context.Context, localIP net.IP, localPort uint16, remoteIP net.IP, ...) (process *Process, err error)
- func GetProcessByPacket(pkt packet.Packet) (process *Process, direction bool, err error)
- func GetProcessFromStorage(pid int) (*Process, bool)
- func (p *Process) Delete()
- func (p *Process) GetExecHash(algorithm string) (string, error)
- func (p *Process) GetProfile(ctx context.Context) error
- func (p *Process) IsAdmin() bool
- func (p *Process) IsKernel() bool
- func (p *Process) IsSystem() bool
- func (p *Process) IsUser() bool
- func (p *Process) Profile() *profile.LayeredProfile
- func (p *Process) Save()
- func (p *Process) String() string
Constants ¶
This section is empty.
Variables ¶
var ( ErrConnectionNotFound = errors.New("could not find connection in system state tables") ErrProcessNotFound = errors.New("could not find process in system state tables") )
Errors
var ( // UnknownProcess is used when a process cannot be found. UnknownProcess = &Process{ UserID: -1, UserName: "Unknown", Pid: -1, ParentPid: -1, Name: "Unknown Processes", } // OSProcess is used to represent the Kernel. OSProcess = &Process{ UserID: 0, UserName: "Kernel", Pid: 0, ParentPid: 0, Name: "Operating System", } )
var (
CfgOptionEnableProcessDetectionKey = "core/enableProcessDetection"
)
Configuration Keys
Functions ¶
func CleanProcessStorage ¶
func CleanProcessStorage(activePIDs map[int]struct{})
CleanProcessStorage cleans the storage from old processes.
func GetActiveConnectionIDs ¶
func GetActiveConnectionIDs() []string
GetActiveConnectionIDs returns a list of all active connection IDs.
func GetPidByEndpoints ¶
func GetPidByEndpoints(localIP net.IP, localPort uint16, remoteIP net.IP, remotePort uint16, protocol packet.IPProtocol) (pid int, direction bool, err error)
GetPidByEndpoints returns the pid of the owner of the described link.
func GetPidByPacket ¶
GetPidByPacket returns the pid of the owner of the packet.
func SetDBController ¶
func SetDBController(controller *database.Controller)
SetDBController sets the database controller and allows the package to push database updates on a save. It must be set by the package that registers the "network" database.
Types ¶
type Process ¶
type Process struct { record.Base sync.Mutex UserID int UserName string UserHome string Pid int ParentPid int Path string Cwd string CmdLine string FirstArg string ExecName string ExecHashes map[string]string LocalProfileKey string Name string Icon string FirstSeen int64 LastSeen int64 Virtual bool // This process is either merged into another process or is not needed. // contains filtered or unexported fields }
A Process represents a process running on the operating system
func GetOrFindPrimaryProcess ¶ added in v0.2.5
GetOrFindPrimaryProcess returns the highest process in the tree that matches the given PID.
func GetOrFindProcess ¶
GetOrFindProcess returns the process for the given PID.
func GetProcessByEndpoints ¶
func GetProcessByEndpoints(ctx context.Context, localIP net.IP, localPort uint16, remoteIP net.IP, remotePort uint16, protocol packet.IPProtocol) (process *Process, err error)
GetProcessByEndpoints returns the process that owns the described link.
func GetProcessByPacket ¶
GetProcessByPacket returns the process that owns the given packet.
func GetProcessFromStorage ¶
GetProcessFromStorage returns a process from the internal storage.
func (*Process) Delete ¶
func (p *Process) Delete()
Delete deletes a process from the storage and propagates the change.
func (*Process) GetExecHash ¶
GetExecHash returns the hash of the executable with the given algorithm.
func (*Process) GetProfile ¶ added in v0.4.0
GetProfile finds and assigns a profile set to the process.
func (*Process) Profile ¶ added in v0.4.0
func (p *Process) Profile() *profile.LayeredProfile
Profile returns the assigned layered profile.