mssql

Forest Trusts MSSQL Abuse

Methodology

  1. Check the SPN's

  2. Check which SPN's you have access to

  3. Check the Privileges you have of the above filtered SPN's

  4. Keep note of the Instance-Name, ServicePrincipalName and the DomainAccount-Name

  5. If you find any service with higher privileges continue below to abuse it

Powershell

[!INFO] Remember to follow the Powershell methodology

PowerUpSQL

For MSSQL and PowerShell hackery, lets use PowerUpSQL

Import-Module .\PowerupSQL-master\PowerupSQL.psd1

. Enumerate SPN

Get-SQLInstanceDomain

2. Check Access

3. Check Privileges / Gather Infromation

Methodology

  1. Check the SQL Server link

  2. Keep note if you have link to any other database in DatabaseLinkName

  3. If SysAdmin:0 means that we will not be allowed to enable xp_cmdshell

  4. Keep on enumerating and check all the linked databases you have access to

  5. Now we can try to execute commands through out all the linked databases found

Enumerate MSSQL links:

Crawl MSSQL links:

Execute command where xp_cmdshell enabled:

Reverse shell on specific MSSQL instance with disabled logging, AMSI bypass and powercat.ps1: https://github.com/besimorhino/powercat/blob/master/powercat.ps1

Enable RPC Out and xp_cmdshell:

Extra Commands

Impersonate an user

Basic SQL Server queries for DB enumeration

Also works with Get-SQLServerLinkCrawl

Last updated