This detection targets adversaries deploying a highly obfuscated and compact Weevely webshell to establish persistent access points within web applications for command execution and data exfiltration. A proactive hunt is essential in Azure Sentinel because these tiny, scrambled artifacts often evade standard signature-based defenses, requiring behavioral analysis to uncover stealthy post-compromise activities before they escalate into significant breaches.
rule Weevely_Webshell {
meta:
description = "Weevely Webshell - Generic Rule - heavily scrambled tiny web shell"
license = "Detection Rule License 1.1 https://github.com/Neo23x0/signature-base/blob/master/LICENSE"
author = "Florian Roth (Nextron Systems)"
reference = "http://www.ehacking.net/2014/12/weevely-php-stealth-web-backdoor-kali.html"
date = "2014/12/14"
score = 60
id = "12aa177a-4ebc-5ed8-a81b-34ec83395ec4"
strings:
$s0 = /\$[a-z]{4} = \$[a-z]{4}\("[a-z][a-z]?",[\s]?"",[\s]?"/ ascii
$s1 = /\$[a-z]{4} = str_replace\("[a-z][a-z]?","","/ ascii
$s2 = /\$[a-z]{4}\.\$[a-z]{4}\.\$[a-z]{4}\.\$[a-z]{4}\)\)\); \$[a-z]{4}\(\);/ ascii
$s4 = /\$[a-z]{4}="[a-zA-Z0-9]{70}/ ascii
condition:
uint32(0) == 0x68703f3c and all of ($s*) and filesize > 570 and filesize < 800
}
This YARA rule can be deployed in the following contexts:
This rule contains 4 string patterns in its detection logic.
Here are 5 specific false positive scenarios for the Weevely Webshell - Generic Rule in an enterprise environment, including suggested filters and exclusions:
Scenario: Automated Backup Script Execution via PowerShell
System.Reflection to dynamically load assemblies for reporting. These scripts frequently generate highly compressed, obfuscated payloads that resemble the “heavily scrambled” signature of a Weevely webshell.powershell.exe) and Command Line. Filter out alerts where the command line contains specific backup keywords (e.g., Veeam.Backup, CommvaultAgent) or originates from a known service account (e.g., DOMAIN\svc_backup).Scenario: CI/CD Pipeline Artifact Deployment
Jenkins/2.x, AzureDevOpsAgent). Additionally, filter by time-of-day if deployments are restricted to maintenance windows.Scenario: Application Server Health Checks with Obfuscated Payloads