🖨️ SeLoadDriverPrivilege
Print Operators is another highly privileged group, which grants its members the SeLoadDriverPrivilege
, rights to manage, create, share, and delete printers connected to a Domain Controller, as well as the ability to log on locally to a Domain Controller and shut it down.
Note
Note: Since Windows 10 Version 1803, the "SeLoadDriverPrivilege" is not exploitable, as it is no longer possible to include references to registry keys under "HKEY_CURRENT_USER".
Alternative #1 Having access to GUI
Step 1. Check group memberships and privileges
Check our group membershipts:
We see Print Operators, which usually has the SeLoadDriverPrivilege. However when we check our permissions is not listed:
Output:
If we issue the command whoami /priv
, and don't see the SeLoadDriverPrivilege
from an unelevated context, we will need to bypass UAC.
- You can bypass it with UACMe repo features or any similar code approach.
- You can also bypass it from user interface. Open a powershell with administrator permissions.
Step 2. If disabled, enabled SeLoadDriverPrivilege
1. Now, next troubleshooting is that the SeLoadDriverPrivilege
may be Disabled. To enable it, we will need the following:
- The executable
EnableSeLoadDriverPrivilege.exe
that we can compile using the forked repo https://github.com/amandaguglieri/enabling-privileges. - The file Capcom.sys. I've forked it to https://github.com/amandaguglieri/Capcom-Rootkit/blob/master/Driver/Capcom.sys
- The DriverView.exe utility, officially available at https://www.nirsoft.net/utils/driverview.html and in my case, also uploaded to my repo.
2. Compiling EnableSeLoadDriverPrivilege.exe
. I've set up Visual Studio 2022 in a Windows Virtual Machine.
3. Download the other required files (Capcom.sys
and DriverView.exe
) to the folder from where you want to serve the payload to the target host.
4. Serve the files to the target host:
5. Download the files to the target host:
6. Save the Capcom.sys
driver from here, and save it to C:\test
. If test does not exist, create it:
7. Issue the commands below to add a reference to this driver under our HKEY_CURRENT_USER tree.
8. Using Nirsoft's DriverView.exe, we can verify that the Capcom.sys driver is not loaded.
9. Run the EnableSeLoadDriverPrivilege.exe
binary.
The Output should be something like this:
Step 3. Use ExploitCapcom Tool to Escalate Privileges
1. Next, verify that the Capcom driver is now listed.
The output should be something like this:
2. Now we will use the ExploitCapcom tool for escalating privileges. I've cloned it into a windows virtual machine with Visual Studio 2022 installed (in my kali machine)
- Open Visual Studio 2022. Clone the project. Once cloned, right click and select "Compile". It's important to change the architecture to x64 in order to compile.
- Executable generated under "C:\Users\vboxuser\source\repos\ExploitCapcom\ExploitCapcom\x64\Release"
3. Upload the ExploitCapcom.exe
file to the target machine:
4. Run the binary:
This launches a shell with SYSTEM privileges.
Alternative #2 With no access to GUI
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
.
1. In our attacking machine, open the Visual Studio from the windows virtualbox machine and modify these lines:
Use these ones instead:
Now compile the code and obtain the ExploitCapcom.exe
file that will open a revshell.exe.
Generate the revshell.exe with msfvenom in your attacking machine:
Copy revshell.exe
and ExploitCapcom.exe
files to the host machine.
We would set up a listener based on the msfvenom
payload we generated and hopefully receive a reverse shell connection back when executing ExploitCapcom.exe
. If a reverse shell connection is blocked for some reason, we can try a bind shell or exec/add user payload.
Alternative #3 Automating the Steps
We can use a tool such as EoPLoadDriver to automate the process of enabling the privilege, creating the registry key, and executing NTLoadDriver
to load the driver. To do this, we would run the following:
We would then run ExploitCapcom.exe
to pop a SYSTEM shell or run our custom binary.
Clean-up
We can cover our tracks a bit by deleting the registry key added earlier.