Skip to main content

like1000 picoCTF 2019 Solution

Extract a flag buried inside a deeply nested series of compressed archives.

Published: April 2, 2026Updated: August 13, 2026

Description

This .tar file got tarred 1000 times. Untar it to find the flag.

Download the tar file into a working directory.

bash
mkdir like1000 && cd like1000
bash
wget <url>/1000.tar

Solution

Want to try it yourself first?

The guided walkthrough reveals hints one step at a time.

Walk me through it
  1. Step 1Write a loop to extract recursively
    Observation
    The description says the file was tarred 1000 times. Unpacking that by hand is not realistic, so the answer is a loop counting down from 1000 to 1.
    The archive is a tar within a tar within a tar, 1000 levels deep. Write a bash loop that repeatedly extracts the tar file until no more tar files exist.
    bash
    for i in $(seq 1000 -1 1); do tar xf $i.tar; done
    What didn't work first

    Tried: Run tar xzf 1000.tar to extract the outermost archive, assuming it is gzip-compressed because .tar files often are.

    The -z in tar xzf forces gzip decompression first. These nested archives are plain uncompressed tar, so tar reports a decompression error and exits without extracting anything. Plain tar xf works because it detects the format itself.

    Tried: Loop from 1 to 1000 in ascending order with 'for i in $(seq 1 1000); do tar xf $i.tar; done'.

    The outermost file is 1000.tar, which holds 999.tar, and so on down. Counting up tries 1.tar first, which does not exist yet, so the loop fails immediately. Counting down works because each extraction produces the next file before the loop needs it.

    Learn more

    The tar utility (tape archive) packages multiple files into a single file without compression. Each tar xf file.tar extracts the contents of the archive into the current directory. If the archive contains another .tar file, you need to extract that one too.

    The loop counts from 1000 down to 1 because the outermost archive is 1000.tar, which contains 999.tar, which contains 998.tar, and so on down to 1.tar.

  2. Step 2Find the flag file
    Observation
    The loop finished and no tar files are left, so the innermost archive is open. Whatever it held should now be sitting in the working directory.
    After the loop completes, the innermost archive yields flag.png (an image, not a text file). Open it to read the flag.
    bash
    ls
    bash
    # the flag is in flag.png - open it in an image viewer

    Expected output

    flag.png
    Learn more

    Each archive also contains a filler file, and depending on the instance the next .tar may land in the current directory or inside a numbered subdirectory. A robust, depth-agnostic loop that handles either layout is a find-based one rather than while [ -f *.tar ] (which errors when the glob matches zero or multiple files):

    while f=$(find . -name '*.tar' | head -1); [ -n "$f" ]; do
      tar -xf "$f" -C "$(dirname "$f")"
      rm "$f"
    done
    # then locate the image:
    find . -name 'flag.png'
Interactive tools
  • File Magic IdentifierIdentify file types from magic numbers. Paste hex bytes or drop a file to detect PNG, JPEG, ZIP, PDF, ELF, PCAP, SQLite, and dozens of other formats.
  • Hex ViewerView text or raw hex bytes as a xxd-style hex dump with byte offset, hex columns, and ASCII sidebar. Highlights printable characters and null bytes.
  • Strings ExtractorPull printable text from any binary, library, or image. ASCII and UTF-16 detection, configurable minimum length, flag-like highlight, no command line needed.

Flag

Reveal flag

picoCTF{l0t5_0f_TAR5}

Repeatedly extract the nested tars (a find-based loop handles whatever subdirectory layout the instance uses) down to the innermost flag.png, then open the image to read the flag.

Key takeaway

Archive formats like tar nest arbitrarily: a tar can hold a tar that holds another tar. Whenever unpacking by hand is impractical because of the depth, a scripted loop is the right tool. The same pattern shows up in nested zip challenges, firmware images with several layers of gzip or LZMA, and malware droppers that unpack in stages to dodge static analysis.

Related reading

Useful tools for Forensics

Where to go next