Web Shell Detection: Script Process Child of Common Web Processes

Identifies suspicious commands executed via a web server, which may suggest a vulnerability and remote shell access.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2021/08/24"
  3integration = ["endpoint", "windows", "system", "sentinel_one_cloud_funnel", "m365_defender", "crowdstrike"]
  4maturity = "production"
  5updated_date = "2026/03/24"
  6
  7[rule]
  8author = ["Elastic"]
  9description = "Identifies suspicious commands executed via a web server, which may suggest a vulnerability and remote shell access."
 10false_positives = [
 11    """
 12    Security audits, maintenance, and network administrative scripts may trigger this alert when run under web
 13    processes.
 14    """,
 15]
 16from = "now-9m"
 17index = [
 18    "endgame-*",
 19    "logs-crowdstrike.fdr*",
 20    "logs-endpoint.events.process-*",
 21    "logs-m365_defender.event-*",
 22    "logs-sentinel_one_cloud_funnel.*",
 23    "logs-system.security*",
 24    "logs-windows.sysmon_operational-*",
 25    "winlogbeat-*",
 26]
 27language = "kuery"
 28license = "Elastic License v2"
 29name = "Web Shell Detection: Script Process Child of Common Web Processes"
 30note = """## Triage and analysis
 31
 32### Investigating Web Shell Detection: Script Process Child of Common Web Processes
 33
 34Adversaries may backdoor web servers with web shells to establish persistent access to systems. A web shell is a web script that is placed on an openly accessible web server to allow an adversary to use the web server as a gateway into a network. A web shell may provide a set of functions to execute or a command-line interface on the system that hosts the web server.
 35
 36This rule detects a web server process spawning script and command-line interface programs, potentially indicating attackers executing commands using the web shell.
 37
 38#### Possible investigation steps
 39
 40- Investigate abnormal behaviors observed by the subject process such as network connections, registry or file modifications, and any other spawned child processes.
 41- Examine the command line to determine which commands or scripts were executed.
 42- Investigate other alerts associated with the user/host during the past 48 hours.
 43- Assess whether this behavior is prevalent in the environment by looking for similar occurrences across hosts.
 44- If scripts or executables were dropped, retrieve the files and determine if they are malicious:
 45  - Use a private sandboxed malware analysis system to perform analysis.
 46    - Observe and collect information about the following activities:
 47      - Attempts to contact external domains and addresses.
 48      - File and registry access, modification, and creation activities.
 49      - Service creation and launch activities.
 50      - Scheduled task creation.
 51  - Use the PowerShell Get-FileHash cmdlet to get the files' SHA-256 hash values.
 52    - Search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
 53
 54### False positive analysis
 55
 56- This activity is unlikely to happen legitimately. Any activity that triggered the alert and is not inherently malicious must be monitored by the security team.
 57
 58### Response and remediation
 59
 60- Initiate the incident response process based on the outcome of the triage.
 61- Isolate the involved host to prevent further post-compromise behavior.
 62- If the triage identified malware, search the environment for additional compromised hosts.
 63  - Implement temporary network rules, procedures, and segmentation to contain the malware.
 64  - Stop suspicious processes.
 65  - Immediately block the identified indicators of compromise (IoCs).
 66  - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
 67- Remove and block malicious artifacts identified during triage.
 68- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
 69- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
 70- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
 71- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
 72"""
 73references = [
 74    "https://www.microsoft.com/security/blog/2020/02/04/ghost-in-the-shell-investigating-web-shell-attacks/",
 75    "https://www.elastic.co/security-labs/elastic-response-to-the-the-spring4shell-vulnerability-cve-2022-22965",
 76    "https://www.elastic.co/security-labs/hunting-for-persistence-using-elastic-security-part-1",
 77]
 78risk_score = 73
 79rule_id = "2917d495-59bd-4250-b395-c29409b76086"
 80severity = "high"
 81tags = [
 82    "Domain: Endpoint",
 83    "OS: Windows",
 84    "Use Case: Threat Detection",
 85    "Tactic: Persistence",
 86    "Tactic: Initial Access",
 87    "Tactic: Execution",
 88    "Resources: Investigation Guide",
 89    "Data Source: Elastic Endgame",
 90    "Data Source: Elastic Defend",
 91    "Data Source: SentinelOne",
 92    "Data Source: Windows Security Event Logs",
 93    "Data Source: Microsoft Defender for Endpoint",
 94    "Data Source: Sysmon",
 95    "Data Source: Crowdstrike",
 96]
 97timestamp_override = "event.ingested"
 98type = "new_terms"
 99
