Script Executed Through Unusual Parent Process
Description
This rule detects the execution of scripts by interpreters like Perl, Python, PHP, Ruby, and Lua, when the parent process is located in an unusual location, or the parent process is hidden. This behavior is often seen in malware that is trying to evade detection by executing scripts from temporary directories or hidden locations.
Query · eql
process where event.type == "start" and event.action == "exec" and process.args_count == 1 and process.executable like (
"/bin/perl*", "/usr/bin/perl*", "/usr/local/bin/perl*",
"/bin/python*", "/usr/bin/python*", "/usr/local/bin/python*",
"/bin/php*", "/usr/bin/php*", "/usr/local/bin/php*",
"/bin/ruby*", "/usr/bin/ruby*", "/usr/local/bin/ruby*",
"/bin/lua*", "/usr/bin/lua*", "/usr/local/bin/lua*"
) and
(process.parent.executable like ("/tmp/*", "/var/tmp/*", "/dev/shm/*", "./*", "/boot/*") or process.parent.name like ".*") and
not (
process.parent.executable like~ (
"/tmp/newroot/*", "./merged/*", "/var/tmp/.mount_*/AppRun", "/tmp/.mount_cursor*/usr/bin//cursor",
"/tmp/baum/easybuild/*/perl", "/var/tmp/buildah*", "/tmp/taddm/fileinfo*", "/tmp/wbrashear/easybuild/*",
"/tmp/.mount_cursor*/usr/share/cursor/cursor"
) or
process.parent.name in ("gogo", "nvim", "build-script-build", "jetbrains-toolbox", "runner") or
process.parent.command_line in ("runc init", "/usr/local/bin/runc init") or
(process.parent.args == "/usr/bin/crun" and process.working_directory == "/ansible")
)