Abusing Unquoted Paths
Each Windows Service maps to an executable file that is run when the service is started. If the path to this file contains one or more spaces, we may be able to take advantage and escalate privileges.
Last updated
Each Windows Service maps to an executable file that is run when the service is started. If the path to this file contains one or more spaces, we may be able to take advantage and escalate privileges.
Last updated
When a Windows service is started, Win32 API is called. lpApplicationName
is the name of the executable and optionally the full path. If the provided string contains spaces and is not inclosed in quotation marks, it can be interpreted in various ways.
Let's say we have the lpApplicationName of C:\Program Files\My Program\My service\service.exe
We can try to abuse this by adding .exe
to the end of each space.
We create a malicious binary and place it in each directory shown above.
We start by enumerating services and find the ones that have spaces in their filepaths.
Once we've enumerated the installed service and found one of interest, we can view the permissions. We can use tools like: icacls Windows utility or the PowerShell Cmdlet Get-ACL
F
Full access
M
Modify access
RX
Read and execute access
R
Read-only access
W
Write-only access
We need to make sure we have permissions in each path that we want to add our malicios binary: