ProtO-BUF serialization using Obfuscation

I am looking for some guidance on what happens when using the obfuscated prototype buf network (Dotfuscator). Half of the project is a DLL, and the other half is an EXE elsewhere, using proto- buf NET, they can exchange data perfectly. Until I confuse the DLL.

At this time, P-BN failed without raising an exception, differently returning a 0-length byte array or a shortened The number of bytes, it depends on what I am fiddling with. This class is very simple (VB):

 _
Friend Class DMailer

Private _Lic As Cert
Private _Sys As Sys
Private _LList As List(Of LItem)

..
. .
End Class

All props decorated with ProtoMember have 3 props to get/set composition class objects. For the sake of brevity.

Again, it works very well Well, until I confuse the DLL. Then, Dotfuscator renamed each of these to null, apparently because they are all friends, which seems to kill the proto-buff. If I exempt the class from renaming (just the class name, not Props/members), it seems to work again. It makes sense that P-BN can only operate on objects with the correct name, but when asked to serialize an empty named object, it seems that the exception may be in order.

On the other hand, many of the charms of PB-N should be independent of serialization of .NET attributes-at least according to my understanding. But in this case, it seems to only apply to classes with names . I tried to use the Name qualifier or parameter as shown above, but to no avail-it obviously didn’t do what I thought was possible.

So, I’m curious if:

a )…I have basically guessed the problem correctly

b)…There are some other attributes or flags that may help serialize
a null named object

c)…If there are any other insights that can help.

If I exempt all 3 or 4 classes renamed by Dotfuscator (LList has not actually been implemented yet, leaving DMailer, Cert and Sys), DLL Seems to work again-at least the output Is the right size. I can live with this, although ambiguous names would be better: Dotfuscator (CE) either exempts them or sets the name to Null-I can’t seem to find a way to force them to be renamed.

An alternative approach I considered is to store the Serializer output of Cert and Sys as byte arrays or Base64 strings in DMailer instead of classes instead of exempting 3 or 4 classes from being renamed. Then let The receiver deserializes each object individually. It’s nice to be able to unlock one thing and make your toy just like magic.

(Multi)TIA

Since there is some rise of interest, this seems to work:

a) any form The reflection can not get the attribute list of the confused type.
I try to find the type with ProtoContract through all types, I can find them
But the attribute names are all changed to a, m, b, j, g.

I also tried Me.GetType.GetProperties with the same result.

You can implement a mapping from the output to indicate that Employee.FirstName is now a0.j, but distribute it Will defeat the purpose of obfuscation.

b) What works to a certain extent is to make the NAME class free from confusion. Since PB-N looks up the ProtoMember attribute to get the data, you can do the attribute/member name Obfuscation, not the CLASS/type name. If the name is similar to FederalReserveLogIn, then your class/type has a bullseye.

I initially had the following success:

1) Build a simple class to store attribute tokens and values. Use ConvertFromInvariantString to store everything as a string. To get the hint from PBN, I used an integer as the token:


Property Foo As String

Enumeration helps to combine everything together in the future. Store them in Dictionary(Of T, NameValuePair)< /p>

2) Add some visitors. These can perform type conversion for you:

Public Sub Add(ByVal Key As T, ByVal value As Object)
If _col.ContainsKey(Key) Then
_col.Remove(Key)
End If

_col.Add(Key, New TValue(value))

End Sub

Public Function GetTItem(Of TT)(key As T) As TT
If _col.ContainsKey(key) Then< br /> Return CType(_col(key).TValue, TT)
Else
Return Nothing
End If
End Function

T is what you want to use Any key type. Integer produces minimal output and still allows subscription code to use enumeration. But it may be String.

TT is the original type:

< pre>myFoo = props.GetTItem(Of Long)(propsEnum.Foo)

3) Expose the internal list (dictionary) to PBN and bingo games, and all are done.

It It is also easy to add converters for points, rectangles, fonts, sizes, colors and even bitmaps.

HTH

I am looking for confusion about using bands Some guidance on what happened during the prototype bufnet (Dotfuscator). Half of the project is a DLL, and the other half is an EXE elsewhere. Using proto-buf NET, they can exchange data perfectly. Until I confuse the DLL.

At this time, P-BN fails without raising an exception, and returns a 0-length byte array or a shortened number of bytes differently, depending on what I am fiddling with. This class is very simple (VB ):

 _
Friend Class DMailer

Private _Lic As Cert
Private _Sys As Sys
Private _LList As List(Of LItem)

..
..
End Class

All modified with ProtoMember Props have 3 props to get/set composing class objects. For the sake of brevity.

Again, it works well until I obfuscate the DLL. Then, Dotfuscator renamed each of these to null, obviously because they are all friends, which seems to kill the proto-buff. If I exempt the class from renaming (just the class name, not the props/members), it seems to work again. It makes sense that P-BN You can only operate on objects with the correct name, but when asked to serialize an empty named object, it seems that the exception may be ordered.

On the other hand, many of the charms of PB-N should be Serialization independent of .NET properties-at least according to my understanding. But in this case, it seems to only work for classes with names. I tried using Name qualifiers or parameters as shown above, but to no avail-it obviously Didn’t do what I thought was possible.

So, I’m very curious, if:

a)…I have basically guessed the problem correctly

b)…There are some other attributes or flags that may help serialize
a null named object

c)… If you have any other insights that can help.

An alternative method I consider It is to store the Serializer output of Cert and Sys as byte arrays or Base64 strings in DMailer instead of classes, instead of exempting 3 or 4 classes from renaming. Then let the receiver deserialize each object individually. Very happy It’s good to be able to unlock one thing and make your toy, just like magic.

(Multi)TIA

Because of Some interest rises, this seems to work:

a) Any form of reflection can’t get a list of attributes of confused types.
I try to find all types with ProtoContract Type, I can I found them
but the property names are all changed to a,m,b,j,g.

I also tried Me.GetType.GetProperties, the result is the same.

You can Implement a mapping from the output to indicate that Employee.FirstName is now a0.j, but distributing it would defeat the purpose of obfuscation.

b) What works to some extent is to make the NAME class free from obfuscation Since PB-N looks for the ProtoMember attribute to get the data, you can obfuscate the attribute/member name instead of the CLASS/type name. If the name is similar to FederalReserveLogIn, then your class/type has a bullseye.

I initially achieved the following success:

1) Build a simple class to store attribute tokens and values. Use ConvertFromInvariantString to store everything as a string. Get the hint from PBN, I An integer is used as the token:


Property Foo As String

Enumeration helps Combine everything together later. Store them in Dictionary(Of T, NameValuePair)

2) Add some visitors. These can perform type conversion for you:

< /p>

Public Sub Add(ByVal Key As T, ByVal value As Object)
If _col.ContainsKey(Key) Then
_col.Remove(Key)
End If

_col.Add(Key, New TValue(value))

End Sub

Public Function GetTItem(Of TT)(key As T) As TT
If _col.ContainsKey(key) Then
Return CType(_col(key).TValue, TT)
Else
Return Nothing< br /> End If
End Function

T is any key type you wish to use. Integers produce minimal output and still allow subscription code to use enums. But it may be String. < /p>

TT is the original type:

myFoo = props.GetTItem(Of Long)(propsEnum.Foo)

3) The list (dictionary) is exposed to PBN and bingo games, and it’s all done.

It’s also easy to add converters for points, rectangles, fonts, sizes, colors, and even bitmaps.

HTH

Leave a Comment

Your email address will not be published.