System Shells Launched via Windows Services
Attackers may configure existing Windows services or create new ones to execute system shells (cmd.exe, powershell.exe) to elevate privileges from administrator to SYSTEM for persistence and further malicious activity.
Attackers can abuse Windows services, which typically run as SYSTEM, to escalate privileges. This involves configuring existing services or creating new ones to execute system shells, such as cmd.exe or powershell.exe, to gain SYSTEM permissions. This technique can also establish persistence by ensuring the malicious shell is executed every time the service starts. The rule "System Shells via Services" aims to detect such activity by identifying instances where services.exe spawns command interpreters, indicating a potential privilege escalation or persistence attempt. This detection focuses on the relationship between services.exe and the spawned shell processes.
Attack Chain
- An attacker gains initial access to the system with administrative privileges.
- The attacker identifies a vulnerable or misconfigured service, or creates a new service using tools like
sc.exeor PowerShell. - The service configuration is modified to execute a command interpreter (cmd.exe, powershell.exe, pwsh.exe, powershell_ise.exe) instead of its legitimate function. This modification can be achieved through registry edits or command-line tools.
- The service is started or restarted, either manually or automatically during system boot.
services.exespawns the configured command interpreter.- The command interpreter executes attacker-controlled commands with SYSTEM privileges. This might include downloading and executing malware, modifying system settings, or exfiltrating data.
- The attacker leverages the SYSTEM privileges to move laterally within the network.
Impact
Successful exploitation allows attackers to gain SYSTEM-level access on the compromised host. This level of access allows for complete control over the system, including installing malicious software, modifying system configurations, stealing sensitive data, and potentially pivoting to other systems on the network. The impact can range from data breaches and system outages to complete compromise of the affected network.
Recommendation
- Deploy the Sigma rule "System Shells via Services" to your SIEM to detect this activity.
- Enable Sysmon process creation logging to ensure the rule can capture the necessary events.
- Investigate any instances of
services.exespawning command interpreters to determine if the activity is legitimate or malicious.
Detection coverage 2
System Shells via Services
mediumDetects command interpreters spawned by services.exe, indicating potential privilege escalation or persistence.
Suspicious Service Creation with Command Interpreter
highDetects the creation of a service where the service binary is a command interpreter (cmd.exe, powershell.exe, etc.)
Detection queries are available on the platform. Get full rules →