MITRE ATT&CK TTPs
Requirements
- Site database access
- Access to the private key used for encryption stored on the primary site server
Summary
SCCM uses many different accounts for various purposes (e.g., network access accounts, domain join accounts, client push installation accounts, etc.). All of these credentials are stored in theSC_UserAccount table in the site MSSQL database as hex-encoded, encrypted blobs. The secrets in this table are encrypted with an RSA private key which is stored in the “Microsoft Systems Management Server” cryptographic service provider (CSP) container on the primary site server for the site the account was added to.
For example, if there are two primary sites, PS1 and PS2, and a network access account was added to PS1, the credentials can be decrypted by the primary site server for PS1, but not the site server for PS2. If a client push installation account is subsequently added to PS2, it cannot be decrypted using the key on the PS1 site server and can only be decrypted on the PS2 site server.
From the site server, which is granted the sysadmin role on the site database, it is possible to query the SC_UserAccount table for usernames and passwords and decrypt the blobs using this private key. Alternatively, this table can be read to obtain the blobs for later offline decryption on the site server or with the stolen private key. This is particularly dangerous if the database is compromised through some attack path where SCCM credentials may not yet have been compromised, such as SQL links.
Impact
If an attacker can compromise the primary site server, they can recover plaintext credentials for any account stored in the site database.Defensive IDs
- PREVENT-10: Enforce the principle of least privilege for accounts
- PREVENT-18: Use strong passwords for DBA accounts
- PREVENT-19: Remove unnecessary links to site databases
- PREVENT-20: Block unnecessary connections to site systems
Examples
Mimikatz (C)
Benjamin Delpy’s mimikatzmisc::sccm command was the first command that could be run on a primary site server that also hosted the site database to retrieve the blobs from the database and decrypt them.
SQLRecon (C#)
Sanjiv Kawa’sSQLRecon can be run on a primary site server that also hosts the site database to retrieve the blobs from the database and decrypt them:
DecryptCredentials module can be used to decrypt the credentials.
SCCMDecryptPoc (C#)
Alternatively, use Adam Chester’ssccmdecryptpoc.cs gist to decrypt the blobs from the site server in the context of a member of the local Administrators group.
PowerShell (.NET Framework)
There is also a .NET Framework binary that ships with ConfigMgr (Microsoft.ConfigurationManager.ManagedBase.dll) that exports aSiteCrypto.Decrypt function that can be executed on a site server to decrypt secrets stored in the site database:
SCCMDecryptor-BOF
There is also a beacon object file (BOF) implementation of Adam’s Chester’ssccmdecryptpoc.cs that can be run in your BOF capable C2 beacon of choice in a local administrative context on the site server.
References
- Benjamin Delpy, https://x.com/gentilkiwi/status/1392204021461569537?s=20
- Benjamin Delpy, mimikatz
- Adam Chester, https://twitter.com/_xpn_/status/1543682652066258946
- Adam Chester, sccmdecryptpoc.cs
- Sanjiv Kawa, SQLRecon
- Marshall Price, SCCMDecryptor-BOF