ProtobufPwn
还原.proto文件
pbtk
1 |
|
逆向
先找到字段字符串
然后通过交叉引用找到message字段的结构体,一般在.data.rel.ro
段
结构体各字段具体如下:
1 |
|
label对应枚举如下:
1 |
|
type对应枚举如下:
Protobuf C Type | C Type | Line Number Minus One (Hex) |
---|---|---|
PROTOBUF_C_TYPE_INT32 | int32 | 0x0 |
PROTOBUF_C_TYPE_SINT32 | signed int32 | 0x1 |
PROTOBUF_C_TYPE_SFIXED32 | signed int32 (4 bytes) | 0x2 |
PROTOBUF_C_TYPE_INT64 | int64 | 0x3 |
PROTOBUF_C_TYPE_SINT64 | signed int64 | 0x4 |
PROTOBUF_C_TYPE_SFIXED64 | signed int64 (8 bytes) | 0x5 |
PROTOBUF_C_TYPE_UINT32 | unsigned int32 | 0x6 |
PROTOBUF_C_TYPE_FIXED32 | unsigned int32 (4 bytes) | 0x7 |
PROTOBUF_C_TYPE_UINT64 | unsigned int64 | 0x8 |
PROTOBUF_C_TYPE_FIXED64 | unsigned int64 (8 bytes) | 0x9 |
PROTOBUF_C_TYPE_FLOAT | float | 0xA |
PROTOBUF_C_TYPE_DOUBLE | double | 0xB |
PROTOBUF_C_TYPE_BOOL | boolean | 0xC |
PROTOBUF_C_TYPE_ENUM | enumerated type | 0xD |
PROTOBUF_C_TYPE_STRING | UTF-8 or ASCII string | 0xE |
PROTOBUF_C_TYPE_BYTES | arbitrary byte sequence | 0xF |
PROTOBUF_C_TYPE_MESSAGE | nested message | 0x10 |
下图
对应的message为:
1 |
|
编译proto文件
1 |
|
编译完成后生成一个proto_file_pb2.py文件,在脚本中通过import proto_file_pb2
引用,通过cont = proto_file_pb2.devicemsg()
创建message对象,其中devicemsg为.proto文件内的message结构体名称,通过cont.whatcon=b’aaaa’赋值,最后通过cont.SerializeToString()解析然后发送。
ProtobufPwn
https://www.w4y2sh3ll.top/2024/05/29/ProtobufPwn/