← Back to Writeups
CUSTOMEasyMisc

Каталогический хаос (Catalog Chaos)

XESXOR9/2/20262 min read
#misc#custom#easy#case_sensitivity_bypass#position_mapping#zip_direct_read#linux

Каталогический хаос (Catalog Chaos)

Platform: duckerz | Category: Misc | Type: Challenge | Difficulty: Easy | OS: Linux | Author: XESXOR | Date: 2026-01-09 | Status: Solved Techniques: case_sensitivity_bypass, position_mapping, zip_direct_read

Summary

Task: ZIP archive with single-char folder/file names where case-sensitivity causes extraction issues on macOS. Solution: Read ZIP directly with Python zipfile to extract character positions and build the flag.

Каталогический хаос (Catalog Chaos) — duckerz

Description

"Как можно работать в этом хаосе?!?!?!?!?"

File: catalogy_chaos.zip

Analysis

Archive Structure

When extracting the archive, an unusual structure is revealed:

  • Folders with single-character names (letters, digits, special characters {, }, _)
  • Each folder contains a .txt file with the same name
  • Files contain numbers — positions of the character in the flag

Problem: Case Sensitivity

Key point: On macOS (case-insensitive filesystem) when extracting a ZIP archive, files overwrite each other! ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

For example:

  • The archive contains folder a/ with file a.txt
  • It also contains folder A/ with file A.txt
  • When extracting on macOS, they merge into one folder

The "chaos" in the task name is a hint about the case mismatch between directory and file names.

Approach

Need to read the ZIP archive directly via Python without extracting to the filesystem:

  • The character is taken from the filename (not the directory)
  • Numbers in the file indicate positions of that character in the flag ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

Solution

python
#!/usr/bin/env python3
"""
Catalog Chaos - duckerz CTF
Read ZIP directly to avoid case-sensitivity issues
"""
import zipfile

positions = {}

with zipfile.ZipFile('catalogy_chaos.zip', 'r') as z:
    for info in z.infolist():
        if info.filename.endswith('.txt'):
            parts = info.filename.split('/')
            if len(parts) >= 3:
                # Take character from filename, not directory
                char = parts[2].replace('.txt', '')
                content = z.read(info.filename).decode('utf-8').strip()
                if content:
                    for line in content.split('\n'):
                        line = line.strip()
                        if line:
                            pos = int(line)
                            positions[pos] = char
‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

# Build the flag
max_pos = max(positions.keys())
flag = ['?'] * (max_pos + 1)
for pos, char in positions.items():
    flag[pos] = char

print(''.join(flag))

Output

DUCKERZ{REDACTED}

Alternative Approaches

  1. Linux VM — extract on a case-sensitive filesystem (ext4)
  2. Docker — use a Linux container for extraction
  3. Create a case-sensitive partition on macOS (APFS case-sensitive)

Lessons

  1. Always inspect ZIP contents directly before extraction
  2. Case-sensitivity — a common trap in CTF tasks
  3. Python zipfile — a powerful tool for working with archives without extraction ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