Detection rules › Sigma

Php Inline Command Execution

Status
test
Severity
medium
Log source
category process_creation, product windows
Author
Nasreddine Bencherchali (Nextron Systems)
Source
github.com/SigmaHQ/sigma

Detects execution of php using the "-r" flag. This is could be used as a way to launch a reverse shell or execute live php code.

MITRE ATT&CK coverage

Telemetry coverage

ProviderRecord / event type
SysmonEvent ID 1: Process creation

Rule body

title: Php Inline Command Execution
id: d81871ef-5738-47ab-9797-7a9c90cd4bfb
status: test
description: Detects execution of php using the "-r" flag. This is could be used as a way to launch a reverse shell or execute live php code.
references:
    - https://www.php.net/manual/en/features.commandline.php
    - https://www.revshells.com/
    - https://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet
author: Nasreddine Bencherchali (Nextron Systems)
date: 2023-01-02
tags:
    - attack.execution
    - attack.t1059
logsource:
    category: process_creation
    product: windows
detection:
    selection_img:
        - Image|endswith: '\php.exe'
        - OriginalFileName: 'php.exe'
    selection_cli:
        CommandLine|contains: ' -r'
    condition: all of selection_*
falsepositives:
    - Unknown
level: medium

Stages and Predicates

Stage 0: condition

all of selection_*

Stage 1: selection_img

selection_img:
    - Image|endswith: '\php.exe'
    - OriginalFileName: 'php.exe'

Stage 2: selection_cli

selection_cli:
    CommandLine|contains: ' -r'

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
CommandLinematch
  • -r corpus 4 (sigma 3, splunk 1)
field:"CommandLine" kind:match value:" -r"
Imageends_with
  • \php.exe
field:"Image" kind:ends_with value:"\php.exe"
OriginalFileNameeq
  • php.exe corpus 2 (sigma 1, elastic 1)
field:"OriginalFileName" kind:eq value:"php.exe"