100query = '''
101host.os.type:windows and event.category:process and event.type:start and process.args : * and
102  process.parent.name:("w3wp.exe" or "httpd.exe" or "nginx.exe" or "php.exe" or "php-cgi.exe" or "tomcat.exe" or "ArcSOC.exe") and
103  (
104    process.name : ("cmd.exe" or "cscript.exe" or "powershell.exe" or "pwsh.exe" or "powershell_ise.exe" or "wmic.exe" or "wscript.exe") or
105    process.name.caseless : ("cmd.exe" or "cscript.exe" or "powershell.exe" or "pwsh.exe" or "powershell_ise.exe" or "wmic.exe" or "wscript.exe")
106  ) and
107  not
108  (
109    process.command_line : (
110      "cmd.exe /c mode CON" or
111      "cmd.exe /s /c \"mode CON\"" or
112      "cmd.exe /c \"mode\"" or
113      "cmd.exe /s /c \"tput colors 2>&1\"" or
114      "cmd.exe /s /c \"stty 2> NUL\"" or
115      "cmd.exe /s /c \"stty 2>&1\"" or
116      "cmd.exe /c \"stty 2>&1\"" or
117      "cmd.exe /s /c \"ipconfig /all 2>&1\"" or
118      "cmd.exe /s /c \"echo '%os%'\"" or
119      *.\\install\\awk.exe*
120    ) or
121    process.args : (\(git or (*artisan* and *queue\:work*) or *rmdir* or "mode CON" or ver or ls or mode or dir) or
122
123    (process.name:cmd.exe and process.parent.args : "c:\\\\xampp\\\\htdocs\\\\open-audit\\\\index.php") or
124
125    (process.name:cmd.exe and process.args:("/V:ON" and "--header-html")) or
126
127    (process.parent.args:"WebCession" and process.args:E\:\\Data\\CLM\\cession\\*.bat) or
128
129    (process.parent.executable :"D:\\AiDKlinik\\php\\php-cgi.exe" and process.args:D\:\\AiDKlinik\\web*) or
130
131    (process.parent.args :"E:/wamp64/bin/apache/apache2.4.62.1" and process.args:node*) or
132
133    (process.parent.name:"php.exe" and process.name:"cmd.exe" and process.args:("/V:ON" and "/E:ON"))
134  )
135'''
136
137
138[[rule.filters]]
139[rule.filters.meta]
140negate = true
141[rule.filters.query.wildcard."process.command_line"]
142case_insensitive = true
143value = "*?:\\\\Program Files\\\\*"
144
145
146[[rule.filters]]
147[rule.filters.meta]
148negate = true
149[rule.filters.query.wildcard."process.command_line"]
150case_insensitive = true
151value = "*?:\\\\Program Files (x86)\\\\*"
152
153
154[[rule.threat]]
155framework = "MITRE ATT&CK"
156
157[[rule.threat.technique]]
158id = "T1505"
159name = "Server Software Component"
160reference = "https://attack.mitre.org/techniques/T1505/"
161
162[[rule.threat.technique.subtechnique]]
163id = "T1505.003"
164name = "Web Shell"
165reference = "https://attack.mitre.org/techniques/T1505/003/"
166
167[rule.threat.tactic]
168id = "TA0003"
169name = "Persistence"
170reference = "https://attack.mitre.org/tactics/TA0003/"
171
172[[rule.threat]]
173framework = "MITRE ATT&CK"
174
175[[rule.threat.technique]]
176id = "T1190"
177name = "Exploit Public-Facing Application"
178reference = "https://attack.mitre.org/techniques/T1190/"
179
180[rule.threat.tactic]
181id = "TA0001"
182name = "Initial Access"
183reference = "https://attack.mitre.org/tactics/TA0001/"
184
185[[rule.threat]]
186framework = "MITRE ATT&CK"
187
188[[rule.threat.technique]]
189id = "T1047"
190name = "Windows Management Instrumentation"
191reference = "https://attack.mitre.org/techniques/T1047/"
192
193[[rule.threat.technique]]
194id = "T1059"
195name = "Command and Scripting Interpreter"
196reference = "https://attack.mitre.org/techniques/T1059/"
197
198[[rule.threat.technique.subtechnique]]
199id = "T1059.001"
200name = "PowerShell"
201reference = "https://attack.mitre.org/techniques/T1059/001/"
202
203[[rule.threat.technique.subtechnique]]
204id = "T1059.003"
205name = "Windows Command Shell"
206reference = "https://attack.mitre.org/techniques/T1059/003/"
207
208[[rule.threat.technique.subtechnique]]
209id = "T1059.005"
210name = "Visual Basic"
211reference = "https://attack.mitre.org/techniques/T1059/005/"
212
213[[rule.threat.technique.subtechnique]]
214id = "T1059.007"
215name = "JavaScript"
216reference = "https://attack.mitre.org/techniques/T1059/007/"
217
218[rule.threat.tactic]
219id = "TA0002"
220name = "Execution"
221reference = "https://attack.mitre.org/tactics/TA0002/"
222[rule.new_terms]
223field = "new_terms_fields"
224value = ["host.id", "process.command_line"]
225[[rule.new_terms.history_window_start]]
226field = "history_window_start"
227value = "now-7d"

