MSSQL Credential Dump
SQL Server stores its own password hashes, linked server credentials, and proxy account secrets within the instance. Sysadmin access gives read access to all of these. Extracted hashes can be cracked offline or used to identify credential reuse across other services.
SQL Login Hashes — sys.sql_logins
The sys.sql_logins catalog view contains the password hash for every SQL Server authentication account. This requires sysadmin or VIEW SERVER STATE:
name password_hash is_disabled sa 0x02001E6E04C3B95C2FD6E6F4A1E3B9D2C5A8F7E0B... 0 app_user 0x0200A1B2C3D4E5F6... 0 backup_svc 0x0200... 1
The 0x0200 prefix indicates MSSQL 2012+ SHA-512 hashing. Older instances may show 0x0100 (SHA-1, MSSQL 2005/2008).
Extract the hash as a string for offline cracking:
Crack SQL Server Hashes with Hashcat
SQL Server 2012+ hashes use hashcat mode 1731. The input format is the hex string from CONVERT above, stripped of the 0x prefix:
Format for hashcat mode 1731: 0x0200<hash> — keep the full hex string including the prefix.
SA passwords are often left at default or set to a weak password matching the server's local admin. Even without cracking, confirming the SA password identifies an often-reused credential.
Linked Server Credentials
Linked server login mappings that use a fixed remote login store the password in encrypted form in the registry under HKLM\SOFTWARE\Microsoft\MSSQLServer\Providers. Mimikatz and impacket-secretsdump can decrypt these if you have SYSTEM access.
From within SQL Server, list the configured login mappings first:
Linked Server Local Login Is Self Mapping Remote Login SQL-PROD-02 NULL 0 sa ORACLE-DB NULL 0 app_oracle
Is Self Mapping = 0 with a remote login means a fixed credential is stored. The password is not readable via T-SQL — extract it from the registry or via secretsdump once you have OS-level SYSTEM access:
Linked server passwords appear in the secretsdump output under [*] Dumping MSSQL credentials.
SQL Server Agent Proxy Credentials
Agent proxy accounts allow SQL Agent jobs to run under specific Windows credentials. These are stored in DPAPI-encrypted credential objects:
proxy_name credential_name credential_identity BackupProxy BackupAcct CORP\backup_svc ReportingProxy ReportAcct CORP\rpt_reader
The plaintext password is not accessible via T-SQL. Retrieve it via the Windows Credential Manager or DPAPI, which requires SYSTEM access. See Windows Token and Credential Harvesting for the DPAPI extraction workflow.
Credential Objects — sys.credentials
Service master key-encrypted credential objects store credentials used by BACKUP, OPENROWSET, and external operations:
name credential_identity create_date S3BackupCred AKIAIOSFODNN7EXAMPLE 2023-06-01 AzureBlobCred storageaccount 2023-08-15
credential_identity often reveals the username or access key ID. The secret is not accessible in plaintext via T-SQL — extraction requires registry access with SYSTEM rights.
Search Agent Jobs for Embedded Credentials
SQL Agent jobs frequently contain PowerShell or T-SQL with embedded connection strings or credentials passed as arguments:
Pay particular attention to PowerShell subsystem jobs and CmdExec jobs — these often pass credentials as plain arguments that appear verbatim in the command column.
References
-
Microsoft — sys.sql_loginslearn.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-sql-logins-transact-sql (opens in new tab)
SQL Server auth account catalog including password hashes
-
Hashcat — MSSQL modeshashcat.net/wiki/doku.php?id=hashcat (opens in new tab)
mode 1731 for MSSQL 2012+, mode 132 for MSSQL 2005/2008
-
Microsoft — sp_helplinkedsrvloginlearn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-helplinkedsrvlogin-transact-sql (opens in new tab)
linked server login mapping enumeration
Was this helpful?
Your feedback helps improve this page.