Writeup · 31 Nights of Root

Dead Reckoning

forensicsmedium-hardsolvedFlag: r00t{REDACTED}

Overview

We are given a corrupted SkyTrack-7 Flight Data Recorder (FDR) log containing 39 entries, some of which are “ghost” entries injected by a known firmware fault (SkyTrack Advisory SA-019). The goal is to reconstruct the aircraft’s true flight path using dead-reckoning physics and identify the authentic entries. The challenge ships several deliberate misdirections to punish analysts who take shortcuts.

Files provided:

File Purpose
01_DEAD-RECKONING.zip Archive (already extracted)
aircraft-manual.txt Aircraft performance manual, incl. DR formula
fdr-spec.txt Binary log format specification
fdr.bin The corrupted flight data recorder log
check Real flag checker (ELF, stripped)
validator Decoy validator (ELF, stripped)

Prerequisites / Setup

  • Python 3 (struct, math)
  • ltrace (to reveal the flag string in check)
  • fdr.bin, aircraft-manual.txt, fdr-spec.txt, check in the working directory

Recon

Step 1 — Inspect the directory and file types

Goal: List the files and confirm their types.

ls
# 01_DEAD-RECKONING.zip  aircraft-manual.txt  check  fdr.bin  fdr-spec.txt  validator

file check
# check: ELF 64-bit LSB pie executable, x86-64, stripped

file validator
# validator: ELF 64-bit LSB pie executable, x86-64, stripped

file fdr.bin
# fdr.bin: data

Read the manuals and specs first. They contain both the real format and the traps.

cat aircraft-manual.txt
cat fdr-spec.txt

Key facts from aircraft-manual.txt

  • Departure: HKNW Nairobi Wilson Airport (-1.3217, 36.8148)
  • Destination: HKMO Mombasa Moi Airport (-4.0348, 39.5942)
  • Cruise speed: ~100–110 kts TAS
  • Cruise altitude: 8500 ft MSL (2591 m)
  • Sample interval: 300 s (5 minutes)
  • Spherical Earth model: R = 6371.0 km
  • DR forward formula (spherical Earth):
Given start (φ₁, λ₁), heading θ (degrees), speed v (kts), time Δt (s):
  d = v × 1.852 × Δt / 3600   [km]
  φ₂ = arcsin( sin(φ₁)·cos(d/R) + cos(φ₁)·sin(d/R)·cos(θ) )
  λ₂ = λ₁ + atan2( sin(θ)·sin(d/R)·cos(φ₁),
                    cos(d/R) − sin(φ₁)·sin(φ₂) )
  • Authentic adjacent entries should match DR prediction within < 1.0 km.
  • Entries deviating > 1.5 km should be treated as suspect (ghosts).

Key facts from fdr-spec.txt

Header (26 bytes, big-endian):

Offset Size Type Field
0 4 bytes MAGIC = FD 52 44 52
4 2 uint16 VERSION
6 8 bytes AIRCRAFT_ID
14 8 int64 BASE_EPOCH
22 4 uint32 N_ENTRIES

Entry (28 bytes, big-endian):

Offset Size Type Field
0 4 int32 EPOCH_DELTA
4 4 int32 LAT_FIXED (× 10⁶)
8 4 int32 LON_FIXED (× 10⁶)
12 2 uint16 ALT_M
14 2 uint16 HDG_10 (× 10)
16 2 uint16 SPEED_KTS
18 2 uint16 FLAGS
20 8 float64 INSTR_ERROR

FLAGS:

  • Bit 0: GPS_CORRECTED
  • Bit 1: AUTOPILOT
  • Bit 2: CAUTION
  • Bits 3–6: CSUM4
  • Bits 7–15: reserved

Trailer:

  • NOTE_MAGIC = "NOTE"
  • NOTE_LEN (uint16)
  • NOTE_DATA (UTF-8, null-terminated)

The Traps

The challenge is built around traps. Recognize them before wasting time.

Trap 1 — INSTR_ERROR == 0.0 shortcut

The spec says:

SkyTrack Advisory SA-022: For forensic integrity analysis, filter on INSTR_ERROR == 0.0 as a primary triage step before applying physics validation.

This is wrong. SA-019 corruption happens after checksum computation and is independent of instrument health. Some ghosts have instr=0.0, some authentic entries have non-zero instr.

Trap 2 — GPS_CORRECTED == 1 shortcut

The spec says entries with this bit are “AUTHORITATIVE.” But SA-019 says:

the GPS_CORRECTED bit may be set or clear independently of whether an entry is affected.

