Deletion of Shell History File
Description
Detects the deletion of shell history files through suspicious or commonly available tooling via a file deletion event. Shell history files are used to store the command history of a user. Adversaries may attempt to delete these files to remove evidence of their activity.
Query · eql
file where event.type == "deletion" and file.name in (
".bash_history", ".zsh_history", ".sh_history", ".ksh_history",
".history", ".csh_history", ".tcsh_history", "fish_history", ".ash_history"
) and
/* Enforce non-backup home & root directories to prevent false positives */
(
file.path like ("/home/*/*", "/root/*", "/etc/*") and
not file.path like ("/home/*/*/*", "/root/*/*")
) and
(
process.name in (
"rm", "sudo", "truncate", "unlink", "find", "xargs", "install", "shred", "vi", "vim",
"vim.basic", "coreutils", "tar", "gzip", "bzip2", "rmdir", "mv", "cp", "ln", "busybox",
"bash", "zsh", "sh", "tcsh", "csh", "ksh", "fish"
) or
process.name like ".*" or
process.executable like (
"./*", "/dev/shm/*", "/tmp/*", "/var/tmp/*", "/run/*", "/var/run/*", "/boot/*", "/sys/*",
"/lost+found/*", "/proc/*", "/var/mail/*", "/var/www/*", "/root/*", "/home/*"
)
)