← Back to Writeups
CUSTOMEasyCrypto

Окей (Okay)

XESXOR9/10/20264 min read
#crypto#custom#easy#brainfuck-interpretation/execu#esoteric-programming-language-#ook!-to-brainfuck-conversion

Окей (Okay)

Platform: hackerlab | Category: Crypto | Type: Challenge | Difficulty: Easy | OS: NA | Author: XESXOR | Date: 2025-12-30 | Status: Solved Techniques: Brainfuck interpretation/execution, Esoteric programming language identification from task name hint, Ook! to Brainfuck conversion

Summary

Task: decode a file containing a repeating Russian word with punctuation into a readable flag. Solution: recognize the Ook! esoteric language (hinted by task name "Okay"), replace "Хорошо" with "Ook", convert to Brainfuck, and interpret the result.

Окей (Okay) - hackerlab

Description

У вас всё хорошо? Точно? А шифр знаете? (Are you okay? Sure? Do you know the cipher?)

Files: task.zip -> task.txt

Analysis

  1. Task name - "Окей" (Okay/OK) - key hint pointing to the Ook! esoteric language

  2. Contents of task.txt - the word "Хорошо" (Russian for "OK/Good") with different punctuation marks (., !, ?), separated by double spaces

  3. Ook! - a Brainfuck derivative where commands are encoded as pairs of "Ook" with punctuation: ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

Ook!BrainfuckDescription
Ook. Ook.+Increment cell
Ook! Ook!-Decrement cell
Ook. Ook?>Move pointer right
Ook? Ook.<Move pointer left
Ook! Ook?[Loop start
Ook? Ook!]Loop end
Ook! Ook..Output character
Ook. Ook!,Input character

Solution

Step 1: Convert "Хорошо" to "Ook"

python
#!/usr/bin/env python3

# Read the file
with open('task.txt', 'r', encoding='utf-8') as f:
    content = f.read()
‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

# Replace "Хорошо" with "Ook"
ook_code = content.replace('Хорошо', 'Ook')
print("Ook! code:")
print(ook_code[:200] + "...")

Step 2: Convert Ook! to Brainfuck

python
def ook_to_brainfuck(ook_code):
    """Converts Ook! code to Brainfuck"""
    # Split into tokens
    tokens = ook_code.split()
    
    # Mapping of Ook pairs to Brainfuck
    mapping = {
        ('Ook.', 'Ook.'): '+',
        ('Ook!', 'Ook!'): '-',
        ('Ook.', 'Ook?'): '>',
        ('Ook?', 'Ook.'): '<',
        ('Ook!', 'Ook?'): '[',
        ('Ook?', 'Ook!'): ']',
        ('Ook!', 'Ook.'): '.',
        ('Ook.', 'Ook!'): ',',
    }
    
    bf_code = []
    for i in range(0, len(tokens), 2):
        if i + 1 < len(tokens):
            pair = (tokens[i], tokens[i+1])
            if pair in mapping:
                bf_code.append(mapping[pair])
    
    return ''.join(bf_code)
‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

bf_code = ook_to_brainfuck(ook_code)
print(f"Brainfuck: {bf_code}")

Step 3: Interpret Brainfuck

python
def brainfuck_interpret(code):
    """Simple Brainfuck interpreter"""
    tape = [0] * 30000
    ptr = 0
    output = []
    code_ptr = 0
    
    # Pre-compute bracket positions
    brackets = {}
    stack = []
    for i, c in enumerate(code):
        if c == '[':
            stack.append(i)
        elif c == ']':
            if stack:
                j = stack.pop()
                brackets[j] = i
                brackets[i] = j
    
    while code_ptr < len(code):
        cmd = code[code_ptr]
        
        if cmd == '+':
            tape[ptr] = (tape[ptr] + 1) % 256
        elif cmd == '-':
            tape[ptr] = (tape[ptr] - 1) % 256
        elif cmd == '>':
            ptr += 1
        elif cmd == '<':
            ptr -= 1
        elif cmd == '.':
            output.append(chr(tape[ptr]))
        elif cmd == ',':
            pass  # No input
        elif cmd == '[':
            if tape[ptr] == 0:
                code_ptr = brackets[code_ptr]
        elif cmd == ']':
            if tape[ptr] != 0:
                code_ptr = brackets[code_ptr]
        
        code_ptr += 1
    
    return ''.join(output)
‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

result = brainfuck_interpret(bf_code)
print(f"Flag: {result}")

Complete Solution Script

python
#!/usr/bin/env python3
"""
Solution for "Окей" (Okay) task - hackerlab
Ook! esoteric language with Russian substitution "Хорошо" instead of "Ook"
"""

def ook_to_brainfuck(ook_code):
    tokens = ook_code.split()
    mapping = {
        ('Ook.', 'Ook.'): '+',
        ('Ook!', 'Ook!'): '-',
        ('Ook.', 'Ook?'): '>',
        ('Ook?', 'Ook.'): '<',
        ('Ook!', 'Ook?'): '[',
        ('Ook?', 'Ook!'): ']',
        ('Ook!', 'Ook.'): '.',
        ('Ook.', 'Ook!'): ',',
    }
    bf = []
    for i in range(0, len(tokens), 2):
        if i + 1 < len(tokens):
            pair = (tokens[i], tokens[i+1])
            if pair in mapping:
                bf.append(mapping[pair])
    return ''.join(bf)
‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

def brainfuck_run(code):
    tape = [0] * 30000
    ptr = 0
    output = []
    cp = 0
    
    brackets = {}
    stack = []
    for i, c in enumerate(code):
        if c == '[':
            stack.append(i)
        elif c == ']' and stack:
            j = stack.pop()
            brackets[j] = i
            brackets[i] = j
    
    while cp < len(code):
        c = code[cp]
        if c == '+': tape[ptr] = (tape[ptr] + 1) % 256
        elif c == '-': tape[ptr] = (tape[ptr] - 1) % 256
        elif c == '>': ptr += 1
        elif c == '<': ptr -= 1
        elif c == '.': output.append(chr(tape[ptr]))
        elif c == '[' and tape[ptr] == 0: cp = brackets[cp]
        elif c == ']' and tape[ptr] != 0: cp = brackets[cp]
        cp += 1
    
    return ''.join(output)
‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

# Read and decode
with open('task.txt', 'r', encoding='utf-8') as f:
    content = f.read()

ook_code = content.replace('Хорошо', 'Ook')
bf_code = ook_to_brainfuck(ook_code)
flag = brainfuck_run(bf_code)

print(f"Flag: {flag}")

Alternative Solution

You can use the online decoder at dcode.fr:

  1. Replace "Хорошо" with "Ook" in the text
  2. Paste into the Ook! decoder
  3. Get the flag

Related Techniques

  • Brainfuck - base esoteric language
  • Ook! - Brainfuck with "Ook" instead of symbols
  • Other Brainfuck derivatives: Spoon, COW, Whitespace ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