Weak XOR Crypto
crypto · easy · +25 XP
// what is Weak XOR Crypto?
Weak XOR cipher — XOR with a repeating key is the textbook example of 'do not roll your own crypto'. Single-byte XOR has 255 possible keys (brute-force in microseconds). Repeating-key XOR is broken by Kasiski / Friedman analysis. The point: any cipher you can describe in 3 lines of code, an attacker can break in 3 lines of code. Use AEAD (AES-GCM, ChaCha20-Poly1305) and never XOR strings yourself.
// how attackers detect it
- [01]If the ciphertext is suspiciously short or has obvious patterns (repeated bytes every N positions) → XOR.
- [02]If you know any plaintext byte, XOR with the ciphertext at that position to recover the key byte.
- [03]Tools:
xortool,xorsearch, CyberChef ('XOR Brute Force' op).
// how defenders prevent it
- ✓Use AES-256-GCM or ChaCha20-Poly1305 with a unique nonce per message — both authenticated + encrypted.
- ✓Never write your own crypto. Use
libsodium(sodium-plus, PyNaCl) — the API is designed to be unmisusable. - ✓Key management > algorithm choice. Rotate keys, store in KMS (AWS KMS, GCP KMS, HashiCorp Vault).
// real-world incidents
CVE-2024-3596
RADIUS MD5-blast (Blast-RADIUS)
Crypto fail in enterprise auth — same family.
CVE-2016-2107
OpenSSL AES-NI padding oracle
Padding-oracle = related downgrade class.
// hands-on tips for this lab
- ›Plaintext starts with
hc{. XOR first byte of ciphertext with'h'(0x68) → key byte. XOR rest of ciphertext with that byte → flag.
was this lesson helpful?
// start of crypto
next
CBC Padding Oracle
1 of 17 · crypto