MSSQL enumeration with nmap and netexec
Target TCP/1433 first. Confirm instance metadata, pull NTLM host/domain hints, validate creds fast, then enumerate accessible DBs/tables/config with authenticated scripts or an interactive client.
Service discovery and instance metadata (no auth)
What you expect:
Instance name, version/build, sometimes service details.
If this returns multiple instances, key off the instance name and port in later NSE script args.
SQL Browser discovery (UDP/1434). Useful for named instances and mapping instance → port.
NTLM info leak over TDS (domain, hostname, OS build hints) when NTLM is enabled:
Quick auth checks (no creds / weak creds)
Check if sa accepts empty password:
Interpretation:
Any positive hit is immediate high impact. Move to authenticated enumeration with that credential set.
Credential validation and controlled spraying (nxc)
Single credential set:
Spray lists:
Domain context (Windows auth paths tend to matter for MSSQL):
What to do with results:
A clean auth success means you can switch to interactive query-based enumeration immediately.
If auth succeeds but actions fail later, it’s usually permission boundary, not connectivity.
Notice
CrackMapExec is legacy for most workflows now. Use nxc (NetExec) for the same “one binary, many protocols” style.
Authenticated enumeration with Nmap NSE
Use authenticated NSE when you want a quick, structured snapshot without fully logging in interactively.
Config + linked servers + DB list signals:
Which DBs this user can access:
Enumerate tables (permission dependent, can be noisy):
Dedicated Admin Connection (DAC) port discovery via SQL Browser:
High-risk capability checks
These are privilege-dependent and can cross into exploitation. Keep them scoped and expect failures unless you’re sysadmin.
Hash dumping requires high DB privileges and is high signal if it works:
Interpretation:
xp_cmdshellsuccess means you have OS-level execution via SQL Server context. That’s no longer “enumeration” work.Hash dump success means you’ve got a credential pipeline. Shift to cracking/offline validation and lateral movement planning.
Interactive enumeration (impacket-mssqlclient, sqsh)
Impacket is usually the fastest for Windows-auth flows.
Windows auth:
SQL auth:
sqsh (handy for quick querying from Linux):
What you do next:
Confirm who you are and what server role you landed in.
Enumerate DBs, then focus on app-owned DBs and anything with secrets/config tables.
High-value SQL queries
Identity and privilege context:
SELECT SYSTEM_USER;
SELECT USER_NAME();
SELECT IS_SRVROLEMEMBER('sysadmin') AS is_sysadmin;
SELECT name, type_desc, is_disabled FROM sys.server_principals ORDER BY type_desc, name;
List databases:
SELECT name FROM master..sysdatabases;
Tables in current database:
SELECT TABLE_SCHEMA, TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE='BASE TABLE'
ORDER BY TABLE_SCHEMA, TABLE_NAME;
Database users/roles (current DB):
SELECT name, type_desc
FROM sys.database_principals
ORDER BY type_desc, name;
Linked servers (common pivot surface):
EXEC sp_linkedservers;
Interpretation that changes decisions:
is_sysadmin = 1means you can usually enable/abuse server-level features (xp_cmdshell, agent jobs, linked server execution). That’s an exploitation page.Linked servers present an immediate pivot graph. Enumerate their security context and whether RPC is enabled next.
References
-
Nmap ms-sql-info NSEnmap.org/nsedoc/scripts/ms-sql-info.html (opens in new tab)
Instance/version discovery behavior
-
Nmap ms-sql-ntlm-info NSEnmap.org/nsedoc/scripts/ms-sql-ntlm-info.html (opens in new tab)
NTLM disclosure fields (host/domain/OS hints)
-
Nmap ms-sql-empty-password NSEnmap.org/nsedoc/scripts/ms-sql-empty-password.html (opens in new tab)
Empty password check for sa
-
Nmap ms-sql-config NSEnmap.org/nsedoc/scripts/ms-sql-config.html (opens in new tab)
Config/DB/linked server enumeration
-
Nmap ms-sql-hasdbaccess NSEnmap.org/nsedoc/scripts/ms-sql-hasdbaccess.html (opens in new tab)
Per-user DB access enumeration
-
Nmap ms-sql-dac NSEnmap.org/nsedoc/scripts/ms-sql-dac.html (opens in new tab)
DAC port discovery via SQL Browser
-
Nmap ms-sql-dump-hashes NSEnmap.org/nsedoc/scripts/ms-sql-dump-hashes.html (opens in new tab)
Hash dumping requirements/output
-
nxc protocol usage patterns
Was this helpful?
Your feedback helps improve this page.