Advanced Privilege Escalation in Active Directory: Stacking The Deck
what if we don't yet have local admin rights on any hosts in the domain?
There are several other ways we can move around a Windows domain:
Remote Desktop Protocol
(RDP
) - is a remote access/management protocol that gives us GUI access to a target hostPowerShell Remoting - also referred to as PSRemoting or Windows Remote Management (WinRM) access, is a remote access protocol that allows us to run commands or enter an interactive command-line session on a remote host using PowerShell
MSSQL Server
- an account with sysadmin privileges on an SQL Server instance can log into the instance remotely and execute queries against the database. This access can be used to run operating system commands in the context of the SQL Server service account through various methods
We can enumerate this access in various ways. The easiest, once again, is via BloodHound, as the following edges exist to show us what types of remote access privileges a given user has:
We can also enumerate these privileges using tools such as PowerView and even built-in tools.
Remote Desktop
Sometimes, we will obtain a foothold with a user that does not have local admin rights anywhere, but does have the rights to RDP into one or more machines.
This access could be extremely useful to us as we could use the host position to:
Launch further attacks
We may be able to escalate privileges and obtain credentials for a higher privileged user
We may be able to pillage the host for sensitive data or credentials
Enumerating the Remote Desktop Users Group (PowerView)
Using PowerView, we could use the Get-NetLocalGroupMember function to begin enumerating members of the Remote Desktop Users
group on a given host
Typically the first thing to check after importing BloodHound data is:
Does the Domain Users group have local admin rights or execution rights (such as RDP or WinRM) over one or more hosts?
Checking the Domain Users Group's Local Admin & Execution Rights using BloodHound
If we gain control over a user through an attack such as LLMNR/NBT-NS Response Spoofing or Kerberoasting, we can search for the username in BloodHound to check what type of remote access rights they have either directly or inherited via group membership under Execution Rights
on the Node Info
tab.
Checking Remote Access Rights using BloodHound
We could also check the Analysis
tab and run the pre-built queries Find Workstations where Domain Users can RDP
or Find Servers where Domain Users can RDP
.
There are other ways to enumerate this information, but BloodHound is a powerful tool that can help us narrow down these types of access rights quickly and accurately, which is hugely beneficial to us as penetration testers under time constraints for the assessment period.
To test this access, we can either use a tool such as xfreerdp
or Remmina
from our VM or the Pwnbox or mstsc.exe
if attacking from a Windows host.
WinRM
Like RDP, we may find that either a specific user or an entire group has WinRM access to one or more hosts.
We can again use the PowerView function Get-NetLocalGroupMember
to the Remote Management Users
group.
This group has existed since the days of Windows 8/Windows Server 2012 to enable WinRM access without granting local admin rights.
Enumerating the Remote Management Users Group
We can also utilize this custom Cypher query
in BloodHound to hunt for users with this type of access. This can be done by pasting the query into the Raw Query
box at the bottom of the screen and hitting enter.
We could also add this as a custom query to our BloodHound installation, so it's always available to us.
Adding the Cypher Query as a Custom Query in BloodHound
Establishing WinRM Session from Windows
From our Linux attack host, we can use the tool evil-winrm to connect.
Installing Evil-WinRM
Connecting to a Target with Evil-WinRM and Valid Credentials
From here, we could dig around to plan our next move.
SQL Server Admin
We may obtain credentials for an account with this access via Kerberoasting (common) or others such as LLMNR/NBT-NS Response Spoofing or password spraying. Another way that you may find SQL server credentials is using the tool Snaffler to find web.config or other types of configuration files that contain SQL server connection strings.
BloodHound, once again, is a great bet for finding this type of access via the SQLAdmin
edge. We can check for SQL Admin Rights
in the Node Info
tab for a given user or use this custom Cypher query to search:
We can use our ACL rights to authenticate with the wley
user, change the password for the damundsen
user and then authenticate with the target using a tool such as PowerUpSQL
, which has a handy command cheat sheet.
Enumerating MSSQL Instances with PowerUpSQL
We can also authenticate from our Linux attack host using mssqlclient.py from the Impacket toolkit.
Running mssqlclient.py Against the Target
We could then choose enable_xp_cmdshell
to enable the xp_cmdshell stored procedure which allows for one to execute operating system commands via the database if the account in question has the proper access rights.
Finally, we can run commands in the format xp_cmdshell <command>
.
Here we can enumerate the rights that our user has on the system and see that we have SeImpersonatePrivilege, which can be leveraged in combination with a tool such as JuicyPotato, PrintSpoofer, or RoguePotato to escalate to SYSTEM
level privileges, depending on the target host, and use this access to continue toward our goal.
Enumerating our Rights on the System using xp_cmdshell
The following section will address a common issue we often run into when using WinRM to connect to hosts in the network.
Kerberos "Double Hop" Problem
There's an issue known as the "Double Hop" problem that arises when an attacker attempts to use Kerberos authentication across two (or more) hops.
Let's say we have three hosts: Attack host
--> DEV01
--> DC01
. Our Attack Host is a Parrot box within the corporate network but not joined to the domain. We obtain a set of credentials for a domain user and find that they are part of the Remote Management Users
group on DEV01. We want to use PowerView
to enumerate the domain, which requires communication with the Domain Controller, DC01.
When we connect to DEV01
using a tool such as evil-winrm
, we connect with network authentication, so our credentials are not stored in memory and, therefore, will not be present on the system to authenticate to other resources on behalf of our user. When we load a tool such as PowerView
and attempt to query Active Directory, Kerberos has no way of telling the DC that our user can access resources in the domain.
This happens because the user's Kerberos TGT (Ticket Granting Ticket) ticket is not sent to the remote session; therefore, the user has no way to prove their identity, and commands will no longer be run in this user's context.
In other words, when authenticating to the target host, the user's ticket-granting service (TGS) ticket is sent to the remote service, which allows command execution, but the user's TGT ticket is not sent. When the user attempts to access subsequent resources in the domain, their TGT will not be present in the request, so the remote service will have no way to prove that the authentication attempt is valid, and we will be denied access to the remote service.
If unconstrained delegation is enabled on a server, it is likely we won't face the "Double Hop" problem.
Workarounds
A few workarounds for the double-hop issue are covered in this post. We can use a "nested" Invoke-Command
to send credentials (after creating a PSCredential object) with every request, so if we try to authenticate from our attack host to host A and run commands on host B, we are permitted.
Workaround #1: PSCredential Object (evil-winrm)
We can also connect to the remote host via host A and set up a PSCredential object to pass our credentials again. Let's see that in action.
If we check with klist
, we see that we only have a cached Kerberos ticket for our current server.
So now, let's set up a PSCredential object and try again. First, we set up our authentication.
Now we can try to query the SPN accounts using PowerView and are successful because we passed our credentials along with the command.
If we try again without specifying the -credential
flag, we once again get an error message.
Workaround #2: Register PSSession Configuration
We've seen what we can do to overcome this problem when using a tool such as evil-winrm
to connect to a host via WinRM. What if we're on a domain-joined host and can connect remotely to another using WinRM? Or we are working from a Windows attack host and connect to our target via WinRM using the Enter-PSSession cmdlet? Here we have another option to change our setup to be able to interact directly with the DC or other hosts/resources without having to set up a PSCredential object and include credentials along with every command (which may not be an option with some tools).
Let's start by first establishing a WinRM session on the remote host.
If we check for cached tickets using klist
, we'll see that the same problem exists.
One trick we can use here is registering a new session configuration using the Register-PSSessionConfiguration cmdlet.
Once this is done, we need to restart the WinRM service by typing Restart-Service WinRM
in our current PSSession. This will kick us out, so we'll start a new PSSession using the named registered session we set up previously.
We can now run tools such as PowerView without having to create a new PSCredential object.
Note: We cannot use Register-PSSessionConfiguration
from an evil-winrm shell because we won't be able to get the credentials popup. Furthermore, if we try to run this by first setting up a PSCredential object and then attempting to run the command by passing credentials like -RunAsCredential $Cred
, we will get an error because we can only use RunAs
from an elevated PowerShell terminal. Therefore, this method will not work via an evil-winrm session as it requires GUI access and a proper PowerShell console.
Bleeding Edge Vulnerabilities
When it comes to patch management and cycles, many organizations are not quick to roll out patches through their networks. Because of this, we may be able to achieve a quick win either for initial access or domain privilege escalation using a very recent tactic.
NoPac (SamAccountName Spoofing)
A great example of an emerging threat is the Sam_The_Admin vulnerability, also called noPac
or referred to as SamAccountName Spoofing
released at the end of 2021. (CVEs 2021-42278 and 2021-42287)
42278
is a bypass vulnerability with the Security Account Manager (SAM).
42287
is a vulnerability within the Kerberos Privilege Attribute Certificate (PAC) in ADDS.
Explained here: https://www.secureworks.com/blog/nopac-a-tale-of-two-vulnerabilities-that-could-end-in-ransomware
We can use this tool to perform this attack.
NoPac uses many tools in Impacket, ensure Impacket is installed and the noPac exploit repo is cloned to our attack host if needed.
Scanning for NoPac
There are many different ways to use NoPac to further our access. One way is to obtain a shell with SYSTEM level privileges. We can do this by running noPac.py with the syntax below to impersonate the built-in administrator account and drop into a semi-interactive shell session on the target Domain Controller. This could be "noisy" or may be blocked by AV or EDR.
We will notice that a semi-interactive shell session
is established with the target using smbexec.py. Keep in mind with smbexec shells we will need to use exact paths instead of navigating the directory structure using cd
.
We could then use the ccache file to perform a pass-the-ticket and perform further attacks such as DCSync. We can also use the tool with the -dump
flag to perform a DCSync using secretsdump.py. This method would still create a ccache file on disk, which we would want to be aware of and clean up.
Windows Defender & SMBEXEC.py Considerations
If Windows Defender (or another AV or EDR product) is enabled on a target, our shell session may be established, but issuing any commands will likely fail. The first thing smbexec.py does is create a service called BTOBTO
. Another service called BTOBO
is created, and any command we type is sent to the target over SMB inside a .bat file called execute.bat
. With each new command we type, a new batch script is created and echoed to a temporary file that executes said script and deletes it from the system. Let's look at a Windows Defender log to see what behavior was considered malicious.
If opsec or being "quiet" is a consideration during an assessment, we would most likely want to avoid a tool like smbexec.py.
PrintNightmare
PrintNightmare
is the nickname given to two vulnerabilities (CVE-2021-34527 and CVE-2021-1675) found in the Print Spooler service that runs on all Windows operating systems.
Before conducting this attack, we must retrieve the exploit we will use. In this case, we will be using cube0x0's exploit. We can use Git to clone it to our attack host:
Cloning the Exploit
For this exploit to work successfully, we will need to use cube0x0's version of Impacket. We may need to uninstall the version of Impacket on our attack host and install cube0x0's
Install cube0x0's Version of Impacket
We can use rpcdump.py
to see if Print System Asynchronous Protocol
and Print System Remote Protocol
are exposed on the target.
Enumerating for MS-RPRN
Output:
After confirming this, we can proceed with attempting to use the exploit. We can begin by crafting a DLL payload using msfvenom
.
Generating a DLL Payload
We will then host this payload in an SMB share we create on our attack host using smbserver.py
.
Creating a Share with smbserver.py
Once the share is created and hosting our payload, we can use MSF to configure & start a multi handler responsible for catching the reverse shell that gets executed on the target.
Configuring & Starting MSF multi/handler
Running the Exploit
Notice how at the end of the command, we include the path to the share hosting our payload (\\<ip address of attack host>\ShareName\nameofpayload.dll
). If all goes well after running the exploit, the target will access the share and execute the payload. The payload will then call back to our multi handler giving us an elevated SYSTEM shell.
PetitPotam (MS-EFSRPC)
PetitPotam (CVE-2021-36942) is an LSA spoofing vulnerability that was patched in August of 2021.
This blog post goes into more detail on NTLM relaying to AD CS and the PetitPotam attack.
In the attack, an authentication request from the targeted Domain Controller is relayed to the Certificate Authority (CA) host's Web Enrollment page and makes a Certificate Signing Request (CSR) for a new digital certificate. This certificate can then be used with a tool such as Rubeus
or gettgtpkinit.py
from PKINITtools to request a TGT for the Domain Controller, which can then be used to achieve domain compromise via a DCSync attack.
Let's walk through the attack. First off, we need to start ntlmrelayx.py
in one window on our attack host, specifying the Web Enrollment URL for the CA host and using either the KerberosAuthentication or DomainController AD CS template. If we didn't know the location of the CA, we could use a tool such as certi to attempt to locate it.
Starting ntlmrelayx.py
In another window, we can run the tool PetitPotam.py
Running PetitPotam.py
Catching Base64 Encoded Certificate for DC01
Back in our other window, we will see a successful login request and obtain the base64 encoded certificate for the Domain Controller if the attack is successful.
ntlmrelayx window
Requesting a TGT Using gettgtpkinit.py
Setting the KRB5CCNAME Environment Variable
The TGT requested above was saved down to the dc01.ccache
file, which we use to set the KRB5CCNAME environment variable, so our attack host uses this file for Kerberos authentication attempts.
Using Domain Controller TGT to DCSync
We can then use this TGT with secretsdump.py
to perform a DCSYnc and retrieve one or all of the NTLM password hashes for the domain.
We could also use a more straightforward command: secretsdump.py -just-dc-user INLANEFREIGHT/administrator -k -no-pass ACADEMY-EA-DC01.INLANEFREIGHT.LOCAL
because the tool will retrieve the username from the ccache file.
We can see this by typing klist
(using the klist
command requires installation of the krb5-user package on our attack host)
Confirming Admin Access to the Domain Controller
Submitting a TGS Request for Ourselves Using getnthash.py
We can also take an alternate route once we have the TGT for our target. Using the tool getnthash.py
from PKINITtools we could request the NT hash for our target host/user by using Kerberos U2U to submit a TGS request with the Privileged Attribute Certificate (PAC) which contains the NT hash for the target.
This can be decrypted with the AS-REP encryption key we obtained when requesting the TGT earlier.
Using Domain Controller NTLM Hash to DCSync
Alternatively, once we obtain the base64 certificate via ntlmrelayx.py, we could use the certificate with the Rubeus tool on a Windows attack host to request a TGT ticket and perform a pass-the-ticket (PTT) attack all at once.
Requesting TGT and Performing PTT with DC01$ Machine Account
Again, since Domain Controllers have replication privileges in the domain, we can use the pass-the-ticket to perform a DCSync attack using Mimikatz from our Windows attack host.
PetitPotam Mitigations
First off, the patch for CVE-2021-36942 should be applied to any affected hosts. Below are some further hardening steps that can be taken:
To prevent NTLM relay attacks, use Extended Protection for Authentication along with enabling Require SSL to only allow HTTPS connections for the Certificate Authority Web Enrollment and Certificate Enrollment Web Service services
Disabling NTLM authentication for Domain Controllers
Disabling NTLM on AD CS servers using Group Policy
Disabling NTLM for IIS on AD CS servers where the Certificate Authority Web Enrollment and Certificate Enrollment Web Service services are in use
Miscellaneous Misconfigurations
There are many other attacks and interesting misconfigurations that we may come across during an assessment. A broad understanding of the ins and outs of AD will help us think outside the box and discover issues that others are likely to miss.
Exchange Related Group Membership
The group Exchange Windows Permissions
is not listed as a protected group, but members are granted the ability to write a DACL to the domain object. This can be leveraged to give a user DCSync privileges. An attacker can add accounts to this group by leveraging a DACL misconfiguration (possible) or by leveraging a compromised account that is a member of the Account Operators group.
This GitHub repo details a few techniques for leveraging Exchange for escalating privileges in an AD environment.
The Exchange group Organization Management
is another extremely powerful group (effectively the "Domain Admins" of Exchange) and can access the mailboxes of all domain users.
This group also has full control of the OU called Microsoft Exchange Security Groups
, which contains the group Exchange Windows Permissions
.
If we can compromise an Exchange server, this will often lead to Domain Admin privileges. Additionally, dumping credentials in memory from an Exchange server will produce 10s if not 100s of cleartext credentials or NTLM hashes. This is often due to users logging in to Outlook Web Access (OWA) and Exchange caching their credentials in memory after a successful login.
PrivExchange
The PrivExchange
attack results from a flaw in the Exchange Server PushSubscription
feature, which allows any domain user with a mailbox to force the Exchange server to authenticate to any host provided by the client over HTTP.
The Exchange service runs as SYSTEM and is over-privileged by default (i.e., has WriteDacl privileges on the domain pre-2019 Cumulative Update). This flaw can be leveraged to relay to LDAP and dump the domain NTDS database. If we cannot relay to LDAP, this can be leveraged to relay and authenticate to other hosts within the domain. This attack will take you directly to Domain Admin with any authenticated domain user account.
Printer Bug
The Printer Bug is a flaw in the MS-RPRN protocol (Print System Remote Protocol).
To leverage this flaw, any domain user can connect to the spool's named pipe with the RpcOpenPrinter
method and use the RpcRemoteFindFirstPrinterChangeNotificationEx
method, and force the server to authenticate to any host provided by the client over SMB.
The spooler service runs as SYSTEM and is installed by default in Windows servers running Desktop Experience. This attack can be leveraged to relay to LDAP and grant your attacker account DCSync privileges to retrieve all password hashes from AD.
The attack can also be used to relay LDAP authentication and grant Resource-Based Constrained Delegation (RBCD) privileges for the victim to a computer account under our control, thus giving the attacker privileges to authenticate as any user on the victim's computer.
This attack can be leveraged to compromise a Domain Controller in a partner domain/forest, provided you have administrative access to a Domain Controller in the first forest/domain already, and the trust allows TGT delegation, which is not by default anymore.
We can use tools such as the Get-SpoolStatus
module from this tool or this tool to check for machines vulnerable to the MS-PRN Printer Bug.
This flaw can be used to compromise a host in another forest that has Unconstrained Delegation enabled, such as a domain controller.
Enumerating for MS-PRN Printer Bug
MS14-068
This was a flaw in the Kerberos protocol, which could be leveraged along with standard domain user credentials to elevate privileges to Domain Admin.
A Kerberos ticket contains information about a user, including the account name, ID, and group membership in the Privilege Attribute Certificate (PAC).
The vulnerability allowed a forged PAC to be accepted by the KDC as legitimate. This can be leveraged to create a fake PAC, presenting a user as a member of the Domain Administrators or other privileged group.
It can be exploited with tools such as the Python Kerberos Exploitation Kit (PyKEK) or the Impacket toolkit. The only defense against this attack is patching. The machine Mantis on the Hack The Box platform showcases this vulnerability.
Sniffing LDAP Credentials
Many applications and printers store LDAP credentials in their web admin console to connect to the domain. These consoles are often left with weak or default passwords. Sometimes, these credentials can be viewed in cleartext. Other times, the application has a test connection
function that we can use to gather credentials by changing the LDAP IP address to that of our attack host and setting up a netcat
listener on LDAP port 389.
When the device attempts to test the LDAP connection, it will send the credentials to our machine, often in cleartext. Accounts used for LDAP connections are often privileged, but if not, this could serve as an initial foothold in the domain. Other times, a full LDAP server is required to pull off this attack, as detailed in this post.
Enumerating DNS Records
We can use a tool such as adidnsdump to enumerate all DNS records in a domain using a valid domain user account. This is especially helpful if the naming convention for hosts returned to us in our enumeration using tools such as BloodHound
is similar to SRV01934.INLANEFREIGHT.LOCAL
. If all servers and workstations have a non-descriptive name, it makes it difficult for us to know what exactly to attack. If we can access DNS entries in AD, we can potentially discover interesting DNS records that point to this same server, such as JENKINS.INLANEFREIGHT.LOCAL
, which we can use to better plan out our attacks.
The tool works because, by default, all users can list the child objects of a DNS zone in an AD environment.
Using adidnsdump
If we run again with the -r
flag the tool will attempt to resolve unknown records by performing an A
query.
Other Misconfigurations
Password in Description Field
Sensitive information such as account passwords are sometimes found in the user account Description
or Notes
fields and can be quickly enumerated using PowerView.
For large domains, it is helpful to export this data to a CSV file to review offline.
Finding Passwords in the Description Field using Get-Domain User
PASSWD_NOTREQD Field
It is possible to come across domain accounts with the passwd_notreqd field set in the userAccountControl attribute. If this is set, the user is not subject to the current password policy length, meaning they could have a shorter password or no password at all (if empty passwords are allowed in the domain).
Just because this flag is set on an account, it doesn't mean that no password is set, just that one may not be required. There are many reasons why this flag may be set on a user account, one being that a vendor product set this flag on certain accounts at the time of installation and never removed the flag post-install.
Checking for PASSWD_NOTREQD Setting using Get-DomainUser
Credentials in SMB Shares and SYSVOL Scripts
The SYSVOL share can be a treasure trove of data, especially in large organizations. We may find many different batch, VBScript, and PowerShell scripts within the scripts directory, which is readable by all authenticated users in the domain.
It is worth digging around this directory to hunt for passwords stored in scripts. Sometimes we will find very old scripts containing since disabled accounts or old passwords, but from time to time, we will strike gold, so we should always dig through this directory.
Group Policy Preferences (GPP) Passwords
When a new GPP is created, an .xml file is created in the SYSVOL share, which is also cached locally on endpoints that the Group Policy applies to. These files can include those used to:
Map drives (drives.xml)
Create local users
Create printer config files (printers.xml)
Creating and updating services (services.xml)
Creating scheduled tasks (scheduledtasks.xml)
Changing local admin passwords.
These files can contain an array of configuration data and defined passwords. The cpassword
attribute value is AES-256 bit encrypted, but Microsoft published the AES private key on MSDN, which can be used to decrypt the password.
Any domain user can read these files as they are stored on the SYSVOL share, and all authenticated users in a domain, by default, have read access to this domain controller share.
This was patched in 2014 MS14-025 Vulnerability in GPP could allow elevation of privilege, to prevent administrators from setting passwords using GPP. The patch does not remove existing Groups.xml files with passwords from SYSVOL. If you delete the GPP policy instead of unlinking it from the OU, the cached copy on the local computer remains.
The XML looks like the following:
If you retrieve the cpassword value more manually, the gpp-decrypt
utility can be used to decrypt the password as follows:
Decrypting the Password with gpp-decrypt
GPP passwords can be located by searching or manually browsing the SYSVOL share or using tools such as Get-GPPPassword.ps1, the GPP Metasploit Post Module, and other Python/Ruby scripts which will locate the GPP and return the decrypted cpassword value. CrackMapExec also has two modules for locating and retrieving GPP passwords. One quick tip to consider during engagements: Often, GPP passwords are defined for legacy accounts, and you may therefore retrieve and decrypt the password for a locked or deleted account.
However, it is worth attempting to password spray internally with this password (especially if it is unique). Password re-use is widespread, and the GPP password combined with password spraying could result in further access.
Locating & Retrieving GPP Passwords with CrackMapExec
It is also possible to find passwords in files such as Registry.xml when autologon is configured via Group Policy. This may be set up for any number of reasons for a machine to automatically log in at boot. If this is set via Group Policy and not locally on the host, then anyone on the domain can retrieve credentials stored in the Registry.xml file created for this purpose.
We can hunt for this using CrackMapExec with the gpp_autologin module, or using the Get-GPPAutologon.ps1 script included in PowerSploit.
Using CrackMapExec's gpp_autologin Module
A theme that we touch on throughout this module is password re-use. Poor password hygiene is common in many organizations, so whenever we obtain credentials, we should check to see if we can use them to access other hosts (as a domain or local user), leverage any rights such as interesting ACLs, access shares, or use the password in a password spraying attack to uncover password re-use and maybe an account that grants us further access towards our goal.
ASREPRoasting
It's possible to obtain the Ticket Granting Ticket (TGT) for any account that has the Do not require Kerberos pre-authentication setting enabled. Many vendor installation guides specify that their service account be configured in this way. The authentication service reply (AS_REP) is encrypted with the account’s password, and any domain user can request it.
With pre-authentication, a user enters their password, which encrypts a time stamp. The Domain Controller will decrypt this to validate that the correct password was used.
ASREPRoasting is similar to Kerberoasting, but it involves attacking the AS-REP instead of the TGS-REP. An SPN is not required. This setting can be enumerated with PowerView or built-in tools such as the PowerShell AD module.
The attack itself can be performed with the Rubeus toolkit and other tools to obtain the ticket for the target account. If an attacker has GenericWrite
or GenericAll
permissions over an account, they can enable this attribute and obtain the AS-REP ticket for offline cracking to recover the account's password before disabling the attribute again.
Below is an example of the attack. PowerView can be used to enumerate users with their UAC value set to DONT_REQ_PREAUTH
.
Enumerating for DONT_REQ_PREAUTH Value using Get-DomainUser
Retrieving AS-REP in Proper Format using Rubeus
Cracking the Hash Offline with Hashcat
When performing user enumeration with Kerbrute
, the tool will automatically retrieve the AS-REP for any users found that do not require Kerberos pre-authentication. (jsmith.txt is a userlist)
Retrieving the AS-REP Using Kerbrute
With a list of valid users, we can use Get-NPUsers.py from the Impacket toolkit to hunt for all users with Kerberos pre-authentication not required.
Hunting for Users with Kerberoast Pre-auth Not Required
Group Policy Object (GPO) Abuse
Group Policy provides administrators with many advanced settings that can be applied to both user and computer objects in an AD environment. Group Policy, when used right, is an excellent tool for hardening an AD environment by configuring user settings, operating systems, and applications.
That being said, Group Policy can also be abused by attackers. If we can gain rights over a Group Policy Object via an ACL misconfiguration, we could leverage this for lateral movement, privilege escalation, and even domain compromise and as a persistence mechanism within the domain.
GPO misconfigurations can be abused to perform the following attacks:
Adding additional rights to a user (such as SeDebugPrivilege, SeTakeOwnershipPrivilege, or SeImpersonatePrivilege)
Adding a local admin user to one or more hosts
Creating an immediate scheduled task to perform any number of actions
We can enumerate GPO information using many of the tools we've been using throughout this module such as PowerView and BloodHound. We can also use group3r, ADRecon, PingCastle, among others, to audit the security of GPOs in a domain.
Enumerating GPO Names with PowerView
Example: We can see that autologon is in use which may mean there is a readable password in a GPO, and see that Active Directory Certificate Services (AD CS) is present in the domain.
If Group Policy Management Tools are installed on the host we are working from, we can use various built-in GroupPolicy cmdlets such as Get-GPO
to perform the same enumeration.
Enumerating GPO Names with a Built-In Cmdlet
Next, we can check if a user we can control has any rights over a GPO.
Enumerating Domain User GPO Rights
We can use the GPO GUID combined with Get-GPO
to see the display name of the GPO.
Converting GPO GUID to Name
Example:
Checking in BloodHound, we can see that the Domain Users
group has several rights over the Disconnect Idle RDP
GPO, which could be leveraged for full control of the object.
If we select the GPO in BloodHound and scroll down to Affected Objects
on the Node Info
tab, we can see that this GPO is applied to one OU, which contains four computer objects.
We could use a tool such as SharpGPOAbuse to take advantage of this GPO misconfiguration by performing actions such as adding a user that we control to the local admins group on one of the affected hosts, creating an immediate scheduled task on one of the hosts to give us a reverse shell, or configure a malicious computer startup script to provide us with a reverse shell or similar.
When using a tool like this, we need to be careful because commands can be run that affect every computer within the OU that the GPO is linked to. If we found an editable GPO that applies to an OU with 1,000 computers, we would not want to make the mistake of adding ourselves as a local admin to that many hosts.
Some of the attack options available with this tool allow us to specify a target user or host.
Last updated