← Back to Writeups
CUSTOMMediumCrypto

Обратный шифр (Reverse Cipher)

XESXOR9/10/20262 min read
#crypto#custom#medium#base64_encoding#hex_to_bytes#hint_interpretation

Обратный шифр (Reverse Cipher)

Platform: duckerz | Category: Crypto | Type: Challenge | Difficulty: Medium | OS: NA | Author: XESXOR | Date: 2026-01-09 | Status: Solved Techniques: base64_encoding, hex_to_bytes, hint_interpretation

Summary

Task: recover a message from hex-encoded data where the encoding order was reversed. Solution: encode the raw hex bytes to Base64 instead of decoding, then interpret the Base64 output with flag-character substitutions.

Обратный шифр (Reverse Cipher) — duckerz

Description

"Я играл во дворе в шпионов. Задача была доставить письмо от Базы к базе безопасно, я решил закодировать сообщения, но похоже я перепутал порядок действий и теперь сообщение не вернуть, может ты найдёшь ошибку?"

Translation: "I was playing spies in the yard. The task was to deliver a letter from Base to base safely, I decided to encode the messages, but it seems I mixed up the order of actions and now the message cannot be recovered, maybe you can find the error?" ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

File: reverse_cipher.txt

0d 40 8a 11 16 7e af 7b f7 af 9d ff 6f 8e 77 eb 8f fb e3 99 3e

Analysis

Key Hints in the Description

  1. "от Базы к базе" (from Base to base) — wordplay pointing to Base64 encoding
  2. "перепутал порядок действий" (mixed up the order of actions) — operations were performed in the wrong order
  3. "Обратный шифр" (Reverse cipher) — need to apply the reverse operation

Understanding the Error

Normal encoding order:

  1. Text → Base64 → Hex

The author "mixed up" and did:

  1. Text → Hex (as raw bytes) ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

Solution: simply encode the raw bytes to Base64.

Solution

python
#!/usr/bin/env python3
"""
Solution for "Обратный шифр" (Reverse Cipher)
duckerz CTF - Crypto - 350 points
"""

import base64

# Data from file
hex_data = "0d 40 8a 11 16 7e af 7b f7 af 9d ff 6f 8e 77 eb 8f fb e3 99 3e"

# Convert hex to bytes
bytes_data = bytes.fromhex(hex_data.replace(" ", ""))
print(f"Bytes: {bytes_data.hex()}")
print(f"Length: {len(bytes_data)} bytes")

# Encode to Base64
b64_encoded = base64.b64encode(bytes_data)
print(f"\nBase64: {b64_encoded.decode()}")
‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

# Result: DUCKERZ+r3v3r53/b45364/745k+

Interpreting the Result

Base64 output: DUCKERZ+r3v3r53/b45364/745k+

Base64 characters are replaced with flag characters:

  • + at position 7 → {
  • / → _
  • + at the end → }

L33t speak decoding:

  • r3v3r53 = reverse
  • b45364 = base64
  • 745k = task

Lessons

  1. Read the description carefully — wordplay often contains hints
  2. Base64 can work both ways — sometimes you need to encode, not decode
  3. L33t speak — a common way to hide readable text in CTF flags ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