Using Impacket to Exploit Misconfigured Microsoft SQL Server

· Original article ↗

Summary

A penetration-testing walkthrough shows how weak SQL credentials, IMPERSONATE permissions, or linked servers can lead to SQL Server sysadmin access, OS command execution, and file uploads, and outlines defenses.

Key points

  • The walkthrough uses Impacket’s mssqlclient.py against a Windows Server running Microsoft SQL Server 2016.
  • It demonstrates database and login enumeration, including identifying IMPERSONATE permissions on the sa login.
  • It shows how impersonation or a linked server configured with sa can enable sysadmin access.
  • With sysadmin privileges, xp_cmdshell can run OS commands; the walkthrough also demonstrates directory enumeration with xp_dirtree.
  • The file-upload example uses xp_cmdshell and certutil to transfer and verify a file.
  • Recommended defenses include securing or disabling sa, removing unnecessary IMPERSONATE permissions, restricting linked servers, disabling xp_cmdshell, auditing activity, and segmenting SQL Server networks.

Article Details

Topic
MSSQL misconfiguration exploitation, including privilege escalation and OS command execution, with defensive hardening recommendations.

Vendors

Products

Tools

Related Articles