behavior/rules/windows/execution_suspicious_php_script_execution.toml (69 lines of code) (raw):

[rule] description = """ Identifies the execution a PHP script utility that was recently dropped followed by an egress network activity or spawning a suspicious child process. """ id = "fb54419b-1284-4e85-abfd-aac59db82c8b" license = "Elastic License v2" name = "Suspicious PHP Script Execution" os_list = ["windows"] version = "1.0.2" query = ''' 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 not process.executable : ("C:\\Program Files (x86)\\PHP\\php.exe", "C:\\Program Files\\*.exe") ] 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"))] ''' min_endpoint_version = "8.4.0" optional_actions = [] [[actions]] action = "kill_process" field = "process.entity_id" state = 0 [[threat]] framework = "MITRE ATT&CK" [[threat.technique]] id = "T1059" name = "Command and Scripting Interpreter" reference = "https://attack.mitre.org/techniques/T1059/" [threat.tactic] id = "TA0002" name = "Execution" reference = "https://attack.mitre.org/tactics/TA0002/" [[threat]] framework = "MITRE ATT&CK" [[threat.technique]] id = "T1071" name = "Application Layer Protocol" reference = "https://attack.mitre.org/techniques/T1071/" [threat.tactic] id = "TA0011" name = "Command and Control" reference = "https://attack.mitre.org/tactics/TA0011/" [internal] min_endpoint_version = "8.4.0"