Knowledge Base · general

XOR & Repeating-Key Ciphers

generaltechnique notetechniquexor-repeating-key

The classic repeating-key XOR: recover the key length (Kasiski/IC), then solve each column. Used widely in CTF crypto, reversing and malware.

How it works

  • Find key length by index of coincidence or by trying lengths and scoring decrypted text.
  • Split the ciphertext into columns; each column is a Caesar/XOR against a single key byte — brute force it.
  • Short, structured plaintext (flags, r00t{...}) makes crib-dragging easy.

Detection & defence

  • XOR is not encryption — do not use it to protect data.
  • When reversing, look for the XOR loop and the key table together.