Python 将二进制文件转换为原始文件

Python 将二进制文件转换为原始文件,python,protocol-buffers,google-protocol-buffer,Python,Protocol Buffers,Google Protocol Buffer,服务器返回给我二进制文件- 我想找到二进制文件的.proto结构 因此,我将该文件添加到该站点- 收到 我创建了proto文件,但没有收到有效文本 我应该在我的原型结构中改变什么 更新1 我曾经 如果您无法获得模式,那么这主要是基于试错的。但是,我可以告诉您,这里的根对象看起来不像一个重复的列表——这是真的 每个子项都有相同的字段号,分别为1和2 每个子项的形状都与其他子项相同,请参见字段4“文本与子对象” 因此,您的根对象有如下内容: 可选的Foo-Foo=1; 可选条=2; 如果您无法获得模

服务器返回给我二进制文件-

我想找到二进制文件的.proto结构

因此,我将该文件添加到该站点-

收到

我创建了proto文件,但没有收到有效文本

我应该在我的原型结构中改变什么

更新1 我曾经


如果您无法获得模式,那么这主要是基于试错的。但是,我可以告诉您,这里的根对象看起来不像一个重复的列表——这是真的

每个子项都有相同的字段号,分别为1和2 每个子项的形状都与其他子项相同,请参见字段4“文本与子对象” 因此,您的根对象有如下内容:

可选的Foo-Foo=1; 可选条=2;
如果您无法获得模式,那么这主要是基于试错的。但是,我可以告诉您,这里的根对象看起来不像一个重复的列表——这是真的

每个子项都有相同的字段号,分别为1和2 每个子项的形状都与其他子项相同,请参见字段4“文本与子对象” 因此,您的根对象有如下内容:

可选的Foo-Foo=1; 可选条=2;
如果这是过时的,很抱歉,但是如果您查看该页面上运行的js,会发现一些用于解码这些对象的代码:

t、 id&&t.hasOwnPropertyid&&e.uint3210.bytest.id, 空!=t、 description和&t.hasownproperty说明和&e.uint3218.stringt.description, 空!=t、 imageUrl&&t.hasOwnPropertyimageUrl&&e.uint3226.stringt.imageUrl, 空!=t、 priceOld&t.HasownProperty priceOld&e.uint3237.Float.priceOld, 空!=t、 priceNew和&t.hasOwnPropertypriceNew和&e.uint3245.Float.priceNew, 空!=t、 priceIsFrom&&t.hasOwnPropertypriceIsFrom&&e.uint3248.boolt.priceIsFrom, t、 segmentId&&t.hasOwnPropertysegmentId&&e.uint3258.bytest.segmentId, 空!=t、 数量和t.HasownProperty数量和e.uint3269.Float.quantity, 空!=t、 quantityUnit和&t.hasOwnPropertyquantityUnit和&e.uint3274.stringt.quantityUnit, 空!=t、 折扣和&t.hasOwnPropertydiscount和&e.uint3285.float.discount, 空!=t、 折扣单位和&t.hasOwnPropertydiscountUnit和&e.uint3290.stringt.discountUnit, 空!=t、 折扣标签和&t.hasOwnPropertydiscountLabel和&e.uint3298.stringt.discountLabel, 空!=t、 折扣百分比和&t.HasownProperty折扣百分比和&e.uint32104.uint32t.discountPercent, 空!=t、 国家和t.HasownProperty国家和e.uint32114.stringt.country, 空!=t、 dateStart&&t.hasOwnPropertydateStart&&e.uint32122.stringt.dateStart, 空!=t、 dateEnd和&t.hasOwnPropertydateEnd和&e.uint32130.stringt.dateEnd, t、 metaId和&t.hasOwnPropertymetaId和&e.uint32138.bytest.metaId, t、 compileids&&t.compileids.length 对于var r=0;r也许这样可以更容易地对protobuf模式进行反向工程。

如果这是过时的,很抱歉,但是如果您查看该页面上运行的js,会发现一些用于解码这些对象的代码:

t、 id&&t.hasOwnPropertyid&&e.uint3210.bytest.id, 空!=t、 description和&t.hasownproperty说明和&e.uint3218.stringt.description, 空!=t、 imageUrl&&t.hasOwnPropertyimageUrl&&e.uint3226.stringt.imageUrl, 空!=t、 priceOld&t.HasownProperty priceOld&e.uint3237.Float.priceOld, 空!=t、 priceNew和&t.hasOwnPropertypriceNew和&e.uint3245.Float.priceNew, 空!=t、 priceIsFrom&&t.hasOwnPropertypriceIsFrom&&e.uint3248.boolt.priceIsFrom, t、 segmentId&&t.hasOwnPropertysegmentId&&e.uint3258.bytest.segmentId, 空!=t、 数量和t.HasownProperty数量和e.uint3269.Float.quantity, 空!=t、 quantityUnit和&t.hasOwnPropertyquantityUnit和&e.uint3274.stringt.quantityUnit, 空!=t、 折扣和&t.hasOwnPropertydiscount和&e.uint3285.float.discount, 空!=t、 折扣单位&t.hasOwnPropertydiscountUnit&e.uin t3290.T.折扣单位, 空!=t、 折扣标签和&t.hasOwnPropertydiscountLabel和&e.uint3298.stringt.discountLabel, 空!=t、 折扣百分比和&t.HasownProperty折扣百分比和&e.uint32104.uint32t.discountPercent, 空!=t、 国家和t.HasownProperty国家和e.uint32114.stringt.country, 空!=t、 dateStart&&t.hasOwnPropertydateStart&&e.uint32122.stringt.dateStart, 空!=t、 dateEnd和&t.hasOwnPropertydateEnd和&e.uint32130.stringt.dateEnd, t、 metaId和&t.hasOwnPropertymetaId和&e.uint32138.bytest.metaId, t、 compileids&&t.compileids.length 对于var r=0;r也许这样更容易对protobuf模式进行反向工程。

