What is the obfuscation of methods’ algorithms
The fast improvement of media and Internet technologies for recent years has provoked the security of such intellectual property as computer programming products (PP).
Building up the best insurance strategy for a specific programming item ends up one of the significant errands of most developers who create particular, paid software, as this enables them to sell their scholarly work and dispense with the likelihood of its unlawful use among customers. At the end of the day, the client won’t most likely utilize the first, authorized duplicate of a specific program without first acquiring, without paying dene its engineer. The expense of makers to make a viable technique for ensuring their product items satisfies and makes up for the potential harm brought about by illicit duplicating and utilizing programs.
Obfuscation is one of the techniques for ensuring programming code, which makes it hard to figure out the code of a secured programming item.
How to start the process of obfuscation. From designing a system (program or class library) that you are going to write. If you need to write the most secure code, you will have to take into account a number of factors when designing a product.
Do not confuse design with programming. What factors need to be considered? Typical obfuscation is symbolic – when the obfuscator changes the names of types, fields, methods, properties, and events to meaningless. The Obfuscator type is renamed to 0, and its Run () method is also set to 0, and the parameters of the methods are simply renumbered – 0,1,2,3,4. After such obfuscation, the logical connection between the classes is lost, the disassembled code is difficult to read.
If it is necessary to obfuscate a closed system, then complete obfuscation will come up when all the names of the assembly members change, and in this case the ends are an order of magnitude more difficult to find than in the case when some methods, types are not obfuscated (this is possible when exe-files not using Reflection).
In addition to symbolic obfuscation, there is also obfuscation of algorithms of methods – when the simplest multiplication I * 3 can be represented by a more complex algorithm, for example – I * ((1 + 1/2) * 2) or entangled while and for. It is rare to find completely closed, autonomous systems, so a typical case would be partial obfuscation. Although the ideal task for better obfuscation would be just the writing of the maximum closed assembly system.
Recommendations for the preparation of the project (product) for obfuscation:
-
To complicate disassembling, you can use type substitution (which is not always possible to implement due to sealed types) This means that a certain system type SomeType is inherited in the new type AnotherType, which is suitable for obfuscation (it lies within the scope of the assembly, it can be assigned as internal). The output is obtained using SomeNamespace.0 instead of the known System.SomeType. If you plan to use some types as public, but I would like to protect them as much as possible, you should put them in the “protective shell” of inheritance. A certain type of public SomeType can be turned into two classes: internal _SomeType (underground class), which carries the entire implementation of a class, except public properties necessary for serialization and for use in external code for building, and public SomeType, which will inherit from _ SomeType ( front class), but carry external load – to have public properties necessary for serialization, conversion, use in external code for the assembly.
-
Attributes are used in the code. Many of them help to interact closely enough with the .Net environment with classes. For example, the TypeConverterAttribute attribute – they are tied to the class class converter SomeConverter. Not every obfuscator “knows” about this – and therefore it is worth protecting the converter class from obfuscation or to check how obfuscator works with attributes. Otherwise, the relationship established between the two classes through the attribute may be destroyed.
-
If a class goes under obfuscation, you need to think about the mechanism of its serialization. The Form-heir class serializes itself in such a way that if the obfuscator changed the name of its SomeForm type to 0, then there will be a problem when initializing the deserialization of such a class – it simply cannot find the resource 0.resources, since it was serialized in SomeForm.resources.
-
The static string of the declarations is used instead of the const string – this makes it difficult to search for the initialization of this field (in the metadata both declarations will be represented as fields).
-
If there is a list of strings that are represented as a list of string constants, better list the strings with declare / describe as a string array, and in constants store the index to the required string in a string array.
-
If it is necessary to protect a certain algorithm from unnecessary viewing, it is necessary to give its execution to several classes, by this we distribute the task to the task, maybe we unload the memory.
-
It is necessary to transfer the execution of algorithms not to one method, but to transfer parts of the algorithm to execution to different classes, in fact, the execution of the algorithm will be the interaction of several classes.
-
It is necessary to initialize the form classes without using .resx and .resources files – it is better to access them by index in order to avoid problems with obfuscation of resources.
After obfuscation:
-
Mandatory testing of obfuscated assembly.
-
After obfuscation, be sure to check the assembly with the peverify utility that comes with the .Net Framework SDK – this utility checks the assembly’s metadata for correctness. If an assembly is marked as CLS-compliant, this testing is required.
-
Be sure to pay attention to how obfuscator itself obfuscator.
-
A test project is created that will quickly test the build.