process where event.action in ("exec", "exec_event", "executed", "process_started") and event.type == "start" and
(
((process.args : ("rm", "echo") or
(process.args : "ln" and process.args : "-sf" and process.args : "/dev/null") or
(process.args : "truncate" and process.args : "-s0"))
and process.args : (".bash_history", "/root/.bash_history", "/home/*/.bash_history","/Users/.bash_history", "/Users/*/.bash_history",
".zsh_history", "/root/.zsh_history", "/home/*/.zsh_history", "/Users/.zsh_history", "/Users/*/.zsh_history")) or
(process.args : "history" and process.args : "-c") or
(process.args : "export" and process.args : ("HISTFILE=/dev/null", "HISTFILESIZE=0")) or
(process.args : "unset" and process.args : "HISTFILE") or
(process.args : "set" and process.args : "history" and process.args : "+o")
)
Install detection rules in Elastic Security
Detect Tampering of Shell Command-Line History 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(opens in a new tab or window).