Shell Command Execution via Kworker
Description
This rule monitors for the execution of shell commands via a kworker parent process. kworker, or kernel worker, processes are part of the kernel's workqueue mechanism. They are responsible for executing work that has been scheduled to be done in kernel space, which might include tasks like handling interrupts, background activities, and other kernel-related tasks. Attackers may attempt to evade detection by masquerading as a kernel worker process.
Query · eql
process where event.type == "start" and event.action == "exec" and process.parent.name like "kworker*" and
process.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and process.args == "-c" and
process.args in (
"bash", "/bin/bash", "/usr/bin/bash", "/usr/local/bin/bash",
"sh", "/bin/sh", "/usr/bin/sh", "/usr/local/bin/sh",
"dash", "/bin/dash", "/usr/bin/dash", "/usr/local/bin/dash",
"tcsh", "/bin/tcsh", "/usr/bin/tcsh", "/usr/local/bin/tcsh",
"csh", "/bin/csh", "/usr/bin/csh", "/usr/local/bin/csh",
"zsh", "/bin/zsh", "/usr/bin/zsh", "/usr/local/bin/zsh",
"ksh", "/bin/ksh", "/usr/bin/ksh", "/usr/local/bin/ksh",
"fish", "/bin/fish", "/usr/bin/fish", "/usr/local/bin/fish"
) and
process.args_count >= 3 and process.command_line like (
"*ip*", "*whoami*", "*id*", "*hostname*", "*touch*", "*curl*", "*wget*", "*chmod*", "*busybox*", "*chattr*", "*echo*",
"*python*", "*php*", "*perl*", "*ruby*", "*lua*", "*openssl*", "*nc*", "*netcat*", "*ncat*"
) and not (
process.command_line == "sh -c /bin/true" or
process.args like ("/sbin/modprobe *", "/usr/sbin/modprobe *")
)