MSSQL
Microsoft SQL Server isn’t just a place data lives — it’s a foothold on a Windows box. Weaksacredentials get you in, andxp_cmdshelllets you run operating-system commands straight from a SQL prompt. A database login becomes code execution on the host.
Protocol: TCP · Port: 1433
What Is MSSQL?
Microsoft SQL Server (MSSQL) is Microsoft’s SQL-based relational database management system. Versions run on Linux and macOS, but you’ll most often meet MSSQL on Windows targets — which is what makes it so valuable: it ties directly into Windows authentication and can execute OS commands.MSSQL Clients
SQL Server Management Studio (SSMS) ships with the MSSQL install package or can be downloaded separately. Because it’s a client application, it can be installed on any admin’s or developer’s workstation — not just the database server.Default System Databases
MSSQL ships with system databases that reveal the structure of everything hosted on the server:Default Configuration
When an admin installs MSSQL to be network-accessible, the service typically runs asNT SERVICE\MSSQLSERVER.
Authentication set to Windows Authentication means the underlying Windows OS processes the login — checking the local SAM database or the domain controller (Active Directory) before granting access to the DBMS. That’s the link that makes MSSQL a stepping stone into the wider Windows environment.
Dangerous Settings
Worth investigating on any MSSQL instance:Footprinting the Service
MSSQL Clients for Pentesters
Beyond SSMS, many clients can connect to MSSQL:mssql-cli- SQL Server PowerShell
- HeidiSQL
- SQLPro
- Impacket’s
mssqlclient.py
mssqlclient.py is usually the most useful — Impacket ships on most pentest distros by default. Find it with:
Nmap
MSSQL listens on TCP 1433. The MSSQL NSE scripts pull a lot at once — hostname, instance name, version, and whether named pipes are enabled:Metasploit mssql_ping
Themssql_ping auxiliary scanner adds more footprinting detail:
Connecting with mssqlclient.py
With guessed or recovered credentials, connect and interact using T-SQL (Transact-SQL). Thewindows-auth flag uses Windows authentication:
sysobjects):
Command Execution with xp_cmdshell
This is what sets MSSQL apart. Withsa (or sufficient privileges), the xp_cmdshell stored procedure runs OS commands as the SQL service account. It’s disabled by default, but you can enable it from the SQL prompt:
Quick Reference
The footprinting flow: nmap
ms-sql-* for instance/version → try sa with weak/default creds → connect with mssqlclient.py → enumerate databases → enable and abuse xp_cmdshell for command execution on the host.
Next: Oracle TNS — the Oracle listener, SID enumeration, and database privilege escalation.