mssql module generates SQL queries designed for use in NTLM relay attacks against SCCM site databases. By executing these queries against the SCCM database, attackers can elevate domain users to SCCM administrative roles, effectively granting full control over the SCCM infrastructure.
Attack Overview
The MSSQL privilege escalation attack works by:- User SID Resolution: Converting the target username to its corresponding SID
- Query Generation: Creating SQL statements to add the user to SCCM administrative roles
- Role Assignment: Granting Full Administrator permissions with appropriate scope access
- RBAC Configuration: Setting up Role-Based Access Control permissions
This attack leverages SCCM’s Role-Based Access Control (RBAC) system to grant administrative privileges. The generated queries can be used in NTLM relay attacks against SQL servers hosting SCCM databases.
SCCM Role-Based Access Control
Understanding SCCM RBAC
SCCM uses a sophisticated RBAC system with three key components:
- Administrative Users: Users or groups with SCCM permissions
- Security Roles: Predefined permission sets (Full Administrator, etc.)
- Security Scopes: Define what objects the user can manage
Prerequisites
Requirements
- Valid Active Directory credentials for SID resolution
- Target user account to elevate privileges for
- SCCM site code for the target environment
- NTLM relay capability against SCCM SQL servers
- Network access to domain controller for SID resolution
Command Syntax
Parameters
Required Parameters
Required Parameters
| Parameter | Description | Example |
|---|---|---|
-d | Target domain name | internal.lab |
-dc-ip | Domain controller IP or FQDN | 10.10.100.100 |
-tu | Target user to grant SCCM admin privileges | lowpriv |
-sc | SCCM site code for privilege assignment | LAB |
Authentication Options
Authentication Options
| Parameter | Description | Example |
|---|---|---|
-u | Username for authentication | administrator |
-p | Password for authentication | P@ssw0rd |
-hashes | NT:LM hash for authentication | aad3b435b51404ee:5fbc3d5fec8206a30f4b6c473d68ae76 |
-k | Use Kerberos authentication | |
-no-pass | Don’t prompt for password | |
-aes | AES key for Kerberos (128/256 bits) | |
-ldaps | Use LDAPS instead of LDAP |
Query Generation Options
Query Generation Options
| Parameter | Description | Use Case |
|---|---|---|
-stacked | Generate single stacked query | NTLM relay attacks requiring single query execution |
-debug | Enable verbose logging | Troubleshooting and detailed output |
Usage Examples
Individual Query Generation for Step-by-Step Execution
Individual Query Generation for Step-by-Step Execution
Generate separate SQL queries for manual execution or multi-step NTLM relay attacksExpected Output:
Individual queries require interactive input to provide the AdminID returned from the first query. This approach is useful for manual SQL execution or when you have interactive access to the database.
Stacked Query Generation for NTLM Relay Attacks
Stacked Query Generation for NTLM Relay Attacks
Generate a single SQL statement combining all privilege escalation stepsExpected Output:
Understanding the SQL Queries
RBAC Database Tables
The generated queries modify three key SCCM database tables:
- RBAC_Admins: Stores administrative users and their basic information
- RBAC_ExtendedPermissions: Links admins to roles and scopes
- Site-specific scope assignments: Grants access to different SCCM objects
Query Breakdown
Query Breakdown
1. RBAC_Admins Table Insert
- Adds the target user as an SCCM administrative user
- Converts domain\username format for SCCM compatibility
- Uses the resolved SID for proper identification
SMS0001R: Full Administrator role (highest privileges)SMS00ALL: All Systems scope (access to all objects)SMS00001: All Systems Collection scopeSMS00004: Default scope for collections
- Each permission links an admin to a role within a specific scope
- Multiple scopes ensure comprehensive access across the SCCM environment
Attack Integration
NTLM Relay Prerequisites
Required for Attack Success:
- SMB signing disabled on SQL servers
- SCCM SQL server accessible via NTLM
- Account with NTLM relay capability
- Network position for man-in-the-middle attacks
Post-Exploitation Benefits
Gained Capabilities:
- Full SCCM administrative access
- Software deployment to all systems
- Operating system deployment control
- Access to all SCCM credentials and secrets
Verification and Testing
Confirming Privilege Escalation Success
Confirming Privilege Escalation Success
After Query Execution:
- Log into SCCM console with elevated account
- Verify administrative role assignment in RBAC settings
- Test software deployment capabilities
- Confirm access to administrative functions
- Navigate to
Administration > Security > Administrative Users - Verify the target user appears with Full Administrator role
- Test creating and deploying applications or task sequences
Next Steps
SCCM Administration
Leverage Full Access:
- Deploy malicious software packages
- Extract additional credentials
- Lateral movement via client push
- Operating system deployment abuse
DPAPI Extraction
Use SCCM admin access to extract secrets from client systems
Persistence
Maintain Access:
- Create additional admin accounts
- Deploy persistent backdoors
- Establish C2 infrastructure
- Document infrastructure for future access