3-Red Teaming Active Directory
3-Red Teaming Active Directory
Introduction
https://mva.microsoft.com/en-us/training-courses/understanding-active-directory-8233
PT e treme - Caendra Inc. © 2017
Active Directory Domain Services require a DNS
infrastructure to operate. Active Directory supports AD
integrated DNS. In the case of AD integrated DNS, DNS
information is stored in Active Directory and replicated
through it.
DNS Domain
Name
DNS
https://mva.microsoft.com/en-us/training-courses/understanding-active-directory-8233
PT e treme - Caendra Inc. © 2017
Active Directory Domain Services consist of various physical
and logical components.
AD DS is composed of both physical and logical components Defines the list of attributes all
Stores the AD DS objects in the AD DS can have.
information. This is a file on
each domain controller.
Physical Components Logical Components Logical, administrative boundary
for users and computers
• Data store • Partitions
Contain a copy of AD DS
Collection of domain controllers
database.
• Domain controllers • Schema that share a common root
domain.
• Global catalog server • Domains
Hosts the global catalog,
which is a partial, read-only • Read-Only Domain • Domain trees Collections of domains sharing a
common AD DS.
copy of all the domain Controller (RODC)
naming contexts in the • Forests
forest. A global catalog Collections of users, groups,
speeds up searches for • Sites computers as defined by their
objects that might be physical locations. Useful during
attached to other domain • Organizational units (OUs) replication tasks.
controllers in the forest.
Organizes the elements found
at a given site or domain for
https://mva.microsoft.com/en-us/training-courses/understanding-active-directory-8233 the purposes of securing
them more selectively.
PT e treme - Caendra Inc. © 2017
First, let’s go through the AD DS physical components:
• Domain Controllers
• Global Catalog Servers
• Data Store
• Replication
• Sites
Domain controllers:
• Host a copy of the AD DS directory store
https://mva.microsoft.com/en-us/training-courses/understanding-active-directory-8233
PT e treme - Caendra Inc. © 2017
Things to note regarding Domain Controllers:
• Each domain controller holds a copy of the directory store and updates
can be made to the AD DS data on all domain controllers except for
RODCs.
• A read-only DC has its own KRBTGT account, which means that Kerberos
is cryptographically isolated from the rest of the domain. RODCs do not
have any domain related passwords on them, by default.
https://mva.microsoft.com/en-us/training-courses/understanding-active-directory-8233
PT e treme - Caendra Inc. © 2017
Things to note regarding Global Catalog Servers:
• Administrators cannot enter information directly into this partition. The
global catalog builds and updates its content based on values of a schema
attribute (isMemberOfPartialAttributeSet), thus deciding when to
replicate that attribute of an AD DS object in the global catalog.
https://mva.microsoft.com/en-us/training-courses/understanding-active-directory-8233
PT e treme - Caendra Inc. © 2017
Things to note regarding the AD DS Data Store:
• The NTDS.DIT file is a database mainly used to:
1. Store the objects accessible in Active Directory
2. Provide references to objects
3. Store the security descriptors
AD DS replication:
• Ensures that all domain controllers have the same information
https://mva.microsoft.com/en-us/training-courses/understanding-active-directory-8233
PT e treme - Caendra Inc. © 2017
Things to note regarding AD DS Replication:
• Domain controllers in the same site replicate their data, typically within
15 seconds after a change, completing replication with all members in a
properly configured tree in about 45 seconds.
Domains:
• An administrative boundary for applying policies to groups of objects
https://mva.microsoft.com/en-us/training-courses/understanding-active-directory-8233
PT e treme - Caendra Inc. © 2017
All of the domain controllers in a particular domain can
receive changes and replicate those changes to all other
domain controllers in the domain.
emea.contoso.co na.contoso.co
m m
https://mva.microsoft.com/en-us/training-courses/understanding-active-directory-8233
PT e treme - Caendra Inc. © 2017
Forests
A forest is a collection of
one or more domain trees
Forests:
• Share a common schema
https://mva.microsoft.com/en-us/training-courses/understanding-active-directory-8233
PT e treme - Caendra Inc. © 2017
Organizational Units
OUs are Active Directory containers that can contain users, groups, computers, and
other OUs
• Apply policies
https://mva.microsoft.com/en-us/training-courses/understanding-active-directory-8233
PT e treme - Caendra Inc. © 2017
Trusts
Trusts provide a mechanism for users to gain access to resources in another domain
https://mva.microsoft.com/en-us/training-courses/understanding-active-directory-8233
PT e treme - Caendra Inc. © 2017
Things to note regarding AD Trusts:
• Domains can allow access to shared resources outside of their
boundaries by using a trust. Forest trusts allow users to access resources
in any domain in the other forest, as well as logon to any domain in the
forest.
✓ https://msdn.microsoft.com/en-us/library/bb727030.aspx
✓ https://www.microsoftpressstore.com/articles/article.asp
x?p=2217264
LDAP Relay can be seen as the good old NTLM Relay with a
twist. The third party host to which we will relay credentials
will be the Domain Controller. LDAP Relay leverages the fact
that signed Lightweight Directory Access Protocol (LDAP)
binds are not required, by default. Consequently, replay
attacks are feasible.
2. Become a man in the middle between his workstation and the gateway
3. Inject a hidden link in the web traffic pointing to a HTTP listener that
requests NTLM authentication
3
We also enable “LDAP Relay” on the MiTM options
4 5
We submit the DC’s IP address and start ARP poisoning Once our link is injected the “credentials” are relayed to
the Domain Controller and intercepter-ng adds a new
user with administrative privileges called “cepter”.
MS15-011 is one of the few cases where the patch alone isn’t
enough. Additional configuration should occur in order to
secure the affected systems.
3 4
Once the target searches for an available update for
the Group Policy, the payload (intercepter’s custom
connect back shell) is executed.
The all time classic tool for RDP MiTM attacks is Cain.
The majority of SMB relaying tools will usually touch disk and
create a new service to provide us with a shell. This is quite
noisy.
Click “choose” to
use a session.
PT e treme - Caendra Inc. © 2017
LLMNR and NBT-NS poisoning
Let’s try and crack this cached credential using JtR. Luckily,
the password was weak enough to crack it.
>> john --format=mscash2 --wordlist=/root/mydict.txt /root/2crack.txt
We managed to identify
that an Administrator is
logged into 10.10.10.107
by SMB relaying an
unprivileged user
There are some vendors that support AMSI, and these are
Microsoft, ESET, and AVG. Following you can see AMSI in
action.
AMSI Bypasses
There are ways to bypass AMSI. Matt Graeber, the author of
PowerSploit, came up with a PowerShell cmdlet that
bypasses AMSI, using reflection.
✓ http://www.exploit-monday.com/2017/08/exploiting-powershell-code-
injection.html
https://blog.cptjesus.com/posts/ms14068
ADSecurity.org
PT e treme - Caendra Inc. © 2017
Unconstrained Delegation
So, when the user provides that service ticket to the server
hosting the requested service, that TGT is placed in LSASS (in
memory) for later use.
Screenshot from
2ndAdmin’s workstation.
We successfully compromised
the DC, using PSRemoting
with the 2ndAdmin ticket we
captured and passed.
http://www.harmj0y.net/blog/redteaming/pass-the-hash-is-
dead-long-live-localaccounttokenfilterpolicy/
We can also
specify aes128
keys, even if they
don’t actually exist.
DCSync (mimikatz)
A better approach in acquiring all of the domain’s password
hashes is DCSync. DCSync is a mimikatz feature that enables
us to act as a Domain Controller and request password data
from the targeted DC.
ADSecurity.org
PT e treme - Caendra Inc. © 2017
Golden Tickets
Evasion Note:
Be aware that the execution of DCSync causes some log
entries. To not create any additional noise while
compromising the parent domain (DCSyncing against the
parent), we can use inside the “ExtraSids (sids)” option the
‘Domain Controllers’ SID of the parent domain and the
‘Enterprise Domain Controllers’ SID.
Through Invoke-DCOM
we can invoke commands
on remote hosts via the
MMC20.Application COM
object over DCOM.
2. The DC encrypts the ticket using the service account associated with the
specified SPN and sends back a TGS
All we have to do now is save this ticket to a file and run JtR
against it, as follows. Note that we are using JtR from this
repository.
>> ./john --format=krb5tgs path_to_ticket path_to_wordlist
We were able to
identify the service’s
PT e treme - Caendra Inc. © 2017 password
Kerberoast
ADSecurity.org
PT e treme - Caendra Inc. © 2017
Silver Tickets
Notes:
• By default, computer account passwords change every 30 days, and two
passwords are stored on the computer.
• PAC validation wouldn’t be useful in this case since the targeted services
are system services
ADSecurity.org
PT e treme - Caendra Inc. © 2017
Trust Tickets
Mimikatz
patches the
PT e treme - Caendra Inc. © 2017 LSASS process
Trust Tickets
To forge a trust ticket for an internal trust, you can follow the
same procedure we used for an external trust.
-k indicates that
we are using
Kerberos
authentication
(i.e. the TGT we
created with the
kinit command)
SSO LDAP
Over-pass-the-Hash Kerberoast
PCredz Responder
snarf AppLocker
Bypassing AMSI using PowerShell 5 DLL Hijacking Bypass via COM hijacking
PSAmsi Invoke-AmsiBypass.ps1
How to Bypass Application Whitelisting and
PS-Attack Constrained Powershell
Kinit_user_bruter.sh S4U2Pwnage