Windows Service Binary Hijacking
Windows services run as SYSTEM or a high-privileged account by default. If the binary a service executes is writable by your user, replacing it with a malicious executable gives you code execution as SYSTEM on the next service restart. This is one of the most common privilege escalation vectors on Windows.
Prerequisites Check
Check current token privileges:
You need to be able to restart the service — either directly (SeShutdownPrivilege, sc stop/start) or wait for a reboot. Check if you can stop and start services:
Step 1 — Find Services with Writable Binaries
Using PowerUp:
This lists all services where the current user has write access to the binary.
Using accesschk:
Manual check — get the binary path and check permissions:
Look for (F) (full control), (M) (modify), or (W) (write) for your user or group.
Step 2 — Create the Malicious Binary
Option A — Add admin user (simple, no listener needed):
For an EXE, compile on attack box:
Option B — PowerShell payload (no compile needed):
Step 3 — Replace the Service Binary
Back up the original first:
Replace with your payload:
Step 4 — Restart the Service
If you cannot restart the service directly, check if you can reboot:
Step 5 — Verify Escalation
If you added a user:
If you used a reverse shell, catch it:
Step 6 — Restore Original Binary
After escalating, restore to avoid service failure:
Identifying Restart Triggers
If you cannot manually restart, find what triggers the service:
References
-
Sysinternals Service and file permission verification tool.
-
Get-ServiceFilePermission and service exploitation functions.
Was this helpful?
Your feedback helps improve this page.