Persistence (TA0003)(external, opens in a new tab or window)
Privilege Escalation (TA0004)(external, opens in a new tab or window)
Credential Access (TA0006)(external, opens in a new tab or window)
Defense Evasion (TA0005)(external, opens in a new tab or window)
text code block:file where host.os.type == "linux" and event.dataset == "fim.event" and event.action == "updated" and file.path : ( // cron, anacron & at "/etc/cron.d/*", "/etc/cron.daily/*", "/etc/cron.hourly/*", "/etc/cron.monthly/*", "/etc/cron.weekly/*", "/etc/crontab", "/var/spool/cron/crontabs/*", "/etc/cron.allow", "/etc/cron.deny", "/var/spool/anacron/*", "/var/spool/cron/atjobs/*", // systemd services & timers "/etc/systemd/system/*", "/usr/local/lib/systemd/system/*", "/lib/systemd/system/*", "/usr/lib/systemd/system/*", "/home/*/.config/systemd/user/*", "/home/*/.local/share/systemd/user/*", "/root/.config/systemd/user/*", "/root/.local/share/systemd/user/*", // LD_PRELOAD "/etc/ld.so.preload", "/etc/ld.so.conf.d/*", "/etc/ld.so.conf", // Dynamic linker "/lib/ld-linux*.so*", "/lib64/ld-linux*.so*", "/usr/lib/ld-linux*.so*", "/usr/lib64/ld-linux*.so*", // message-of-the-day (MOTD) "/etc/update-motd.d/*", // SSH "/home/*/.ssh/*", "/root/.ssh/*", "/etc/ssh/*", // system-wide shell configurations "/etc/profile", "/etc/profile.d/*", "/etc/bash.bashrc", "/etc/zsh/*", "/etc/csh.cshrc", "/etc/csh.login", "/etc/fish/config.fish", "/etc/ksh.kshrc", // root and user shell configurations "/home/*/.profile", "/home/*/.bashrc", "/home/*/.bash_login", "/home/*/.bash_logout", "/root/.profile", "/root/.bashrc", "/root/.bash_login", "/root/.bash_logout", "/home/*/.zprofile", "/home/*/.zshrc", "/root/.zprofile", "/root/.zshrc", "/home/*/.cshrc", "/home/*/.login", "/home/*/.logout", "/root/.cshrc", "/root/.login", "/root/.logout", "/home/*/.config/fish/config.fish", "/root/.config/fish/config.fish", "/home/*/.kshrc", "/root/.kshrc", // Alias files "/home/*/.bash_aliases", "/root/.bash_aliases", "/home/*/.zsh_aliases", "/root/.zsh_aliases", "/home/*/.aws/cli/alias", "/root/.aws/cli/alias", // runtime control "/etc/rc.common", "/etc/rc.local", // System V init/Upstart "/etc/init.d/*", "/etc/init/*", // passwd/sudoers/shadow "/etc/passwd", "/etc/shadow", "/etc/sudoers", "/etc/sudoers.d/*", // Systemd udevd "/lib/udev/*", "/etc/udev/rules.d/*", "/usr/lib/udev/rules.d/*", "/run/udev/rules.d/*", "/usr/local/lib/udev/rules.d/*", // XDG/KDE autostart entries "/home/*/.config/autostart/*", "/root/.config/autostart/*", "/etc/xdg/autostart/*", "/usr/share/autostart/*", "/home/*/.kde/Autostart/*", "/root/.kde/Autostart/*", "/home/*/.kde4/Autostart/*", "/root/.kde4/Autostart/*", "/home/*/.kde/share/autostart/*", "/root/.kde/share/autostart/*", "/home/*/.kde4/share/autostart/*", "/root/.kde4/share/autostart/*", "/home/*/.local/share/autostart/*", "/root/.local/share/autostart/*", "/home/*/.config/autostart-scripts/*", "/root/.config/autostart-scripts/*", // LKM configuration files "/etc/modules", "/etc/modprobe.d/*", "/usr/lib/modprobe.d/*", "/etc/modules-load.d/*", "/run/modules-load.d/*", "/usr/local/lib/modules-load.d/*", "/usr/lib/modules-load.d/*", // PAM modules & configuration files "/lib/security/*", "/lib64/security/*", "/usr/lib/security/*", "/usr/lib64/security/*", "/lib/x86_64-linux-gnu/security/*", "/usr/lib/x86_64-linux-gnu/security/*", "/etc/pam.d/*", "/etc/security/pam_*", "/etc/pam.conf", // Polkit Rule files "/etc/polkit-1/rules.d/*", "/usr/share/polkit-1/rules.d/*", // Polkit pkla files "/etc/polkit-1/localauthority/*", "/var/lib/polkit-1/localauthority/*", // Polkit Action files "/usr/share/polkit-1/actions/*", // Polkit Legacy paths "/lib/polkit-1/rules.d/*", "/lib64/polkit-1/rules.d/*", "/var/lib/polkit-1/rules.d/*", // NetworkManager "/etc/NetworkManager/dispatcher.d/*", // D-bus Service files "/usr/share/dbus-1/system-services/*", "/etc/dbus-1/system.d/*", "/lib/dbus-1/system-services/*", "/run/dbus/system.d/*", "/home/*/.local/share/dbus-1/services/*", "/home/*/.dbus/session-bus/*", "/usr/share/dbus-1/services/*", "/etc/dbus-1/session.d/*", // GRUB "/etc/default/grub.d/*", "/etc/default/grub", "/etc/grub.d/*", "/boot/grub2/grub.cfg", "/boot/grub/grub.cfg", "/boot/efi/EFI/*/grub.cfg", "/etc/sysconfig/grub", // Dracut "/lib/dracut/modules.d/*", "/usr/lib/dracut/modules.d/*", // Misc. "/etc/shells" ) and not ( file.path : ( "/var/spool/cron/crontabs/tmp.*", "/run/udev/rules.d/*rules.*", "/home/*/.ssh/known_hosts.*", "/root/.ssh/known_hosts.*" ) or file.extension in ("dpkg-new", "dpkg-remove", "SEQ") )
Install detection rules in Elastic Security
Detect Potential Persistence via File Modification 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).