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"
) or
(
process.parent.executable == "/var/lib/dpkg/info/omi.postinst" and
process.parent.command_line like "/bin/sh /var/lib/dpkg/info/omi.postinst configure *"
) or
process.parent.command_line like "/bin/bash --init-file */.vscode-server/cli/servers/*/server/out/vs/workbench/*" or
process.working_directory like (
"/var/lib/docker/rootfs/overlayfs/*/builds/*", "/home/runner/_work/omnicontext-generator/omnicontext-generator/source*",
"/home/runner/_work/*"
) or
process.parent.args like (
"/usr/local/bin/oksid/sql-guard.sh", "./scans/surface-discovery/wayback/query_wayback.sh", "*/usr/openv/netbackup/client/*/ssh_to_client", "*/.claude/hooks/*"
)
)] 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|*"
)]