πŸ“ΈCCTV

https://app.hackthebox.com/machines/CCTV

HTB CCTV β€” Full Write-up


1) Recon

Nmap

Open ports:

  • 22/tcp SSH (OpenSSH 9.6p1 Ubuntu)

  • 80/tcp HTTP (Apache 2.4.58)

Web app on /zm identified as ZoneMinder.

Added host entry:


2) Initial Access to ZoneMinder

Default credentials worked on API login:

From API responses:

  • ZoneMinder version: 1.37.63

  • API version: 2.0


3) SQL Injection in ZoneMinder Request Endpoint(CVE-2024-51482)

Vulnerable endpoint:

tid confirmed as time-based blind SQLi.

Working sqlmap extraction command:

Extracted hash for mark:

Cracked with rockyou (hashcat -m 3200):

SSH login:


4) Post-Login Enumeration as mark

  • sudo -l: no sudo rights.

  • Found second user home: /home/sa_mark (not accessible by mark).

  • No user.txt in /home/mark.

Local service discovery :

From the full local listener list, an internal-only web service was identified:

  • 127.0.0.1:8765 listening (localhost-only)

Service details:

  • motionEye 0.43.1b4

  • motioneye.service running as root

  • Motion control interface also local on 127.0.0.1:7999

/etc/systemd/system/motioneye.service:


5) motionEye Pivot β†’ Root RCE

Why this worked

motionEye writes motion config values used by motion. The picture_filename / snapshot_filename fields were injectable and executed in shell context when triggering snapshot actions.

Trigger path used

Set payload through local motion control API (7999) and trigger snapshot:

Listener:

Received shell as root@cctv.


6) Flags

From root execution context:

  • User flag (/home/sa_mark/user.txt):

  • Root flag (/root/root.txt):


7) Attack Chain Summary

  1. Enumerate web app (/zm) β†’ identify ZoneMinder.

  2. Abuse weak/default creds (admin:admin) for API access.

  3. Extract DB creds via API.

  4. Exploit SQLi on tid parameter to retrieve user hashes.

  5. Crack mark hash (opensesame) and SSH as mark.

  6. Enumerate internal-only services and find localhost motionEye (8765 + 7999).

  7. Abuse command injection in picture_filename/snapshot_filename.

  8. Trigger snapshot to execute payload as root.

  9. Read both flags (sa_mark user flag + root flag).


Last updated