Leveraging Windows Services
Service Binary Hijacking
Initial Checks:
# Check for Installed windows Service.
# PowerShell Command
# Check for abnormal installation path
Get-CimInstance -ClassName win32_service | Select Name,State,PathName | Where-Object {$_.State -like 'Running'}
# Skipping default system32 folder.
Get-CimInstance -ClassName win32_service | Select Name,State,PathName | Where-Object {$_.State -like 'Running' -and $_.PathName -notmatch "WINDOWS\\system32"}
# checking all processes running or stoped both. Skipping default system32 folder. also
# Useful in Unquoted service path attact.
Get-CimInstance -ClassName win32_service | Select Name,State,PathName, StartMode | Where-Object {$_.PathName -notmatch "WINDOWS\\system32"}
# Check the permission of current user to that path.
icacls <PATH OF THE FOLDER>
# Check the restart permission of the binary
Get-CimInstance -ClassName win32_service | Select Name, StartMode | Where-Object {$_.Name -like '<NameOfTheService>'}
# If not then check the restart permission.
# Check for restart permission
whoami /priv # See the SeShutDownPrivilege. It must be enabled.
Code for making User and creating executable file
Compiling the code
Directly Getting shell
Using automated tools
DLL Hijacking
Common Technique used during DLL Hijacking
Initial checks
Creating User using DLL Hijacking
Example attempt of DLL Hijacking



Example of DLL Hijacking and then getting shell.




Getting shell using DLL Hijacking
Example from Module exercise:
Unquoted Service Paths
Initial Check
Adding user by using exe file
Using Getting Reverse shell using .exe file
Unoquoted service automated tool
Last updated