我使用 Charles Proxy 捕获了 Android 应用程序和网站之间的一些流量。 Charles 将流量识别为 Protocol Buffer 流。
Charles中所示的结构:
- site.com
|
-- sub
|
--- message.proto
原始消息:
POST site.com/sub/message.proto HTTP/1.1
token: random
Id: random
Authorization: Basic OTI[..]
User-Agent: Dalvik/1.6.0 (Linux; U; Android 4.3; Galaxy Nexus Build/JWR66Y)
Host: site.com
Connection: Keep-Alive
Accept-Encoding: gzip
Content-Type: application/x-www-form-urlencoded
Content-Length: 580
��hï õÜÕñ6iaõ*|{6¤oQIùk*դž¼
S_½ª¥8.3ÝÎu öÚ´êVFBeùõÈî¿;µ¼ö%S [...]
我尝试了一些方法来解码内容,但都没有成功。命令proton decode_raw < message.txt
导致失败消息 Failed to parse input
.现在我不确定该消息是否真的是 protobuf 消息,因为 header 中的 Content-Type 并不表示使用了 protobuf。我还将流量保存为 .bin
文件。
Charles 有能力显示 protobuf 消息的上下文,但需要相应的描述 rune 件。但是,要获取描述 rune 件,我需要实际的 .proto
我没有的文件。
那么,我是被迫手动解码消息还是有其他我忽略的可能性?
我怀疑使用了应用程序级加密并且 Charles 无意中将流量识别为 protobuf。
最佳答案
在我看来内容只是被压缩了:
Accept-Encoding: gzip
Content-Type: application/x-www-form-urlencoded
尝试用 gunzip 解压。
我同意它可能不是一个 protobuf。 Charles Proxy 可能对以 .proto
结尾的 URL 感到困惑。
请注意,尝试解码数据时(无论是作为 protobuf 还是作为 gzip),您需要确保只解码请求的正文,即不是文本 HTTP标题。请注意,在文本编辑器中编辑标题可能不起作用,因为将二进制数据转换为文本通常会损坏它。您可能最好通过执行以下操作来提取数据:
tail -c 580 message.txt | zcat
或者,如果您认为它毕竟是一个 protobuf:
tail -c 580 message.txt | protoc --decode_raw
请注意,580 来自 Content-Length
header 。
https://stackoverflow.com/questions/31403884/