Weak ACLs (Service & Registry)

This section focuses on exploiting misconfigured ACLs for services and the different ways to exploit them.

We use the tool SharpUp https://github.com/GhostPack/SharpUp/arrow-up-right which runs the following checks:

              - AlwaysInstallElevated
              - CachedGPPPassword
              - DomainGPPPassword
              - HijackablePaths
              - McAfeeSitelistFiles
              - ModifiableScheduledTask
              - ModifiableServiceBinaries
              - ModifiableServiceRegistryKeys
              - ModifiableServices
              - ProcessDLLHijack
              - RegistryAutoLogons
              - RegistryAutoruns
              - TokenPrivileges
              - UnattendedInstallFiles
              - UnquotedServicePath

Below we details the most common attacks:

Modifiable Service Binaries

We run SharpUp

It seems we can modify the bin of a service. We check its permissions:

We found Everyone:(I)(F) which means we have full access.

We can now replace the bin by a malicious one and (re)start the service if we can to trigger it.

Weak Service Permissions

We check the service DACL with accesschk:

-q (omit banner), -u (suppress errors), -v (verbose), -c (specify name of a Windows service), and -w (show only objects that have write access).

We found we have full control over it:

This means we can change the service binary (here to a command that makes us admin):

We restart the service

Even if we see an error it worked and we can logout and log back in to get our privileged token.

circle-info

This method of privesc has a very well known CVE (CVE-2019-1322) that allowed any service account to elevate privileges to SYSTEM by exploiting the service Update Orchestrator Service (UsoSvc)arrow-up-right, which is responsible for downloading and installing operating system updates.

Unquoted Service Path

For this make sure you read the Service#Service Path section.

We can look for services for which the binary path isn't enclosed in quotes:

We check the service to confirm:

We confirm BINARY_PATH_NAME : C:\Program Files (x86)\System Explorer\service\SystemExplorerService64.exe isn't within quotes.

This means we could create malicious service bin to hijack the PATH:

  • C:\Program.exe

  • C:\Program Files (x86)\System.exe

Permissive Registry ACLs for Services

We can also look for weak services ACLs in the Windows Registry, using accesschk.

We can change the value of ImagePath to a bin/command of our choice:

Modifiable Registry Autorun Binary

We can list programs runned at startup with WMIC:

If we have write permissions to the registry for a given binary or can overwrite a binary listed we will be able to privesc the next time the user logs in.

Last updated