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 ?
Is there any way to decompiler google protobuf binary file(.pb file) to .proto file
Asked Answered
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/decode –
Trophozoite
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 file –
Ella
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.
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_in
–
Trophozoite Sorry. It's typo. What I use is descriptor_set_in –
Ella
@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 out –
Trophozoite Hm,
Unknown flag: --descriptor_set_in
, version 3.14.0 –
Flask © 2022 - 2024 — McMap. All rights reserved.