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.
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 this 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.