Persistence File Creation Through Unusual Executable
Description
This rule detects the creation of files that are commonly used for persistence mechanisms, through a process executable located in a suspicious location. This could be indicative of a persistence mechanism being established on the system.
Query · eql
sequence by process.entity_id with maxspan=10s
[process where event.type == "start" and event.action == "exec" and
process.executable like (
"/tmp/*", "/var/tmp/*", "/dev/shm/*", "/run/*", "/var/run/*", "/boot/*", "/sys/*", "*/www/html/*",
"/lost+found/*", "/var/mail/*", "/var/www/*", "/mnt/*", "/media/*", "/proc/*/fd/*", "?memfd:*", "memfd:*",
"*/wp-content/*", "*/wp-includes/*", "*/wp-admin/*"
)]
[file where event.type == "creation" and
file.path like (
"/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/*",
"/var/spool/anacron/*", "/var/spool/atjobs/*",
"/etc/rc.local", "/etc/rc.common", "/etc/init.d/*", "/etc/update-motd.d/*", "/etc/profile", "/etc/profile.d/*",
"/etc/systemd/user/*", "/usr/lib/systemd/user/*", "/home/*/.config/systemd/user/*", "/home/*/.local/share/systemd/user/*",
"/root/.config/systemd/user/*", "/root/.local/share/systemd/user/*",
"/lib/udev/*", "/etc/udev/rules.d/*", "/usr/lib/udev/rules.d/*", "/run/udev/rules.d/*", "/usr/local/lib/udev/rules.d/*",
"/etc/xdg/autostart/*", "/usr/share/autostart/*", "/home/*/.config/autostart/*", "/root/.config/autostart/*",
"/home/*/.local/share/autostart/*", "/root/.local/share/autostart/*", "/home/*/.config/autostart-scripts/*", "/root/.config/autostart-scripts/*"
) and
not (
process.executable like (
"/run/k3s/containerd/io.containerd.runtime.v2.task/k8s.io/*", "/run/containerd/io.containerd.runtime.v2.task/k8s.io/*"
) or
(process.executable like "/tmp/VeeamApp_*" and file.path like "/etc/init.d/veeamagent") or
(process.executable like "/tmp/vmis.*/install/vmware-installer/vmis-launcher" and file.path like "/etc/init.d/vmware*") or
(process.executable like "/tmp/newroot/usr/sbin/anacron" and file.path like "/var/spool/anacron/*") or
(process.executable like "/tmp/buildah*" and file.path like "/etc/cron.d/php.dpkg-new") or
(process.executable like "/tmp/tmp.*/nix-installer" and file.path like "/etc/profile.d/nix-installer-tmp.*") or
(process.executable like "/tmp/octofence-agent-installer_*" and file.path like "/etc/init.d/octofence-agent") or
(process.executable like "/tmp/vmware-tools-distrib/vmware-install.pl" and file.path like "/etc/init.d/vmware-tools") or
(process.executable like "/tmp/ubuntu-release-upgrader-*" and file.path == "/usr/lib/systemd/user/upgrade-restore-font.service")
)]