Detect Shared Webroot in Splunk
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/
SPL Detection Query
index=wineventlog (
(sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=11)
OR
(sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1)
OR
(sourcetype="WinEventLog:Security" EventCode=5140)
)
| eval DetectionBranch=case(
EventCode=11 AND match(TargetFilename, "(?i)(inetpub.wwwroot|xampp.htdocs|wamp.www|Apache24.htdocs|nginx.html|tomcat.webapps|web.wwwroot)") AND match(TargetFilename, "(?i)\.(php5?|phtml|aspx?|ashx|asmx|jspx?|cfml?|pl|cgi|shtml)$"),
"WebRootFileDrop",
EventCode=1 AND match(ParentImage, "(?i)(w3wp|httpd|nginx|php(-cgi|-win)?|tomcat[0-9]?|java|iisexpress)\.exe$") AND match(Image, "(?i)(cmd|powershell|pwsh|wscript|cscript|mshta|net1?|whoami|ipconfig|systeminfo|nltest|certutil|bitsadmin|rundll32|regsvr32)(\.exe)?$"),
"WebShellChildProcess",
EventCode=5140 AND match(ShareName, "(?i)(wwwroot|htdocs|webroot|www)$"),
"WebRootShareAccess",
true(), null()
)
| where isnotnull(DetectionBranch)
| eval FileDropped=if(DetectionBranch="WebRootFileDrop", TargetFilename, null())
| eval ChildProcess=if(DetectionBranch="WebShellChildProcess", Image, null())
| eval ShareAccessed=if(DetectionBranch="WebRootShareAccess", ShareName, null())
| eval Actor=coalesce(User, SubjectUserName)
| table _time, host, Actor, DetectionBranch, FileDropped, ChildProcess, ShareAccessed,
Image, CommandLine, ParentImage, ParentCommandLine, TargetFilename
| sort - _time Detects shared webroot abuse across three event sources using Sysmon and Windows Security logs. Sysmon EventCode 11 (File Create) identifies script files written to webroot paths. Sysmon EventCode 1 (Process Create) identifies web server processes spawning command interpreters indicating webshell execution. Windows Security EventCode 5140 (Network Share Object Accessed) detects direct SMB access to web root shares. The DetectionBranch field identifies which indicator fired, enabling targeted analyst triage.
Data Sources
Required Sourcetypes
False Positives & Tuning
- Web developers pushing code via mapped network drive directly to development webroot directories
- CI/CD deployment agents writing application files to IIS webroots — common with TeamCity, Jenkins, GitHub Actions self-hosted runners
- CMS plugin installers: WordPress, Drupal, Joomla write PHP files to webroot as part of normal install/update flows
- Legitimate administrative scripts that query system info via web server context (e.g., monitoring endpoints that call ipconfig or systeminfo)
- Penetration testing or red team exercises targeting the web server in authorized engagements
- IIS Web Deploy (MSDeploy) writing files to wwwroot as part of standard deployment packages
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.