Skip to content

Lesson pack 2 · Foundation · 90 minutes

Classical ciphers and frequency analysis

Break Caesar, Vigenere, and arbitrary substitution using letter statistics - and learn why statistics beat guessing.

Print this page for a paper plan - the navigation and links drop out.Student-facing version

Before the session

  • Nothing to install. Students need a browser and https://ctfpal.com. Confirm the room can reach it once; after that it works offline.
  • Read the lesson yourself first - about 6 minutes.
  • Have one worked example ready to paste. The classroom link builder on the instructor page turns it into a URL that opens preloaded.

Objectives

Written as things a student can do afterwards, so they can be assessed rather than asserted.

  1. Break a Caesar shift with chi-squared scoring rather than by reading 26 candidates
  2. Recover a Vigenere key length using the index of coincidence, then the key itself per column
  3. Distinguish a transposition from a substitution by looking at letter frequencies
  4. Explain why short ciphertexts defeat statistical attacks

Running order (90 min)

TimeWhat happens
0:00-0:09Frame the problemWhat the category looks like when you meet it cold, and why the naive approach fails.
0:09-0:27Teach the methodThe technique itself, on the board or from the lesson. No tools open yet.
0:27-0:50Demonstrate liveSame technique, in the workspace, on your worked example. Narrate every choice.
0:50-1:21Practice setStudents work the challenges. Circulate rather than present.
1:21-1:30Checkpoint and wrapCollect the artefact, name what comes next.

Tools used

  • Caesar cipher decoder with automatic shift detection - Break a Caesar shift without guessing. ctfpal scores all 26 rotations by chi-squared letter frequency and puts the English one first.https://ctfpal.com/?tool=caesar-cipher
  • Vigenere cipher solver with automatic key recovery - Decrypt Vigenere with a known key, or recover the key from ciphertext alone using index-of-coincidence period detection and per-column chi-squared.https://ctfpal.com/?tool=vigenere-cipher
  • Monoalphabetic substitution cipher solver - Break an arbitrary substitution cipher automatically by hill-climbing on quadgram statistics - no key, no guessing.https://ctfpal.com/?tool=substitution-cipher-solver
  • Rail fence cipher solver - Brute-force rail fence transposition across 2-8 rails and every starting offset, ranked by English-likeness.https://ctfpal.com/?tool=rail-fence-cipher

Reading

  • Chi-squared, index of coincidence, and why classical ciphers fall - 6 min. Caesar, Vigenere, and substitution ciphers do not need guesswork - they need two statistics. How chi-squared scores a candidate plaintext, how the index of coincidence recovers a key length, and how to combine them into an attack that runs in milliseconds.

Practice set

Real picoCTF challenges tagged with this module’s techniques, easiest first. Assign the first three in class and the rest as homework.

  1. 13 - picoCTF 2019, easy
  2. interencdec - picoCTF 2024, easy
  3. Mod 26 - picoCTF 2021, easy
  4. The Numbers - picoCTF 2019, easy
  5. caesar - picoCTF 2019, medium
  6. credstuff - picoCTF 2022, medium
  7. Easy1 - picoCTF 2019, medium
  8. Guess My Cheese (Part 1) - picoCTF 2025, medium
  9. Guess My Cheese (Part 2) - picoCTF 2025, medium
  10. Hidden Cipher 1 - picoCTF 2026, medium
  11. Hidden Cipher 2 - picoCTF 2026, medium
  12. la cifra de - picoCTF 2019, medium

Checkpoint (gradeable)

Recover a Vigenere key from ciphertext alone and report the index of coincidence at each candidate period.

Deliberately a produced artefact rather than a quiz question: it is either there or it is not, which makes it fast to mark and hard to bluff. Every tool in ctfpal is deterministic, so two students who did the work correctly hand in the same value.

Where the room gets stuck

This is the first module where the tool’s output is a ranked list rather than an answer. Students need to be told explicitly that reading the ranking - and noticing when the top two candidates score similarly - is the skill being taught.

If you finish early

  • Hand out a challenge from the cross-CTF index in this category - each one has published solutions to compare afterwards.
  • Run the same input through Identify and let the class argue with the ranking. Disagreeing with a confidence score is where the technique actually lands.
  • Ask a student to break their own example - construct an input that defeats the tool, and explain why.