Services are tasks that are generally supposed to execute certain logic in the background, similar to daemons on Linux. So, there is no surprise that malware authors commonly use them to achieve reliable persistence.
Services are controlled by the Service Control Manager (SCM) implemented in %SystemRoot%\System32\services.exe. All services have the corresponding HKLM\SYSTEM\CurrentControlSet\services\<service_name> registry key. It contains multiple values describing the service, including the following:
- ImagePath: A file path to the corresponding executable with optional arguments
- Type: The REG_DWORD value specifies the type of the service. Examples of supported values include the following:
-
0x00000001 (kernel): In this case, the logic is implemented in a driver (which will be covered in more detail in Chapter 6, Understanding Kernel-Mode Rootkits, which is dedicated to kernel-mode threats).
-
0x00000010 (own): The service runs in its own process.
-
0x00000020...
-