Persistence (TA0003)(external, opens in a new tab or window)
Privilege Escalation (TA0004)(external, opens in a new tab or window)
text code block:file where event.type != "deletion" and /* open events currently only log file opens with write intent */ event.action in ("creation", "rename", "open") and ( file.path like ( // Cron & Anacron Jobs "/etc/cron.allow", "/etc/cron.deny", "/etc/cron.d/*", "/etc/cron.hourly/*", "/etc/cron.daily/*", "/etc/cron.weekly/*", "/etc/cron.monthly/*", "/etc/crontab", "/var/spool/cron/crontabs/*", "/var/spool/anacron/*", // At Job "/var/spool/cron/atjobs/*", "/var/spool/atjobs/*", // Sudoers "/etc/sudoers*" ) or ( // Systemd Service/Timer file.path like ( "/etc/systemd/system/*", "/etc/systemd/user/*", "/usr/local/lib/systemd/system/*", "/lib/systemd/system/*", "/usr/lib/systemd/system/*", "/usr/lib/systemd/user/*", "/home/*/.config/systemd/user/*", "/home/*/.local/share/systemd/user/*", "/root/.config/systemd/user/*", "/root/.local/share/systemd/user/*" ) and file.extension in ("service", "timer") ) or ( // Shell Profile Configuration file.path like ("/etc/profile.d/*", "/etc/zsh/*") or ( file.path like ("/home/*/*", "/etc/*", "/root/*") and file.name in ( "profile", "bash.bashrc", "bash.bash_logout", "csh.cshrc", "csh.login", "config.fish", "ksh.kshrc", ".bashrc", ".bash_login", ".bash_logout", ".bash_profile", ".bash_aliases", ".zprofile", ".zshrc", ".cshrc", ".login", ".logout", ".kshrc" ) ) ) ) and container.id like "?*" and not process.name in ("apt", "apt-get", "dnf", "microdnf", "yum", "zypper", "tdnf", "apk", "pacman", "rpm", "dpkg")
Install detection rules in Elastic Security
Detect Modification of Persistence Relevant Files Detected via Defend for Containers in the Elastic Security detection engine by installing this rule into your Elastic Stack.
To setup this rule, check out the installation guide for Prebuilt Security Detection Rules(external, opens in a new tab or window).