Potential Proxy Execution via PHP
Description
This rule detects the execution of a command or binary through the PHP interpreter. Attackers may use this technique to execute commands while attempting to evade detection.
Query · eql
process where event.type == "start" and event.action == "exec" and
process.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and
// Check if the parent process is a PHP interpreter with an optional version number
process.parent.name regex~ """php?[0-9]?\.?[0-9]{0,2}""" and process.parent.args == "-r" and
// Check if -r is used right after the PHP process or process path
process.parent.command_line regex~ """(\/.*\/)?php[0-9]?\.?[0-9]{0,2} \-r .*"""
and not (
process.command_line in (
"sh -c mysql --version 2>/dev/null", "sh -c locale -a", "locale -a", "stty -a", "datadog-ipc-helper",
"sh -c whereis -b traceroute", "sh -c git describe --always --tags --abbrev=0", "sh -c git rev-parse --short HEAD",
"/usr/sbin/sendmail -t -i", "sh -c /usr/sbin/sendmail -t -i", "sh -c stty -a | grep columns", "whereis -b traceroute",
"sh -c /usr/sbin/sendmail -t -i ", "sh -c exec rpm -q --queryformat '%{VERSION}.%{RELEASE}' SecurityCenter",
"sh -c /usr/bin/convert -version 2>&1", "sh -c /usr/bin/convert -list delegate 2>&1"
) or
process.args like ("/var/lib/asterisk/bin/backup.php*", "/usr/sbin/sendmail*") or
process.executable in ("/usr/bin/newrelic-daemon", "/usr/bin/git") or
process.command_line like "*git*" or
process.parent.command_line == "php get_monatsdaten.php -v -s1 -r"
)