text code block:sequence by host.id, user.id with maxspan=1m [file where host.os.type == "linux" and event.action == "creation" and process.name in ("curl", "wget", "fetch", "ftp", "sftp", "scp", "rsync", "ld") and file.path : ("/dev/shm/*", "/run/shm/*", "/tmp/*", "/var/tmp/*", "/run/*", "/var/run/*", "/var/www/*", "/proc/*/fd/*")] by file.name [process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and process.parent.name in ("bash", "dash", "ash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and not process.parent.executable like ( "/tmp/VeeamApp*", "/tmp/rajh/spack-stage/*", "plz-out/bin/vault/bridge/test/e2e/base/bridge-dev", "/usr/bin/ranlib", "/usr/bin/ar", "plz-out/bin/vault/bridge/test/e2e/base/local-k8s" )] by process.name [file where host.os.type == "linux" and event.action == "deletion" and file.path : ( "/dev/shm/*", "/run/shm/*", "/tmp/*", "/var/tmp/*", "/run/*", "/var/run/*", "/var/www/*", "/proc/*/fd/*" ) and not process.name in ("rm", "ld", "conftest", "link", "gcc", "getarch", "ld")] by file.name
Install detection rules in Elastic Security
Detect File Creation, Execution and Self-Deletion in Suspicious Directory 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).