Windows Privilege Escalation with Groups and Privileges

Contains the details of the topic Privilege Escalation/Windows/Groups and Privileges.

SeImpersonate & SeAssignPrimaryToken

These privileges can be used to impersonate a privileged account such as SYSTEM. Often these privileges are found in services such as Web, SQL, etc. Named pipes are used for local and remote Inter-Process communication. You have to create a named pipe and convince a privileged process to connect. After connecting, with SeImpersonatePrivilege you can impersonate that account and perform operations in its security context.

See Potatoesarrow-up-right.

!! Set -c <{clsid}> if necessary.

For Windows 10 and Server 2016/2019.

ex.

In meterpreter session

SeDebug

This privilege can be used to acquire sensitive information from system memory or elevate our privileges to SYSTEM.

Dump lsass

or with procdump.exearrow-up-right

Then extract hashes with mimikatzarrow-up-right or pypykatzarrow-up-right

Privileged Shell

With psgetsystemarrow-up-right

SeTakeOwnership

With this privilege, a user could take ownership of any file or object and make changes that could result in access to sensitive data, RCE, or DoS.

SeBackupPrivilege (Backup Operatorsarrow-up-right)

The SeBackupPrivilege allows us to traverse any folder and list the folder contents. This will let us copy a file from a folder, even if there is no access control entry (ACE) for us in the folder's access control list (ACL). However, we can't do this using the standard copy command. Instead, we need to programmatically copy the data, making sure to specify the FILE_FLAG_BACKUP_SEMANTICSarrow-up-right flag.

Read Sensitive Data

With SeBackupPrivilegearrow-up-right

Get ntds.dit from DC

Shadow copy of the drive with diskshadow.exearrow-up-right

Now we copy the ntds.dit file from drive E which, unlike the one in C, is not used by another process and therefore readable.

Or with robocopyarrow-up-right

Many Windows commands support passing a password as a parameter, and if process command line checking is enabled, this sensitive information will be captured. If you are part of the Event Log Readers group we can query Windows events from the command line using the wevtutilarrow-up-right utility and the PowerShell Get-WinEvent cmdlet looking for sensitive information.

In PowerShell

The DNS service is run with SYSTEM privileges. If you are part of the DnsAdmin group you can use the dnscmdarrow-up-right utility to load a custom DLL with zero verification. When DNS is restarted, the DLL will be executed. the following attack can be executed when DNS is run on a Domain Controller (which is very common)

DLL Attack

Create DLL

Or enter system(“<COMMAND>”); under fclose in kdns.carrow-up-right and compile the project to get the modified mimilib.dll. The payload is executed for each query to the DNS service and all DNS queries will be logged in C:\Windows\system32\kiwidns.log

Load DLL

Restart DNS

Or wait for reboot if you don't have permissions.

Cleaning Up

Must be taken from an elevated console with a local or domain admin account. Until our custom DLL is removed, we will not be able to properly start the DNS service again.

WPAD Attck

We need to disable the global query block list and creating a WPAD record. Every machine running WPAD with default settings will have its traffic proxied through our attack machine. We could use a tool such as Responderarrow-up-right or Inveigharrow-up-right to perform traffic spoofing, and attempt to capture password hashes and crack them offline or perform an SMBRelay attack.

Grants its members the SeLoadDriverPrivilege. If we issue the command whoami /priv, and don't see the SeLoadDriverPrivilege from an unelevated context, we will need to bypass UAC. Alternatively, from a GUI, we can open an administrative command shell.

Download the Capcom.sysarrow-up-right driver. Use EoPLoadDriverarrow-up-right to automate the process of enabling the privilege, creating the registry key, and executing NTLoadDriver to load the driver.

Use ExploitCapcomarrow-up-right to explit Capcom.sys

If we do not have GUI access to the target, we will have to modify the ExploitCapcom.cpp code before compiling, line 292, with msfvenom payload.

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

The Server Operators group allows members to administer Windows servers without needing assignment of Domain Admin privileges. It is a very highly privileged group that can log in locally to servers, including Domain Controllers. Membership of this group confers the powerful SeBackupPrivilege and SeRestorePrivilege privileges and the ability to control local services.

Querying Service

Modifying the Service Binary Path

Start the service

The service startup fails, as expected, but the command will be executed correctly.

Last updated

Was this helpful?