Writeup · Cyberweek Africa 2026 - National CTF (Finals)

Heritage Trail 7: Fragments of a Nation

miscmedium-hardsolvedFlag: FLAG{REDACTED}

Overview

This is the finale of the Heritage Trail. The brief says there is nothing new to research and that everything needed has already been collected. The six fragments from the earlier stages “were never independent answers”. Each describes part of one operation:

Role in the operation Hint in the brief
Where to look Identifies the right file
The structure Describes how the file is organised
Where to begin Gives the starting point for reading
Which direction to follow Gives the reading direction
What to extract Gives the cells to take
How to preserve the sequence Gives the order to join the results

The goal is a final archive key, which is the flag content, to be kept exactly as recovered because it opens the final vault.

Earlier answers are masked in the vault, so this note describes each stage’s role and leaves the values out.

Recon

The archive

unzip heritage_archive.zip
cat A*

The zip holds eight files. Each is named after an archive box and frame, and each starts with a header in the form ARCHIVE nn - FRAME nn followed by a one-line catalogue note.

Catalogue note Count
Regional transport ledger fragment 1
Oral-history index reconstruction 1
Coastal correspondence fragment 1
Administrative boundary notes 1
Index page, adjacent frame 1
Composite national heritage index 1
Institutional chronology index 1
Photographic index transcription 1

Seven notes are mundane. One is “Composite national heritage index”, which stands out, and another is “Index page, adjacent frame”, which describes a near-duplicate of the same box.

The shape of every file

All eight files share one layout:

  • Two panels per file. The panel titles vary (Panel, Section, Table, Half, Chamber, House, Side), but there are always two.
  • A start marker under each panel title (START, BEGIN, ORIGIN, ENTRY, ROOT, SOURCE or FIRST), followed by an arrow pointing right.
  • Three rows of cells in each panel, labelled M, A and P in the left column.
  • Eight cells per row, normally two uppercase letters each.

Most rows look like random letter pairs. In the most suspicious file, a few cells break the pattern: they have a hyphen or contain four letters.

Exploitation

Step 1: Map each earlier answer to a role

Role Source stage What it supplies
Where to look Stage 5 (archive identifier) The file name: the box and frame identifier from the metadata
The structure Stage 6 (the key word) A word describing a two-part system, matching the two panels in every file
Where to begin Stage 1 (the first word) A word naming the start marker used in the panels
Which direction Stage 3 (compass direction) East, so reading runs left to right along the arrow
What to extract Stage 2 (three marker codes) Three letter-digit pairs, read as row letter plus column number
How to preserve the sequence Stage 4 (the order word) Keep results in order: row by row within a panel, then panel by panel

Stage 2’s code is the least obvious one. Its three pairs each pair a letter with a digit, and the letters match the row labels in every file (M, A, P). So each pair reads as “take the cell in column N of row L”.

Mapping each clue to a stage was settled by testing, and the mapping above is the only one that produced a readable result.

Step 2: Pick the file

The stage 5 identifier is the filename of one of the eight. The catalogue note on that file, “Composite national heritage index”, is also the one that stands out from the rest. The file named after the neighbouring frame in the same box is the decoy: “Index page, adjacent frame”.

Step 3: Apply the extraction

For each panel in order, take the three cells named by the stage 2 pairs, in row order. Using one-based column numbers, and with the cells of the genuine file masked:

Panel Row M cell Row A cell Row P cell
I masked masked masked
II masked masked masked

Joining the six cells in order produces the flag content. Two of the six cells are not plain letter pairs: one contains a hyphen, and one is four letters long. That fits a phrase built from two words with a hyphen in between, not a random cipher string.

Step 4: Test the decoys

The same extraction applied to the neighbouring frame gives a meaningless string of letters. Applying it to all eight files shows that only one gives a readable result:

File (box and frame) Catalogue note Result
A04 F12 Regional transport ledger fragment Gibberish
A08 F03 Oral-history index reconstruction Gibberish
A11 F07 Coastal correspondence fragment Gibberish
A13 F04 Administrative boundary notes Gibberish
A17 F02 Index page, adjacent frame Gibberish
Genuine file Composite national heritage index Readable phrase, with non-standard cells
A18 F06 Institutional chronology index Gibberish
A21 F01 Photographic index transcription Gibberish

The genuine file is also the only one containing irregular cells. That gives two independent signals pointing at the same file: its name matches the stage 5 identifier, and its contents are the only ones that read as a phrase.

Step 5: Automate it

A solver script (solve_heritage_trail_7.py) parses the panels, applies the extraction and picks the genuine file without being told which one to use.

Core logic:

SPEC = [...]          # (row label, 1-based column) pairs from the stage 2 code (masked)

def extract(panels, spec):
    out = []
    for panel in panels:             # panel I before panel II
        for label, col in spec:      # row order from the spec
            out.append(panel[label][col - 1])   # left to right, one-based
    return out

def looks_irregular(cell):
    return len(cell) != 2 or not cell.isalpha()

How it behaves:

Mode Behaviour
Default Solves every A*.txt file (or the contents of a zip) and picks the only one with irregular cells
Ambiguous If none or several files show irregular cells, falls back to the stage 5 identifier, and if that file is missing it stops and asks for --frame
--table Prints every file’s extraction result
--frame <stem> Forces one file

Parsing does not depend on panel titles. A new panel starts whenever the first row label shows up again, which handles the seven different panel-naming schemes.

Flag

FLAG{REDACTED}

Lessons / Takeaways

  • Keep every intermediate answer. The final stage reused six earlier answers, including ones the challenges had said were only keys or directions. Anything that was not the final flag of its own stage still mattered.
  • Read the role list as a decoder ring. The brief lists six roles in plain language. Matching each to a stage is a matching exercise, and the types of the answers (a word, a direction, a code with letters and digits, an identifier) narrow the matches quickly.
  • Spot the self-describing file. The catalogue note “Composite national heritage index” was the odd one out, and the near-duplicate “adjacent frame” file was the deliberate decoy built to catch a loose reading of the identifier.
  • Let the output validate the method. A procedure that gives a readable phrase for exactly one file and noise for the other seven is very unlikely to be wrong.
  • Preserve exact content. Hyphens and longer cells are part of the answer. The brief’s instruction to keep content exactly as recovered is a warning against tidying the data.
  • Parse by structure, not by labels. Panel titles changed from file to file while the layout did not, so detecting a new panel by the first row label is more robust than matching titles.
  • Automate the sweep. Running the same extraction on every file takes a few lines and gives both the answer and the proof that the other files fail.

Techniques

  • Multi-Stage Puzzle Chaining
  • Grid Extraction
  • Python Scripting for CTFs
  • Clue-Based Enumeration