Lesson 5 of 6

The hidden record

Goal

Walk through records of varying length

01

Explanation

This is a block of bytes from a made-up data file. Its first byte is the number of records, and the records follow one after another. Each record starts with a tag byte that gives its type, then a length byte, then that many bytes of data:

count | tag len data... | tag len data... | ...

The record whose tag is 0xFF holds the flag. The records have different lengths, so you can't know where a record starts until you've read the length of the one before it.

02

Your task

Write a function extract_flag(blob) that reads the records in order and returns the data of the record whose tag is 0xFF as bytes, or None if the block has no such record. The checks give it other blocks with different records.

Checks

5 checks
  1. Extracts the flag from the first record
  2. Finds the flag in the third record
  3. Handles empty and long records
  4. Isn't fooled by 0xFF bytes inside the data
  5. Returns None when there's no flag record
03

Hints

0/3
Track lessons0 of 6 done

Six challenges of rising difficulty where you reverse a check function or bytecode and extract the key with your own code, not by copying it.

Advanced level, 6 lessons, 2 hours in total.

main.py
OutputPython (Pyodide)

Loading Python. This only happens once. Your browser keeps it after that.

–/5

Checks start once the environment is ready.

5 checks listed under “Your task”.

Track lessons0 of 6 done

Six challenges of rising difficulty where you reverse a check function or bytecode and extract the key with your own code, not by copying it.

Advanced level, 6 lessons, 2 hours in total.