First Find

Published: March 5, 2024

Description

Find uber-secret.txt hidden somewhere inside the provided archive. Hidden directories (those prefixed with a dot) might conceal the answer.

Local forensicsDownload files.zip

Download the archive and extract it. Grep can inspect the expanding tree faster than manual browsing.

Hidden directories (prefixed with .) appear once the archive is unzipped, so make sure your shell shows them.

wget https://artifacts.picoctf.net/c/500/files.zip
unzip files.zip && rm files.zip

Solution

  1. Step 1Locate the hidden folder
    Once unzipped, the structure includes .secret nested multiple levels deep. Rather than traversing each directory by hand, let grep reveal which file mentions picoCTF.
    grep -R pico
    Learn more

    In Unix-like systems, any file or directory whose name begins with a dot (.) is treated as hidden. These entries are excluded from the default output of ls and most file browsers, but they are fully accessible if you know the name or use flags like ls -a (show all). This convention is commonly used for configuration directories (~/.ssh, ~/.config) and is a classic hiding spot in CTF challenges.

    The recursive grep approach bypasses the need to navigate the directory tree at all. grep -R pico . opens every file in every directory (including hidden ones) and prints matching lines. Because the flag starts with picoCTF, the pattern pico is broad enough to match it without needing to know the exact flag format in advance.

    In a real security context, analysts use exactly this approach to search for sensitive strings (passwords, API keys, PII) across a file system during a code audit or incident response. Tools like trufflehog, gitleaks, and semgrep automate this at scale for large repositories, but knowing the underlying grep mechanics helps you understand what those tools are doing and catch cases they miss.

  2. Step 2Inspect uber-secret.txt
    Grep output shows that files/adequate_books/more_books/.secret/deeper_secrets/deepest_secrets/uber-secret.txt contains the flag. Read it directly to confirm.
    cat files/adequate_books/more_books/.secret/deeper_secrets/deepest_secrets/uber-secret.txt
    Learn more

    Once grep reveals the full path, cat reads and prints the file contents. The deeply nested path (adequate_books/more_books/.secret/deeper_secrets/deepest_secrets/) demonstrates how archives can be structured to make manual browsing impractical - there are simply too many directories to check one by one.

    The hidden directory name .secret is a common CTF convention inspired by real-world hidden directories. On Linux systems, the .ssh directory stores private keys, .bash_history stores command history, and .gnupgstores GPG keys - all sensitive files that rely partially on the "hidden by convention" mechanism for obscurity. Attackers know to check these locations first.

    The takeaway is that security through obscurity alone - hiding files in unusual places or giving them inconspicuous names - is not a reliable defense. Any tool that reads the file system recursively (grep, find, Autopsy) will discover the file regardless of its depth or name. Real security requires access controls, encryption, or both.

  3. Step 3Trim the output
    If you only want the flag text, pipe grep through an extractor such as grep -oE, cut, or sed to strip away the path prefix.
    grep -R pico | grep -oE 'picoCTF\{.*\}' --color=none
    Learn more

    When grep finds a match inside a named file, it outputs the result in the format filename:matching_line. The nested grep with -o and an extended regex extracts only the portion of the line that matches picoCTF\{.*\}. The .* inside the braces is a greedy match that captures everything between the opening and closing brace.

    The --color=none flag prevents ANSI escape codes from appearing in the output, which matters if you are piping the result into another program or saving it to a file - terminal color codes are invisible on screen but would corrupt the text if processed further.

    This kind of double-grep pipeline (first to find relevant lines, then to extract exactly the right token) appears constantly in CTF automation scripts. Once you internalize it, you can adapt it to extract any structured pattern from noisy output: IP addresses, URLs, email addresses, UUIDs, and more. The same pattern is used in log parsing, threat intelligence extraction, and security automation.

Flag

picoCTF{f1nd_15_f457_ab44...}

Once you know the hidden directory path, viewing uber-secret.txt prints the precise flag shown by grep.

Want more picoGym Exclusive writeups?

Useful tools for General Skills

Related reading

What to try next