TTP — Two-Time Pad
TTP — Two-Time Pad
Platform: CUSTOM | Category: Crypto | Type: Challenge | Difficulty: Medium | OS: N/A | **Author: XESXOR Techniques: otp_reuse_attack, two_time_pad_attack
Summary
Walkthrough of the CUSTOM Crypto TTP — Two-Time Pad. Task: Two ciphertexts encrypted with OTP using the same key, one known plaintext. Solution: Two-Time Pad attack - recover key by XORing known plaintext with its ciphertext, then decrypt the second mes
Description
"Looks like OTP, but 🤔". Two ciphertexts with same key, one known plaintext.
Analysis
Two-Time Pad attack: when OTP (One-Time Pad) is used twice with the same key, security is completely lost.
If C1 = P1 ⊕ K and C2 = P2 ⊕ K, then:
- C1 ⊕ C2 = P1 ⊕ P2
- Knowing P1, we can find K = C1 ⊕ P1
- Then P2 = C2 ⊕ K
Solution
python read-only • copy allowed#!/usr/bin/env python3 # Given: # C1 - first ciphertext # C2 - second ciphertext # P1 = "good_morning_mister_Bond" - known plaintext def xor_bytes(a, b): return bytes(x ^ y for x, y in zip(a, b)) # From the task file c1 = bytes.fromhex("...") # first ciphertext c2 = bytes.fromhex("...") # second ciphertext p1 = b"good_morning_mister_Bond" # Recover the key key = xor_bytes(c1, p1) # Decrypt the second message p2 = xor_bytes(c2, key) print(p2.decode()) # Output: spbctf{REDACTED}
Key Takeaways / Lessons
- Mastering otp_reuse_attack, two_time_pad_attack was key to this challenge.
- Always check for common misconfigurations and verify assumptions.
Crafted by XESXOR Research • 2026-03-08 • CUSTOM • TTP — Two-Time Pad • Difficulty: Medium