Multi-Value Secret Searching via Grep
Description
Identifies the execution of the grep, egrep, fgrep or pgrep commands with a multi-value search pattern to collect sensitive information. This is a common technique used by attackers to collect sensitive information from the system.
Query · eql
sequence by process.parent.entity_id with maxspan=10s
[process where event.type == "start" and event.action == "exec" and process.name in ("grep", "egrep", "fgrep", "pgrep") and
process.command_line regex~ """.*\([a-z]{1,15}\|[a-z]{1,15}.*\).*""" and
process.command_line like~ (
"*|pem*", "*pem|*", "*|key*", "*key|*", "*|cred*", "*cred|*", "*|db*", "*db|*", "*|sqlite*", "*sqlite|*", "*|ssh*", "*ssh|*",
"*|conf*", "*conf|*", "*|cnf*", "*cnf|*", "*|ini*", "*ini|*", "*|secret*", "*secret|*", "*|token*", "*token|*",
"*|auth*", "*auth|*", "*|passwd*", "*passwd|*", "*|shadow*", "*shadow|*", "*|env*", "*env|*", "*|database*", "*database|*",
"*|mysql*", "*mysql|*", "*|postgres*", "*postgres|*", "*|mongo*", "*mongo|*", "*|redis*", "*redis|*", "*|vault*", "*vault|*"
) and
not (process.parent.args like ("/var/tmp/rpm-tmp*", "/usr/openv/netbackup/bin/private/nb_init_cfg") and process.command_line like "*/tmp/NBInstallAnswer.conf")] as event0
[process where event.type == "start" and event.action == "exec" and process.name in ("grep", "egrep", "fgrep", "pgrep") and
not startswith~(process.command_line, event0.process.command_line) and
process.command_line regex~ """.*\([a-z]{1,15}\|[a-z]{1,15}.*\).*""" and
process.command_line like~ (
"*|pem*", "*pem|*", "*|key*", "*key|*", "*|cred*", "*cred|*", "*|db*", "*db|*", "*|sqlite*", "*sqlite|*", "*|ssh*", "*ssh|*",
"*|conf*", "*conf|*", "*|cnf*", "*cnf|*", "*|ini*", "*ini|*", "*|secret*", "*secret|*", "*|token*", "*token|*",
"*|auth*", "*auth|*", "*|passwd*", "*passwd|*", "*|shadow*", "*shadow|*", "*|env*", "*env|*", "*|database*", "*database|*",
"*|mysql*", "*mysql|*", "*|postgres*", "*postgres|*", "*|mongo*", "*mongo|*", "*|redis*", "*redis|*", "*|vault*", "*vault|*"
)] as event1
[process where event.type == "start" and event.action == "exec" and process.name in ("grep", "egrep", "fgrep", "pgrep") and
not startswith~(process.command_line, event1.process.command_line) and
process.command_line regex~ """.*\([a-z]{1,15}\|[a-z]{1,15}.*\).*""" and
process.command_line like~ (
"*|pem*", "*pem|*", "*|key*", "*key|*", "*|cred*", "*cred|*", "*|db*", "*db|*", "*|sqlite*", "*sqlite|*", "*|ssh*", "*ssh|*",
"*|conf*", "*conf|*", "*|cnf*", "*cnf|*", "*|ini*", "*ini|*", "*|secret*", "*secret|*", "*|token*", "*token|*",
"*|auth*", "*auth|*", "*|passwd*", "*passwd|*", "*|shadow*", "*shadow|*", "*|env*", "*env|*", "*|database*", "*database|*",
"*|mysql*", "*mysql|*", "*|postgres*", "*postgres|*", "*|mongo*", "*mongo|*", "*|redis*", "*redis|*", "*|vault*", "*vault|*"
)]