A Windows UAC (User Account Control) bypass implementation using COM (Component Object Model) elevation monikers. This project demonstrates how to leverage the ICMLuaUtil interface to execute processes with elevated privileges without triggering the standard UAC prompt.
- Overview
- How It Works
- Architecture
- Project Structure
- Building the Project
- Usage
- Technical Details
- Limitations
- License
This project implements a UAC bypass technique that exploits Windows COM elevation monikers. Instead of using traditional methods that trigger UAC prompts, this implementation uses the undocumented ICMLuaUtil COM interface to execute processes with administrator privileges.
- Silent Elevation: Executes processes with elevated privileges without user interaction
- COM-Based: Uses Windows COM elevation monikers for privilege escalation
- Clean Code: Well-structured, optimized, and readable C++ implementation
- RAII Pattern: Automatic resource management with smart guards
- Error Handling: Comprehensive error checking and validation
The bypass technique works by:
- COM Initialization: Initializes the COM library in apartment-threaded mode
- Moniker Creation: Constructs an elevation moniker string in the format:
Elevation:Administrator!new:{CLSID} - Object Resolution: Uses
CoGetObjectto resolve the moniker and obtain an elevated COM object - Interface Access: Retrieves the
ICMLuaUtilinterface from the elevated object - Process Execution: Calls
ShellExecmethod to launch the target executable with elevated privileges
The elevation moniker is a special COM moniker format that Windows recognizes:
Elevation:Administrator!new:{3E5FC7F9-9A51-4367-9063-A120244FBEC7}
This tells Windows to create an instance of the specified CLSID with administrator privileges, bypassing the standard UAC prompt.
BypassUAC/
│
├── BypassUAC/ # Main DLL project
│ ├── BypassUAC.h # Interface definitions and declarations
│ ├── BypassUAC.cpp # Core implementation
│ ├── BypassUAC2.cpp # Rundll32 entry point
│ ├── BypassUAC.def # DLL export definitions
│ ├── dllmain.cpp # DLL entry point
│ ├── stdafx.h/cpp # Precompiled headers
│ └── targetver.h # Windows version targeting
│
├── Test/ # Test application (optional)
│ └── Test.cpp # Test harness
│
└── BypassUAC.sln # Visual Studio solution file
Contains:
- Interface Definitions:
ICMLuaUtilCOM interface structure with virtual function table - Constants: CLSID and IID definitions for the CMSTPLUA component
- Function Declarations: Public API functions
Core implementation with:
CoCreateInstanceAsAdmin(): Creates COM objects with elevated privileges- Uses RAII pattern with
CoInitGuardfor automatic COM cleanup - Validates all parameters before use
- Constructs elevation moniker dynamically
- Uses RAII pattern with
CMLuaUtilBypassUAC(): Main bypass function- Validates input parameters
- Converts string CLSID/IID to binary format
- Creates elevated COM object
- Executes target process via
ShellExec
Rundll32 entry point that:
- Exports
BypassUACfunction for rundll32.exe invocation - Currently hardcoded to launch
cmd.exe(can be modified)
- Visual Studio 2022
- Windows SDK (included with Visual Studio)
- Windows 7 or later (for testing)
-
Open the Solution
# Open BypassUAC.sln in Visual Studio -
Build the Project
- Press
Ctrl+Shift+Bor use Build → Build Solution - The DLL will be generated in
BypassUAC/[Configuration]/[Platform]/
- Press
-
Verify Output
- Check for
BypassUAC2.dllin the output directory - Ensure no compilation errors or warnings
- Check for
The project uses:
- Runtime Library: Multi-threaded DLL (
/MDor/MDd) - Character Set: Unicode
- Platform Toolset: v140 or later
rundll32.exe BypassUAC2.dll,BypassUACThis will execute the hardcoded command (cmd.exe) with elevated privileges.
To use the bypass function in your own code:
#include "BypassUAC.h"
// Execute a program with elevated privileges
BOOL success = CMLuaUtilBypassUAC(L"C:\\Windows\\System32\\notepad.exe");
if (success)
{
// Process launched successfully with admin rights
}
else
{
// Bypass failed - check error codes
}Modify BypassUAC2.cpp to accept command-line arguments:
void CALLBACK BypassUAC(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int iCmdShow)
{
// Parse lpszCmdLine to get target executable
// Convert to wide string and call CMLuaUtilBypassUAC()
}The ICMLuaUtil interface is an undocumented Windows COM interface used internally by the Windows UAC system. Key methods:
ShellExec: Executes a process with elevated privilegesHRESULT ShellExec( LPCWSTR lpFile, // Path to executable LPCTSTR lpParameters, // Command-line parameters (optional) LPCTSTR lpDirectory, // Working directory (optional) ULONG fMask, // Flags (usually 0) ULONG nShow // Window show state (SW_SHOW, etc.) );
-
CLSID_CMSTPLUA:
{3E5FC7F9-9A51-4367-9063-A120244FBEC7}- Component Manager Shell TPLUA (Trusted Platform Local User Account)
-
IID_ICMLuaUtil:
{6EDD6D74-C007-4E75-B76A-E5740995E24C}- Interface identifier for ICMLuaUtil
The implementation includes several optimizations:
- RAII Pattern:
CoInitGuardautomatically manages COM initialization/cleanup - Parameter Validation: All inputs are validated before use
- Early Returns: Fail-fast error handling reduces nesting
- Memory Safety: Proper initialization and cleanup of all buffers
- Error Propagation: HRESULT values properly propagated and checked
class CoInitGuard
{
// Automatically initializes COM on construction
// Handles RPC_E_CHANGED_MODE gracefully
// Automatically uninitializes COM on destruction
};Benefits:
- Exception-safe resource management
- No memory leaks even on early returns
- Handles already-initialized COM gracefully
HRESULT BuildElevationMonikerName(
REFCLSID rclsid, // Input CLSID
LPWSTR monikerName, // Output buffer
size_t monikerLength // Buffer size
);This helper function:
- Validates input parameters
- Converts CLSID to string format
- Constructs the elevation moniker string
- Uses safe string functions (
StringCchPrintfW)
-
Windows Version: May not work on all Windows versions
- Tested on Windows 7/8/10/11
- Behavior may vary between versions
-
UAC Settings: Effectiveness depends on UAC configuration
- May not work if UAC is completely disabled
- May not work if UAC is set to "Always notify"
-
Process Integrity: The elevated process inherits the integrity level of the parent
-
COM Dependencies: Requires COM to be available and properly configured
This project is provided for educational purposes.
This project is licensed under the MIT License. For more information, see the LICENSE file.