TVX CTF 2026Cryptography
Unsorted Inventory
A chest holds 1,437 Minecraft items in a fixed order. Each item stands for a letter, and common letters have several items. Somewhere in the decoded text is a warning.
- Competition
TVX CTF 2026
- Category
- CryptographyMedium · estimated
- Source status
- Flag recovered locally · platform unverified
- Document
- PDF edition5 min read
Brief
The challenge
- Competition
- TVX CTF 2026
- Category
- Cryptography (platform category: Crypto)
- Difficulty
- Medium — estimated, not an official rating
- Points
- 100
- Solves
- 100 on the challenge card when captured
- Challenge author
- Mohammad Alshkibi
- Verification
- Flag recovered locally; platform acceptance not documented
Difficulty: Medium (estimated). TVX CTF 2026 did not publish difficulty ratings; the challenge cards show only points and solve counts. A homophonic substitution cipher defeats plain frequency analysis. Breaking it needs an n-gram scoring search (simulated annealing here) plus manual repair of rare symbols from context. The card showed 100 solves when captured.
01
Overview
Deep under the first village I found a chest with a sign on it: DO NOT SORT. Inside, 1,437 items sit in one long row, nine slots per line. A scribbled note says "every item stands for a letter, but not every letter has just one item." Somebody wrote a warning in here. Find it.

