text code block:sequence by process.entity_id with maxspan=15s [process where host.os.type == "macos" and event.type == "start" and event.action == "exec" and process.parent.name in ("bash", "sh", "zsh") and process.name in ("whoami", "ifconfig", "system_profiler", "dscl", "arch", "csrutil") and process.args_count == 1] [file where host.os.type == "macos" and event.action == "modification" and file.path like ("/Users/Shared/*", "/tmp/*", "/private/tmp/*", "/Library/WebServer/*", "/Library/Graphics/*", "/Library/Fonts/*", "/private/var/root/Library/HTTPStorages/*", "/*/.*") and not file.path like ("/private/tmp/*.fifo", "/private/tmp/tcl-tk*")]
Install detection rules in Elastic Security
Detect Discovery Command Output Written to Suspicious File 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).