Trust Abuse - MSSQL Servers
MS SQL servers are generally deployed in plenty in a Windows domain.
SQL Servers provide very good options for lateral movement as domain users can be mapped to database roles.
For MSSQL and PowerShell hackery, lets use PowerUpSQL https://github.com/NetSPI/PowerUpSQL
Discovery (SPN Scanning)
Check Accessibility
Gather Information
Database Links
A database link allows a SQL Server to access external data sources like other SQL Servers and OLE DB data sources.
In case of database links between SQL servers, that is, linked SQL servers it is possible to execute stored procedures.
Database links work even across forest trusts.
Searching for Database Links:
Enumerating Database Links Manually
Openquery() function can be used to run queries on a linked database
Enumerating Database Links
Executing Commands
On the target server, either xp_cmdshell should be already enabled; or
If rpcout is enabled (disabled by default), xp_cmdshell can be enabled using:
Use the -QuertyTarget parameter to run Query on a specific instance (without -QueryTarget the command tries to use xp_cmdshell on every link of the chain)
Last updated