Detect Shared Webroot in Google Chronicle
Adversaries may add malicious content to an internally accessible website through an open network file share that contains the website's webroot or web content directory. By writing a malicious script (PHP, ASPX, JSP, etc.) to the shared webroot and then browsing to it, the adversary causes the web server process to execute the content — typically resulting in a webshell. This technique enables lateral movement to the system running the web server, as the code runs under the web server process context (IIS, Apache, nginx) which may have local system or administrative privileges. The attack chain: (1) discover open share pointing to webroot, (2) write malicious web script via SMB, (3) trigger execution via HTTP request. This technique has been deprecated by MITRE but the underlying behavior remains operationally relevant as a webshell deployment vector.
MITRE ATT&CK
- Tactic
- Lateral Movement
- Canonical reference
- https://attack.mitre.org/techniques/T1051/
YARA-L Detection Query
rule T1051_shared_webroot_webshell_execution {
meta:
author = "df00tech"
description = "Detects web server processes spawning suspicious child processes indicative of webshell execution following shared webroot compromise (T1051). Web servers (IIS w3wp, Apache httpd, nginx, Tomcat java) should not directly spawn cmd.exe, PowerShell, or reconnaissance utilities under normal operation."
mitre_attack_tactic = "Lateral Movement"
mitre_attack_technique = "T1051"
mitre_attack_technique_name = "Shared Webroot"
severity = "HIGH"
confidence = "MEDIUM"
priority = "HIGH"
rule_version = "1.0"
events:
$e.metadata.event_type = "PROCESS_LAUNCH"
$e.principal.process.file.full_path = /(?i)(w3wp|httpd|httpd2|nginx|php-cgi|php-win|tomcat[0-9]?|java|iisexpress|UMWorkerProcess)\.exe$/
$e.target.process.file.full_path = /(?i)(cmd|powershell|pwsh|wscript|cscript|mshta|net1?|whoami|ipconfig|systeminfo|nltest|certutil|bitsadmin|rundll32|regsvr32|msiexec)\.exe$/
condition:
$e
}
rule T1051_shared_webroot_file_drop {
meta:
author = "df00tech"
description = "Detects web script files (PHP, ASPX, JSP, CFM, CGI) written to known webroot directories by non-web-server processes, indicating a likely webshell drop via shared network drive (T1051). Monitor for files written by SMB client processes, script interpreters, or admin tools rather than the web server itself."
mitre_attack_tactic = "Lateral Movement"
mitre_attack_technique = "T1051"
mitre_attack_technique_name = "Shared Webroot"
severity = "HIGH"
confidence = "MEDIUM"
priority = "HIGH"
rule_version = "1.0"
events:
$e.metadata.event_type = "FILE_CREATION"
$e.target.file.full_path = /(?i)(\\inetpub\\wwwroot\\|\\xampp\\htdocs\\|\\wamp\\www\\|\\wamp64\\www\\|\\Apache24\\htdocs\\|\\nginx\\html\\|\\tomcat\\webapps\\|\\jetty\\webapps\\|\/var\/www\/html\/|\/srv\/www\/|\/usr\/share\/nginx\/)/
$e.target.file.full_path = /(?i)\.(php5?|phtml|aspx?|ashx|asmx|jspx?|cfml?|pl|cgi|shtml)$/
NOT $e.principal.process.file.full_path = /(?i)(w3wp|httpd|httpd2|nginx|msiexec|TrustedInstaller|MicrosoftEdgeUpdate)\.exe$/
condition:
$e
} Two Chronicle YARA-L 2.0 rules for T1051 Shared Webroot. Rule 1 (T1051_shared_webroot_webshell_execution) detects web server processes spawning suspicious interpreter or reconnaissance child processes using UDM PROCESS_LAUNCH events — this is the highest-fidelity signal indicating active webshell execution. Rule 2 (T1051_shared_webroot_file_drop) detects web script file creation in known webroot directories by non-web-server processes using UDM FILE_CREATION events — catches the initial write phase. Both rules should be deployed together in Chronicle to maximize coverage across the attack chain. YARA-L 2.0 does not support UNION within a single rule; deploy both as separate detection rules. Requires Chronicle UDM normalization of endpoint telemetry (Sysmon, CrowdStrike, Carbon Black, etc.).
Data Sources
Required Tables
False Positives & Tuning
- Java application servers (Tomcat, WildFly) that use java.exe as both the server process and for spawning legitimate JVM child processes for JSP compilation or scheduled tasks — the parent/child java→java pattern may be benign; focus on java spawning cmd.exe, PowerShell, or OS utilities specifically
- Automated web application deployment tools (msdeploy.exe, deploy.sh, Capistrano) running under a service account that writes ASPX or PHP files to the webroot — these are not web server processes so they will trigger the file drop rule; whitelist known deployer binary paths in the NOT clause
- Security scanning agents (Nessus, Qualys, Rapid7) that perform authenticated web application scanning may create temporary probe files with script extensions in webroot directories — identify scanner service account names and add them to the exclusion list
Other platforms for T1051
Testing Methodology
Validate this detection against 5 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1Drop PHP Webshell via SMB Network Share to Webroot
Expected signal: Windows Security Event ID 5140: Network share \\TARGET_WEBSERVER\wwwroot accessed from source workstation. Windows Security Event ID 4624: Network logon (Type 3) to TARGET_WEBSERVER using webadmin credentials. Sysmon Event ID 11 on TARGET_WEBSERVER: FileCreate for df00tech-test-shell.php in C:\inetpub\wwwroot\, InitiatingProcess will be System (SMB kernel write). DeviceFileEvents on TARGET_WEBSERVER: FileCreated for df00tech-test-shell.php with folder path containing wwwroot.
- Test 2Trigger Webshell Execution via HTTP GET Request
Expected signal: Sysmon Event ID 1 on TARGET_WEBSERVER: Process Create where ParentImage is php-cgi.exe (or w3wp.exe for ASPX), Image is cmd.exe or whoami.exe, CommandLine contains 'whoami'. DeviceProcessEvents: InitiatingProcessFileName=php-cgi.exe spawning FileName=cmd.exe. IIS access log entry for GET /df00tech-test-shell.php with query string cmd=whoami, HTTP 200 response.
- Test 3Drop ASPX Webshell to IIS Webroot via Local File Copy
Expected signal: Sysmon Event ID 11: FileCreate for df00tech-test-shell.aspx in C:\inetpub\wwwroot\, InitiatingProcess=cmd.exe. DeviceFileEvents: FileCreated, FileName=df00tech-test-shell.aspx, FolderPath=C:\inetpub\wwwroot\, InitiatingProcessFileName=cmd.exe. Security Event ID 4663 if object-level SACL auditing is configured on the wwwroot directory.
- Test 4Enumerate Accessible Webroot Network Shares
Expected signal: Windows Security Event ID 5140 on TARGET_WEBSERVER: Network share \\TARGET_WEBSERVER\wwwroot accessed. Windows Security Event ID 5156: Windows Filtering Platform allowed inbound connection on port 445. Sysmon Event ID 3 on attacker host: outbound network connection to TARGET_WEBSERVER:445. Windows Security Event ID 4624: Type 3 (Network) logon to TARGET_WEBSERVER.
- Test 5PHP File Drop Simulating CMS Plugin Install Gone Wrong
Expected signal: Sysmon Event ID 11: FileCreate for df00tech-update.php in C:\inetpub\wwwroot\uploads\, InitiatingProcess=powershell.exe. DeviceFileEvents: FileCreated, FileName=df00tech-update.php, FolderPath=C:\inetpub\wwwroot\uploads\, InitiatingProcessFileName=powershell.exe. PowerShell ScriptBlock Log Event ID 4104 with Set-Content command writing PHP content.
References (10)
- https://attack.mitre.org/techniques/T1051/
- https://www.webroot.com/blog/2011/02/22/malicious-php-scripts-on-the-rise/
- http://httpd.apache.org/docs/2.4/getting-started.html#content
- https://capec.mitre.org/data/definitions/563.html
- https://learn.microsoft.com/en-us/iis/manage/configuring-security/application-pool-identities
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1505.003/T1505.003.md
- https://github.com/SigmaHQ/sigma/tree/master/rules/windows/file
- https://learn.microsoft.com/en-us/windows/security/threat-protection/auditing/event-5140
- https://www.sans.org/reading-room/whitepapers/webserv/detecting-web-shells-33156
- https://www.cisa.gov/news-events/alerts/2021/02/10/cisa-er21-02-01-remediating-microsoft-exchange-vulnerabilities
Unlock Pro Content
Get the full detection package for T1051 including response playbook, investigation guide, and atomic red team tests.