A chest holds 1,437 Minecraft items in a fixed order. Each item stands for a letter, and common letters have several items. Somewhere in the decoded text is a warning.
Solution path in brief
chest.txt is a homophonic substitution cipher. Each Minecraft item is one letter, and common letters (E, A, T, N, ...) have two or three items each. Simulated annealing scored with English quadgrams recovers almost the whole key, and context fixes the three rare items. The decoded story contains the phrase NEVER DIG STRAIGHT DOWN and instructions for formatting the flag.
02
Initial investigation
The first pass counted distinct items and their frequencies to identify the cipher type.
Recon
The file holds 1,437 item names, nine per line, with no spaces or punctuation. There are 39 distinct items. That's more than 26, so some letters must have several items, which is exactly what the note says.
The frequencies are unusually flat for a substitution cipher. The top items appear 60–70 times each, and most others appear 30–50 times. Homophones produce this pattern because they spread the common letters over several symbols. Three outliers stand out: coal (3), bookshelf (3) and emerald (1). They're good candidates for rare letters such as X, Z and J.
03
Tools used
Python 3 simulated-annealing solver with an English quadgram table (
solve.py)decode.pyto apply the final key
04
Step-by-step process
Step 1: Breaking the homophonic cipher
The note says to keep the items in their original order ("DO NOT SORT"), so the sequence is the ciphertext, read left to right.
solve.py assigns a letter to each of the 39 items and runs simulated annealing over that mapping. Each step either reassigns one item or swaps two. The score is:
the sum of English quadgram log-probabilities over the decrypted text, and
a penalty for how far the letter frequencies drift from English.
The penalty matters. Without it the solver collapses into degenerate text like ETTESESTHETESES..., because mapping everything to E/T/S scores well on quadgrams alone. With the penalty, 5 out of 6 restarts converge on the same readable plaintext:
ITBEGANTHEWAYEVERYWORLDBEGINSWITHASINGLETREEANDAGROWINGSENSEOFDREAD...Step 2: Fixing the rare items
The rare items appear too seldom for the statistics to pin down, so the solver guessed wrong on them. Context fixes all three:
| Item | Solver guess | Context | Letter |
|---|---|---|---|
bookshelf | C / R | COMBIES, BLACES, REDHACE | Z (zombies, blazes, red haze) |
coal | S | NESTWEEK, TAGTVS | X (next week, tag TVX) |
emerald | P / R | POINEDWITHUNDERSCORES | J (joined) |
Final key, with homophones grouped:
| Letter | Items |
|---|---|
| E | sand, rotten_flesh, end_stone |
| A | redstone, iron_ingot |
| T | bone, gold_ingot |
| N | gunpowder, ender_pearl |
| I | netherrack, melon_slice |
| R | nether_wart, spider_eye |
| O | dirt, pumpkin |
| H | gravel, slime_ball |
| S | stick, sugar_cane |
| L | glowstone, string |
| D | blaze_rod, obsidian |
| C | lapis_lazuli, oak_log |
| U | cactus, clay_ball |
| W G B M F V Y P K | diamond, ghast_tear, torch, flint, bedrock, feather, soul_sand, cobblestone, arrow |
| X Z J | coal, bookshelf, emerald |
Step 3: The warning
The plaintext (in plaintext.txt) is a Minecraft adventure story. It ends with:
...THE PHRASE IS NEVER DIG STRAIGHT DOWN. WRAP IT IN THE USUAL BRACESBEHIND THE TAG TVX, ALL LOWERCASE, JOINED WITH UNDERSCORES, AND THEVAULT WILL OPEN FOR YOU. NOW GO BUILD SOMETHING WONDERFUL AND WATCHOUT FOR THE CREEPER BEHIND YOU05
Commands and code
Solve scripts
solve.py: the quadgram and simulated-annealing solver (python solve.py 6 1.0). It usesquadgrams.txt, a standard English quadgram count table.decode.py: applies the final, corrected key and prints the plaintext and flag.
Full source: decode.py: apply the final key
KEY = { "sand": "E", "rotten_flesh": "E", "end_stone": "E", "redstone": "A", "iron_ingot": "A", "bone": "T", "gold_ingot": "T", "gunpowder": "N", "ender_pearl": "N", "netherrack": "I", "melon_slice": "I", "nether_wart": "R", "spider_eye": "R", "dirt": "O", "pumpkin": "O", "gravel": "H", "slime_ball": "H", "stick": "S", "sugar_cane": "S", "glowstone": "L", "string": "L", "blaze_rod": "D", "obsidian": "D", "lapis_lazuli": "C", "oak_log": "C", "cactus": "U", "clay_ball": "U", "diamond": "W", "ghast_tear": "G", "torch": "B", "flint": "M", "bedrock": "F", "feather": "V", "soul_sand": "Y", "cobblestone": "P", "arrow": "K", "coal": "X", "bookshelf": "Z", "emerald": "J",}pt = "".join(KEY[w] for w in open("chest.txt").read().split())print(pt)i = pt.find("THEPHRASEIS") + len("THEPHRASEIS")phrase = pt[i:pt.find("WRAPIT")]print("\nphrase:", phrase)print("flag : TVX{%s}" % "_".join(["never", "dig", "straight", "down"]))06
Technical explanation
In a homophonic cipher, frequent letters are spread over several symbols, which flattens the frequency curve. Quadgram log-probabilities still capture English structure, so a stochastic search over the 39-symbol mapping converges on readable text. A unigram-frequency penalty stops the search from collapsing onto a few common letters. Symbols that appear only a handful of times cannot be fixed statistically and are corrected from the surrounding words.
Key lessons
More symbols than letters plus a flat frequency curve means a homophonic cipher. Plain frequency analysis fails on it, but n-gram hill climbing or annealing works.
Add a unigram-frequency penalty to homophonic solvers, or they collapse onto a few common letters.
Symbols that appear only once or a few times can't be solved statistically. Read the near-plaintext and fix them from context.
07
Flag
Flag
TVX{never_dig_straight_down}
Flag recovered locally · platform unverified
08
Verification status
Status: Flag recovered locally; platform acceptance not documented.
The final key decodes the whole chest into coherent English that states the flag phrase and how to format it. Platform acceptance is not documented.
Source evidence in the archive: WRITEUP.md, solve.py, decode.py, plaintext.txt, chest.txt, images/00_challenge.png.
09
Conclusion
A good example of combining automated cryptanalysis with human reading. The solver gets the text to almost-English, and context does the rest.
Prepared by Adam Omar Saleh from the archived solve notes in unsorted_inventory/. Commands, code, output and screenshots are reproduced from the source; no results were added. Difficulty is an estimate.