Register to stream ATT&CKcon 2.0 October 29-30

Modify Existing Service

Windows service configuration information, including the file path to the service's executable or recovery programs/commands, is stored in the Registry. Service configurations can be modified using utilities such as sc.exe and Reg.

Adversaries can modify an existing service to persist malware on a system by using system utilities or by using custom tools to interact with the Windows API. Use of existing services is a type of Masquerading that may make detection analysis more challenging. Modifying existing services may interrupt their functionality or may enable services that are disabled or otherwise not commonly used.

Adversaries may also intentionally corrupt or kill services to execute malicious recovery programs/commands. [1] [2]

ID: T1031
Tactic: Persistence
Platform: Windows
Permissions Required: Administrator, SYSTEM
Data Sources: Windows Registry, File monitoring, Process monitoring, Process command-line parameters
CAPEC ID: CAPEC-551
Contributors: Travis Smith, Tripwire; Matthew Demaske, Adaptforward
Version: 1.0

Procedure Examples

Name Description
APT19 An APT19 Port 22 malware variant registers itself as a service. [16]
APT32 APT32 modified Windows Services to ensure PowerShell scripts were loaded on the system. [14]
Bankshot Bankshot can terminate a specific process by its process id. [6] [7]
BBSRAT BBSRAT can modify service configurations. [11]
Empire Empire can utilize built-in modules to modify service binaries and restore them to their original state. [5]
GreyEnergy GreyEnergy chooses a service, drops a DLL file, and writes it to that serviceDLL Registry key. [8]
Honeybee Honeybee has batch files that modify the system service COMSysApp to load a malicious DLL. [15]
PlugX PlugX has a module to change service configurations as well as start, control, and delete services. [13]
PoisonIvy PoisonIvy creates a Registry entry modifying the Logical Disk Manager service to point to a malicious DLL dropped to disk. [10]
PowerSploit PowerSploit contains a collection of Privesc-PowerUp modules that can discover and replace/modify service binaries, paths, and configs. [3] [4]
TYPEFRAME TYPEFRAME can delete services from the victim’s machine. [12]
Volgmer Volgmer installs a copy of itself in a randomly selected service, then overwrites the ServiceDLL entry in the service's Registry entry. [9]

Mitigations

Mitigation Description
Audit Use auditing tools capable of detecting privilege and service abuse opportunities on systems within an enterprise and correct them.
User Account Management Limit privileges of user accounts and groups so that only authorized administrators can interact with service changes and service configurations.

Detection

Look for changes to service Registry entries that do not correlate with known software, patch cycles, etc. Changes to the binary path and the service startup type changed from manual or disabled to automatic, if it does not typically do so, may be suspicious. Tools such as Sysinternals Autoruns may also be used to detect system service changes that could be attempts at persistence. [17]

Service information is stored in the Registry at HKLM\SYSTEM\CurrentControlSet\Services.

Command-line invocation of tools capable of modifying services may be unusual, depending on how systems are typically used in a particular environment. Collect service utility execution and service binary path arguments used for analysis. Service binary paths may even be changed to execute cmd commands or scripts.

Look for abnormal process call trees from known services and for execution of other commands that could relate to Discovery or other adversary techniques. Services may also be modified through Windows system management tools such as Windows Management Instrumentation and PowerShell, so additional logging may need to be configured to gather the appropriate data.

References