Reputation: 93
I'm using a program that sends HTTP requests to the Spotify API using application/x-protobuf
as Content-Type:
Connection: keep-alive
Content-Type: application/x-protobuf
User-Agent: Spotify/113500458 Win32/0 (PC laptop)
Accept-Language: en
Sec-Fetch-Site: none
Sec-Fetch-Mode: no-cors
Sec-Fetch-Dest: empty
Accept-Encoding: gzip, deflate
Content-Length: 134
0A 4D 0A 20 36 35 62 37 30 38 30 37 33 66 63 30 | M 65b708073fc0
34 38 30 65 61 39 32 61 30 37 37 32 33 33 63 61 | 480ea92a077233ca
38 37 62 64 12 29 53 2D 31 2D 35 2D 32 31 2D 37 | 87bd )S-1-5-21-7
39 33 32 33 31 30 32 38 33 2D 30 37 30 35 31 31 | 932310283-070511
38 35 38 32 2D 37 36 37 32 36 37 33 34 35 30 AA | 8582-7672673450ª
06 34 0A 0A 66 69 73 6C 64 70 65 75 74 65 12 09 | 4 fisldpeute
67 70 73 73 65 70 75 74 65 1A 1B 1B 1B 1B 1B 1B | gpssepute
1B 1B 1B 1B 1B 1B 1B 1B 1B 1B 1B 1B 1B 1B 1B 1B |
1B 1B 1B 1B 1B 1B |
How can I please decode that? How does it work and how can I "achieve the same"?
My goal would be to reproduce the request by editing some info in the data it sends.
Upvotes: 3
Views: 6788
Reputation: 1062780
You can decode it (or write the same kind of message) with any protobuf serializer. However, unlike things like XML/JSON, protobuf doesn't include things like field names in the payload, just numeric tokens (field numbers). The best thing to do is to ask "is the .proto schema for this available?". If not, you can still do it, but some of the data types are ambiguous (meaning: two different values can, depending on the schemas, be the exact same bytes) - so a little inspired guesswork is requird. You can reverse-engineer a .proto schema relatively easily, though, using tools like https://protogen.marcgravell.com/decode (I must go and fix the regex there, so you can paste your input including the spaces!)
my guess at that schema
syntax = "proto3";
message SomeRoot {
Header header = 1;
Body body = 101;
}
message Header {
string id = 1; // example "65b708073fc0480e..."
string ref = 2; // example "S-1-5-21-7932310..."
}
message Body {
string Foo = 1; // example "fisldpeute"
string Bar = 2; // example "gpssepute"
bytes Blap = 3; // example 1B1B1B1B1B...? some metadata?
}
based on:
Upvotes: 3