Suspicious PHP Script Execution
Description
Identifies the execution a PHP script utility that was recently dropped followed by an egress network activity or spawning a suspicious child process.
Query · eql
sequence with maxspan=5m
[any where
(
(event.category == "process" and event.type == "start" and process.pe.original_file_name == "php.exe" and
(process.Ext.relative_file_creation_time <= 300 or process.Ext.relative_file_name_modify_time <= 300) and
process.executable : "C:\\*") or
(event.category == "library" and event.action == "load" and dll.pe.original_file_name : ("php?.dll", "php.dll") and
(dll.Ext.relative_file_creation_time <= 300 or dll.Ext.relative_file_name_modify_time <= 300) and
process.executable : "C:\\*")
) and
process.executable : ("C:\\Users\\*.exe", "C:\\ProgramData\\*.exe", "C:\\Windows\\*")
] as event0
[any where
/* spawn a child process */
(event.category == "process" and event.action == "start" and process.name : ("cmd.exe", "powershell.exe") and
process.parent.entity_id == event0.process.entity_id and
not process.command_line : ("* /V:ON /E:ON /D*", "cmd.exe /c \"echo '%os%'\"",
"cmd.exe /s /c \"echo '%os%'\"", "cmd.exe /s /c \"mode CON\"",
"cmd.exe /s /c \"stty 2>&1\"", "cmd.exe /c \"stty 2> NUL\"", "cmd.exe /c mode CON")) or
/* DNS lookup */
(event.category == "dns" and process.entity_id == event0.process.entity_id and dns.question.name != null) or
/* perform an egress conn to the internet */
(event.category == "network" and event.action in ("disconnect_received", "connection_attempted") and
process.entity_id == event0.process.entity_id and
not cidrmatch(destination.ip, "10.0.0.0/8", "127.0.0.0/8", "169.254.0.0/16", "172.16.0.0/12", "192.0.0.0/24",
"192.0.0.0/29", "192.0.0.8/32", "192.0.0.9/32", "192.0.0.10/32", "192.0.0.170/32", "192.0.0.171/32",
"192.0.2.0/24", "192.31.196.0/24", "192.52.193.0/24", "192.88.99.0/24", "224.0.0.0/4",
"100.64.0.0/10", "192.175.48.0/24","198.18.0.0/15", "198.51.100.0/24", "203.0.113.0/24", "240.0.0.0/4", "::1",
"FE80::/10", "FF00::/8"))]