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 = "2025/03/20"
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 = "eql"
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 = "eql"
99
100query = '''
101process where host.os.type == "windows" and event.type == "start" and
102 process.parent.name : ("w3wp.exe", "httpd.exe", "nginx.exe", "php.exe", "php-cgi.exe", "tomcat.exe") and
103 process.name : ("cmd.exe", "cscript.exe", "powershell.exe", "pwsh.exe", "powershell_ise.exe", "wmic.exe", "wscript.exe") and
104 not
105 (
106 process.parent.name : ("php.exe", "httpd.exe") and process.name : "cmd.exe" and
107 process.command_line : (
108 "cmd.exe /c mode CON",
109 "cmd.exe /s /c \"mode CON\"",
110 "cmd.exe /c \"mode\"",
111 "cmd.exe /s /c \"tput colors 2>&1\""
112 )
113 )
114'''
115
116
117[[rule.threat]]
118framework = "MITRE ATT&CK"
119[[rule.threat.technique]]
120id = "T1505"
121name = "Server Software Component"
122reference = "https://attack.mitre.org/techniques/T1505/"
123[[rule.threat.technique.subtechnique]]
124id = "T1505.003"
125name = "Web Shell"
126reference = "https://attack.mitre.org/techniques/T1505/003/"
127
128
129
130[rule.threat.tactic]
131id = "TA0003"
132name = "Persistence"
133reference = "https://attack.mitre.org/tactics/TA0003/"
134[[rule.threat]]
135framework = "MITRE ATT&CK"
136[[rule.threat.technique]]
137id = "T1190"
138name = "Exploit Public-Facing Application"
139reference = "https://attack.mitre.org/techniques/T1190/"
140
141
142[rule.threat.tactic]
143id = "TA0001"
144name = "Initial Access"
145reference = "https://attack.mitre.org/tactics/TA0001/"
146[[rule.threat]]
147framework = "MITRE ATT&CK"
148[[rule.threat.technique]]
149id = "T1047"
150name = "Windows Management Instrumentation"
151reference = "https://attack.mitre.org/techniques/T1047/"
152
153[[rule.threat.technique]]
154id = "T1059"
155name = "Command and Scripting Interpreter"
156reference = "https://attack.mitre.org/techniques/T1059/"
157[[rule.threat.technique.subtechnique]]
158id = "T1059.001"
159name = "PowerShell"
160reference = "https://attack.mitre.org/techniques/T1059/001/"
161
162[[rule.threat.technique.subtechnique]]
163id = "T1059.003"
164name = "Windows Command Shell"
165reference = "https://attack.mitre.org/techniques/T1059/003/"
166
167[[rule.threat.technique.subtechnique]]
168id = "T1059.005"
169name = "Visual Basic"
170reference = "https://attack.mitre.org/techniques/T1059/005/"
171
172
173
174[rule.threat.tactic]
175id = "TA0002"
176name = "Execution"
177reference = "https://attack.mitre.org/tactics/TA0002/"
toml
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.
- Observe and collect information about the following activities:
- 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.
- Use a private sandboxed malware analysis system to perform analysis.
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
- Command Execution via SolarWinds Process
- New ActiveSyncAllowedDeviceID Added via PowerShell
- Persistence via WMI Event Subscription
- Potential Foxmail Exploitation
- ScreenConnect Server Spawning Suspicious Processes