python谷歌序列化传输[Python基础]
今日破解某app加密app当中用到了谷歌序列化传输
1.请求序列化文件
# Generated by the protocol buffer compiler. DO NOT EDIT!# source: xbeiapp.proto
# 用于x呗请求参数的序列化
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode("latin1"))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
from google.protobuf import descriptor_pb2
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
DESCRIPTOR = _descriptor.FileDescriptor(
name="xbeiapp.proto",
package="",
syntax="proto3",
serialized_pb=_b("
x0exbei.proto"xd0x01
x0cTerminalInfox12x14
x0cterminalTypex18x01 x01( x12x12
appVersionx18x02 x01( x12x15
systemVersionx18x03 x01( x12x11
deviceKeyx18x04 x01( x12x0c
x04langx18x05 x01( x12x12
appChannelx18x07 x01( x12x13
x0bproductTypex18x08 x01( x12x13
x0bproductNamex18 x01( x12x0f
x07x61ppTypex18
x01( x12x0f
x07x61ppNamex18x0b x01( "xe6x02
x0fx45nvironmentInfox12x16
x0ex64x65viceUniqueIdx18x04 x01( x12x10
x08x62lackBoxx18x05 x01( x12x12
intranelIPx18x07 x01( x12x11
longiTudex18 x01( x12x10
x08latiTudex18
x01( x12x0b
x03macx18x0b x01( x12x0c
x04imeix18x0c x01( x12x15
phoneOperatorx18 x01( x12x13
x0bphoneMarkerx18x0e x01( x12x12
phoneModelx18x0f x01( x12x14
x0coperationSysx18x11 x01( x12x1b
x13operationSysVersionx18x12 x01( x12x12
isEmulatorx18x18 x01( x12/
resolutionx18x13 x03(x0bx32x1b.EnvironmentInfo.Resolutionx1ax1d
Resolutionx12x0f
x07smartidx18x06 x01( "x81x01
x08xbeix12x13
x0bphoneNumberx18x03 x01( x12#
x0cterminalInfox18x02 x03(x0bx32.TerminalInfox12x10
x08x63odeTypex18x04 x01( x12)
x0fx65nvironmentInfox18x05 x03(x0bx32x10.EnvironmentInfobx06proto3")
)
_TERMINALINFO = _descriptor.Descriptor(
name="TerminalInfo",
full_name="TerminalInfo",
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name="terminalType", full_name="TerminalInfo.terminalType", index=0,
number=1, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="appVersion", full_name="TerminalInfo.appVersion", index=1,
number=2, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="systemVersion", full_name="TerminalInfo.systemVersion", index=2,
number=3, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="deviceKey", full_name="TerminalInfo.deviceKey", index=3,
number=4, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="lang", full_name="TerminalInfo.lang", index=4,
number=5, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="appChannel", full_name="TerminalInfo.appChannel", index=5,
number=7, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="productType", full_name="TerminalInfo.productType", index=6,
number=8, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="productName", full_name="TerminalInfo.productName", index=7,
number=9, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="appType", full_name="TerminalInfo.appType", index=8,
number=10, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="appName", full_name="TerminalInfo.appName", index=9,
number=11, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
],
extensions=[
],
nested_types=[],
enum_types=[
],
options=None,
is_extendable=False,
syntax="proto3",
extension_ranges=[],
oneofs=[
],
serialized_start=19,
serialized_end=227,
)
_ENVIRONMENTINFO_RESOLUTION = _descriptor.Descriptor(
name="Resolution",
full_name="EnvironmentInfo.Resolution",
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name="smartid", full_name="EnvironmentInfo.Resolution.smartid", index=0,
number=6, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
],
extensions=[
],
nested_types=[],
enum_types=[
],
options=None,
is_extendable=False,
syntax="proto3",
extension_ranges=[],
oneofs=[
],
serialized_start=559,
serialized_end=588,
)
_ENVIRONMENTINFO = _descriptor.Descriptor(
name="EnvironmentInfo",
full_name="EnvironmentInfo",
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name="deviceUniqueId", full_name="EnvironmentInfo.deviceUniqueId", index=0,
number=4, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="blackBox", full_name="EnvironmentInfo.blackBox", index=1,
number=5, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="intranelIP", full_name="EnvironmentInfo.intranelIP", index=2,
number=7, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="longiTude", full_name="EnvironmentInfo.longiTude", index=3,
number=9, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="latiTude", full_name="EnvironmentInfo.latiTude", index=4,
number=10, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="mac", full_name="EnvironmentInfo.mac", index=5,
number=11, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="imei", full_name="EnvironmentInfo.imei", index=6,
number=12, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="phoneOperator", full_name="EnvironmentInfo.phoneOperator", index=7,
number=13, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="phoneMarker", full_name="EnvironmentInfo.phoneMarker", index=8,
number=14, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="phoneModel", full_name="EnvironmentInfo.phoneModel", index=9,
number=15, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="operationSys", full_name="EnvironmentInfo.operationSys", index=10,
number=17, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="operationSysVersion", full_name="EnvironmentInfo.operationSysVersion", index=11,
number=18, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="isEmulator", full_name="EnvironmentInfo.isEmulator", index=12,
number=24, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="resolution", full_name="EnvironmentInfo.resolution", index=13,
number=19, type=11, cpp_type=10, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
],
extensions=[
],
nested_types=[_ENVIRONMENTINFO_RESOLUTION, ],
enum_types=[
],
options=None,
is_extendable=False,
syntax="proto3",
extension_ranges=[],
oneofs=[
],
serialized_start=230,
serialized_end=588,
)
_xbei = _descriptor.Descriptor(
name="xbei",
full_name="xbei",
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name="phoneNumber", full_name="xbei.phoneNumber", index=0,
number=3, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="terminalInfo", full_name="xbei.terminalInfo", index=1,
number=2, type=11, cpp_type=10, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="codeType", full_name="xbei.codeType", index=2,
number=4, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="environmentInfo", full_name="xbei.environmentInfo", index=3,
number=5, type=11, cpp_type=10, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
],
extensions=[
],
nested_types=[],
enum_types=[
],
options=None,
is_extendable=False,
syntax="proto3",
extension_ranges=[],
oneofs=[
],
serialized_start=591,
serialized_end=720,
)
_ENVIRONMENTINFO_RESOLUTION.containing_type = _ENVIRONMENTINFO
_ENVIRONMENTINFO.fields_by_name["resolution"].message_type = _ENVIRONMENTINFO_RESOLUTION
_xbei.fields_by_name["terminalInfo"].message_type = _TERMINALINFO
_xbei.fields_by_name["environmentInfo"].message_type = _ENVIRONMENTINFO
DESCRIPTOR.message_types_by_name["TerminalInfo"] = _TERMINALINFO
DESCRIPTOR.message_types_by_name["EnvironmentInfo"] = _ENVIRONMENTINFO
DESCRIPTOR.message_types_by_name["xbei"] = _xbei
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
TerminalInfo = _reflection.GeneratedProtocolMessageType("TerminalInfo", (_message.Message,), dict(
DESCRIPTOR = _TERMINALINFO,
__module__ = "xbei_pb2"
# @@protoc_insertion_point(class_scope:TerminalInfo)
))
_sym_db.RegisterMessage(TerminalInfo)
EnvironmentInfo = _reflection.GeneratedProtocolMessageType("EnvironmentInfo", (_message.Message,), dict(
Resolution = _reflection.GeneratedProtocolMessageType("Resolution", (_message.Message,), dict(
DESCRIPTOR = _ENVIRONMENTINFO_RESOLUTION,
__module__ = "xbei_pb2"
# @@protoc_insertion_point(class_scope:EnvironmentInfo.Resolution)
))
,
DESCRIPTOR = _ENVIRONMENTINFO,
__module__ = "xbei_pb2"
# @@protoc_insertion_point(class_scope:EnvironmentInfo)
))
_sym_db.RegisterMessage(EnvironmentInfo)
_sym_db.RegisterMessage(EnvironmentInfo.Resolution)
xbei = _reflection.GeneratedProtocolMessageType("xbei", (_message.Message,), dict(
DESCRIPTOR = _xbei,
__module__ = "xbei_pb2"
# @@protoc_insertion_point(class_scope:xbei)
))
_sym_db.RegisterMessage(xbei)
# @@protoc_insertion_point(module_scope)
2.返回参数反序列化
# Generated by the protocol buffer compiler. DO NOT EDIT!# source: xbei.proto
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode("latin1"))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
from google.protobuf import descriptor_pb2
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
DESCRIPTOR = _descriptor.FileDescriptor(
name="xbei.proto",
package="",
syntax="proto3",
serialized_pb=_b("
x0cxbei.proto">
StatusInfox12x0c
x04x63odex18x01 x01( x12x0f
x07messagex18x02 x01( x12x11
timestampx18x03 x01(x03")
x06xbeix12x1f
statusInfox18x01 x03(x0bx32x0b.StatusInfobx06proto3")
)
_STATUSINFO = _descriptor.Descriptor(
name="StatusInfo",
full_name="StatusInfo",
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name="code", full_name="StatusInfo.code", index=0,
number=1, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="message", full_name="StatusInfo.message", index=1,
number=2, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode("utf-8"),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name="timestamp", full_name="StatusInfo.timestamp", index=2,
number=3, type=3, cpp_type=2, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
],
extensions=[
],
nested_types=[],
enum_types=[
],
options=None,
is_extendable=False,
syntax="proto3",
extension_ranges=[],
oneofs=[
],
serialized_start=16,
serialized_end=78,
)
_xbei = _descriptor.Descriptor(
name="xbei",
full_name="xbei",
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name="statusInfo", full_name="xbei.statusInfo", index=0,
number=1, type=11, cpp_type=10, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None, file=DESCRIPTOR),
],
extensions=[
],
nested_types=[],
enum_types=[
],
options=None,
is_extendable=False,
syntax="proto3",
extension_ranges=[],
oneofs=[
],
serialized_start=80,
serialized_end=121,
)
_xbei.fields_by_name["statusInfo"].message_type = _STATUSINFO
DESCRIPTOR.message_types_by_name["StatusInfo"] = _STATUSINFO
DESCRIPTOR.message_types_by_name["xbei"] = _xbei
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
StatusInfo = _reflection.GeneratedProtocolMessageType("StatusInfo", (_message.Message,), dict(
DESCRIPTOR = _STATUSINFO,
__module__ = "xbei_pb2"
# @@protoc_insertion_point(class_scope:StatusInfo)
))
_sym_db.RegisterMessage(StatusInfo)
xbei = _reflection.GeneratedProtocolMessageType("xbei", (_message.Message,), dict(
DESCRIPTOR = _xbei,
__module__ = "xbei_pb2"
# @@protoc_insertion_point(class_scope:xbei)
))
_sym_db.RegisterMessage(xbei)
# @@protoc_insertion_point(module_scope)
3.序列化部分py代码
def util(self, ip): data_pb = shengbei_pb2.xbei()
terminalInfo = data_pb.terminalInfo.add()
environmentInfo = data_pb.environmentInfo.add()
resolution = environmentInfo.resolution.add()
terminalInfo.terminalType = "app"
terminalInfo.appVersion = "7.14.0"
terminalInfo.systemVersion = self.device_info["version"]
terminalInfo.deviceKey = self.device_info["imei"]
terminalInfo.lang = "CN"
terminalInfo.appChannel = "xxxx"
terminalInfo.productType = "loan"
terminalInfo.productName = "bbd_android"
terminalInfo.appType = "android"
terminalInfo.appName = "xxxxx"
environmentInfo.deviceUniqueId = self.device_info["uniqueId"]
environmentInfo.blackBox = self.device_info["black_box"]
environmentInfo.intranelIP = ip
environmentInfo.longiTude = self.log1
environmentInfo.latiTude = self.lat1
environmentInfo.mac = self.device_info["mac"]
environmentInfo.imei = self.device_info["imei"]
environmentInfo.phoneOperator = "未知"
environmentInfo.phoneMarker = "LGE"
environmentInfo.phoneModel = self.device_info["mobile"]
environmentInfo.operationSys = "android"
environmentInfo.operationSysVersion = self.device_info["version"]
resolution.smartid = self.device_info["smartid"]
environmentInfo.isEmulator = "false"
data_pb.phoneNumber = self.phone
data_pb.codeType = "02"
return data_pb.SerializeToString()
4.反序列化部分py代码
data_pb = shengb_pb2.xbei()data_pb.ParseFromString(content)
以上是 python谷歌序列化传输[Python基础] 的全部内容, 来源链接: utcz.com/z/530035.html