SCCM - Takeover
SCCM Takeover Techniques
TAKEOVER-1 - Hierarchy takeover via NTLM coercion and relay to MSSQL on remote site database
This attack requires the site database be hosted separately from the site server, because we are coercing the site server's computer account against the database server (it would not be possible to coerce against itself).
With the following command we can create a oneliner query that gives our normal domain user (mike), SCCM full administrator permissions (-sc
is the site code):
The target IP is the database server (hosted separately from the site server):
So for example:
Next we coerce the target with petitpotam (or Coercer etc). First IP is that of your ntlmrelayx host, second IP should be the site server:
Next, we can confirm with sccmhunter that we have SCCM Full Administrator permissions and thus are part of the local SMS admins group on the site server:
What can we do with Full Administrator permissions?
The "Full Administrator" security role is granted all permissions in Configuration Manager for all scopes and all collections. An attacker with this privilege can execute arbitrary programs on any client device that is online as SYSTEM, the currently logged on user, or as a specific user when they next log on. They can also leverage tools such as CMPivot and Run Script to query or execute scripts on client devices in real-time using the AdminService or WMI on an SMS Provider. See EXEC-1,2 etc.
Recommendation:
Use Extended Protection for Authentication (EPA) on ADCS and site databases.
TAKEOVER-2 - Hierarchy takeover via NTLM coercion and relay to SMB on remote site database
Similar to Takeover-1 but now we target SMB instead of MSSQL.
Start ntlmrelay to dump the SAM of the database server or use -socks
option:
Coerce the site server computer account against site database (<ntlmrelayx IP>
<site server IP>
):
With -socks
option:
Then dump SAM or get a shell:
At this point, if the service is running in the context of LocalSystem, you can access the database to grant your domain account the Full Administrator role (see TAKEOVER-1 SQL query). If the database is running in the context of a domain service account, further steps are needed:
In your shell check who is running sqlservr.exe:
Get the SQL service domain account password:
Sync time if needed (Clock skew too great error):
Get TGT for sqlsccmsvc:
Get SPNs:
Then S4U:
Once the ticket is obtained, it needs to be referenced with the following variable:
Get access to the site database (MSSQL):
Then give your low priv user Full administrator permissions (see the SQL query from Takeover-1).
TAKEOVER-3 - Hierarchy takeover via NTLM coercion and relay to HTTP on AD CS
When available, SCCM uses public key infrastructure (PKI) for authentication and authorization. While not required, administrators may choose to deploy Active Directory Certificate Services (AD CS) to support SCCM's various certificate requirements rather than use self-signed certificates. AD CS is home to its own misconfigurations; particularly ESC8. In short, the certificate enrollment web interface is vulnerable to NTLM relaying. An attacker may coerce NTLM authentication from a coercion target and relay to the AD CS enrollment web service to enroll in and acquire a valid certificate template on behalf of the target. The template can then be used to escalate to "Full Administrator" in SCCM by impersonating the coerced target.
Check if ADCS is vulnerable to ESC8:
And NTLM authentication is enabled (check on all CA's):
Start ntlmrelayx and target the URL of the certificate enrollment web interface:
Next use Petitpotam (or Coercer) to coerce the site server. The SMB connection is relayed to the ADCS enrollment service to request a certifcate for the coerced target:
Use the pfx to get the NTLM hash for the site server computer account:
Authenticate to an SMS Provider as the site server and grant a user the Full Administrator role:
TAKEOVER-4 - Hierarchy takeover via NTLM coercion and relay from CAS to origin primary site server
This requires a CAS (Central Administration Site) which can only be found in a multi-site hierarchy (not in the SCCM lab). See documentation for the details.
TAKEOVER-5 - Hierarchy Takeover via NTLM coercion and relay to AdminService on remote SMS Provider
Requires a remote SMS provider because you cannot relay the site server to itself (not in the SCCM lab). See documentation for the details.
TAKEOVER-6 - Hierarchy takeover via NTLM coercion and relay to SMB on remote SMS Provider
Requires a remote SMS provider because you cannot relay the site server to itself (not in the SCCM lab). See documentation for the details.
TAKEOVER-7 - Hierarchy Takeover via NTLM coercion and relay to SMB between primary and passive site servers
Requires an active and passive site server (not in the SCCM lab). See documentation for the details.
TAKEOVER-8 - Hierarchy takeover via NTLM coercion and relay HTTP to LDAP on domain controller
This is a good alternative if SMB signing is enabled on the site server.
Check if LDAP signing and/or binding are used:
Check if you can create computer accounts. MachineAccountQuota should be more than 0 (default is 10):
Check if webdav is enabled on the site server:
On the attacker machine we first start ntlmrelayx and target LDAP on any DC (there is also support for ldaps://, however if the domain requires ldaps, ntlmrelayx will auto switch this for you). This command will automatically add computer account to perform the RBCD attack. It is also possible to do that step manually by first adding a computer account with the impacket-addcomputer
tool and adding --escalate-user <COMPUTER$>
to the ntlmrelayx command:
Next, we add a DNS record hackdef
to the domain which points to our attacker machine (10.2.10.99). Authenticated users can add DNS records by default:
This hostname is needed for the web client authentication (webdav). Specifying an IP in the following PetitPotam command won't work
We coerce the site server (10.2.10.15) with a tool such as Petitpotam/printerbug or Coercer:
LYQVFVGE$
can now impersonate users on SCCM-SITESRV$ via S4U2Proxy. Take note of the created computer account and its password.
Request a silver ticket for the domainadmin
user which is only valid for SCCM-SITESRV.ludus.domain
. It is possible to specify other SPNs than CIFS (needed for Psexec) such as HOST and HTTP for WinRM. Make sure that the domain admin you target is enabled and not part of the protected users group! The password is the one for the computer account:
If you get a clock skew error:
Export the ticket:
Use the ticket with tools such as netexec to retrieve the site server computer account NTLM hash (SCCM-SITESRV$):
This NTLM hash can be used to dump all credentials from the site database, see the CRED-5 section.
Recommendation:
- Require LDAP signing and binding.
- Disable the webclient on site servers.
- Make sure that normal users can not add computer accounts by setting MachineAccountQuota to 0.
- Do not allow authenticated users to add DNS records.
TAKEOVER-9 - Crawl site database links configured with DBA privileges
There are no other MSSQL servers in the SCCM lab and the documentation is missing for this one. However, I'm assuming that Takeover 9 is meant to describe how you can abuse MSSQL links configured with DBA privileges. If such a link is configured with the site database, it would allow for command execution on the site database MSSQL server.