SQL Server
Fingerprint SQL Server, test authentication and distinguish enumeration from xp_cmdshell execution.
SQL Server listens on 1433/TCP by default. A reachable port does not establish
which authentication mode the instance accepts or whether the sa account is
still enabled.
Detection
nmap -sV -p 1433 --script ms-sql-info <IP>Connection
The following examples test an empty password for sa; this is not a guaranteed
default. SQL authentication must be enabled and the account usable.
# Local authentication
nxc mssql <SUBNET> -u sa -p '' --local-auth
# Command execution when available
nxc mssql <SUBNET> -u sa -p '' --local-auth -x whoamiThe mssqlclient.py tool also allows this type of test:
# MSSQL authentication
mssqlclient.py -db <DB_NAME> <USER>:<PASSWORD>@<IP>
# Windows authentication
mssqlclient.py -db <DB_NAME> <USER>:<PASSWORD>@<IP> -windows-authXP_Cmdshell
enable_xp_cmdshell changes the server configuration and requires suitable
privileges. The resulting command runs as the SQL Server service or configured
proxy account, not necessarily SYSTEM.
enable_xp_cmdshell
xp_cmdshell $CMDUnlike ms-sql-info, the NSE script
ms-sql-xp-cmdshell
executes an OS command. Do not include it in a routine detection scan.
Provenance and confidence
- Version
- 2
- Sources reviewed
- 2026-11-23
- Confidence
- medium — Legacy RTFM; v2 editorial review on 2026-11-23 separates detection from execution and configuration changes. Nmap xp_cmdshell documentation consulted; no SQL Server test.
Also searched as: mssql, sql server, xp_cmdshell, 1433/tcp, base de données