string theory: netstrings, read by their lengths

huntress ctf 2026, day 24 · warmups · all three modes

tools used: decoding search engine and timed-attempt pipeline.

"count carefully. the comma knows where to stop." day 23's newest line was ascii85; day 24's was a run of netstrings, the length-prefixed framing where every item says how long it is and ends in a comma. the single and the time trial were one such line each, one netstring per character of the message; the mastery was a zip of 118 blobs of twenty-four numbered lines, whose twenty-fourth line was the same framing.

the key insight: a netstring is parsed by its length, never by its delimiter. the message's own commas and colons sit inside the items, so splitting on commas breaks the text; reading the decimal length, taking exactly that many characters and then requiring the comma reads it exactly, and turns the comma into a check.

challenge shape

single         1 field    the slug one blob's decoded text instructs
time trial     1 field    the same, a fresh blob
mastery      118 fields   one slug per blob, 118 blobs of 24 numbered lines

the field is message (setK.message in mastery).

artifact anatomy

a netstring is <length>:<data>,: the data's length in decimal, a colon, that many bytes of data and a comma. 5:hello, carries hello, and 0:, is the empty string. the format comes from daniel j. bernstein's 1997 note, which also explains the comma: a reader that finds anything else after the stated length knows the framing is broken.

the single's blob is one line of one-character netstrings back to back, each of length 1, each carrying one character of the message; the time trial's is the same. because every item holds exactly one character, the message's punctuation shows up as items that look wrong at first glance: a comma in the text is 1:,, and a colon is 1::,.

in the mastery each blob is NN<tab>chunk lines: one message split over twenty-four lines, line k encoded by day k's encoding. the twenty-fourth chunk is a handful of one-character netstrings, the message's last few characters.

extraction method

the reading walks the line item by item: digits up to the colon are the length, the data is the next length characters, and the character after them must be a comma. whitespace between items is skipped.

def netstring(text: str) -> str:
    s, out, i = text.strip(), [], 0
    while i < len(s):
        while i < len(s) and s[i] in " \t\r\n":
            i += 1
        if i == len(s):
            break
        j = s.find(":", i)
        if j <= i or not s[i:j].isdigit():
            raise ValueError("not a netstring")
        end = j + 1 + int(s[i:j])
        if end >= len(s) or s[end] != ",":
            raise ValueError("netstring length mismatch")
        out.append(s[j + 1 : end])
        i = end + 1
    return "".join(out)

the colon search starts at the item's first character, so a colon inside the data is never mistaken for the next item's separator: by the time the search runs again, the reader has already stepped past the data by its length.

in the mastery, line k is read by day k's row of the schedule first, and only a line past the schedule is searched; the netstring reading is now a line reading, its hint words (count, comma, length, colon) rank it first for a prompt like this one, and the schedule names row 24 as netstring.

validation and answer formatting

the comma is the validation: a wrong length lands on a character that is not a comma and the reading is refused, so a line that merely contains digits and colons does not decode by accident. the decoded message must then read as english and end in a slug of the shape the question states ("three lowercase words separated by hyphens, followed by a hyphen and a two-digit number; submit the slug only").

failed approaches and pivots

the decoder had no netstring reading when the day opened, and the prompt's words (count, comma) pointed at no reading it knew, so its search ended with no decoding path. the line was easy to read by eye, since every item shows its character, and the single was answered by hand; the reading went into the decoder next, and the time trial and mastery used it.

automation across modes

with the reading in place the time trial's blob decoded in about 0.1 seconds and the mastery's 118 blobs in about 0.7.

lessons

solve times

public scoreboard · day 24 finish: top 3

  • 0:21.6single#5 of 167 solvers
  • 0:37.3time trial#5 of 162 solvers
  • 0:40.6mastery#3 of 159 solvers
  • #3team day finishof 139 teams that cleared it, in 3:47.1
  • #5single orderof the day's 7, by our flag time

from the public scoreboard: 09:00 et release to our flag; the table below counts from our attempt's start.

from when we started working on the mode to its flag. attempts counts our solver runs; the single's answer was read by hand.

mode work to flag attempts wrong submits
single 21.0s 1 0
time trial 1.0s 1 0
mastery 1.2s 1 0

the clock

server timer of the winning attempt; used is attempt start to flag, left is what remained on the clock.

mode time available time used time left
time trial 30.0s 1.0s 29.0s
mastery 135.0s 1.2s 133.8s

where we got stuck

flags: single, time trial, and mastery [redacted].

{generated by a clanker}