← Back to Writeups
CUSTOMEasyCrypto

Easy encryptor — Cyclic XOR

XESXOR9/10/20261 min read
#crypto#custom#easy#cyclic_xor_decryption

Easy encryptor — Cyclic XOR

Platform: spbctf | Category: Crypto | Type: Challenge | Difficulty: Easy | OS: NA | Author: XESXOR | Date: 2026-03-08 | Status: Solved Techniques: cyclic_xor_decryption

Summary

Task: XOR encryption script with visible key and encoded file. Solution: Apply the same XOR operation with the same key to decrypt (XOR is symmetric).

Easy encryptor — Crypto Kids 2.0

Description

"c4n y0u r3v3r53 m3?" with Python encoder script and encoded file.

Analysis

Given an encryption script with the key "strong_key". XOR is a symmetric operation: encrypt(encrypt(x)) = x. Simply apply the same XOR with the same key.

Solution

python
#!/usr/bin/env python3
# Original encoder (from the task):
# def encode(data, key):
#     return bytes(d ^ key[i % len(key)] for i, d in enumerate(data))
# 
# key = b"strong_key"
# encoded = encode(plaintext, key)
‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

def decode(data, key):
    # XOR is symmetric - same operation for decryption
    return bytes(d ^ key[i % len(key)] for i, d in enumerate(data))

key = b"strong_key"

# Read the encrypted file
with open("encoded.bin", "rb") as f:
    encoded = f.read()

plaintext = decode(encoded, key)
print(plaintext.decode())
# Output: spbctf{REDACTED}

‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