Bypassing UAC

circle-info

Read more about UAC on the dedicated section in Windows Security.

There is no command-line version of the UAC GUI consent prompt, so if we need to bypass the UAC in a CLI environment we will have to proceed as follow:

0 - Situation

We have shell access to a windows target but are restricted by UAC which we must bypass.

1 - Check UAC status & level

Confirm UAC is enabled:

C:\hacker> REG QUERY HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ /v EnableLUA

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System
    EnableLUA    REG_DWORD    0x1

0x1 for enabled and 0x0 for disabled.

Check UAC level:

C:\htb> REG QUERY HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ /v ConsentPromptBehaviorAdmin

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System
    ConsentPromptBehaviorAdmin    REG_DWORD    0x5

From level 1 (0x1) to level 5 (0x5)

2- Check Windows Build

UAC bypasses leverage flaws or unintended functionality in different Windows builds.

Build version 14393, which on thisarrow-up-right page corresponds to Windows release 1607.

3 - Find exploit on UACME

The UACMEarrow-up-right project maintains a list of UAC bypasses. We can find older ones (fixed by Windows) here => https://github.com/hfiref0x/UACME/tree/v3.2.xarrow-up-right

We will use method 54 for this example:

circle-info

This technique targets the 32-bit version of the auto-elevating binary SystemPropertiesAdvanced.exe. There are many trusted binaries that Windows will allow to auto-elevate without the need for a UAC consent prompt.

According to thisarrow-up-right blog post, the 32-bit version of SystemPropertiesAdvanced.exe attempts to load the non-existent DLL srrstr.dll, which is used by System Restore functionality.

4 - Review the PATH

As mentionned in the blog post, SystemPropertiesAdvanced.exe will attempt to load a non-existing DLL called srrstr.dll from C:\Users\<USER>\AppData\Local\Microsoft\WindowsApps\

Non-privilege users can write to this directory because it's used to install Microsoft apps.

If this dir is in our path (which it should) we can hijack the DLL (check section on DLIB if needed)

5 - Generating malicious DLL

Using msfvenom we will spawn a reverse shell.

And transfer it to the target.

6 - Verify the DLL

If we execute the DLL itself, we should catch a shell, still restricted by UAC.

7 - Getting unrestricted shell

We can now execute SystemPropertiesAdvanced.exe which will load the dll which should send us an unrestricted shell this time (sinc SystemPropertiesAdvanced.exe can auto-elevate):

We should catch a shell, of course still under Sarah but without UAC which we can confirm:

We have significantly more privileges than with a restricted shell.

Last updated