Service Binary Hijacking
This attack involves replacing the service binary with a malicious version and restart the service.
Enumerate Services
PowerShell cmdlet
Get-CimInstance -ClassName win32_service | Select Name,State,PathName | Where-Object {$_.State -like 'Running' -and $_.PathName -notlike "C:\Windows\system32*"}Registry
$servicios = Get-ItemProperty "registry::HKLM\System\CurrentControlSet\Services\*" | Where-Object {$_.imagepath -notmatch "system" -and $_.imagepath -ne $null } | Select-Object pschildname,imagepath ; foreach ($servicio in $servicios ) {Get-Service $servicio.PSChildName -ErrorAction SilentlyContinue | Out-Null ; if ($? -eq $true) {$privs = $true} else {$privs = $false} ; $Servicios_object = New-Object psobject -Property @{"Service" = $servicio.pschildname ; "Path" = $servicio.imagepath ; "Privileges" = $privs} ; $Servicios_object
}Enumerate Binary Permissions
icacls "<binary_path>"Mask
Permissions
Creating The Malicious Binary
Triggering the Execution
Manual restart
Automatic restart
Automated Process
References
Last updated