Overview
Each Windows service has a registry key underHKLM\SYSTEM\CurrentControlSet\Services\. If you have write access to a service’s registry key, you can change its binary path, add parameters, or modify its configuration to execute arbitrary code as SYSTEM.
Find Writable Service Registry Keys
accesschk
KEY_ALL_ACCESS or KEY_SET_VALUE.
PowerShell
Modify ImagePath
If writable, change the service binary:Add Admin User via ImagePath
Service DLL
Some services load a DLL specified in the registry:ServiceDll key is writable:
AppendData Permission
If you haveAppendData but not SetValue:
Startup Type
Change service to auto-start:| Value | Meaning |
|---|---|
2 | Automatic |
3 | Manual |
4 | Disabled |
Other Interesting Registry Locations
Run Keys (Persistence)
Winlogon
AutoLogon
Quick Reference
| Target | Registry Path |
|---|---|
| Service binary | HKLM\...\Services\<Name>\ImagePath |
| Service DLL | HKLM\...\Services\<Name>\Parameters\ServiceDll |
| Startup type | HKLM\...\Services\<Name>\Start |
| Run keys | HKLM\...\CurrentVersion\Run |
| AutoLogon creds | HKLM\...\Winlogon\DefaultPassword |