VP 23: Crib Drag (15 pts + 35 extra)

Background

One-time pads are very secure, but not if you use the pad more than once. Russia made this error during World War II and it led to complete compromise of their encryption system, as detailed in this book.

What You Need

Any computer with Python 3. You can also use an online Python environment, such as https://colab.research.google.com

Using a One-Time Pad

Let's use this keystring:
Unbreakable awesome secret secure system
To encrypt this message:
Four score and seven
This Python code does the encryption:
key = "Unbreakable awesome secret secure system"
plaintext = "Four score and seven"

i = 0
ciphertext = ""
for p in plaintext:
  ip = ord(p)
  k = key[i]
  ik = ord(k)
  inew = ip ^ ik
  ciphertext += chr(inew)
  print(p, hex(ip), k, hex(ik), hex(inew))
  i += 1
print(ciphertext.encode("ascii").hex())
This program encrypts the string, as shown below.
Decrypting uses the same operation, since XOR reverses itself:
key = "Unbreakable awesome secret secure system"
ciphertext = bytes.fromhex("130117004512080e100945410f1345000a1b004e")

i = 0
plaintext = ""
for c in ciphertext:
  k = key[i]
  ik = ord(k)
  ip = c ^ ik
  p = chr(ip)
  print(c, k, ik, ip, p)
  plaintext += p
  i += 1
print(plaintext)
This string is decrypted, as shown below.

VP 23.1: Using a Known Key (5 pts)

Use this key:
Wow, what a great key!
Decrypt this ciphertext:
0e20220c67383c413d7440
The plaintext is the flag.

VP 23.2: Crib Drag (10 pts)

The key starts with:
The
Both these ciphertexts were encrypted with the same key:
1a0d134503550e0a1d4542071f56
0d0710071d19490d0e5607004f00074e47
To break this, start with a guess at the key, like this:
The................................
This shows the first three letters of the two plaintext messages, as shown below.
From the partial plaintexts, you can guess another letter or two, and use those letters to extend the key. Continue adding one or two letters at a time until you get the whole plaintext. This is called the crib drag attack.

Submit the first plaintext message as the flag.

VP 23.3: Crib Drag (15 pts extra)

Both these ciphertexts were encrypted with the same key:
13070b4954491b53114816450d1b101c100000090952480105044e4b000f4b4e5453
070d0a1e4c0c4e4d1d0f0d54431c10175311480a464604140a5b4e64373722233153
One of the plaintext messages contains the flag.

VP 23.4: Crib Drag (20 pts extra)

Both these ciphertexts were encrypted with the same key:
7e5e491142414350595441145c49435719454a1559425e5d4b114b49505c574e555d0016475e5757584f4651524054194149494c0c55595e144d4454195b494b1e19
734558115956551247545947510c5841195851500c535e544b544a58114844435b54495b190c665b540c545c514b1150460c7e76606a7962777c02
One of the plaintext messages contains the flag.

Posted 8-31-24
Video added 10-9-24