← Back to Writeups
CUSTOMMediumSteganography

Куда показывают стрелки?

XESXOR9/10/20262 min read
#steganography#custom#medium#brainfuck_decoding#lsb_extraction

Куда показывают стрелки?

Platform: taipanbyte | Category: Steganography | Type: Challenge | Difficulty: Medium | OS: NA | Author: XESXOR | Date: 2026-01-22 | Status: Solved Techniques: brainfuck_decoding, lsb_extraction

Summary

Task: PNG image with meme, hints about 'arrows'. Solution: LSB extraction reveals Brainfuck code (< > are the 'arrows'), executing it produces the flag.

Куда показывают стрелки? — TaipanByte CTF

Description

Given a PNG image — a meme with text "Now I'll open the file with stegsolve and get 1000 points". The task description hinted at "arrows" and "clock".

Analysis

  1. Initial hypothesis: "clock arrows" — possibly something related to time or direction
  2. Actual meaning: "Arrows" are the < and > symbols in Brainfuck language!
  3. The meme was ironic about simple stegsolve usage — but stegsolve still helped find the LSB

Solution

Step 1: LSB Extraction

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

Used stegsolve or manual extraction of least significant bits from RGB channels:

python
#!/usr/bin/env python3
from PIL import Image

def extract_lsb(image_path):
    img = Image.open(image_path)
    pixels = img.load()
    width, height = img.size
    
    bits = []
    for y in range(height):
        for x in range(width):
            pixel = pixels[x, y]
            for channel in range(3):  # RGB
                bits.append(pixel[channel] & 1)
    
    # Convert bits to bytes
    chars = []
    for i in range(0, len(bits), 8):
        byte = bits[i:i+8]
        if len(byte) == 8:
            char = chr(int(''.join(map(str, byte)), 2))
            if char.isprintable() or char in '\n\r\t':
                chars.append(char)
            else:
                break
    
    return ''.join(chars)
‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

hidden = extract_lsb("image.png")
print(hidden)

Step 2: Brainfuck Code Discovered

Brainfuck code (esoteric language) was hidden in LSB:

brainfuck
++++++++++[>+>+++>+++++++>++++++++++<<<<-]>>>---.>----------------.<+++.>+++++++++++++++++++++++++++++++++++++++.--------.---.<------------------.>++.<-.>-------------------.++++++++++++++.++++++++++++.--------------------------.<+++++++++++++++.>-------------.<--------------.---.>----.+++++++++++++++++++++++++++++++++++++++++++++++.

Step 3: Executing Brainfuck

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

python
#!/usr/bin/env python3
def brainfuck(code):
    tape = [0] * 30000
    ptr = 0
    pc = 0
    output = []
    
    # Find matching brackets
    brackets = {}
    stack = []
    for i, c in enumerate(code):
        if c == '[':
            stack.append(i)
        elif c == ']':
            j = stack.pop()
            brackets[j] = i
            brackets[i] = j
    
    while pc < len(code):
        cmd = code[pc]
        if cmd == '>':
            ptr += 1
        elif cmd == '<':
            ptr -= 1
        elif cmd == '+':
            tape[ptr] = (tape[ptr] + 1) % 256
        elif cmd == '-':
            tape[ptr] = (tape[ptr] - 1) % 256
        elif cmd == '.':
            output.append(chr(tape[ptr]))
        elif cmd == ',':
            tape[ptr] = 0  # No input
        elif cmd == '[':
            if tape[ptr] == 0:
                pc = brackets[pc]
        elif cmd == ']':
            if tape[ptr] != 0:
                pc = brackets[pc]
        pc += 1
    
    return ''.join(output)
‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

code = "++++++++++[>+>+++>+++++++>++++++++++<<<<-]>>>---.>----------------.<+++.>+++++++++++++++++++++++++++++++++++++++.--------.---.<------------------.>++.<-.>-------------------.++++++++++++++.++++++++++++.--------------------------.<+++++++++++++++.>-------------.<--------------.---.>----.+++++++++++++++++++++++++++++++++++++++++++++++."

print(brainfuck(code))

Notes

  • Brainfuck — an esoteric programming language using only 8 commands: > < + - . , [ ]
  • Symbols < and > move the pointer along the memory tape — hence "arrows"
  • Online interpreters: https://copy.sh/brainfuck/, https://www.dcode.fr/brainfuck-language ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