Unquoted service paths. are a common privilehe escalation attack.
You need to have Write permissions on a service’s main directory or subdirectories. It also works when you cannot replace the service files themselves.
The idea of this attack is that if the path is not quoted when it has spaces in itself, It will go left to right and append .exe after each space to see where the path ends and what are the arguments after it. It will check that on each space until it finally find the correct match - here’s an example of this behavior for path C:\Program Files\My Program\My Service\service.exe:
C:\Program.exe
C:\Program Files\My.exe
C:\Program Files\My Program\My.exe
C:\Program Files\My Program\My service\service.exe
To exploit this and subvert the original unquoted service call, we must create a malicious executable, place it in a directory that corresponds to one of the interpreted paths, and match its name to the interpreted filename. Then, once the service is started, our file gets executed with the same privileges that the service starts with. Often, this happens to be the LocalSystem account.
The naming of our malicious file depends on the name windows guesses in each of the paths (see above). So we could name it for example Program.exe, or My.exe.
You can find great commands to look for such services in Finding unquoted services.
Windows services - As a next step you can check if you can start and stop the service Start-Service,Stop-Service if not, you can try rebooting the target host or wait for someone to start it for you.
Then you use icacls to see if you can Write to any of those directories - the closer to root, the less chance.
Then you can input some executable with malicious code or an interactive shell - Windows add user C binary - compile it as .exe with the corresponding name and run the service.