SReverseby Simpa Labs

Binary protocols

Recovering field boundaries in a custom binary protocol

Recover a binary message's framing and fields from the app's codec and controlled samples. Validate the map before turning it into an encoder and decoder.

Map the message boundary

Start with the transport and the app's encode/decode calls. Record where the message begins, its declared length, any compression or encryption, and where the parser finishes. Compare samples that differ in one known input.

A shared prefix is a candidate header, not proof of framing. A number that reaches a plausible boundary is a candidate length. Confirm both with more samples and the reader or writer code.

Identify the actual field layout

Binary formats can use fixed layouts, tags, lengths, offsets or combinations of them. Do not impose a separate tag byte and type byte on an unknown format.

Protobuf is one documented example: its field number and wire type share a varint tag. Length-delimited values then carry a varint length, and several declared types share that wire representation. The protobuf wire guide provides a format to compare when the app actually uses it.

For a custom format, record integer width, byte order, signedness, length units and the offsets used by the app. Check known values and boundaries across samples before assigning a field name or type.

Resolve nesting and padding

A range that parses as a nested message still needs confirmation from its caller. It can also hold bytes, text, compressed data or another encoding. Follow the parser's use of that range.

Runs of zero bytes can be data, reserved space or padding. Check how the writer calculates the next offset and how the reader skips it. Preserve unknown bytes where the protocol requires them and keep their role marked in the field notes.

Test the parser with controlled fixtures

Change a known field, truncate a message and vary a candidate length in a local test harness. Check bounds, parser position and decoded values. A remote rejection alone does not identify a length prefix or a signed range: parsing, authentication and application rules can all reject input.

Test encoder/decoder round trips and compare meaningful results with the app. Exact bytes also matter when a signature covers the serialization, so keep that comparison separate from semantic equality.

Deliver the codec with the workflow

A useful handoff includes callable methods, field notes, representative fixtures and error behavior. Binary protocol reconstruction connects that codec with authentication, signing and the app's full client workflows. The protobuf guide covers its known wire format.

Reviewed 19 October 2026 · SReverse research desk

Start your full APK reconstruction

Send the full APK

Projects start at $70. Choose WhatsApp or email, then attach the APK in the app that opens. We reply within one hour with the next step and send the fixed quote after review.

Want us to contact you?