Summery

SeLoadDriverPrivilege allows a user to load and unload device drivers, it is very often paired with the membership in the Print Operators group.
If abused, it can potentially lead to privilege escalation to NT AUTHORITY\SYSTEM, depending on the Windows version, driver-loading restrictions, and available vulnerable drivers.

Exploitation

It’s well known that the driver Capcom.sys contains functionality to allow any user to execute shellcode with SYSTEM privileges.

Manual method

You can use SeLoadDriverPrivilege to load this vulnerable driver and escalate privileges. You can use this PoC, it enables the privilege as well as loads the driver.

Download it locally and edit it, pasting over the includes below.

#include <windows.h>
#include <assert.h>
#include <winternl.h>
#include <sddl.h>
#include <stdio.h>
#include "tchar.h"

Next, from a Visual Studio 2019 Developer Command Prompt, compile it using cl.exe - cl /DUNICODE /D_UNICODE EnableSeLoadDriverPrivilege.cpp.
Then, download the Capcom.sys driver from here, and save it to C:\temp. Issue the commands below to add a reference to this driver under the HKEY_CURRENT_USER tree:

  • reg add HKCU\System\CurrentControlSet\CAPCOM /v ImagePath /t REG_SZ /d "\??\C:\Tools\Capcom.sys"
  • reg add HKCU\System\CurrentControlSet\CAPCOM /v Type /t REG_DWORD /d 1

Use Nirsoft’s DriverView.exe, to verify that the Capcom.sys driver is not yet loaded - .\DriverView.exe /stext drivers.txt and cat drivers.txt | Select-String -pattern Capcom.
Run the EnableSeLoadDriverPrivilege.exe binary - EnableSeLoadDriverPrivilege.exe.
Next, verify that the Capcom driver is now listed - .\DriverView.exe /stext drivers.txt and cat drivers.txt | Select-String -pattern Capcom.

Use ExploitCapcom Tool to escalate privileges after compiling with it Visual Studio. If we do not have GUI access to the target, we will have to modify the ExploitCapcom.cpp code before compiling. Here we can edit line 292 and replace "C:\\Windows\\system32\\cmd.exe" with, say, a reverse shell binary created with msfvenom, for example: c:\ProgramData\revshell.exe. If a reverse shell connection is blocked for some reason, we can try a bind shell or exec/add user payload.

All of this, should lunch a shell with the SYSTEM privileges.

Automated method

  1. If not present on the target host, download the Capcom.sys driver from here, and save it to C:\temp.
  2. Use EoPLoadDriver to automate the process of enabling the privilege, creating the registry key, and executing NTLoadDriver to load the driver. To do this, run it with EoPLoadDriver.exe System\CurrentControlSet\Capcom c:\temp\Capcom.sys.
  3. Then run ExploitCapcom.exe to pop a SYSTEM shell or run our custom binary

References

Further reads: Print Operators