Coder Social home page Coder Social logo

yet-zio / wusabypassuac Goto Github PK

View Code? Open in Web Editor NEW
29.0 2.0 6.0 1.12 MB

UAC bypass abusing WinSxS in "wusa.exe". Referred from and similar to: https://github.com/L3cr0f/DccwBypassUAC , Kudos to L3cr0f and FuzzySecurity for their efforts

C 1.53% C++ 97.89% CMake 0.58%
uac-bypass windows-10 windows exploit dll-hijacking winsxs comctl32 malware bypass-uac bypass-defender

wusabypassuac's Introduction

WusaBypassUAC

This exploit is similar to how https://github.com/L3cr0f/DccwBypassUAC works as it abuses the way "WinSxS" is managed by "dccw.exe" by means of a derivative Leo's Davidson "Bypass UAC" method so as to obtain an administrator shell without prompting for consent. Here we abuse that method in Windows Update Standalone Installer(wusa.exe) by its call to comctl32.dll

  • Tested on Windows 10 20H2, hopefully will work on Windows 8.1 as well.
  • Supports "x86" and "x64" architectures.

DISCLAIMER

I do not take any responsibility if someone uses the exploit provided in this repository to perform illegal activities.

1. Process Vulnerability

1.1. Checking Manifest

"Windows Update Standalone Installer" or "wusa.exe" is one of the processes which have autoElevate attribute as true in its manifest. This is why it can run as Administrator without UAC Prompts.

This is proven by Sigcheck:

1.2. Capturing execution by Process Monitor

By filtering execution of wusa.exe caught by Procmon, we found that wusa.exe tried to check by IRP_MJ_CREATE if location wusa.exe.Local is available in C:\Windows\System32, whereas in 32bit it will be checked under C:\Windows\SysWOW64\ as shown below:

However, wusa.exe is trying to look for a DLL called comctl32.dll similar to how dccw.exe looks for GdiPlus.dll. Since it doesn't contain the DLL, wusa.exe looks under WinSxS for a folder with the structure:

[arch]_microsoft.windows.common-controls_[sequencial_code]_[windows_version]_none_[sequencial_number]

However, there are two folders from where comctl32.dll can be loaded by wusa.exe.

This can be exploited by a 32bit process when it copies a Malicious DLL to one of these locations and invokes wusa.exe which will launch its target program and children with high integrity.

1.3. Vulnerability Verification

Since we know that a mode of vulnerability is possible, we can verify it by creating the "wusa.exe.Local" folder and under that the first WinSxS folder wusa.exe loads comctl32.dll from. On doing that and on capturing the execution of wusa.exe in Procmon, we get the following results:

As we expected, wusa.exe throws an error as it cannot find comctl32.dll under any of those folders we created. This proves that the vulnerability exists in wusa.exe.

2. Developing an exploit

On developing one, we followed the same steps as Exploit-Development till Interoperability.

2.1. The Malicious DLL

Just like dccw.exe, wusa.exe depends on some functions from comctl32.dll that we need to create or forward to the original DLL. Without implementing or forwarding the execution of these functions to the original DLL, wusa.exe will fail to launch with an error that it can't find those functions in the DLL.

2.1.1. Porting Exports To Original DLL

Ofcourse we can use the tool ExportsToC++ to port all exports from comctl32.dll to C++ by pragma, this resolves the issue of defining them.

The reason we are using "C:\Windows\System32" is because this path does not change in Windows unlike the WinSxS folders.

2.1.2. Checking Imports

All available functions are resolved and saved as a cpp source. However, we only need to forward the functions wusa.exe needs, not all from comctl32.dll. To check which all functions are imported by wusa.exe, we can use the MSVC tool called DUMPBIN which lists out several information about a binary file. We can use the following command to list out the imports from wusa.exe:

dumpbin.exe /IMPORTS C:\Windows\System32\wusa.exe

DUMPBIN shows the following imports of wusa.exe from comctl32.dll:

2.1.3 Passing by Ordinal

By this, we can figure out that wusa.exe only imports 2 functions from comctl32.dll and that we have to provide exports for those functions only.

However, one of the functions it imports are by ordinal 344 and not by its name. ExportsToC++ only generates exports by names and some with [NONAME].

But this can easily be dealt with, by the following export:
#pragma comment (linker, "/export:#344=c:/windows/system32/comctl32.#344,@344,NONAME")

2.2. Avoiding Detection by Antimalware and Users

This process of copying the malicious DLL, doing other functions leaves a trace to the system and even the user may come upon what we are doing if something goes wrong. For this reason, all the temporary files created during the process are removed after the exploit is successful.

3. Final Execution

After the exploit is successful, we can execute any malicious code, open programs or whatever written within our malicious DLL as Administrator without UAC Prompts.

4. Requirements

To get successful execution of the exploit the targeted machine must comply the following requirements:

  • It must be a Windows 8 or 10, no matter what build version.
  • The UAC settings must not be set to "Always notify".
  • The compromised user must belong to the "Administrators group".

5. Sources

Most of the source in this repo is modified from https://github.com/L3cr0f/DccwBypassUAC as its a similar exploit. However, we provide CMakeLists.txt as we compiled it under CLion.

6. Demo

Following shows executing the compiled exploit with command line in a x64bit Windows VM:

7. About UAC

User Access Control (UAC) is a technology introduced with Windows Vista that provides a method of separating standard user privileges and tasks from those that require Administrator access. If a Standard User is using the system and attempts to perform an action for which the user has no authorization, a prompt from Windows appears and asks the Administrator account’s password. If an Administrator is using the system and attempts to do the same task, there is only a warning prompt. That prompt is known as a "Consent Prompt" because the administrator is only asked to agree to the action before proceeding. A weakness that would allow to bypass the "Consent Prompt" is not considered a security vulnerability, since that is not considered a security boundary.

However, Microsoft also states that "User Account Control (UAC) is a fundamental component of Microsoft's overall security vision".

8. Conclusion

This was just a source on how one could use WinSxS folders to bypass UAC by DLL-hijacking. However, wusa.exe and dccw.exe are not the only programs with such issue. Most of the autoElevated programs are found to have this vulnerability.

wusabypassuac's People

Contributors

yet-zio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

wusabypassuac's Issues

error compiling the comctl132.dll

hey,

need help to compile the comctl132.dll .
i open the project in visual studio 2019 and try to compile i get error ( target missing executable)

help ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.