← Back to SOC feed Coverage →

Potential PHP Reverse Shell

sigma HIGH SigmaHQ
imProcessCreate
This rule was pulled from an open-source repository and enriched with AI. Validate in a test environment before deploying to production.
View original rule at SigmaHQ →
Retrieved: 2026-03-25T02:50:08Z · Confidence: medium

Hunt Hypothesis

The hypothesis is that the detected PHP CLI usage may indicate an adversary establishing a reverse shell to exfiltrate data or execute commands remotely. SOC teams should proactively hunt for this behavior in Azure Sentinel to identify potential command and control channels and mitigate advanced persistent threats.

Detection Rule

Sigma (Original)

title: Potential PHP Reverse Shell
id: c6714a24-d7d5-4283-a36b-3ffd091d5f7e
status: test
description: |
    Detects usage of the PHP CLI with the "-r" flag which allows it to run inline PHP code. The rule looks for calls to the "fsockopen" function which allows the creation of sockets.
    Attackers often leverage this in combination with functions such as "exec" or "fopen" to initiate a reverse shell connection.
references:
    - https://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet
    - https://www.revshells.com/
author: '@d4ns4n_'
date: 2023-04-07
tags:
    - attack.execution
logsource:
    category: process_creation
    product: linux
detection:
    selection:
        Image|contains: '/php'
        CommandLine|contains|all:
            - ' -r '
            - 'fsockopen'
        CommandLine|contains:
            - 'ash'
            - 'bash'
            - 'bsh'
            - 'csh'
            - 'ksh'
            - 'pdksh'
            - 'sh'
            - 'tcsh'
            - 'zsh'
    condition: selection
falsepositives:
    - Unknown
level: high

KQL (Azure Sentinel)

imProcessCreate
| where TargetProcessName contains "/php" and (TargetProcessCommandLine contains " -r " and TargetProcessCommandLine contains "fsockopen") and (TargetProcessCommandLine contains "ash" or TargetProcessCommandLine contains "bash" or TargetProcessCommandLine contains "bsh" or TargetProcessCommandLine contains "csh" or TargetProcessCommandLine contains "ksh" or TargetProcessCommandLine contains "pdksh" or TargetProcessCommandLine contains "sh" or TargetProcessCommandLine contains "tcsh" or TargetProcessCommandLine contains "zsh")

False Positive Guidance

MITRE ATT&CK Context

Original source: https://github.com/SigmaHQ/sigma/blob/master/rules/linux/process_creation/proc_creation_lnx_php_reverse_shell.yml