Skip to content
Adam Omar Saleh

PINK CTF placeholder badge (unofficial)PINK CTFMisc

Bayrisches Theater

The file is 3,964 blue and white squares (🟦 = 1, ⬜ = 0) split into 62 lines of random length.

Competition
PINK CTF placeholder badge (unofficial)PINK CTF
Category
MiscMedium · estimated
Source status
Source-documented · not platform-verified
Document
PDF edition2 min read

Brief

The challenge

Category
bavarian, emoji
Points
100
Author
Poris & QWERTZ
File
bayrisches.theater
Challenge page
Challenge page

TL;DR

The file is 3,964 blue and white squares (🟦 = 1, ⬜ = 0) split into 62 lines of random length. The line breaks are a decoy. Joined into one stream, the bits form rows of 128 squares, each row ending in a fixed 1111. That leaves a 31 × 31 grid of 4-bit cells. Cells with the value 0000, 0101 or 1010 are dark modules of a QR code, and every other value is light. The QR code holds the address of the Bavarian State Opera (Nationaltheater München) and the year it opened.

01

First look

The file has only three characters: 🟦 (1,709 times), ⬜ (2,255 times) and newline. All 62 lines have lengths that are multiples of 4 (28 to 92 squares), so the 4-square nibble is clearly a unit. Read as nibbles (🟦 = 1), three values are far more common than the rest:

NibbleCount
0000147
0101143
1010136
any other value30 to 60 each

Lines don't repeat or share prefixes, and decoding them as Morse code, big integers or a bitmap font gives nothing.

02

The line breaks are a decoy

Join every line into one bit stream and split it into bytes. The high nibble is never F, but the low nibble is F 30 times. Since the chance of that happening at random is about 2⁻³⁰, the stream must have structure that ignores the line breaks.

Listing where the 1111 nibbles sit settles it:

Text
positions: 31, 63, 95, 127, ..., 959gaps:      32, 32, 32, ...

1111 appears only at every 32nd nibble. The file is really 128-square rows, each ending in four blue squares. 3,964 = 31 × 128 − 4, so there are 31 rows and the last terminator was cut off.

Stream reflowed to 128 squares per row: note the solid blue column on the right
Stream reflowed to 128 squares per row: note the solid blue column on the right

03

A 31 × 31 grid

Once the terminator is dropped, each row holds 31 nibbles, which gives a square 31 × 31 grid of 4-bit cells using only 15 values. Printed in hex, the first and last rows contain no 0, 5 or a at all, while the other rows are full of them. Marking those three values as #:

Text
................................#######.#.#.#..##..#..#######..#.....#.###.#.##......#.....#..#.###.#..##..###....#.#.###.#..#.###.#.##.#....#..##.#.###.#..#.###.#..#.#.#....#...#.###.#..#.....#..##.#.#..###..#.....#..#######.#.#.#.#.#.#.#.#######..........###.###..####............

Those are QR finder patterns: a version-3 (29 × 29) QR code with a one-cell border. The values 0000, 0101 and 1010 (all white, or the blue/white lozenge pattern of the Bavarian flag) are dark modules, and the other 12 values are random light filler.

04

Decoding

solve.py draws the grid as an image and decodes it with OpenCV:

Recovered QR code
Recovered QR code
Text
$ python solve.pyPINK{M4x_J053ph_P14tz_2_1818}

Max-Joseph-Platz 2 in Munich is the address of the Nationaltheater, home of the Bavarian State Opera, which opened in 1818. That is the "Bavarian theatre" in the title.

Files

  • grid.py joins the stream and builds the 31 × 32 grid, and tests box-drawing bit orders (a dead end).

  • solve.py renders the QR code and decodes it.

Flag

Flag

PINK{M4x_J053ph_P14tz_2_1818}

Source-documented · not platform-verified

PDF edition

Writeup PDF

Formatted edition of this walkthrough, built from my source notes · 4 pages.