Wanna
Wanna
Platform: CUSTOM | Category: Crypto | Type: Challenge | Difficulty: Medium | OS: N/A | **Author: XESXOR Techniques: image_reconstruction, known_plaintext_attack, xor_key_recovery
Summary
Walkthrough of the CUSTOM Crypto Wanna. Task: Decrypt a ransomware-encrypted BMP file. Solution: Used known-plaintext attack to recover 16-byte XOR key from black pixels, then decrypted image data to reveal the flag.
Description
Ransomware-encrypted BMP file. The task name references WannaCry and ECB mode.
Analysis
- File size 900064 bytes = 64-byte header + 900000 bytes of image data
- XOR encryption with a 16-byte repeating key
- Encryption starts at offset 64 (header is not encrypted or encrypted separately)
- BMP images often contain areas with zero/black pixels
- Data size 900000 = 1000 × 300 × 3 (RGB) — standard image dimensions
Key Recovery
Using known-plaintext attack: if pixels in the original were black (0x00), then encrypted bytes = key XOR 0x00 = key.
Recovered 16-byte key: cc5c1c2ca8e0b1570fb1be945cc91d98
Solution
python read-only • copy allowed#!/usr/bin/env python3 from PIL import Image # Read encrypted file with open("encrypted.bmp", "rb") as f: data = bytearray(f.read()) # 16-byte XOR key (recovered from known plaintext) key = bytes.fromhex("cc5c1c2ca8e0b1570fb1be945cc91d98") # Decrypt data starting from offset 64 for i in range(64, len(data)): data[i] ^= key[(i - 64) % 16] # Extract RGB data (after 64-byte header) rgb_data = bytes(data[64:]) # Create 1000x300 RGB image # BMP stores rows bottom-to-top, so we flip width, height = 1000, 300 img = Image.frombytes('RGB', (width, height), rgb_data) img = img.transpose(Image.FLIP_TOP_BOTTOM) # BMP bottom-to-top img.save("decrypted.png") img.show() # Flag visible in image: REDACTED
Alternative Key Recovery Method
python read-only • copy allowed#!/usr/bin/env python3 # Key recovery from known plaintext (black pixels) with open("encrypted.bmp", "rb") as f: data = f.read() # Look for repeating pattern in encrypted data # If original contained zeros, encrypted bytes = key encrypted_body = data[64:] # Analyze first 16 bytes as potential key # (assuming first pixels were black) potential_key = encrypted_body[:16] print(f"Potential key: {potential_key.hex()}") # Check periodicity for i in range(0, min(160, len(encrypted_body)), 16): chunk = encrypted_body[i:i+16] if chunk == potential_key: print(f"Key repeats at offset {i}")
Key Takeaways / Lessons
- Mastering image_reconstruction, 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 • Wanna • Difficulty: Medium