Is there any way to decompiler google protobuf binary file(.pb file) to .proto file
Asked Answered
E

1

6

When I'm reversing an apk I got .pb file but not .proto file, is there any way to decompiler this file to .proto file or can I just generate java code from this .pb file ?

Ella answered 29/7, 2019 at 8:33 Comment(4)
The .pb file - is it the data? Or is it a compiled descriptor set? If it is data: you'll have to reverse engineer it - there are tools to help, so it isn't necessarily hard. If it is the compiled descriptor set: much easier. Protoc has a tool for looking at raw payloads, as does my online tooling here protogen.marcgravell.com/decodeTrophozoite
It's the compiled descriptor set. do you mean --decode_raw ? Is there any way I can get .proto file directly ?Ella
question: what do you need the .proto for? is it for editing? if it is for code-gen, IIRC protoc will accept the compiled descriptor set as input (or you can invoke the plugins directly - the way plugins work is that the compiled descriptor set is piped to stdin)Trophozoite
For java code generate. Which plugin ? protoc may not be able to generate by this fileElla
T
4

If (as per comments) the file you have is the compiled descriptor set, then you can use protoc to generate any language (that it usually supports) from this; simply use the --descriptor_set_in=FILES option at the command line to specify your file as input (in place of FILES), and use --java_out=OUT_DIR (or whatever) to indicate the output language and location.

Trophozoite answered 30/7, 2019 at 7:7 Comment(5)
How does this actually work ? When I use the command protoc --description_set_in=./myfile.pb --java_out=. I got an error "Missing input file.". When I add an empty file to the end(no matter it exists or not). I got an error "No such file or directory".Ella
@Ella descriptor_set_in, not description_set_inTrophozoite
Sorry. It's typo. What I use is descriptor_set_inElla
@Ella oops, my bad - you still need to specify the file - it checks the descriptor sets before it tests the file. So: try protoc --descriptor_set_in=your.pb --java_out=somedir your.proto - I've just tested this locally, and it worked fine (no your.proto in the drive); the only trick is : knowing the name of the file in the descriptor set. I can probably extract that if you can't figure it outTrophozoite
Hm, Unknown flag: --descriptor_set_in, version 3.14.0Flask

© 2022 - 2024 — McMap. All rights reserved.