Imagery
Imagery
Platform: HackTheBox | Category: Machines | Type: Machine | Difficulty: Medium | OS: Linux | Author: DonutMaster | Date: 2026-02-11 | Status: Solved Techniques: Stored XSS in Bug Report Admin Panel, Cookie Hijacking, LFI via System Logs, Python DB JSON Enumeration, ImageMagick Command Injection RCE, AES Crypt Backups Decryption
Summary
Walkthrough of the HackTheBox Medium machine Imagery (Linux). Foothold achieved by exploiting Stored XSS in the admin bug report feature to steal the admin session cookie, leveraging admin access for LFI via system log download, reading db.json and app.py, and executing command injection via ImageMagick wrapper (apply_visual_transform). Privilege escalation via AES-encrypted zip backup cracking and path/binary hijacking.
Recon
Port Scan
bash read-only • copy allowedrustscan -a imagery.htb -- -A
| Port | Service | Version | Notes |
|---|---|---|---|
| 22/tcp | ssh | OpenSSH 9.7p1 | Standard SSH |
| 8000/tcp | http | Werkzeug 3.1.3 (Python) | Image Gallery Web App |
Foothold
Exploitation Steps
- Register user and submit a bug report containing Stored XSS payload targeting the un-sanitized details field.
- Admin reviews bug report; attacker receives admin session cookie via callback HTTP server.
- Access Admin panel and use Log Download feature vulnerable to LFI to read
app.py,config.py, anddb.json. - Log into the testuser account (credentials extracted from
db.json) and exploit command injection inapply_visual_transformvia ImageMagick (shell=True).
Privilege Escalation
Lateral Movement & Root
- Locate AES-encrypted zip backup under
/var/backup/. - Extract hash using
aescrypt2hashcat.pland crack with Hashcat to retrieve backup passphrase. - Unzip backup to inspect application source or credentials, and leverage system misconfigurations for root escalation.
Flags
| Flag | Location | Value |
|---|---|---|
| user | /home/web/user.txt | REDACTED |
| root | /root/root.txt | REDACTED |
Key Takeaways / Lessons
DOMPurify.sanitize()must be applied across all user-supplied fields, not just subset properties like report names.- Avoid
shell=Truein subprocess calls when handling image transformation parameters.