VS.: Modern Active Directory Attacks, Detection, & Protection
VS.: Modern Active Directory Attacks, Detection, & Protection
Blue:
Modern Active Directory Attacks,
Detection, & Protection
Sean Metcalf
Persistence
AutoRun
WMI
“Sticky Keys”
PowerShell
PowerShell Overview
Dave Kennedy: “Bash for Windows”
Available by default in supported Windows versions
v2: Win 7 / Win 2k8R2
v3: Win 8 / Win 2012
v4: Win 8.1 / Win 2012R2
v5: Win 10 / Win 2016
Leverages .Net Framework
PowerShell.exe only an entry point into PowerShell
Provides access to WMI & COM
Microsoft code = whitelisted
Download & run code in memory
Offensive PowerShell
PowerSploit
Invoke-Mimikatz (updated 2/16/2015)
Invoke-TokenManipulation
Invoke-Shellcode
Get-GPPPassword
Persistence
PowerView
Hunting Sys Admins
“SPN Scanning”: Service Discovery
SQL servers, instances, ports, etc.
MSSQLSvc/adsmsSQLAP01.adsecurity.org:1433
Exchange
exchangeMDB/adsmsEXCAS01.adsecurity.org
RDP
TERMSERV/adsmsEXCAS01.adsecurity.org
WSMan/WinRM/PS Remoting
WSMAN/adsmsEXCAS01.adsecurity.org
Hyper-V Host
Microsoft Virtual Console Service/adsmsHV01.adsecurity.org
VMWare VCenter
STS/adsmsVC01.adsecurity.org
SPN Scanning for MS SQL Servers with Discover-PSMSSQLServers
Getting Domain Admin in Active Directory
Poor Service Account Passwords
Passwords in SYSVOL
Credential Theft
Misconfiguration / Incorrect Perms
Exploit Vulnerability
SPN Scanning for Service Accounts with Find-PSServiceAccounts
SPN Directory:
http://adsecurity.org/?page_id=183
Cracking Service Account Passwords (Kerberoast)
Request/Save TGS service tickets & crack offline.
“Kerberoast” python-based TGS password cracker
No elevated rights required!
No traffic sent to target!
Reference: Tim Medin “Attacking Microsoft Kerberos: Kicking the Guard Dog of Hades”
https://www.youtube.com/watch?v=PUyhlN-E5MU
Group Policy Preferences (GPP)
Authenticated Users have read access to
SYSVOL
Configuration data xml stored in SYSVOL
Password is AES-256 encrypted
Common credential use cases:
Create Local Users
Scheduled Tasks
Change local Administrator passwords
Exploiting Group Policy Preferences
The private key is publicly available on MSDN
https://msdn.microsoft.com/en-us/library/2c15cbf0-f086-4c74-8b70-1f2fa45dd4be.aspx
Exploiting Group Policy Preferences
\\<DOMAIN>\SYSVOL\<DOMAIN>\Policies\
The GPP Credential Vulnerability Fix?
Vulnerability in GPP could allow elevation
of privilege (May 13, 2014)
MS14-025 (KB2962486)
Install on all systems with RSAT
Passwords are not removed from SYSVOL
Pivoting with Local Admin
Using GPP Credentials:
GPP renames local Administrator account to “ADSAdmin”
GPP sets Password to “P@ssw0rd11!”
Connect to other computers using ADSAdmin account
Compromise Local Admin creds = Admin rights on all
Always RID 500 – doesn’t matter if renamed.
Mimikatz for more credentials!
Mimikatz: The Credential Multi-tool
Dump credentials
Windows protected memory (LSASS). *
Active Directory Domain Controller database . *
Dump Kerberos tickets
for all users. *
for current user.
Credential Injection
Password hash (pass-the-hash)
Kerberos ticket (pass-the-ticket)
Generate Silver and/or Golden tickets (depending on
password hash available).
* Requires debug or system rights
Dump Credentials with Mimikatz
User Service Account
Default Logon Rights to Domain Controllers
Enterprise Admins (admin on all DCs in the forest),
Domain Admins
Administrators
Backup Operators
Server Admins
Account Operators
Print Operators
Other groups delegated in your environment
Dumping AD Domain Credentials
Dump credentials on DC (local or remote).
Run code (Mimikatz, WCE, etc) on DC.
Invoke-Mimikatz on DC via PS Remoting.
Get access to the NTDS.dit file & extract data.
Copy AD database from remote DC.
Grab AD database copy from backup.
Get Virtual DC data.
Dump AD Credentials with Mimikatz
Dump LSASS Process Memory
Remotely Grab the DIT!
Remotely Grab the DIT using Pass The Ticket
Instead of VSS, why not leverage NTDSUtil?
Finding NTDS.dit on the Network
http://adsecurity.org/?tag=ms14068
MS14-068 (PyKEK 12/5/2014)
MS14-068 Kekeo Exploit
MS14-068 Kekeo Exploit – Packet Capture
User to Admin in 5 Minutes?
“Victims quickly learned that the path from a few
infected systems to complete compromise of an
Active Directory domain could be incredibly
short.”
“Kerberos Attacks: After gaining domain
administrator privileges, attackers used the
Kerberos golden ticket attack to authenticate as
any privileged account—even after domain
password resets.“
- Mandiant M-Trends 2015 report
Forging Kerberos Golden/Silver Tickets
Requires KRBTGT pw hash / service account pw hash.
Forged TGT (Golden Ticket) bypasses all user restrictions.
Create anywhere & use on any computer on the network.
No elevated rights required to create/use.
Impersonate existing user.
Invent a fictional user with elevated rights.
Spoof access without changing group membership
User password changes have no impact on forged ticket!
KRBTGT: The AD Kerberos Service Account
KRBTGT account: disabled and not visible.
Sign/encrypt AD Kerberos tickets
Pwd set when domain created & (almost) never changes
Password changes when DFL -> 2008 (or newer).
Current & Previous Password valid for Kerberos tickets
KRBTGT password exposed? Requires changing twice!
RODC Kerberos Account: KRBTGT_######.
KRBTGT: The AD Service Account
The Golden Ticket (Forged TGT)
Encrypted/Signed by KRBTGT (RID 502).
Bypasses Smart Card authentication requirement
Golden Ticket options:
Impersonate existing Domain Admin
Create Fictitious user
Spoof access by adding groups to the ticket
Impersonate C-level executive access
Where are the crown jewels?
Golden Ticket (Forged TGT) Communication
Forging a Golden Ticket: KRBTGT NTLM Hash
Forging a Golden Ticket: Impersonate Valid DA
Forging a Golden Ticket: Fictional User
The Silver Ticket (Forged TGS)
Service account configured for Kerberos auth (SPN).
Encrypted with the service account private key:
Service account NLTM password hash
AD computer account NLTM password hash
Service opens TGS ticket to validate.
Golden Ticket equivalent access to service.
No associated TGT exists, so no comm with a DC
Silver Ticket (Forged TGS) Communication
Silver Ticket: Domain Controller Exploitation
• Attacker dumped AD & has all domain creds.
• Corp IT changed all user, admin, and service
account passwords (and KRBTGT pw 2x).
• Attacker still has Domain Controller computer
account password hashes.
Best Mitigation: Don’t let attackers run code on DCs – Protect DAs!
Blue Team (Defense)
Raising the Bar
•System-wide transcripts
•Script block logging
•Constrained PowerShell
•Antimalware Integration (Win 10)
Mitigation Level One (Low)
• Minimize the groups (& users) with DC admin/logon rights
• Separate user & admin accounts (JoeUser & AdminJoeUser)
• No user accounts in admin groups
• Set all admin accounts to “sensitive & cannot be delegated”
• Deploy Security Back-port patch (KB2871997) which adds local
SIDs & enable regkey to prevent clear-text pw in LSASS.
• Set GPO to prevent local accounts from connecting over network
to computers (easy with KB2871997).
• Use long, complex (>25 characters) passwords for SAs.
• Delete (or secure) GPP policies and files with creds.
• Patch server image (and servers) before running DCPromo
• Implement RDP Restricted Admin mode
Mitigation Level Two (Moderate)
• Microsoft LAPS (or similar) to randomize computer local admin
account passwords.
• Service Accounts (SAs):
• Leverage “(Group) Managed Service Accounts”.
• Implement Fine-Grained Password Policies (DFL >2008).
• Limit SAs to systems of the same security level, not shared
between workstations & servers (for example).
• Remove Windows 2003 from the network.
• Separate Admin workstations for administrators (locked-
down & no internet).
• PowerShell logging
Mitigation Level Three (“It’s Complicated”)
• Number of Domain Admins = 0
• Complete separation of administration New Admin Model
• ADAs use SmartCard auth w/ rotating pw
• ADAs never logon to other security tiers.
• ADAs should only logon to a DC
(or admin workstation or server).
• Time-based, temporary group membership.
• No Domain Admin service accounts running on
non-DCs.
• Disable default local admin account & delete all
other local accounts.
• Implement network segmentation.
• CMD Process logging & enhancement (KB3004375).
Attack Detection Paradigm Shift
• Microsoft Advanced Threat Analytics (ATA, formerly Aorato)
• Monitors all network traffic to Domain Controllers
• Baselines “normal activity” for each user (computers, resources, etc)
• Alerts on suspicious activity by user
• Natively detects recon & attack activity without writing rules