MSSQL server

Background


MSSQL is a relational database management system developed by microsoft. It uses SQL to store and retrieve data. It is widely used for various applications.

MSSQL Local Authentication

When using Local Authentication, logins are created in SQL server that aren't based on windows accounts. In this mode of authentication, both the username and the password are created by SQL Server and are stored in SQL Server. Users connecting with Local Auth must provide their credentials every time they login.

MSSQL Windows Authentication

When a user connects through a windows user account, SQL Server validates the username and the password with the windows principal token present in the OS. In simple words, Windows validates the authentication. SQL Server doesn't perform the identity validation, it trusts the credentials provided by Windows. Windows Authentication uses NTLM or kerberos. In windows authentication, logins are based on windows user accounts.

Checking Access


User and password

# with NetExec (Windows Auth)
nxc mssql $TARGETIP -u $USER -p $PASSWORD

# with NetExec (Local Auth)
nxc mssql $TARGETIP -u $USER -p $PASSWORD --local-auth

# with impacket-mssqlclient (USE SQL Auth)
mssqlclient.py $DOMAIN/$USER:$PASSWORD@$IP

# with impacket-mssqlclient (USE Windows Auth)
mssqlclient.py $DOMAIN/$USER:$PASSWORD@$IP -windows-auth

Kerberos authentication

User Impersonation

xp_dirtree

This file has logs from the SQL server

Database Enumeration;

Cmd injection to RCE

so in this we can’t use normal powershell payload

why because of firewall so in this we have to use custom shell

for that we we will do this first

this is power shell obfuscation

so now how to use this

RID BruteForce

Abusing Linked Servers:

Read Local Files:

Last updated