Blur: Keep your code away from the peeping eye

Source: Internet
Author: User
We know that the Java compiler source program gets the byte code, VS. NET compiled source is MSIL (Microsoft intermediate language), which is called "incomplete compilation," and is especially easy to decompile or reverse-engineer. Unlike native code, the intermediate code that is not fully compiled retains the variable, the procedure name, so that the resulting program is almost exactly the same as the original program, and the remainder is almost intact.

For developers of commodity software, high quality decompile code poses a great risk: the algorithm may be stolen and modified, and the program code may be copied and changed. (Even the non-commercial software used in-house, because of the source code leakage caused by the decompile also poses a great threat.) For example, it is easy for a user to see a password that accesses a database or an Embedded SQL command for a program. Similarly, web sites that use an external unit hosting server are at risk, and once the ASP.net application code is uploaded, the person in the managed unit may view and change the program code at will.

More worrying is that hackers or curious users can now easily get a variety of reverse engineering tools. Microsoft itself provides an MSIL disassembler, called ILDASM, free of charge, and there is a source code open. NET Decompile tool Anakrino; and, of course, many other vendors offer a commercialized reverse-engineering tool.

First, modify the variable name

The most effective way to prevent the threat of such reverse engineering is to blur it. (According to the American Traditional dictionary, "vague" means "confusing, confusing, confusing, or ambiguous, making it difficult to feel or understand"). Fuzzy tools use various means to achieve this goal, but the main way is to let the variable name no longer have the ability to indicate its role, encrypt strings and text, insert a variety of spoofing instructions so that the code can not compile the decompile.

An upcoming version of Visual Studio (called Vs.net 2003, code name Everett) integrates a fuzzy tool that Microsoft recommends to use to finalize the. NET Intermediate code. This fuzzy device is another tool Dotfuscator's so-called lite version. The Dotfuscator feature, produced by Preemptive Solutions, is more powerful, and the company, located in Cleveland, Northeast Ohio, initially developed a fuzzy technology for Java code. The Dotfuscator Blur uses a range of superior technologies to make reverse engineering futile, or at least to make reverse engineering difficult.

Preemptive Solutions The patented technology that modifies the variable name in the middle code takes a name called overload Sensing (overload induction), and the vs.net version of Lite 2003 has only this fuzzy function. (The fuzzy device will never change the original source code, even do not need to use the source code as a reference.) This technique fully utilizes the characteristics of the Vs.net code: the same identifier can be applied simultaneously to classes and methods with different characteristics; in different namespaces, variables can have the same name without conflict.

Dotfuscator make full use of these semiotic features of vs.net to convert as many symbols as possible to the letter "A". According to the company, some code about 33% of the reference can be changed to "A", and 10% can be changed to "B". After the obfuscation, the code obtained by reverse engineering will be difficult to understand. Let's look at an example.

Reverse-engineer code without obfuscation:

private void Calcpayroll (Speciallist employeegroup) {
while (Employeegroup.hasmore ()) {
Employee = Employeegroup.getnext (true);
Employee.updatesalary ();
Distributecheck (employee);
}
}



The same code is obfuscated and then reverse engineered:

private void A (a b) {
while (B.A ()) {
A = B.A (true);
A.A ();
A (a);
}
}



Obviously, the two pieces of code have the same processing logic. However, it is difficult to say exactly what the second piece of code is doing, even to determine which methods and variables it is accessing.

The ability to change the name of a variable is configurable, for example, if you are constructing a DLL that requires no changes to the API. Interestingly, this process apparently simply abbreviated the names of a large number of variables into a single character, but with a very good blur effect.

Second, encrypted string

String encryption is another security issue, but this security issue is also true in native code-extracting characters and text from binary code is a simple matter. For example, using the UNIX strings tool to process any binary file, you can quickly get an ASCII text list that is contained in the binary file.

In the simplest case, this list only leaks the copyright information and which libraries are referenced by the binary execution file. However, if the program wants to access the database, the list will contain all the SQL commands, and the password will not be secret if the code module has a password embedded in it.

For intermediate code, unencrypted strings can also pose an additional risk. By analyzing a reference to a particular string, hackers can determine where to start code is protected by a password, and then add a patch to bypass the password verification section.

In order to solve the security problems caused by the plaintext of strings, most of them use the technique of encrypting string. Because the decryption operation requires a certain amount of overhead, the performance of the Run-time access string will certainly be reduced. Interestingly, native code does not take advantage in this respect, because if the same effect is to be achieved, the native code developer must manually encrypt and decrypt each string, but for the intermediate code the work can be done by the blur.

Iii. Hide the execution process

Control process blur is a technique used to mislead the compiler, which inserts many goto instructions into the original code, although the sequence of instructions is still the same as the original, but too many "circuitous actions" make it difficult to analyze the actual logical process of the program. Let's look at an example.

Reverse engineer Intermediate Code with no control process obfuscation:

public int CompareTo (Object o) {
int n = occurrences-((wordoccurrence) O). Occurrences;
if (n = = 0) {
n = String.Compare (Word, (wordoccurrence) O). Word;
}
return (n);
}



The same code, after the control process fuzzy processing and then reverse engineering:

public virtual int A (object a_0) {
int local0;
int local1;

Local0 = THIS.A-(c) a_0.a;
if (local0!= 0)
Goto I0;
Goto I1;
while (true) {
return local1;
I0:local1 = local0;
}
I1:local0 = System.String.Compare (this.b, (c) a_0.b);
Goto I0;
}



As you can see, after the control process is obfuscated, the code is inserted into a pseudo conditional detection statement, and then a goto instruction is executed. At the destination of Goto, the original statement (in a obfuscated form) is executed, followed by a goto statement that transfers control to the original logical process branch. Note that while () loops are not executed, it only acts as a misleading function. This code fragment is small, and even without the original code to compare and reference, the possibility of identifying the actual process of the program still exists. However, for a larger process, if there is no source code to refer to, those specifically used to muddy the process of normal execution of the instructions will make the analysis of the Code of the people, and eventually have to give up.

In other words, the fundamental idea of this obfuscation is to make it extremely difficult to recover the original code, forcing the hacker to change his mind, perhaps for a lighter one, such as "Write Your own code".

Obfuscation of the control process to insert some code into the binary file, it adds some running time overhead. If your code is very demanding on running time, you can add this extra layer of protection to only those parts that are particularly important.

█ Blur and anti-compiler big films:

▲ Fuzzy Device:

LSW dotnet IL Obfuscator

Demeanor for. NET

Salamander. NET Obfuscator

Dotfuscator

Aspose.obfuscator

. NET Il-obfuscator

Deploy. NET

Salamander. NET Protector

Thinstall

Xenocode

▲ Anti-compiler:

Salamander. NET Decompiler

Exemplar/anakrino

1:18 | Comments (1)




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.