User Session File Deletion
Description
Detects the deletion of user session files on Linux systems. These files are used to store user session information. Unauthorized deletion of these files can be an indicator of an attacker attempting to hide their session from common tooling such as "w".
Query · eql
file where event.type == "deletion" and file.path like ("/run/systemd/sessions/*", "/var/run/systemd/sessions/*") and
process.executable != null and
not (
process.executable in (
"/usr/lib/systemd/systemd-logind", "/usr/lib/systemd/systemd-logind (deleted)", "/usr/libexec/elogind/elogind",
"/lib/systemd/systemd-logind", "/lib/systemd/systemd-logind (deleted)", "/lib/systemd/systemd",
"/usr/lib/systemd/systemd", "/sbin/ebtables-restore", "/usr/sbin/nft", "/usr/bin/systemctl", "/bin/lxc-info",
"/usr/bin/dpkg", "/usr/bin/smbclient", "/usr/bin/gpg-agent", "/sbin/vgs", "/usr/sbin/ebtables", "/usr/bin/gpgconf",
"/usr/lib/elogind/elogind", "/usr/lib/elogind/elogind (deleted)"
) or
process.executable like (
"/nix/store/*/lib/systemd/systemd-logind", "/usr/lib/systemd/systemd-logind*",
"/var/lib/containers/storage/overlay/*/merged/usr/lib/systemd/systemd-logind",
"/zpool/*/usr/lib/systemd/systemd-logind (deleted)", "/zpool/*/usr/lib/systemd/systemd-logind"
)
)