← Back to Writeups
CUSTOMEasyMisc

Карусель (Karusel)

XESXOR9/2/20262 min read
#misc#custom#easy#cyclic_pattern_recognition#multi_encoding_decode

Карусель (Karusel)

Platform: hackerlab | Category: Misc | Type: Challenge | Difficulty: Easy | OS: NA | Author: XESXOR | Date: 2025-12-24 | Status: Solved Techniques: cyclic_pattern_recognition, multi_encoding_decode

Summary

Task: Decode data from task.txt where elements are separated by | in a cyclic pattern. Solution: Recognize the triplet pattern (binary|hex|base64) and decode each element accordingly to reveal the flag.

Карусель (Karusel) — HackerLab

Description

Кажется, тут используется 3 метода кодирования. Я уверен, что Python Вам поможет, Вы же не будете это декодировать вручную?)

Analysis

The task provides a file task.txt with data separated by the | character.

Analyzing the data reveals a clear pattern:

  • Every third element is a binary number (e.g., 1000111)
  • The next one is hex (e.g., 72)
  • Then base64 (e.g., ZQ==)

The task name "Карусель" (Carousel) hints at cyclic interleaving of encoding methods. ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

Data Structure

binary|hex|base64|binary|hex|base64|...

Each triplet encodes three characters of the original text:

  1. Binary → 1 character
  2. Hex → 1 character
  3. Base64 → 1 character

Solution

python
#!/usr/bin/env python3
"""
Карусель (Karusel) - HackerLab
Decoding cyclically encoded data: binary|hex|base64
"""
import base64

with open('task.txt', 'r') as f:
    data = f.read().strip()

parts = data.split('|')
result = []

for i in range(0, len(parts), 3):
    if i + 2 < len(parts):
        # Binary -> char
        bin_char = chr(int(parts[i], 2))
        # Hex -> char
        hex_char = chr(int(parts[i+1], 16))
        # Base64 -> char
        b64_char = base64.b64decode(parts[i+2]).decode('utf-8')
        
        result.extend([bin_char, hex_char, b64_char])
‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

message = ''.join(result)
print(message)

Decoding Result

Great job, buddy! Did you do it manually? In principle it doesn't matter. 
Check out the lines: Lorem ipsum dolor sit amet... 
Take your flag - CODEBY{REDACTED}.
Thanks for passing and good luck in the next task

Alternative Approach (one-liner)

python
import base64
print(''.join([chr(int(p[i],2))+chr(int(p[i+1],16))+base64.b64decode(p[i+2]).decode() for p in [open('task.txt').read().strip().split('|')] for i in range(0,len(p),3) if i+2<len(p)]))

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