Suspicious File Overwrite and Modification via Echo
Description
Detects the abnormal use of the echo command via a shell to write text into a file located in a suspicious location. Threat actors have used this as a method for creating second stage payloads on systems after initial access has been achieved.
Query · eql
sequence by process.entity_id with maxspan=20s
[process where event.type == "start" and event.action == "exec" and
process.name in ("bash", "sh", "zsh") and
process.args == "-c" and
process.args like~ ("echo* > /.*",
"echo* > /usr/local/bin/*",
"echo* > ~/.*",
"echo* > /tmp/*",
"echo* > /var/root/*",
"echo* > /private/tmp/*",
"echo* > /var/tmp/*",
"echo* > /var/folders/*",
"echo* > /Library/*",
"echo* > /Users/*",
"echo* > ~/*") and
process.args_count <= 3 and
process.Ext.effective_parent.name == null and
not process.parent.executable like ("/Library/Developer/*", "/Applications/Xcode.app/Contents/*")]
[file where event.action == "modification" and process.name in ("sh", "zsh", "bash") and
not file.path like~ ("/private/tmp/docker-desktop-privileged*/exitcode.txt", "/Users/*/Library/Logs/zoom.us/crashlog/usage.txt")]