T1051

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.

Microsoft Sentinel / Defender
kusto
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
high severity medium confidence

Data Sources

File: File Creation Process: Process Creation Microsoft Defender for Endpoint

Required Tables

DeviceFileEvents DeviceProcessEvents

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)

Unlock Pro Content

Get the full detection package for T1051 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections