Generic.Remediation.KillProcess
Type: Client
Terminates processes whose name or executable path matches a regex (and optionally whose command line matches a second regex).
Without ReallyDoIt the artifact only lists the processes it would
kill, so it can be used as a dry run first. The agent’s own process
and PIDs 0 to 4 are never touched.
WARNING: killing processes across many hosts can disrupt users and services. Test the regex with a dry run before deploying widely.
Required permissions: EXECVE
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
ProcessRegex |
regex | ThisIsAUniqueName |
Matched against the process name and executable path. |
CommandLineRegex |
regex | . |
Only kill processes whose command line also matches. |
ReallyDoIt |
bool | Kill the matching processes. Otherwise only list them. |
Source
Defined in artifacts/definitions/Generic/Remediation/KillProcess.yaml.
name: Generic.Remediation.KillProcess
description: |
Terminates processes whose name or executable path matches a regex
(and optionally whose command line matches a second regex).
Without `ReallyDoIt` the artifact only lists the processes it would
kill, so it can be used as a dry run first. The agent's own process
and PIDs 0 to 4 are never touched.
WARNING: killing processes across many hosts can disrupt users and
services. Test the regex with a dry run before deploying widely.
type: CLIENT
required_permissions:
- EXECVE
parameters:
- name: ProcessRegex
type: regex
default: ThisIsAUniqueName
description: Matched against the process name and executable path.
- name: CommandLineRegex
type: regex
default: .
description: Only kill processes whose command line also matches.
- name: ReallyDoIt
type: bool
description: Kill the matching processes. Otherwise only list them.
sources:
- query: |
// Only the running agent process itself is exempt, by PID. Other
// processes started from the same binary can still be killed.
LET agent_pid <= getpid()
LET targets = SELECT Pid, Ppid, Name, Exe, CommandLine, Username,
Pid = agent_pid AS IsAgent
FROM pslist()
WHERE ( Name =~ ProcessRegex OR Exe =~ ProcessRegex )
AND CommandLine =~ CommandLineRegex
AND Pid > 4
SELECT Pid, Ppid, Name, Exe, CommandLine, Username,
if(condition=IsAgent, then="Skipped (agent)",
else=if(condition=ReallyDoIt,
then=if(condition=pskill(pid=Pid), then="Killed", else="Failed"),
else="Dry run")) AS Result
FROM targets