
HTB - Queier
Machine Info
Querier is a medium difficulty Windows box which has an Excel spreadsheet in a world-readable file share. The spreadsheet has macros, which connect to MSSQL server running on the box. The SQL server can be used to request a file through which NetNTLMv2 hashes can be leaked and cracked to recover the plaintext password. After logging in, PowerUp can be used to find Administrator credentials in a locally cached group policy file.
Enumeration
Scope
IP Address: 10.10.10.125
Nmap Scan
┌──(kali㉿kali)-[~/…/HackThebox/HTB/machines/Cascade]
└─$ nmap -p- --min-rate 10000 $ip -Pn
PORT STATE SERVICE REASON
135/tcp open msrpc syn-ack
139/tcp open netbios-ssn syn-ack
445/tcp open microsoft-ds syn-ack
1433/tcp open ms-sql-s syn-ack
5985/tcp open wsman syn-ack
┌──(kali㉿kali)-[~/…/HackThebox/HTB/machines/Queier]
└─$ nmap -p135,139,445,1433,5985 -sCV $ip -Pn -oN Nmap/script-scan
PORT STATE SERVICE VERSION
135/tcp open msrpc Microsoft Windows RPC
139/tcp open netbios-ssn Microsoft Windows netbios-ssn
445/tcp open microsoft-ds?
1433/tcp open ms-sql-s Microsoft SQL Server 2017 14.00.1000.00; RTM
|_ssl-date: 2024-07-11T13:38:17+00:00; +7s from scanner time.
| ms-sql-ntlm-info:
| 10.10.10.125:1433:
| Target_Name: HTB
| NetBIOS_Domain_Name: HTB
| NetBIOS_Computer_Name: QUERIER
| DNS_Domain_Name: HTB.LOCAL
| DNS_Computer_Name: QUERIER.HTB.LOCAL
| DNS_Tree_Name: HTB.LOCAL
|_ Product_Version: 10.0.17763
| ssl-cert: Subject: commonName=SSL_Self_Signed_Fallback
| Not valid before: 2024-07-11T13:34:28
|_Not valid after: 2054-07-11T13:34:28
| ms-sql-info:
| 10.10.10.125:1433:
| Version:
| name: Microsoft SQL Server 2017 RTM
| number: 14.00.1000.00
| Product: Microsoft SQL Server 2017
| Service pack level: RTM
| Post-SP patches applied: false
|_ TCP port: 1433
5985/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-server-header: Microsoft-HTTPAPI/2.0
|_http-title: Not Found
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
Host script results:
| smb2-security-mode:
| 3:1:1:
|_ Message signing enabled but not required
| smb2-time:
| date: 2024-07-11T13:38:13
|_ start_date: N/A
|_clock-skew: mean: 6s, deviation: 0s, median: 6sRPC Enumeration
SMB Enumeration
smbclient managed to get results but CME failed, The share Reports is not standard share, So let's explore it
I mount the share to my kali machine to explore it easily
Initial Access
Shell as reporting
I searched online for this file extension, and I found that It's Excel file macros enabled which contain visual basic script
I searched for a tool that can extract the script from xslm file and a found this one:

The macros script simply has a connection string to connect to database and execute some SQL query
So, the credentials are reporting:PcwTWTHRwryjc$c6, Let's connect to mssql database
Confirm access with CME
I tried these credentials against other protocols RPC, SMB but it didn't authenticate me although I have valid credentials
Shell as mssql-svc
One possible attack from mssql is to connect to remote smb server and get the hash of the service account of the database.
Start smb server and wait for the hash

Crack with hashcat
Authenticate with this credentials MSSQL-SVC:corporate568, I can see from CME that we have admin privileges over mssql instance
Connect to the database as that user
Confirm admin pivileges
I want to execute system command with xp_cmdshell but I need to enable it first
User Flag: a113d259fb6b81c18xxxxxxxxxxxxxxxxxx
Privilege Escalation
Path 1
The service account mssql-svc often has SeImpersonatePrivilege & SeAssignPrimaryTokenPrivilege privileges which can be used to escalate to SYSTEM account
We can use
RoguePotatoorPrintSpoofertools andnc.exeto execute this attack
First download them to the windows machine
Execute PrintSpoofer.exe with the following syntax and start nc listener on kali machine to receive connection back

Root Flag: 42be413e54f4658662xxxxxxxxxxxxxx
Path2
Get a shell to easily explore the system for possible escalation paths
Download PowerUp.ps1 which search for misconfigurations and weaknesses on the system
I downloaded RunasCs.exe tool to get a shell with another user - administrator - in my case
And get a shell as admin :)

Root Flag: 42be413e54f4658662xxxxxxxxxxxxxx
Last updated