How deserialize this response with OP2?

Hllo,

i need help on How deserialize this protobuf and get “10076528” correctly to use it in another request

5 {
1 {
1 {
1 {
3 {
2: “10076528”
}
}
}
}
}

1 Like

You can parse it with either LR or Regex

L = 2: "
R = "

Regex = \d{8} would work unless its not always 8 digits

2 Likes

thanks ,

but not work with protobuf-serialized byte array ,
before Parse need to Deserialize it

1 Like

If you have the .proto contract you can use this guide

Otherwise your best bet is to use data.RAWSOURCE, convert it to hex and parse between the octets, then convert it back to a UTF8 string.

2 Likes

@Ruri
i have a question
I decoded my target post data and now I want to create config using the method you said

my post data:

1 {
1: “9a8d2f0ce77a4e248bb71fefcb557637”
2: “720b9ee1c15fbfce”
}
101 {
1: “[email protected]
2: “xxxxxxxx”
3: “&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&”
}

I put up these two
ProtoBuf
System.IO

In the next steps you are going to enter the code in loli, you have used Address and Person. Do I have to change them or import them the same way? I think if you give an example for that, the members of the association will understand more easily
can you help me?

1 Like

Without the .proto file I have absolutely no idea, sorry

1 Like

@Ruri
Is it not possible with the method you mentioned in this link?

1 Like

Well yeah if you can sniff the raw data it’s possible

1 Like

@Ruri
What do you mean by proto contract? I decoded the post data, which was Protobuff, and sent it to you before

1 Like

Usually when designing data structures to be transfered with protobuf, you write .proto files which are then transformed into classes by a code generator. If you can find those files, then you can easily replicate the data structure used and serialize/deserialize data. If you cannot find them, you either reverse engineer the client-side code or the data structure itself.

I honestly don’t know what 101 means in your case, it could be a nested class or it could be some other thing, I didn’t research enough into how protobuf serializes stuff to byte arrays so I don’t know where that 101 is coming from and how you can join those two pieces together.

1 Like

@Ruri
I dont have them can you give me example with data.RAWSOURCE?

1 Like

Read this

1 Like
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?
}

I guess that’s the .proto file this

1 Like

Thanks for the explanation, didn’t know this ^^

1 Like

No probs sir, you always help me and us all :smiley: :smiley:, can you do that in ob2 using that .proto text
?

If Anyone can execute this .proto code in ob2 please try guys, cuz i dont know much about protobuf and c# :sweat_smile:

In the guide I linked a website that can turn proto files into C# classes, just follow the guide

I Have made it the way it was supposed to be but its showing an error, is something wrong here?

[ProtoContract]

class SomeRoot {

    [ProtoMember(1)]

    public Header Header {get;set;}

    [ProtoMember(101)]

    public Body Body {get;set;}

}

[ProtoContract]

class Header {

    [ProtoMember(1)]

    public string Id {get;set;}

    [ProtoMember(2)]

    public string Ref {get;set;}

}

[ProtoContract]

class Body {

    [ProtoMember(1)]

    public string Foo {get;set;}

    [ProtoMember(2)]

    public string Bar {get;set;}

    [ProtoMember(3)]

    public byte[] Blap {get; set;}

}

var header = new Header

{

    Id = "9a8d2f0ce77a4e248bb71fefcb557637",

    Ref = "720b9ee1c15fbfce",

    Body = new Body

    {

        Foo = "[email protected]",

        Bar = "xxxxxxxx"

    }

};

// This will serialize the object to a byte array using the protobuf serialization

var ms = new MemoryStream();

Serializer.Serialize(ms, header);

var bytes = ms.ToArray();

ms.Dispose();

This is the error

(64,92): error CS0117: ‘Header’ does not contain a definition for ‘Body’

Your object initialization is wrong, here’s how you should do it

var root = new SomeRoot
{
    Header = new Header
	{
		Id = "9a8d2f0ce77a4e248bb71fefcb557637",
    	Ref = "720b9ee1c15fbfce"
	},
	Body = new Body
    {
        Foo = "[email protected]",
        Bar = "xxxxxxxx"
    }
};

var ms = new MemoryStream();
Serializer.Serialize(ms, root);
var bytes = ms.ToArray();
ms.Dispose();