Summery
Each Windows service has an associated binary file. These binary files are executed when the service is started or transitioned into a running state.
The basic idea of Binary hijacking attacks is that we find a service that runs with too broad permissions (like M or F in icacls) giving us the the ability to modify the rights over it. Then, we can swap the innocent binary for our, malicious one. After that, we can either restart the service or if it works on boot, we need to restart the host (SeShutdownPrivilege) or wait for someone to do that for us.
Some Windows theory:
There is this thing, called “Microsoft Management Console” which is a Window’s framework for managing all system settings.
Think of it as a toolbox which stores a bunch off tools, plugins called “snap-in”. Such snap-in are programs which you might already know like Event Viewer, Services, Group Policy etc. They all share the same format .msc - eventvwr.msc, services.msc, gpedit.msc.
Anyway, to access and view the services you can eaither do that by a GUI snap-in services.msc or using CLI commands like Get-Service or Get-CimInstance.
Here’s an exmaple of the Get-CimInstance command usage - Get-CimInstance -ClassName win32_service | Select Name,State,PathName. You can also add | Where-Object {$_.State -like 'Running'} to query for only running services.
To find potential serivece we can just look for any services that are not created in Windows directories like C:\xampp which makes it seem that someone created them by hand.
To verify if they are vulnerable to hijacking we can just go to them and run either icacls or Get-ACL.
As for malicious files, rather than using msfvenom you can try Windows reverse shell C binary, Windows add user C binary