psconfeu - offensive active directory (with powershell!)

16
Offensive Active Directory Will Schroeder (@harmj0y) With PowerShell!

Upload: will-schroeder

Post on 21-Apr-2017

5.286 views

Category:

Internet


0 download

TRANSCRIPT

Page 1: PSConfEU - Offensive Active Directory (With PowerShell!)

Offensive Active Directory

Will Schroeder (@harmj0y)

With PowerShell!

Page 2: PSConfEU - Offensive Active Directory (With PowerShell!)

Agenda• Offensive Active Directory 101• Hunting for Users• Local Administrator Enumeration• GPO Enumeration and Abuse• Active Directory ACLs• Domain Trusts

Page 3: PSConfEU - Offensive Active Directory (With PowerShell!)

Offensive AD 101• Red teams and ‘real’ bad guys have been abusing AD for years, but not much offensive AD information has existed publicly (until recently)• See http://adsecurity.org/

• A lot of what we do on a red team is essentially just (authorized) domain administration• We find misconfigurations and chain access/trust relationships to turn one machine compromise into achieving our objective

Page 4: PSConfEU - Offensive Active Directory (With PowerShell!)

PowerView• A pure PowerShell domain/network situational awareness tool• Version 2.0 compliant• Fully self-contained and loadable in memory

• Now part of PowerSploit™ (not really trademarked)

• Many modules are implemented in Empire

• Built to automate large components of the tradecraft on our red team engagements

Page 5: PSConfEU - Offensive Active Directory (With PowerShell!)

Sidenote

“The best tool these days for understanding windows networks is Powerview [1].”

-Phineas Fisherhttp://pastebin.com/raw/0SNSvyjJ

Page 6: PSConfEU - Offensive Active Directory (With PowerShell!)

Hunting for Users• On nearly every engagement, we end up wanting to know where specific users are logged in

• We break this down into:• Pre-elevated access, where we have regular domain user privileges. This is out “lateral spread” phase

• Post-elevated access, where we have some type of elevated (e.g. Domain Admin) access. This is usually our ‘demonstrate impact’ phase

Page 7: PSConfEU - Offensive Active Directory (With PowerShell!)

Win32 API Access• Several techniques we rely on for user-hunting depend on various Windows API calls• Specifically NetWkstaUserEnum and NetSessionEnum

• There are several methods to access these API calls through PowerShell• C# Add-Type, straight reflection, PSReflect

• See Matt Graeber’s US PowerShell Summit talk on Win32 API access for more details

Page 8: PSConfEU - Offensive Active Directory (With PowerShell!)

• Windows allows any domain-authenticated user to enumerate the members of a local group on a remote machine• Either through the NetLocalGroupGetMembers Win32 API call or the WinNT service provider

• “Derivative Local Admin”• Alice is (effectively) an admin on Bob’s machine, and Bob is (effectively) an admin on Eve’s machine

• Alice can derive Eve’s rights though compromising and leveraging Bob’s credentials

Local Administrator Enumeration

Page 9: PSConfEU - Offensive Active Directory (With PowerShell!)

• Machines obviously have to somehow determine what users have administrative rights• Usually set through restricted groups or group policy preferences

• These GPO policies are accessible by anyone on the domain

• From of offensive perspective, we can often query a domain controller, and determine who has administrative rights to what machines

GPO Enumeration and Abuse

Page 10: PSConfEU - Offensive Active Directory (With PowerShell!)

• Very few organizations properly audit AD ACLs or alert on their alteration

• Almost every organization has some kind of misconfiguration SOMEWHERE in the object access rights in their domain structure

• This is also a great candidate place for ‘sneaky’ persistence!

Active Directory ACLs

Page 11: PSConfEU - Offensive Active Directory (With PowerShell!)

• Trusts allow separate domains to form inter-connected relationships• Often utilized during acquisitions (i.e. forest trusts or cross-link trusts)

• A trust just links up the authentication systems of two domains and allows authentication traffic to flow between them• Allows for the possibility of privileged access between domains, but doesn’t guarantee it*

Domain Trusts

Page 12: PSConfEU - Offensive Active Directory (With PowerShell!)

• Mimikatz Golden Tickets now accept SidHistories though the new /sids:<X> argument

• If you compromise a DC in a child domain, you can create a golden ticket with the “Enterprise Admins” in the SID history

• This can let you compromise the parent domain!• The FOREST is the trust boundary, not the domain!

Sidenote: The Mimikatz Trustpocalypse

Page 13: PSConfEU - Offensive Active Directory (With PowerShell!)

Summary• There’s a lot of overlap between offensive engagements and legitimate domain administration

• You can find where users are logged in WITHOUT elevated domain privileges

• You can enumerate the local users of a remote machine WITHOUT elevated domain privileges

• Domain trusts can easily be enumerated, visualized, and abused with PowerView

Page 14: PSConfEU - Offensive Active Directory (With PowerShell!)

Questions?

Page 15: PSConfEU - Offensive Active Directory (With PowerShell!)

• Will Schroeder (@harmj0y)• http://blog.harmj0y.net | will [at] harmj0y.net

• Security researcher and red teamer for Veris Group‘s Adaptive Threat Division

• Offensive open-source developer:• Veil-Evasion, Empire, PowerSploit

• Recent Microsoft CDM/PowerShell MVP

About_Author

Page 16: PSConfEU - Offensive Active Directory (With PowerShell!)

• The Mimikatz Trustpocalypse brought to you by:• Benjamin Delpy (@gentilkiwi)• Sean Metacalf (@pyrotek3) - http://adsecurity.org

• My Active Directory background brought to you by:• Carlos Perez (@darkoperator)• Sean Metcalf (@pyrotek3) - http://adsecurity.org

• Get PowerView:• https://github.com/PowerShellMafia/PowerSploit/blob/dev/Recon/PowerView.ps1

• Cheat sheets: https://github.com/harmj0y/cheatsheets/

About_References