PayDay_writeup

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


Summary

PayDay runs CS-Cart on Apache/PHP. The admin panel accepted admin:admin, and CS-Cart's authenticated template editor allows uploading a .phtml file, which is a known authenticated RCE path (EDB-48891). Uploading a PHP reverse shell renamed to .phtml gave a shell as www-data. Local user patrick's password turned out to simply be patrick, and patrick had unrestricted passwordless-after-auth sudo rights ((ALL) ALL), giving root directly via sudo su -.


Service Enumeration

Nmap

nmap -sCV -oN scans/tcp.nmap $IP
sudo nmap -sU --top-ports 20 -oN scans/udp.nmap $IP

Open ports: 22 (OpenSSH 4.6p1 Debian), 80 (Apache 2.2.4, PHP 5.2.3, "CS-Cart. Powerful PHP shopping cart software"), 110/143/993/995 (Dovecot POP3/IMAP), 139/445 (Samba 3.0.26a, workgroup MSHOME). UDP scan returned mostly closed, with netbios-ns open.

Web (80) - CS-Cart

Main page:

Account registration available:

Searching for CS-Cart vulnerabilities found EDB-48891 (authenticated RCE via the admin panel's template editor, uploading a .phtml file) and a matching walkthrough gist. The admin login at /admin.php accepted admin:admin.

SMB, SMTP, SNMP, and further directory/vhost enumeration were queued as fallback options but not needed once the CS-Cart path worked:

smbclient -L //$IP -N | tee scans/smbclient.md
nullinux $IP | tee scans/nullinux.md
enum4linux -a $IP | tee scans/enum4linux.md
enum4linux-ng $IP | tee scans/enum4linux-ng.md
smtp-user-enum -M VRFY -U /usr/share/seclists/Usernames/top-usernames-shortlist.txt -t $IP | tee scans/smtp-user-enum.md
snmpbulkwalk -v2c -c public $IP | tee scans/snmp.md

Initial Access - CS-Cart Template Editor RCE (EDB-48891)

Logged into the CS-Cart admin panel (admin:admin), then under Look and Feel > Template Editor, uploaded a PHP reverse shell (PentestMonkey, via revshells.com) renamed with a .phtml extension:


Started a listener and requested the uploaded shell at /skins/shell.phtml:

Stabilized the shell (python3 wasn't available, fell back to python2):

python -c 'import pty;pty.spawn("/bin/bash")'

then stty raw -echo; fg on the attacking machine and export TERM=xterm in the shell.

local.txt found under patrick's home directory (readable by www-data):

cd /home/patrick
whoami && hostname && cat local.txt


Privilege Escalation - patrick's Weak Password and Unrestricted sudo

Manual checks (sudo -l for www-data, cron, SUID binaries, listening services, /etc/passwd) showed patrick as the only real login-capable user besides root. patrick's password turned out to be patrick:

su patrick

Checking patrick's sudo rights:

sudo -l
User patrick may run the following commands on this host:
    (ALL) ALL

proof.txt found under /root:

sudo su -
whoami && hostname && cat /root/proof.txt


Flags

Flag Value
local.txt 6d57350eea4841d35815135548589837
proof.txt 5c5265a432a52c7ccdf2035612c3487b