HTTP 请求中的 Protobuf 数据
Protobuf data in HTTP request
我正在使用一个程序发送 HTTP 请求到 Spotify API 使用 application/x-protobuf
作为 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 |
请问我该如何解码?它是如何工作的,我怎样才能“达到同样的效果”?
我的目标是通过编辑请求发送的数据中的一些信息来重现请求。
您可以使用任何 protobuf 序列化程序对其进行解码(或编写相同类型的消息)。但是,与 XML/JSON 之类的东西不同,protobuf 在有效负载中不包含字段名称之类的东西,只包含数字标记(字段编号)。 最好 要做的是问“是否有可用的 .proto 架构?”。如果不是,您仍然可以这样做,但是某些数据类型是不明确的(意思是:根据模式,两个不同的值可以是完全相同的字节)——因此需要一些启发性的猜测。不过,您可以使用 https://protogen.marcgravell.com/decode 之类的工具相对轻松地对 .proto 模式进行逆向工程(我必须去那里修复正则表达式,这样您就可以粘贴包括空格在内的输入!)
我对该模式的猜测
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?
}
基于:
我正在使用一个程序发送 HTTP 请求到 Spotify API 使用 application/x-protobuf
作为 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 |
请问我该如何解码?它是如何工作的,我怎样才能“达到同样的效果”?
我的目标是通过编辑请求发送的数据中的一些信息来重现请求。
您可以使用任何 protobuf 序列化程序对其进行解码(或编写相同类型的消息)。但是,与 XML/JSON 之类的东西不同,protobuf 在有效负载中不包含字段名称之类的东西,只包含数字标记(字段编号)。 最好 要做的是问“是否有可用的 .proto 架构?”。如果不是,您仍然可以这样做,但是某些数据类型是不明确的(意思是:根据模式,两个不同的值可以是完全相同的字节)——因此需要一些启发性的猜测。不过,您可以使用 https://protogen.marcgravell.com/decode 之类的工具相对轻松地对 .proto 模式进行逆向工程(我必须去那里修复正则表达式,这样您就可以粘贴包括空格在内的输入!)
我对该模式的猜测
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?
}
基于: