Service Control Spawned via Script Interpreter

Identifies Service Control (sc.exe) spawning from script interpreter processes to create, modify, or start services. This can potentially indicate an attempt to elevate privileges or maintain persistence.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2020/02/18"
  3integration = ["endpoint", "system", "windows", "m365_defender", "crowdstrike"]
  4maturity = "production"
  5updated_date = "2026/09/18"
  6[transform]
  7[[transform.osquery]]
  8label = "Osquery - Retrieve All Services"
  9query = "SELECT description, display_name, name, path, pid, service_type, start_type, status, user_account FROM services"
 10
 11[[transform.osquery]]
 12label = "Osquery - Retrieve Services Running on User Accounts"
 13query = """
 14SELECT description, display_name, name, path, pid, service_type, start_type, status, user_account FROM services WHERE
 15NOT (user_account LIKE '%LocalSystem' OR user_account LIKE '%LocalService' OR user_account LIKE '%NetworkService' OR
 16user_account == null)
 17"""
 18
 19[[transform.osquery]]
 20label = "Osquery - Retrieve Service Unsigned Executables with Virustotal Link"
 21query = """
 22SELECT concat('https://www.virustotal.com/gui/file/', sha1) AS VtLink, name, description, start_type, status, pid,
 23services.path FROM services JOIN authenticode ON services.path = authenticode.path OR services.module_path =
 24authenticode.path JOIN hash ON services.path = hash.path WHERE authenticode.result != 'trusted'
 25"""
 26
 27
 28[rule]
 29author = ["Elastic"]
 30description = """
 31Identifies Service Control (sc.exe) spawning from script interpreter processes to create, modify, or start services.
 32This can potentially indicate an attempt to elevate privileges or maintain persistence.
 33"""
 34from = "now-9m"
 35index = [
 36    "endgame-*",
 37    "logs-crowdstrike.fdr*",
 38    "logs-endpoint.events.process-*",
 39    "logs-m365_defender.event-*",
 40    "logs-system.security*",
 41    "logs-windows.forwarded*",
 42    "winlogbeat-*",
 43]
 44language = "eql"
 45license = "Elastic License v2"
 46name = "Service Control Spawned via Script Interpreter"
 47note = """## Triage and analysis
 48
 49### Investigating Service Control Spawned via Script Interpreter
 50
 51Windows services are background processes that run with SYSTEM privileges and provide specific functionality or support to other applications and system components.
 52
 53The `sc.exe` command line utility is used to manage and control Windows services on a local or remote computer. Attackers may use `sc.exe` to create, modify, and start services to elevate their privileges from administrator to SYSTEM.
 54
 55> **Note**:
 56> This investigation guide uses the [Osquery Markdown Plugin](https://www.elastic.co/guide/en/security/current/invest-guide-run-osquery.html) introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide.
 57
 58#### Possible investigation steps
 59
 60- Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
 61- Examine the command line, registry changes events, and Windows events related to service activities (for example, 4697 and/or 7045) for suspicious characteristics.
 62  - Examine the created and existent services, the executables or drivers referenced, and command line arguments for suspicious entries.
 63    - $osquery_0
 64    - $osquery_1
 65    - $osquery_2
 66  - Retrieve the referenced files' SHA-256 hash values using the PowerShell `Get-FileHash` cmdlet and search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
 67- Identify the user account that performed the action and whether it should perform this kind of action.
 68- Contact the account owner and confirm whether they are aware of this activity.
 69- Investigate other alerts associated with the user/host during the past 48 hours.
 70- Assess whether this behavior is prevalent in the environment by looking for similar occurrences across hosts.
 71
 72### False positive analysis
 73
 74- This activity is not inherently malicious if it occurs in isolation. As long as the analyst did not identify suspicious activity related to the user, host, and service, such alerts can be dismissed.
 75
 76### Response and remediation
 77
 78- Initiate the incident response process based on the outcome of the triage.
 79- Isolate the involved host to prevent further post-compromise behavior.
 80- 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.
 81- Delete the service or restore it to the original configuration.
 82- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
 83- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
 84- 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).
 85"""
 86
 87setup = """## Setup
 88
 89This rule is designed for data generated by [Elastic Defend](https://www.elastic.co/security/endpoint-security), which provides native endpoint detection and response, along with event enrichments designed to work with our detection rules.
 90
 91Setup instructions: https://ela.st/install-elastic-defend
 92
 93### Additional data sources
 94
 95This rule also supports the following third-party data sources. For setup instructions, refer to the links below:
 96
 97- [CrowdStrike](https://ela.st/crowdstrike-integration)
 98- [Microsoft Defender XDR](https://ela.st/m365-defender)
 99- [Windows Process Creation Logs](https://ela.st/audit-process-creation)
100"""
101
102references = ["https://www.elastic.co/security-labs/invisible-miners-unveiling-ghostengine"]
103risk_score = 21
104rule_id = "e8571d5f-bea1-46c2-9f56-998de2d3ed95"
105severity = "low"
106tags = [
107    "Domain: Endpoint",
108    "OS: Windows",
109    "Use Case: Threat Detection",
110    "Tactic: Privilege Escalation",
111    "Tactic: Defense Evasion",
112    "Tactic: Execution",
113    "Data Source: Elastic Endgame",
114    "Resources: Investigation Guide",
115    "Data Source: Elastic Defend",
116    "Data Source: Windows Security Event Logs",
117    "Data Source: Microsoft Defender XDR",
118    "Data Source: Crowdstrike",
119    "Noise: Medium",
120    "Performance: Normal",
121    "Threat: Living off the Land",
122    "Rule Type: Event Correlation (EQL)",
123    "Platform: Windows",
124    "Resources: Osquery",
125]
126timestamp_override = "event.ingested"
127type = "eql"
128
129query = '''
130/* This rule is not compatible with Sysmon due to user.id issues */
131
132process where host.os.type == "windows" and event.type == "start" and
133  (process.name : "sc.exe" or ?process.pe.original_file_name == "sc.exe") and
134  process.parent.name : ("cmd.exe", "wscript.exe", "rundll32.exe", "regsvr32.exe",
135                         "wmic.exe", "mshta.exe","powershell.exe", "pwsh.exe") and
136  process.args:("config", "create", "start", "delete", "stop", "pause") and
137  /* exclude SYSTEM SID - look for service creations by non-SYSTEM user */
138  not user.id : "S-1-5-18"
139'''
140
141
142[[rule.threat]]
143framework = "MITRE ATT&CK"
144
145[[rule.threat.technique]]
146id = "T1543"
147name = "Create or Modify System Process"
148reference = "https://attack.mitre.org/techniques/T1543/"
149
150[[rule.threat.technique.subtechnique]]
151id = "T1543.003"
152name = "Windows Service"
153reference = "https://attack.mitre.org/techniques/T1543/003/"
154
155[rule.threat.tactic]
156id = "TA0004"
157name = "Privilege Escalation"
158reference = "https://attack.mitre.org/tactics/TA0004/"
159
160[[rule.threat]]
161framework = "MITRE ATT&CK"
162
163[[rule.threat.technique]]
164id = "T1047"
165name = "Windows Management Instrumentation"
166reference = "https://attack.mitre.org/techniques/T1047/"
167
168[[rule.threat.technique]]
169id = "T1059"
170name = "Command and Scripting Interpreter"
171reference = "https://attack.mitre.org/techniques/T1059/"
172
173[[rule.threat.technique.subtechnique]]
174id = "T1059.001"
175name = "PowerShell"
176reference = "https://attack.mitre.org/techniques/T1059/001/"
177
178[[rule.threat.technique.subtechnique]]
179id = "T1059.003"
180name = "Windows Command Shell"
181reference = "https://attack.mitre.org/techniques/T1059/003/"
182
183[[rule.threat.technique.subtechnique]]
184id = "T1059.005"
185name = "Visual Basic"
186reference = "https://attack.mitre.org/techniques/T1059/005/"
187
188[[rule.threat.technique]]
189id = "T1569"
190name = "System Services"
191reference = "https://attack.mitre.org/techniques/T1569/"
192
193[[rule.threat.technique.subtechnique]]
194id = "T1569.002"
195name = "Service Execution"
196reference = "https://attack.mitre.org/techniques/T1569/002/"
197
198[rule.threat.tactic]
199id = "TA0002"
200name = "Execution"
201reference = "https://attack.mitre.org/tactics/TA0002/"
202
203[[rule.threat]]
204framework = "MITRE ATT&CK"
205
206[[rule.threat.technique]]
207id = "T1218"
208name = "System Binary Proxy Execution"
209reference = "https://attack.mitre.org/techniques/T1218/"
210
211[[rule.threat.technique.subtechnique]]
212id = "T1218.005"
213name = "Mshta"
214reference = "https://attack.mitre.org/techniques/T1218/005/"
215
216[[rule.threat.technique.subtechnique]]
217id = "T1218.010"
218name = "Regsvr32"
219reference = "https://attack.mitre.org/techniques/T1218/010/"
220
221[[rule.threat.technique.subtechnique]]
222id = "T1218.011"
223name = "Rundll32"
224reference = "https://attack.mitre.org/techniques/T1218/011/"
225
226[rule.threat.tactic]
227id = "TA0005"
228name = "Defense Evasion"
229reference = "https://attack.mitre.org/tactics/TA0005/"

Triage and analysis

Investigating Service Control Spawned via Script Interpreter

Windows services are background processes that run with SYSTEM privileges and provide specific functionality or support to other applications and system components.

The sc.exe command line utility is used to manage and control Windows services on a local or remote computer. Attackers may use sc.exe to create, modify, and start services to elevate their privileges from administrator to SYSTEM.

Note: This investigation guide uses the Osquery Markdown Plugin introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide.

Possible investigation steps

  • Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
  • Examine the command line, registry changes events, and Windows events related to service activities (for example, 4697 and/or 7045) for suspicious characteristics.
    • Examine the created and existent services, the executables or drivers referenced, and command line arguments for suspicious entries.
      • $osquery_0
      • $osquery_1
      • $osquery_2
    • Retrieve the referenced files' SHA-256 hash values using the PowerShell Get-FileHash cmdlet and search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
  • Identify the user account that performed the action and whether it should perform this kind of action.
  • Contact the account owner and confirm whether they are aware of this activity.
  • 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.

False positive analysis

  • This activity is not inherently malicious if it occurs in isolation. As long as the analyst did not identify suspicious activity related to the user, host, and service, such alerts can be dismissed.

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.
  • 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.
  • Delete the service or restore it to the original configuration.
  • 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