SLA
SLA
Platform: CUSTOM | Category: Crypto | Type: Challenge | Difficulty: Easy | OS: N/A | **Author: XESXOR Techniques: known_plaintext_attack, xor_key_recovery
Summary
Walkthrough of the CUSTOM Crypto SLA. Task: XOR stream cipher with ciphertext provided. Solution: Recover key using known plaintext attack with flag prefix matching key length.
Description
Stream cipher task with XOR encryption. Ciphertext provided, need to recover the flag.
Analysis
- XOR encryption with 7-character key "locator"
- Plaintext is doubled: flag + flag (concatenated with itself)
- Known prefix "spbctf{" is exactly 7 characters = key length
- This allows direct key recovery via XOR with known plaintext
Solution
Since we know the first 7 bytes of plaintext ("spbctf{") and the key is 7 bytes long, we can recover the entire key by XORing the known plaintext with the first 7 bytes of ciphertext.
python read-only • copy allowed#!/usr/bin/env python3 # XOR key recovery with known plaintext prefix def xor_bytes(a, b): return bytes([x ^ y for x, y in zip(a, b)]) # Read ciphertext with open('ciphertext.bin', 'rb') as f: ct = f.read() # Known prefix = key length known_prefix = b'spbctf{' key_len = len(known_prefix) # 7 # Recover key: key = ct[:7] XOR known_prefix key = xor_bytes(ct[:key_len], known_prefix) print(f"Recovered key: {key}") # b'locator' # Decrypt full ciphertext plaintext = b'' for i, c in enumerate(ct): plaintext += bytes([c ^ key[i % key_len]]) # Plaintext is flag+flag, take first half flag = plaintext[:len(plaintext)//2].decode() print(f"Flag: {flag}")
Key Takeaways / Lessons
- Mastering known_plaintext_attack, xor_key_recovery was key to this challenge.
- Always check for common misconfigurations and verify assumptions.
Crafted by XESXOR Research • 2026-03-09 • CUSTOM • SLA • Difficulty: Easy