SQL Server Instance
Instance
get-sqlinstancelocal
get-sqlinstancedomain
Get-SQLConnectionTest -Instance "srv-1.red.com,1433"Server Info
get-sqlserverinfo -instance "redsql\sqlexpress"Privilege Enumeration
Sysadmin logins/users
Get-SQLQuery -Instance 'red.com,1433' -query "select name from master..syslogins where sysadmin=1;"User/Login can be impersonated
Get-SQLQuery -Instance 'red.com,1433' -query "SELECT distinct b.name FROM sys.server_permissions a INNER JOIN sys.server_principals b ON a.grantor_principal_id = b.principal_id WHERE a.permission_name = 'IMPERSONATE';"Linked Servers
Not all users can see all links
select * from master..sysservers; (SQL Query)
exec sp_linkedservers; (SQL Query)
get-sqlserverlinkcrawl -instance "cywebdw\sqlexpress" -username webapp11 -password 89543dfGDFGH4d (PowerUpSQL Query)
get-sqlquery -instance "CYWEBDW\SQLEXPRESS" -query "select * from openquery(""m3sqlw.red.local"",'select * from master..sysservers')" (PowerUpSQL Open Query)Value of xp_cmdshell
Enable xp_cmdshell
xp_cmdshell Meterpreter Shell
Enable Rpcout
Privilege Escalation is not necessary to be done immediately
DA or some specific domain users have admin privilege over current host
Password/Hash reuse
Similar machines could share the same password/hash
SQL01 and SQL02
SQL01 and File01
Last updated