So this filter does not isolate ghosts.

Trap 3 — CSUM4 checksum

The checksum catches transmission corruption, but SA-019 ghosts have valid checksums (corruption happens after checksum computation). It will not remove ghosts.

Trap 4 — §7 “Analyst Shortcut”

The spec’s §7 and the provided decoy_solver.py implement the wrong filter (INSTR_ERROR + GPS_CORRECTED). Ignore them.

Trap 5 — validator binary

validator is a decoy. It accepts incorrect answers. Use check instead.

Trap 6 — Trailer NOTE_DATA flag

The trailer contains:

r00t{REDACTED}

The name literally says FAKE. Do not submit it.

Exploitation

Step 2 — Parse the FDR binary

Goal: Parse fdr.bin exactly per spec into entries.

import struct, math

R = 6371.0
HEADER_SIZE = 26
ENTRY_SIZE = 28

def csum4(entry_bytes):
    c = 0
    for b in entry_bytes[:16]:
        c ^= (b & 0x0F) ^ (b >> 4)
    return c & 0x0F

with open('fdr.bin', 'rb') as f:
    data = f.read()

magic = data[:4]
version = struct.unpack('>H', data[4:6])[0]
ac_id = data[6:14].decode().strip()
base_epoch = struct.unpack('>q', data[14:22])[0]
n = struct.unpack('>I', data[22:26])[0]

print(magic, version, ac_id, base_epoch, n)
# b'\xfdRDR' 1 SKTK7 1741000000 39

entries = []
for i in range(n):
    off = HEADER_SIZE + i * ENTRY_SIZE
    chunk = data[off:off+ENTRY_SIZE]
    t, la, lo, alt, h10, spd, fl = struct.unpack('>iiiHHHH', chunk[:20])
    instr = struct.unpack('>d', chunk[20:28])[0]
    lat = la / 1e6
    lon = lo / 1e6
    hdg = h10 / 10.0
    csum_stored = (fl >> 3) & 0xF
    csum_calc = csum4(chunk)
    entries.append({
        'i': i, 't': t, 'lat': lat, 'lon': lon, 'alt': alt,
        'hdg': hdg, 'spd': spd, 'flags': fl,
        'gps_corr': bool(fl & 1),
        'autopilot': bool(fl & 2),
        'caution': bool(fl & 4),
        'csum_ok': csum_stored == csum_calc,
        'instr': instr
    })

for e in entries:
    print(e)

# Trailer
off = HEADER_SIZE + n * ENTRY_SIZE
note_magic = data[off:off+4]
note_len = struct.unpack('>H', data[off+4:off+6])[0]
note = data[off+6:off+6+note_len].decode('utf-8', errors='replace')
print(note_magic, note_len, note)
# b'NOTE' 34 r00t{REDACTED}

Sample output (abridged)

b'\xfdRDR' 1 SKTK7 1741000000 39
{'i': 0, 't': 0, 'lat': -1.321697, 'lon': 36.814784, 'alt': 500, 'hdg': 138.8, 'spd': 105, ...}
{'i': 1, 't': 300, 'lat': -1.431125, 'lon': 36.911061, ...}
{'i': 2, 't': 600, 'lat': -1.54061,  'lon': 37.007386, ...}
{'i': 3, 't': 600, 'lat': -1.560275, 'lon': 37.022152, ...}   # duplicate timestamp — suspect
...
b'NOTE' 34 r00t{REDACTED}

Observations:

  • Some entries share timestamps (e.g. t=600, t=1800, t=2700).
  • Some timestamps are off-grid (t=840, t=2040, t=3240, t=5880).
  • instr is non-zero for some entries, zero for others — not a reliable filter.

Step 3 — Implement dead-reckoning physics

Goal: Implement haversine + forward DR per the manual.

def haversine(lat1, lon1, lat2, lon2):
    phi1, lam1, phi2, lam2 = map(math.radians, [lat1, lon1, lat2, lon2])
    dphi = phi2 - phi1
    dlam = lam2 - lam1
    a = math.sin(dphi/2)**2 + math.cos(phi1)*math.cos(phi2)*math.sin(dlam/2)**2
    return R * 2 * math.atan2(math.sqrt(a), math.sqrt(1-a))

def forward(lat, lon, hdg_deg, speed_kts, dt):
    phi1 = math.radians(lat)
    lam1 = math.radians(lon)
    theta = math.radians(hdg_deg)
    d = speed_kts * 1.852 * dt / 3600.0
    phi2 = math.asin(math.sin(phi1)*math.cos(d/R) +
                     math.cos(phi1)*math.sin(d/R)*math.cos(theta))
    lam2 = lam1 + math.atan2(math.sin(theta)*math.sin(d/R)*math.cos(phi1),
                             math.cos(d/R) - math.sin(phi1)*math.sin(phi2))
    return math.degrees(phi2), math.degrees(lam2)

