Skip to main content
Default Port: 1433/TCP MSSQL is Microsoft’s own database engine and shows up constantly in Windows-heavy environments, often running as a service account with far more privilege than the database itself needs. That combination, a database reachable over the network plus a privileged service account behind it, is what makes MSSQL one of the more reliable paths from “database access” to full domain compromise.

SQL Authentication

Username and password managed inside SQL Server itself, independent of Windows. The sa account is the built-in sysadmin here, and the one worth testing default and weak credentials against first.

Windows Authentication

Authenticates using the current domain session instead of a separate SQL login. Relevant once you’ve got a foothold on the domain rather than testing the service blind.
xp_cmdshell is the single most important feature on this page. If it’s enabled, or you have the privilege to enable it, you have OS-level command execution as the SQL Server service account, not just database access.

Connecting

The most common tool for interactive access, supports both authentication types and pass-the-hash.
Common default credentials worth trying before anything else: sa: (blank), sa:sa, sa:password, sa:Password123, sa:P@ssw0rd.

Recon and Instance Discovery

Before touching port 1433 directly, the SQL Server Browser service on UDP 1434 can reveal multiple named instances running on a single host, instances that might not be obvious from a TCP scan alone.
A single nmap command covering most of the initial enumeration in one pass, worth running early on any confirmed MSSQL target:

Manual Enumeration


Brute Forcing


Command Execution via xp_cmdshell

Enabling xp_cmdshell requires sysadmin privileges and is a loud, easily logged change. If it’s already enabled, skip straight to execution; only enable it yourself once you’re confident doing so is in scope.
Turn it back off once you’re done if stealth matters: EXEC sp_configure 'xp_cmdshell', 0; RECONFIGURE;

Getting a Shell

A PowerShell reverse shell runs directly through xp_cmdshell without needing to drop a file to disk first:
For a full Meterpreter session instead, generate a payload and pull it down through xp_cmdshell:
Using Metasploit’s HTA server as the delivery mechanism instead of a raw executable:

Reading and Writing Files

With xp_cmdshell already enabled, reading and listing files is just as easy through native commands:

Capturing the Service Account’s NTLM Hash

This is an active technique that intercepts authentication traffic. Confirm scope before running it, and remember that it captures the SQL Server service account’s hash, not a user’s.
xp_dirtree and related procedures will happily follow a UNC path, which forces the SQL Server service account to authenticate to whatever SMB server you point it at. Pointed at a listener you control, that’s a captured NetNTLMv2 hash.
Crack whatever Responder captures:

Impersonation

Impersonation lets a lower-privileged login temporarily act as a higher-privileged one, frequently sa, without ever needing that account’s password.

Linked Servers

A linked server is one MSSQL instance configured to query another. If the credentials stored for that link have higher privileges than your own, this is a direct privilege escalation path, and if the chain goes several servers deep, a lateral movement one too.
Command execution chains through linked servers the same way xp_cmdshell does locally, just wrapped in EXEC (...) AT:

Persistence

Creating logins or scheduled jobs are high-impact, easily detected changes to the target. Confirm scope explicitly covers this before going beyond enumeration and impersonation.

Metasploit Modules


Quick Reference Tools

Hackviser: MSSQL

Quick-reference pentesting guide for the MSSQL service.

HackTricks: MSSQL

Deeper breakdown of MSSQL enumeration and exploitation techniques.
xp_cmdshell, hash capture, and persistence are all high-impact actions capable of fully compromising the host. Confirm scope before going past read-only enumeration.