这是否回答了您的问题?这回答了你的问题吗@发誓我不能告诉你名字-二进制内容不包括这些-我只知道它们是不同的。您需要分别对每个负载进行反向工程。大概其中一个就是你所说的城市类型。另一个是不同的形状,所以它是另一个。我不会说俄语,也不知道上下文是什么,所以…@swor的内容与网站截图基本相同。这里真正的问题是什么?我不能告诉你这些字段是什么或是什么意思。有一些明显的文本字段和一些整数字段,尽管我不能告诉您它们是否有符号。第一种消息类型中的两个字段字段1和第二种消息类型中的字段1和字段2可能是字节,但我不能告诉您这些字节代表什么。@第一条消息中的SWAR btw字段4可能是持续时间或时间戳可能是时间戳-2005年4月27日有什么意义吗?@SWORM还有,16字节表示guid/uuid,但是我不能告诉你哪一个端点/布局有多个约定use@swor定义消除。在我看来,没有一条消息是不好的。如果你不关心数据,当然:你可以忽略它。@发誓我不能告诉你名称-二进制内容不包括这些-我只知道它们是不同的。您需要分别对每个负载进行反向工程。大概其中一个就是你所说的城市类型。另一个是不同的形状,所以它是另一个。我不会说俄语,也不知道上下文是什么,所以…@swor的内容与网站截图基本相同。这里真正的问题是什么?我不能告诉你这些字段是什么或是什么意思。有一些明显的文本字段和一些整数字段,尽管我不能告诉您它们是否有符号。第一种消息类型中的两个字段字段1和第二种消息类型中的字段1和字段2可能是字节,但我不能告诉您这些字节代表什么。@第一条消息中的SWAR btw字段4可能是持续时间或时间戳可能是时间戳-2005年4月27日有什么意义吗?@SWORM还有,16字节表示guid/uuid,但是我不能告诉你哪一个端点/布局有多个约定use@swor定义消除。在我看来,没有一条消息是不好的。如果你不关心数据,当然:你可以忽略它。
syntax = "proto2";

    message Cities {
      repeated City city = 1;
    }
    
    message City {
      optional string name = 2;
      optional string name2 = 3;
      optional string name3 = 4;
      optional string name4 = 5;
      optional string name5 = 6;
      optional string name6 = 7;
      optional int32 name7 = 8;
      optional int32 name8 = 9;
      optional int32 name9 = 10;
      optional string name10 = 11;
    }
protoc --decode_raw < binary_file.protobuf
1 {
  1: "U\222\017\352c\021\021\346\204\237RT\000\020\266\010"
  2: "\320\241\320\260\320\275\320\272\321\202-\320\237\320\265\321\202\320\265\321\200\320\261\321\203\321\200\320\263"
  4 {
    1: 0x426fc1a3
    2: 0x41f286ea
  }
  5: "\320\241\320\260\320\275\320\272\321\202-\320\237\320\265\321\202\320\265\321\200\320\261\321\203\321\200\320\263"
  5: "\320\241\320\260\320\275\320\272\321\202-\320\237\320\265\321\202\320\265\321\200\320\261\321\203\321\200\320\263\320\260"
  5: "\320\241\320\260\320\275\320\272\321\202-\320\237\320\265\321\202\320\265\321\200\320\261\321\203\321\200\320\263\321\203"
  5: "\320\241\320\260\320\275\320\272\321\202-\320\237\320\265\321\202\320\265\321\200\320\261\321\203\321\200\320\263"
  5: "\320\241\320\260\320\275\320\272\321\202-\320\237\320\265\321\202\320\265\321\200\320\261\321\203\321\200\320\263\320\276\320\274"
  5: "\320\241\320\260\320\275\320\272\321\202-\320\237\320\265\321\202\320\265\321\200\320\261\321\203\321\200\320\263\320\265"
  5: "\320\241\320\260\320\275\320\272\321\202-\320\237\320\265\321\202\320\265\321\200\320\261\321\203\321\200\320\263\320\265"
  6: "sankt-peterburg"
  7: 2
}
2 {
  1: "\224\331\203\202B\303\021\346\224\031RT\000\020\266\010"
  2: "\260\336\t\360I\026I\006\217\232t\2021T\030B"
  3: "\320\237\321\217\321\202\321\221\321\200\320\276\321\207\320\272\320\260"
  4: "https://leonardo.edadeal.io/dyn/re/retailers/images/icons/sq/85cd6908f8a34aefbe66dd1948cc3d39.png"
  5: "https://leonardo.edadeal.io/dyn/re/retailers/images/logos/sq/992af68cffaa47de9ff23079648074ad.png"
  6: "eb2316"
  7: 733
  8: 55
  9: 425
  10: "5ka"
}
2 {
  1: "\224\331\205\336B\303\021\346\224\031RT\000\020\266\010"
  2: "\260\336\t\360I\026I\006\217\232t\2021T\030B"
  3: "\320\224\320\270\320\272\321\201\320\270"
  4: "https://leonardo.edadeal.io/dyn/re/retailers/images/icons/sq/146db05ebc81464cbf4872675cb2e761.png"
  5: "https://leonardo.edadeal.io/dyn/re/retailers/images/logos/sq/9c2b2c291f134929949fa4daab88252f.png"
  6: "FF8A38"
  7: 691
  8: 61
  9: 276
  10: "dixy"
}