packet loss prevention: a capture's packet count from its record

huntress ctf 2026, day 27 · metadata forensics · all three modes

tools used: archive and metadata readers and timed-attempt pipeline.

"packet captures, exports, and host artifacts describe the same incident from different angles. count traffic, reject malformed captures, and find the host narrative missing network evidence." day 27 opened a new file family for the lane: a pcap inside the evidence zip, and one question about it, its packet count.

the key insight is that the family was new to the questions, not to the readers: a pcap record (magic, version, snapshot length, link type, timestamp precision, packet count, first and last packet time) was already among the metadata readers' record families, and the question's words named one of its keys.

challenge shape

single         1 field    the packet count of capture-001.pcap in the zip
time trial    32 fields   the count on a fresh capture, the note and
                          roster fields, every earlier day's property, and
                          the sha-256 order field
mastery      352 fields   the same 32 per set, over eleven sets

the field was d27-pcap-001-pcap-packet-count, "determine pcap.packet_count for capture-001.pcap", answer kind integer: "base-10 integer with no units, separators, or explanatory text".

artifact anatomy

a pcap is a 24-byte global header (magic, version, time zone, snapshot length, link type) followed by records, each a 16-byte header (seconds, microseconds, captured length, original length) and the captured bytes. the packet count is the number of records, walking from the first record to the end of the file by each record's captured length. the magic sets the byte order and the timestamp unit: d4 c3 b2 a1 little-endian microseconds, a1 b2 c3 d4 big-endian, 4d 3c b2 a1 and a1 b2 3c 4d the same two with nanoseconds. the mastery used all four, over ethernet, raw ip and 802.11 link types, and the single's capture used a user-defined link type no dissector decodes; none of the day's captures ended in a partial record.

extraction method

the pcap reader walks the records once and builds the record the metadata readers expose under the file's kind:

def pcap_record(data: bytes) -> dict:
    magic = data[:4]
    order = "<" if magic in (b"\xd4\xc3\xb2\xa1", b"\x4d\x3c\xb2\xa1") else ">"
    major, minor, zone, _, snaplen, link = struct.unpack_from(
        order + "HHiIII", data, 4
    )
    pos, count = 24, 0
    while pos + 16 <= len(data):
        _, _, incl_len, _ = struct.unpack_from(order + "IIII", data, pos)
        count += 1
        pos += 16 + incl_len             # captured length, not original
    return {"link_type": link, "packet_count": count, ...}

wireshark's capinfos -c capture-001.pcap prints the same number for any of the four magics. a question is answered from a record by its words: pcap-packet-count names the pcap record and its packet_count key, so the lane solver's record lookup returned the count with nothing written for the day.

validation and answer formatting

the count is a bare base-10 integer. the file's kind comes from its magic (the four above; pcapng has its own reader), and the walk steps by the captured length, so a frame cut short by the snapshot length is still one packet. no graded capture ended in a partial record, so the day never showed whether a record header with missing data counts; our walk counts it. the mastery's sets each carried their own capture and earlier days' files, read by the same lookup.

failed approaches and pivots

none on day 27.

automation across modes

the record lookup answered the single, the time trial and every mastery set; the mastery's solve took 1.8 seconds for eleven sets.

lessons

solve times

public scoreboard · day 27 finish: below top 10

  • 0:03.8singlefirst blood, +0.51 s
  • 0:06.4time trialfirst blood, +1.7 s
  • 0:11.2masteryfirst blood, +1.1 s
  • #38team day finishof 127 teams that cleared it, in 34:43.1
  • #3single orderof the day's 8, 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 the mode's first attempt start to its flag (server times). attempts counts our solver runs.

mode work to flag attempts wrong submits
single 1.2s 1 0
time trial 0.8s 1 0
mastery 3.3s 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 50.0s 0.8s 49.2s
mastery 355.0s 3.3s 351.7s

where we got stuck

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

{generated by a clanker}