This detection identifies adversaries deploying a malicious web shell named “moon.php” to establish persistent access and execute arbitrary commands on compromised web servers. Proactive hunting for this artifact in Azure Sentinel is critical because web shells often serve as a stealthy entry point for lateral movement and data exfiltration that may evade standard signature-based alerts.
rule webshell_php_moon {
meta:
description = "Web Shell - file moon.php"
license = "Detection Rule License 1.1 https://github.com/Neo23x0/signature-base/blob/master/LICENSE"
author = "Florian Roth (Nextron Systems)"
date = "2014/01/28"
score = 70
hash = "2a2b1b783d3a2fa9a50b1496afa6e356"
id = "393e738a-b4c2-5630-a55f-c3caee4ff75e"
strings:
$s2 = "echo '<option value=\"create function backshell returns string soname"
$s3 = "echo \"<input name='p' type='text' size='27' value='\".dirname(_FILE_).\""
$s8 = "echo '<option value=\"select cmdshell(\\'net user "
condition:
2 of them
}
This YARA rule can be deployed in the following contexts:
This rule contains 3 string patterns in its detection logic.
Here are 5 specific false positive scenarios for the Web Shell - file moon.php detection rule, including suggested filters and exclusions tailored for an enterprise environment:
Scenario: Automated Backup Script Execution
moon.php in the web root (/var/www/html/reports/) to log completion metrics. This file is created by the service account and immediately deleted after processing, but the rule triggers on its creation.veeam-agent.exe or python3) AND the file path contains /reports/. Additionally, add a time-based exclusion for the specific window when backups run (e.g., 02:00–04:00 UTC).Scenario: CI/CD Pipeline Deployment Artifact
moon.php as part of the application update package. This file is a legitimate component of the new version, not an injected web shell, and is deployed to the staging environment (/opt/app/staging/public/moon.php).jenkins-agent, github-actions-runner) where the destination path matches the known deployment directory structure. Include a condition that ignores events if the file size is within the expected range of the standard module (e.g., 2KB–10KB).Scenario: Scheduled Health Check by Monitoring Tool