Decoding protobuf without schema

我怕爱的太早我们不能终老 提交于 2019-12-23 09:16:19

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!