CTFroom: Pickle Rick — Web Enumeration, Command Injection & Sudo Abuse
A complete walk-through of the Pickle Rick room: uncovering credentials in HTML comments, bypassing basic bash command filters on the web portal, and escalating privileges to root via full sudo privileges.
Challenge Overview
Pickle Rick is an introductory challenge simulating a real-world scenario where poor access controls, client-side leaked credentials, and unfiltered administrative command execution lead to complete root compromise.
Phase 1: Reconnaissance & Port Scanning
We begin with a standard two-stage Nmap scan against the target IP to discover exposed network services:
Scan Results
Phase 2: Web Enumeration & Credential Discovery
Navigating to http://10.10.124.87/, we inspect the page source (Ctrl+U). Hidden within the HTML comments, we identify the first clue:
Next, we run automated directory brute-forcing with gobuster and simultaneously inspect /robots.txt:
The string Wubbalubbadubdub appears to be an unusual password or key.
Directory enumeration reveals /login.php. Testing the credentials:
RICKRULZ2420WubbalubbadubdubAuthentication succeeds, redirecting us to an administrative command execution panel at /portal.php.
Phase 3: Command Injection & Filter Bypass
The portal presents a command execution form allowing administrators to run diagnostics on the server. Attempting a basic command:
Yields directory contents, including Sup3rS3cretPickl3Ingred.txt.
However, running cat Sup3rS3cretPickl3Ingred.txt returns:
The web application blacklists common inspection commands (cat, head, tail, more). We can bypass this filter using several alternative techniques:
First ingredient recovered: mr. meeseek hair.
Phase 4: Interactive Reverse Shell
To escape the restrictive web form and obtain an interactive terminal, we set up a local Netcat listener on port 4444:
We execute a Python reverse shell one-liner through the web portal:
The connection arrives, granting us a shell as www-data. We upgrade to a full TTY:
Phase 5: Privilege Escalation to Root
We immediately check our current user's sudo privileges:
Output:
www-data is permitted to execute any command as root without a password. We escalate directly:
Navigating to /root, we read the final flag:
Key Takeaways & Defense Remediation
exec, system).NOPASSWD: ALL to web-server service accounts (www-data) creates a catastrophic single point of failure.