githubEdit

Windows Privileges

Windows Privileges

Privilege check command: whoami /priv

We can enable all privileges if possible using this script:

https://raw.githubusercontent.com/fashionproof/EnableAllTokenPrivs/master/EnableAllTokenPrivs.ps1

Examples of dangerous privileges:

SeRestore

Tool: https://github.com/xct/SeRestoreAbuse

1: Transfer files on victim system, then:

SeRestoreAbuse.exe "cmd /c C:\users\user\reverse.exe"

OR add our user to local administrators group, then connect with psexec

SeRestoreAbuse.exe "cmd /c net localgroup administrators user /add"

Manual Exploitation

1: Rename utilman.exe to utilman.old

ren C:\Windows\System32\utilman.exe utilman.old

2: Rename cmd.exe to utilman.exe

3: Connect via RDP, then press Win+U keys to run cmd.exe as SYSTEM

SeBackup

1: Backup SAM and SYSTEM hashes

2: Create SMB Server on attacking machine

3: Copy backups to share folder

4: Retrieve hashes

OR

5: Pass-The-Hash Attack (PtH)

TIP: We can also use evil-winrm for PtH attacks.

Mimikatz

Alternate Method to transfer the Hives: reg.py remotely on Linux

Alternate Method: SeBackupPrivilegeUtils https://github.com/giuliano108/SeBackupPrivilege

Usage:

Alternate Method: Robocopy

Alternate Method: Volume Shadow Copy

1) On our machine, create a .dsh file that will automate the process.

2) File contents

3) Convert the file to a Windows-compatible format

4) Upload the file, then run it with diskshadow

5) Transfer the ntds.dit file from Z: to Temp directory

6) Extract the SYSTEM hive, then download it for offline hash dumping with impacket

7) Dump hashes

SeTakeOwnership

Essentially, we can take ownership of a service running as SYSTEM and elevate privileges.

Example: Utilman.exe

1:

2:

3:

4: Trigger utilman : Lock screen, click ease of access

SeImpersonate/SeAssignPrimaryToken

A lot of potato exploits work with these privileges, so in our example we will talk about RoguePotato.

RogueWinRM.exe exploit

1: Start listener

Tool: PrintSpoofer

Interactive shell on same session

Run reverse shell

Tool: Invoke-BadPotato

Download the script on our target machine

Run the script to get system

Tool: RottenPotato

SeDebug Privilege

Tools: Meterpreter, https://github.com/decoder-it/psgetsystem

Steps:

1)

2) Download and execute Meterpreter on target machine to connect to us

3)

4)

5) VOILA!

Alternate method: Powershell

Use powershell to duplicate the lsass.exe token (example)

Alternate Method for SeImpersonate and SeDebug:

https://github.com/0xCyberY/Exploit-SeImpersonatePrivilege-and-SeDebugPrivilege

SeCreatePagefile

This privilege allows a user to create and modify the paging file. Exploit this privilege by gaining access to sensitive information by creating or modifying the hibernation file to analyze offline.

Steps:

1) Enable hibernation

2) After a reboot, the hiberfil.sys file will be created in the root of the system drive. Use volatility to analyze the hiberfil.sys file.

Identify the profile and image type

List registry hives

Dump hashes from the registry

SeLoadDriver

This privilege allows users to load and unload device drivers.

Steps

1) Load a vulnerable driver

2) Start the vulnerable driver

SeRelabel

This privilege allows users to modify the integrity labels of system files.

1) Change the integrity label of a file

SeTrustedCredManAccess

Access stored credentials in Credential Manager to obtain sensitive information

Access Credential Manager in Powershell

SeManageVolumeAbuse

With this privilege, an attacker can gain full control over C:\ by crafting and placing a malicious .dll file in C:\Windows\System32\

Link: https://github.com/emmasolis1/OSCP/blob/main/04.privilege_escalation/windows/SeManageVolumeExploit.exe

1) Check for permission

2) Download and run the executable on target

3) Create the malicious DLL

4) Transfer the DLL to the victim in C:\Windows\System32\wbem\tzres.dll

5) Setup listener

6) Run systeminfo to trigger the DLL

Last updated