Privilege escalation in Active Directory from Windows
Resources
- [TheHacker.recipes](https://www.thehacker.recipes/ad/movement/dacl/forcechangepassword#forcechangepassword
Hardening and auditing Active Directory
Attacking from linux
Attacking from Windows
Linux in AD
š Attacking SAM
š¤ Attacking LSASS
LSASS stores credentials that have active logon sessions on Windows systems. When we dumped LSASS process memory into the file, we essentially took a "snapshot" of what was in memory at that point in time.
š Attacking NTDS
By default, the NTDS file (NTDS.dit) is located inĀ %SystemRoot%\NTDS\Ntds.dit
Ā of a domain controller. The .dit stands for directory information tree.
š Kerberoasting
Kerberoasting is a lateral movement/privilege escalation technique in Active Directory environments.
š Access Control List (ACL)Abuse
During an assessment where the client has taken care of all of the "low hanging fruit" AD flaws/misconfigurations, ACL abuse can be a great way for us to move laterally/vertically and even achieve full domain compromise.
See more on Access Control List (ACL)Abuse
ā Privileged Access
Sometimes we don't Ā have local admin rights on any hosts in the domain. However there are other ways to access the host:
-
Remote Desktop Protocol
Ā (RDP
) - is a remote access/management protocol that gives us GUI access to a target host -
PowerShell 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.
Via BloodHound we can enumerate the following edges to see what types of remote access privileges a given user has:
Remote Desktop
Enumerating the Remote Desktop Users Group with PowerView.ps1.
From Bloodhound, we can 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
.
Test access with Linux: xfreerdp, rdesktop, Remmina Windows: mstsc.exe.
WinRM
Enumerating the Remote Management Users Group with PowerView.ps1.
In Bloodhound, we can use this Cypher query and add it as a custom query:
To access from Linux, use evil-winrm.
To access from Windows, use Powershell and the Enter-PSSessionĀ cmdlet:
SQL Server Admin
Enumerate via Bloodhound and 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:
Enumerating MSSQL Instances with PowerUpSQL. The command needs to be ran by an user with SQLAdmin
rights:
Authenticate against the remote SQL server host and run custom queries or operating system commands.
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>
.
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.
šØļø 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.
š Print Spooler
The Print Spooler exploitation leverages the Windows Print Spooler service in conjunction with the SeImpersonatePrivilege privilege. The goal is to impersonate a SYSTEM token to escalate privileges. Tools like PrintSpoofer automate this process effectively. Below are detailed steps for exploiting this vulnerability:
šŖ¤ NoPac (SamAccountName Spoofing)
Detailed explanations
This vulnerability encompasses two CVEsĀ 2021-42278Ā andĀ 2021-42287, allowing for intra-domain privilege escalation from any standard domain user to Domain Admin level access in one single command.
See more on NoPac (Sam account Spoofing).
š± Exchange Related Group Membership
See some techniques at: https://github.com/gdedrouas/Exchange-AD-Privesc This repository provides a few techniques and scripts regarding the impact of Microsoft Exchange deployment on Active Directory security. This is a side project of AD-Control-Paths, an AD permissions auditing project to which I recently added some Exchange-related modules.
- 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. - 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. It is not uncommon for sysadmins to be members of this group. 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.
š Attacking Domain Trusts # 1: Child -> Parent Trusts
See more on Attacking Domain Trusts
- SidHistory: ExtraSids Attack - Mimikatz
- Cross-Forest Kerberoasting
- Admin Password Re-Use & Group Membership
- SID History Abuse - Cross Forest
š„ø Dumping creds from browser: Lazagne
TheĀ LaZagne projectĀ is an open source application used toĀ retrieve lots of passwordsĀ stored on a local computer.
Evasion Techniques
Downgrade Powershell
Many defenders are unaware that several versions of PowerShell often exist on a host. If not uninstalled, they can still be used. Powershell event logging was introduced as a feature with Powershell 3.0 and forward. With that in mind, we can attempt to call Powershell version 2.0 or older. If successful, our actions from the shell will not be logged in Event Viewer.
WithĀ Script Block LoggingĀ enabled, we can see that whatever we type into the terminal gets sent to this log. If we downgrade to PowerShell V2, this will no longer function correctly. Our actions after will be masked since Script Block Logging does not work below PowerShell 3.0.
PowerShell Operational Logs are kept under underĀ Applications and Services Logs > Microsoft > Windows > PowerShell > Operational
.
Also the Windows PowerShell
Ā log is located atĀ Applications and Services Logs > Windows PowerShell
.
Net Commands Trick
TypingĀ net1
Ā instead ofĀ net
Ā will execute the same functions without the potential trigger from the net string. Example:
Mitigations
Auditing for and removing dangerous ACLs
Organizations should have regular AD audits performed but also train internal staff to run tools such as BloodHound and identify potentially dangerous ACLs that can be removed.
Monitor group membership
Visibility into important groups is paramount. All high-impact groups in the domain should be monitored to alert IT staff of changes that could be indicative of an ACL attack chain.
Audit and monitor for ACL changes
Enabling theĀ Advanced Security Audit PolicyĀ can help in detecting unwanted changes, especiallyĀ Event ID 5136: A directory service object was modifiedĀ which would indicate that the domain object was modified, which could be indicative of an ACL attack. If we look at the event log after modifying the ACL of the domain object, we will see some event IDĀ 5136
Ā created. If we check out theĀ Details
Ā tab, we can see that the pertinent information is written inĀ Security Descriptor Definition Language (SDDL)Ā which is not human readable.
We can use theĀ ConvertFrom-SddlString cmdletĀ to convert this to a readable format.