MSSQL Attacks
Setup
Load the SQL-BOF Aggressor script:
Go to Cobalt Strike > Script Manager
Click Load
Select
C:\Tools\SQL-BOF\SQL\SQL.cna
Enumeration
Find MSSQL Servers via LDAP
ldapsearch (&(samAccountType=805306368)(servicePrincipalName=MSSQLSvc*)) --attributes name,samAccountName,servicePrincipalName
# Example output:
name: MSSQL Service
sAMAccountName: mssql_svc
servicePrincipalName: MSSQLSvc/ilf-db-1.inlanefreight.local:1433, MSSQLSvc/ilf-db-1.inlanefreight.local
retrieved 1 results totalServer Information
Impersonate User with Access
xp_cmdshell
Direct command execution with output.
Check if Enabled
Enable
Execute Commands
Disable (Cleanup)
OLE Automation Procedures
Command execution without output - use for reverse shells.
Check if Enabled
Enable
Execute Reverse Shell
Generate encoded PowerShell command:
Execute:
Disable (Cleanup)
SQL CLR (Common Language Runtime)
Execute .NET assemblies within SQL Server.
Check if Enabled
Create CLR Assembly
Create new Class Library (.NET Framework) in Visual Studio
Project name:
MyProcedure
Add
smb_x64.xthread.binas embedded resourceUse the following code:
Execute CLR DLL
Disable (Cleanup)
Linked Servers
Pivot through SQL Server links.
Enumerate Links
Check Identity on Linked Server
Enable RPC for Linked Server
Execute CLR via Linked Server
SQL Server Privilege Escalation
Escalate from SQL service account to SYSTEM using potato attacks.
Check Token Privileges
Find Writable Directory
Upload Payload
Execute SweetPotato
Quick Reference
xp_cmdshell
✅ Yes
Quick command execution
OLE Automation
❌ No
Reverse shell payload
CLR
❌ No
Beacon injection
Linked Servers
Varies
Pivot to other SQL servers
sql-info
Server information
sql-whoami
Current user context
sql-query
Execute raw SQL
sql-enablexp / sql-disablexp
Toggle xp_cmdshell
sql-xpcmd
Execute via xp_cmdshell
sql-enableole / sql-disableole
Toggle OLE Automation
sql-olecmd
Execute via OLE
sql-clr
Execute CLR assembly
sql-disableclr
Disable CLR
sql-links
Enumerate linked servers
sql-checkrpc / sql-enablerpc
Toggle RPC
Last updated