问题
Is it possible to decode protobuf serialized files without schema with tools or anything that would decode the binary data to readable format?
回答1:
You can often deduce the schema. In fact, IIRC the "protoc" tool has a set of parameters (--decode_raw
, iirc) where it will do precisely that - making informed guesses. However, it is a guess - the format is ambiguous in that multiple different types of data can be stored in the same mechanisms - for example, a length-prefixed chunk could be:
- a sub-object (of any user type)
- a packed array (of various primitive types)
- a utf-8 string
- a raw byte[]
- and probably something else I'm forgetting
Likewise, a 4-byte fixed-width chunk could be a fixed-width integer, or a float; the integer could be signed or unsigned.
来源:https://stackoverflow.com/questions/25898230/decoding-protobuf-without-schema