← Back to Writeups
CUSTOMMediumMisc

RGB

XESXOR9/2/20263 min read
#misc#custom#medium#image-enhancement-for-hidden-t#image-reconstruction-from-raw-#text-file-parsing-with-regex#linux

RGB

Platform: hackerlab | Category: Misc | Type: Challenge | Difficulty: Medium | OS: Linux | Author: XESXOR | Date: 2025-12-26 | Status: Solved Techniques: Image enhancement for hidden text detection, Image reconstruction from raw RGB pixel data, Text file parsing with regex

Summary

Task: Text file with pixel coordinates and RGB values, filename hints at image dimensions. Solution: Parse pixel data and reconstruct image using PIL, then enhance contrast to reveal hidden flag in corner.

RGB — HackerLab

Description

"Если Вы будете делать это вручную, то возможно станете художником" (If you do this manually, you might become an artist)

Files: task.zip → 1280x853.txt (24MB, ~1 million lines)

Analysis

File Investigation

Unpack the archive and examine the contents:

bash
$ unzip task.zip
$ wc -l 1280x853.txt
1091840 1280x853.txt

$ head -5 1280x853.txt
(0, 0): 38, 22, 16
(1, 0): 25, 9, 3
(2, 0): 20, 4, 0
(3, 0): 24, 8, 2
(4, 0): 24, 8, 2

Key Observations

  1. Filename 1280x853.txt — clear hint at image dimensions
  2. Line count: 1,091,840 = 1280 × 853 (exact match!)
  3. Data format: (x, y): R, G, B — pixel coordinates and RGB values
  4. Task description: "manually become an artist" — hint at the need for automation ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

Solution

Script for Image Reconstruction

python
#!/usr/bin/env python3
"""
RGB Task - Reconstruct image from pixel data
Format: (x, y): R, G, B
Image size: 1280x853
"""

from PIL import Image
import re

# Image dimensions from filename
WIDTH = 1280
HEIGHT = 853

# Create new image
img = Image.new('RGB', (WIDTH, HEIGHT))

# Parse the data file
with open('1280x853.txt', 'r') as f:
    for line in f:
        # Parse format: (x, y): R, G, B
        match = re.match(r'\((\d+), (\d+)\): (\d+), (\d+), (\d+)', line.strip())
        if match:
            x = int(match.group(1))
            y = int(match.group(2))
            r = int(match.group(3))
            g = int(match.group(4))
            b = int(match.group(5))
            
            if 0 <= x < WIDTH and 0 <= y < HEIGHT:
                img.putpixel((x, y), (r, g, b))
‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

# Save the image
img.save('output.png')
print(f"Image saved as output.png ({WIDTH}x{HEIGHT})")

Result

The reconstructed image shows a "CYBERCOLISEUM" style picture with two hooded figures.

Finding the Flag

In the top-left corner of the image, there is barely visible text. To read it:

  1. Increase contrast and brightness in any image editor
  2. Use Python for automatic enhancement:
python
from PIL import Image, ImageEnhance

img = Image.open('output.png')

# Crop corner area
corner = img.crop((0, 0, 300, 100))
‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

# Enhance contrast and brightness
enhancer = ImageEnhance.Contrast(corner)
corner = enhancer.enhance(3.0)

enhancer = ImageEnhance.Brightness(corner)
corner = enhancer.enhance(1.5)

corner.save('corner_enhanced.png')

After enhancement, the flag becomes readable in the corner.

Alternative Approaches

  1. Numpy + Matplotlib — faster for large images:
python
import numpy as np
import matplotlib.pyplot as plt

data = np.zeros((853, 1280, 3), dtype=np.uint8)
# ... parse and fill array
plt.imsave('output.png', data)

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

  1. Pandas — for fast parsing of CSV-like data

Notes

  • File size 24MB for a 1280×853 image — that's ~22 bytes per pixel (text format is very inefficient)
  • Hidden text in the corner — classic steganography technique
  • Always check corners and edges of reconstructed images for hidden information ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