ARCHETYPE

10.10.10.27

Personal Remark: I thought this box was more challenging than noted. I had plenty of problems getting a successful reverse shell since there was some sort of defender software stopping certain functionalities. I also struggled to get a reverse shell that was interactive and stable. Ignoring these points, it also required knowledge of existing libraries like Impacket.

Recon

First let's check if the box in reachable using ping.

ping 10.10.10.27

It is reachable so nmap the target and get all its open information.

nmap-auto 10.10.10.27 all

The most notable information here is the existence of a smb service as noted by the Windows Server 2019 Standard 17763 under the smb-os-discovery. This pairs up with the open 139 and 445 ports. This leads me to believe this box has existent samba vulnerabilities. There is also a known port for SQL servers, 1433, which uses the Microsoft SQL Server 2017, so there is a possibility this could be useful too.

Enumeration

nmap -Pn -T4 --script smb-vuln* -p 139,445 10.10.10.27

We found one likely vulnerability: CVE-2008-4250. This is a vulnerability that allows remote attackers to execute arbitrary code via a crafted RPC request that triggers an overflow during path canonicalization. Let's find a usable exploit that we can follow. This path ended up being a dead end.

nmap -Pn -T4 --script=smb-enum-shares.nse -p 445 10.10.10.27

This shows that there are 4 shares on the smb service:

  • ADMIN$

  • C$

  • IPC$

  • backups

Also, the share \\10.10.10.27\IPC$ has READ/WRITE privileges as anonymous and the current user. It's possible to log in to that share using the following smbclient command: smbclient //10.10.10.27/IPC$ -U guest. The share \\10.10.10.27\backups also has READ access. Logging into it with a similar command smbclient //10.10.10.27/backups -U guest shows me that there is a file in it. Get it with the command get prod.dtsConfig. It contains the following:

Exploitation

A dtsConfig file is an XML file used to apply property values to SQL Server Integration Services packages. So maybe it can log us into the SQL server. To access the server as a client, there is [Impacket](https://github.com/SecureAuthCorp/impacket) which is a collection of Python classes for working with network protocols. The specific script is [mssqlclient.py](https://github.com/SecureAuthCorp/impacket/blob/master/examples/mssqlclient.py). This can be found on the Kali box at "/usr/local/bin/" or in the "usr/share/doc/python3-impacket/examples" folder.

mssqlclient.py ARCHETYPE/sql_svc:M3g4c0rp123@10.10.10.27 -windows-auth

Within the mssql client, test the grounds:

Enabling the xp_cmdshell allows the execution of windows commands from the sql server. Using the command whoami shows that the logged in user is sql_svc. Doing a little searching shows the 'user.txt'.

An xp_cmdshell is great and all, but it's not a legit shell. That means the next step is gaining a legit shell. Powershell is a nice and easy way to create a reverse shell. Edit the listening host and port of the following script and execute it on the windows box:

To get it to execute on the windows box, do the following:

  1. Host the file on a python webserver: python -m SImpleHTTPServer 80

  2. Create a netcat listener on the host machine: nc -nvlp 9000

  3. Use powershell to execute it remotely:

If this went smoothly, the netcat listener should have caught a shell.

Privilege Escalation

The next step is to escalate to administrator. Searching through important files, credentials can be found in the powershell command history:

type c:\users\sql_svc\appdata\roaming\microsoft\windows\powershell\psreadline\consolehost_history.txt

Using another Impacket tool, [psexec.py](https://github.com/SecureAuthCorp/impacket/blob/master/examples/psexec.py), it's possible to login remotely through the open smb service.

Now that there's an interactive administrator shell, anything is possible! Navigating to the administrator folder shows root.txt.

Last updated