Skip to main content

spelling-quiz picoMini by redpwn Solution

Decrypt a classically encrypted message and apply what you learn to recover the flag.

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

Description

A spelling quiz study guide and flag file were encrypted with the same substitution cipher. Recover the key.

Download the encrypted study guide and flag.txt from the challenge page.

Solution

Want to try it yourself first?

The guided walkthrough reveals hints one step at a time.

Walk me through it
  1. Step 1Analyze the ciphertext
    Observation
    The study guide and flag.txt share one substitution key, and the guide is a long English text. A substitution preserves letter frequencies, so that length is enough for frequency analysis.
    The study guide is a long English text encrypted with a monoalphabetic substitution cipher - each letter is consistently replaced by exactly one other letter. The large amount of English text makes frequency analysis effective.
    Learn more

    A monoalphabetic substitution cipher replaces each letter of the plaintext with a fixed corresponding letter from a scrambled alphabet. There are 26! (about 4 × 10^26) possible substitution alphabets, making exhaustive search completely infeasible. However, the cipher preserves the statistical properties of the underlying language - letter frequencies, bigram frequencies, and common word patterns all survive the substitution unchanged.

    In English, the most frequent letters by occurrence are approximately: e, t, a, o, i, n, s, h, r, d, l, u. The most common bigrams are th, he, in, er, an. The most common trigrams are the, and, ing, her, hat. A long ciphertext preserves these ratios, making it possible to map cipher letters to plaintext letters by matching frequency distributions.

    The Caesar cipher is the simplest substitution cipher (shift each letter by a fixed amount) and is broken by just trying all 25 shifts. A general monoalphabetic cipher requires frequency analysis or automated solving. Historical monoalphabetic ciphers - including the one famously used in Edgar Allan Poe's "The Gold-Bug" - were broken exactly this way long before computers existed.

  2. Step 2Break the substitution cipher
    Observation
    Thousands of characters under a fixed mapping is plenty for an automated cryptogram solver, which hill-climbs to the full key in seconds.
    Paste the encrypted study guide into quipqiup.com or use a tool like SubstitutionBreaker. The solver uses letter frequency statistics and common bigrams/trigrams to recover the alphabet mapping automatically.
    bash
    # Online: https://quipqiup.com
    What didn't work first

    Tried: Run frequency analysis only on flag.txt instead of the study guide.

    flag.txt runs under 60 characters, so its letter frequencies are sampling noise rather than English. The most common letter in it could easily be an x or a z, which sends the whole key reconstruction sideways. The study guide supplies the thousands of characters those statistics need to converge.

    Tried: Try a Caesar cipher solver on the study guide, cycling through all 25 shifts.

    A Caesar shift moves every letter by the same offset. A monoalphabetic substitution maps each letter independently, which is 26 factorial keys rather than 25. A Caesar solver therefore produces jumbled text at every offset, because the mapping was never a uniform shift.

    Learn more

    quipqiup is an automated cryptogram solver that uses a combination of frequency analysis and dictionary-guided hill climbing. It starts with a frequency-based initial guess at the substitution key and then iteratively swaps letter mappings, keeping changes that increase how many common English words appear in the decryption. Given a sufficiently long ciphertext, it converges on the correct key within seconds.

    The automated approach works because the study guide provides far more ciphertext than is needed for reliable frequency analysis. Frequency analysis typically requires at least a few hundred characters to be reliable; a full study guide provides thousands. More text means the observed letter frequencies in the ciphertext converge tightly to the true English frequencies, making the mapping unambiguous.

    Before automated tools existed, cryptanalysts broke substitution ciphers manually using frequency tables, looking for common short words (likely candidates for the, a, an, in), and word patterns. A word like XYYXZ in the ciphertext is almost certainly level or another word with the pattern ABBA+C. This pattern-matching intuition is what automated solvers encode in their scoring functions.

  3. Step 3Apply the recovered key to flag.txt
    Observation
    Both files share the key, so the alphabet recovered from the guide applies straight to flag.txt. Python's translation table does it in one pass.
    Once you have the substitution key (e.g. pcubfwhvjknairmetszdxygolq mapping to abcdefghijklmnopqrstuvwxyz), apply it to decrypt flag.txt using Python's str.translate().
    python
    python3 -c "
    key   = 'pcubfwhvjknairmetszdxygolq'
    alpha = 'abcdefghijklmnopqrstuvwxyz'
    table = str.maketrans(key, alpha)
    print(open('flag.txt').read().translate(table))
    "

    Expected output

    picoCTF{perhaps_the_dog_jumped_over_was_just_tired}
    What didn't work first

    Tried: Build the translation table with key and alpha swapped: str.maketrans(alpha, key) instead of str.maketrans(key, alpha).

    The translation table maps each character in its first argument to the matching one in its second. The recovered key is the cipher alphabet, the letters appearing in the ciphertext, so it goes first. Swap the arguments and you have built the encryption direction, which re-encrypts the ciphertext into garbage.

    Tried: Apply the substitution table only to lowercase letters, forgetting that the flag wrapper picoCTF{} contains uppercase and special characters.

    A lowercase-only table leaves uppercase letters and punctuation untouched, which is what you want here. The trap is assuming the solver's key covers uppercase: it returns a lowercase mapping, and extending it by hand with the case wrong garbles the letters inside the braces while the wrapper still looks right.

    Learn more

    str.maketrans(from, to) builds a translation table: a dictionary mapping each character in from to the corresponding character in to. str.translate(table) applies that mapping to every character in the string in a single pass. This is the idiomatic Python way to implement any character-level substitution without a loop.

    The same key that decrypts the study guide decrypts the flag because both were encrypted with the same cipher. This is a common CTF pattern: give you a large, known-plaintext-adjacent file (the study guide is English text you can guess at) so you can recover the key, then ask you to apply that key to the short target file (flag.txt) that alone would not have enough ciphertext for frequency analysis.

    The broader lesson is about key reuse: using the same key for multiple messages always creates exploitable relationships between those messages. In symmetric cryptography, this principle extends to nonce reuse in stream ciphers and IV reuse in block cipher modes - the consequences range from trivial decryption (as here) to full key recovery depending on the cipher.

Interactive tools
  • Vigenère CipherEncrypt or decrypt text with the Vigenère polyalphabetic substitution cipher using a keyword.
  • Cipher Identifier & Auto-DecoderPaste any ciphertext and the tool auto-runs every common decoder (base64, hex, Morse, ROT, Atbash, Bacon, binary, decimal, URL) and ranks the results by English-likeness.
  • ROT / Caesar CipherDecode Caesar-shifted and ROT-encoded text. Drag the shift slider or scan all 26 rotations at once.

Flag

Reveal flag

picoCTF{perhaps_the_dog_jumped_over_was_just_tired}

A monoalphabetic substitution cipher with enough English ciphertext is breakable via frequency analysis - the distribution of letters (e, t, a, o, i, n...) directly reveals the key.

Key takeaway

A monoalphabetic substitution preserves letter frequencies, so any ciphertext long enough to sample English breaks easily, and an automated solver hill-climbs to the key in seconds. Reusing a key across messages always creates that relationship: the long study guide gave up the key that then decrypted a flag file far too short to analyze on its own.

Related reading

Useful tools for Cryptography

Where to go next