Reconnaissance
Let’s start by scanning the machine to find out which ports are open. We will use Nmap for this.
We can see that there are several ports open, but let’s focus on port 80 http
for now. Don’t forget to add <ip> solarlab.htb
to /etc/hosts
file.
The web page doesn’t seem to have much information, but we can see on port 6791
there is a redirect to report.solarlab.htb
. Let’s add this to our /etc/hosts
file and visit the page.
The page requires us to login, but we don’t have any credentials yet.
Moving on to another port, now with 139
, which is well known for SMB
. Let’s use smbclient
to list the shares.
From the above, we can see that the port 139
is sharing a folder named Documents
. After accessing the folder, there are 2 files, details-file.xlsx
and old_leave_request_form.docx
. Let’s see what they contain.
This file contains valuable information about the users and their passwords.
Username | Password |
---|---|
blake.byte | ThisCanB3typedeasily1@ |
AlexanderK | danenacia9234n |
ClaudiaS | dadsfawe9dafkn |
I tried all of them but none worked. But we can see that the username pattern is different for blake.byte
, so let’s try to change it to blakeb
to match the pattern.
And voila! We are in.
There are 4 options on the page, but I am not sure what kind of web service it is. I have tried the Leave Request
option, and it generated a PDF
file. I downloaded the file and take a look inside, but there is nothing interesting. So I tried to investigate further using exiftool
to see if there is any metadata.
From the above, we can see that the Producer
is ReportLab PDF Library
. I tried to search for any vulnerabilities related to this library, and I found this CVE-2023-33733 which allows an attacker to execute arbitrary code via supplying a crafted PDF file.
That’s enough for the reconnaissance phase. Let’s move on to the exploitation phase.
Exploitation
I will use this exploit to exploit the vulnerability. But there is a problem, the inputs are characters limited, so I need to find a way to bypass this limitation. I used Burp Suite
to intercept the request and modify them, but it didn’t work for 3 other options. The only possible option is Leave Request
with the Contact Phone Number
field.
If the exploit is successful, it will create a file named exploited
in the /tmp
directory and the text exploit
will be displayed in red color.
The exploit was successful, we can see the text exploit
in red color. Now let’s replace the touch /tmp/exploited
with reverse shell from this website https://reverse-shell.sh/.
The reverse shell was successful and we can get the user.txt
flag from C:\Users\blake\Desktop
.
Privilege Escalation
I checked the C:\Program Files
directory and found a program named Openfire
, a quick search on the internet shows that this program running on port 9090
and 9091
. I ran netstat -ano
to check.
But I cannot access because the web service is running locally. So I have to forward it using chisel. The tool comes with Kali Linux by default.
The version of Openfire is 4.7.4
and I found this exploit which allows an attacker to retrieve the JSESSIONID
cookie and add a new admin user.
In this repository, there is another exploit that allows an attacker to add a plugin to the Openfire server. Which can be used to execute code on the target machine.
From the Plugins
tab, I added the openfire-management-tool-plugin.jar
file.
After adding the plugin, we can find the tool in the Server/Server Settings
tab and at the bottom of the sidebar.
The password is 123
, here comes the web shell.
However, after testing around, I found lots of limitations, so I decided to get the reverse shell using the PowerShell #3 Base64
payload from revshell
I did some enumeration and found a database script file named openfire.script
in the C:\Program Files\Openfire\embedded-db
directory. I found the admin
encrypted password and hash key.
This script can be use to decrypt the password.
The decrypted password is ThisPasswordShouldDo!@
, but where can we use this password? this is the password for the admin
user, maybe we can use it to login using WinRM
if it is enabled.
Found that the port 5985
is open, which is the default port for WinRM
. Before I can use Evil-WinRM
, we need to forward the port using chisel
cause the port is only listening on localhost
.
And we are in! I got the root.txt
flag from C:\Users\Administrator\Desktop
.