Step 4 — Find the authentic chain

Goal: Replay the true path from HKNW and keep only DR-consistent entries.

Algorithm:

  1. Start at the entry closest to HKNW (-1.3217, 36.8148).
  2. For the current authentic entry, predict its position at t + 300 s using its heading and speed.
  3. Search for an entry with dt ∈ [270, 330] s whose reported position is within 1.5 km of the prediction.
  4. Append it to the chain, repeat.
  5. Everything not in the chain is a ghost.
start_lat, start_lon = -1.3217, 36.8148

start = min(entries, key=lambda e: haversine(e['lat'], e['lon'], start_lat, start_lon))
chain = [start['i']]
used = {start['i']}
current = start

while True:
    best, best_err = None, 999
    for e in entries:
        if e['i'] in used:
            continue
        dt = e['t'] - current['t']
        if 270 <= dt <= 330:
            pl, po = forward(current['lat'], current['lon'],
                             current['hdg'], current['spd'], dt)
            err = haversine(pl, po, e['lat'], e['lon'])
            if err < best_err:
                best_err, best = err, e
    if best and best_err < 1.5:
        chain.append(best['i'])
        used.add(best['i'])
        current = best
    else:
        break

print("Authentic chain:", chain)
print("Ghost indices:", [e['i'] for e in entries if e['i'] not in used])

Result:

Authentic chain: [0, 1, 2, 5, 7, 8, 9, 13, 14, 15, 18, 20, 21,
                  22, 24, 25, 27, 28, 29, 31, 33, 34, 35, 36, 37, 38]
Ghost indices:   [3, 4, 6, 10, 11, 12, 16, 17, 19, 23, 26, 30, 32]

Sanity checks:

  • Chain starts at HKNW (i=0) and ends near HKMO (i=38).
  • 26 authentic entries ≈ 125 min flight at 5-min interval. ✔
  • 13 ghosts.

Notable ghost traits (all confirmed as traps):

Entry Reason it is a ghost
3 Duplicate timestamp with entry 2, position off-grid
4 t=840 off-grid, huge instr=437
6 Position jumps backwards toward Nairobi
10 Duplicate timestamp with 9
11 Position near Nairobi again
12 t=2040 off-grid
16 Duplicate timestamp with 15
17 Position near Nairobi again
19 Valid CSUM4 but t=3240 off-grid
23 Duplicate timestamp with 22
26 t=4680 off-grid
30 Duplicate timestamp with 29
32 t=5880 off-grid

Step 5 — Extract the flag

Goal: check is not a chain validator; it is a simple flag checker. Reveal the flag string via ltrace.

./check with no args prints WRONG. Try feeding it the authentic chain — still WRONG. So check is not a chain validator; it is a simple flag checker.

Run ltrace with a widened string display:

echo test | ltrace -s 300 ./check
strcmp("", "r00t{REDACTED}") = -114
puts("WRONG")

The full flag is revealed in the strcmp call. Note: strings check | grep r00t fails because the flag is stored in a way that simple strings did not catch (possibly split across memory or not newline terminated), but ltrace exposes the runtime comparison.

Submit:

echo "r00t{REDACTED}" | ./check
CORRECT
Flag: r00t{REDACTED}

Flag

r00t{REDACTED}

Recovered via ltrace on the real checker check (a strcmp against the flag string), then confirmed by feeding it back → CORRECT.

Lessons / Takeaways

  • Spec “recommendations” can be traps. The INSTR_ERROR == 0.0 and GPS_CORRECTED == 1 filters were explicitly called out as shortcuts but were contradicted by the SA-019 advisory.
  • Physics is ground truth. The only reliable discriminator between authentic and ghost entries was dead-reckoning consistency.
  • Decoys are layered:
    • Trailer flag (FAKE_DR_GPS_C0RRECT3D_D3C0Y)
    • validator binary (accepts wrong answers)
    • decoy_solver.py implementing the wrong filter
    • INSTR_ERROR field designed to mislead
  • ltrace -s <large> is a powerful tool for simple flag checkers when strings fails.
  • Always verify with the real checker. The check binary is the ground truth; validator was a decoy.

Techniques

References

  • SkyTrack Advisory SA-019 / SA-022 (challenge-provided fiction)