Triage and analysis

Investigating Web Shell Detection: Script Process Child of Common Web Processes

Adversaries may backdoor web servers with web shells to establish persistent access to systems. A web shell is a web script that is placed on an openly accessible web server to allow an adversary to use the web server as a gateway into a network. A web shell may provide a set of functions to execute or a command-line interface on the system that hosts the web server.

This rule detects a web server process spawning script and command-line interface programs, potentially indicating attackers executing commands using the web shell.

Possible investigation steps

  • Investigate abnormal behaviors observed by the subject process such as network connections, registry or file modifications, and any other spawned child processes.
  • Examine the command line to determine which commands or scripts were executed.
  • Investigate other alerts associated with the user/host during the past 48 hours.
  • Assess whether this behavior is prevalent in the environment by looking for similar occurrences across hosts.
  • If scripts or executables were dropped, retrieve the files and determine if they are malicious:
    • Use a private sandboxed malware analysis system to perform analysis.
      • Observe and collect information about the following activities:
        • Attempts to contact external domains and addresses.
        • File and registry access, modification, and creation activities.
        • Service creation and launch activities.
        • Scheduled task creation.
    • Use the PowerShell Get-FileHash cmdlet to get the files' SHA-256 hash values.
      • Search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.

False positive analysis

  • This activity is unlikely to happen legitimately. Any activity that triggered the alert and is not inherently malicious must be monitored by the security team.

Response and remediation

  • Initiate the incident response process based on the outcome of the triage.
  • Isolate the involved host to prevent further post-compromise behavior.
  • If the triage identified malware, search the environment for additional compromised hosts.
    • Implement temporary network rules, procedures, and segmentation to contain the malware.
    • Stop suspicious processes.
    • Immediately block the identified indicators of compromise (IoCs).
    • Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
  • Remove and block malicious artifacts identified during triage.
  • Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
  • Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
  • Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
  • Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).

References

Related rules

to-top