Method, system and storage medium for constructing opaque predicates without size constraints
Through the non-dimensional constraint-free opaque predicate construction method, using integer arrays and variables to generate a constant false opaque predicate, solving the problem of low reverse detection and construction efficiency in the prior art, and achieving high-intensity and low execution cost program protection effect .
Patent Information
- Application Number
- CN202210386385.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-13
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2042-04-13
AI Technical Summary
The existing opaque predicate construction method has the problem of reverse detection, which is less efficient in construction and is easily recognized by attackers.
Using the opaque predicate construction method without dimension constraints, a constant false opaque predicate is generated by constructing integer arrays and integer variables, increasing the difficulty of attack. The specific steps include reading the integer parameters from the function to be protected, building integer variables related to the array, and forming unequal expressions to implement opaque predicates.
It improves the difficulty of reverse attack of opaque predicates, enables attackers to mistakenly recognize predicates, enhances the confusion intensity and flexibility of the program, and has a low execution cost.
Smart Images

Figure CN114780920B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information security, and in particular to a method, system and storage medium for constructing an opaque predicate without size constraints. Background Art
[0002] An opaque predicate is a special expression whose value is known before obfuscation but is difficult to deduce through reverse analysis. Opaque predicates are often used in Boolean expressions, and include three forms: always true, always false, and true or false. The existing scheme generally uses mathematical theorems, chaos theory, and encryption methods to construct opaque predicates. For example, opaque predicates are constructed using the state of the solution of the congruence equation system and the Chinese remainder theorem is used to judge the predicate output. The internal logic of the predicate can be hidden through complex mathematical transformations, making it have good anti-static reverse analysis capabilities, but the value of this predicate is fixed during operation. By constructing a chaotic opaque predicate based on En_Logistic mapping, it has extremely high confidentiality and uncertainty of the predicate result. The hyperchaotic opaque predicate construction method based on two-dimensional hyperchaotic mapping transforms the predicate solving problem into solving the hyperchaotic problem to greatly increase the difficulty of conditional judgment. The construction of N-state opaque predicates through two-dimensional chaotic mapping has high security and control flow cyclic complexity, but there is a problem of low construction efficiency. Two-dimensional tent chaos map is used to construct an opaque expression and this expression is used to replace constants in opaque predicates, thereby increasing the difficulty of predicate cracking and reducing the execution cost. Summary of the invention
[0003] 1. Purpose of the present invention
[0004] The present invention aims to solve the problem that existing opaque predicates are usually relatively simple and have the problem of reverse detection, resist detection attacks on opaque predicates, and proposes a method and system for constructing opaque predicates without size constraints.
[0005] 2. Technical solution adopted by the present invention
[0006] The present invention proposes a method for constructing an opaque predicate without size constraints, comprising:
[0007] (1) Construct an integer array whose initial value is an increasing positive integer starting from 0 and with a step length of 1. The number of array elements is not less than 2.
[0008] (2) Read the integer parameter from the function to be protected;
[0009] (3) constructing an integer variable related to the parameter of the function to be protected and the array;
[0010] (4) Constructing an inequality expression between the integer variable and the parameter of the function, wherein the conditional inequality expression is a always false opaque predicate.
[0011] Furthermore, the integer array a[], i.e., int a[], has array element initial values of: increasing positive integers starting from 0 with a step length of 1, M>1, M is a positive integer greater than 1, i.e., int a[] = {0, 1, 2, …, i, i+1, …M-1}.
[0012] Furthermore, reading the parameter from the function to be protected is to read the integer parameter par from the function to be protected func(int par, ...).
[0013] Furthermore, constructing the integer variable is specifically as follows: constructing an integer variable s=f(par,a[]) related to the parameter par of the function to be protected func(int par,…) and the array a[], where f(par,a[])=a[a[par%(M-1)+1]].
[0014] Furthermore, the conditional inequality expression is: s!=par%(M-1)+1.
[0015] The present invention proposes a method system for constructing an opaque predicate without size constraints, comprising a memory and a processor, wherein the memory stores a computer program, and the method steps are implemented when the processor executes the computer program.
[0016] The present invention provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method steps described are implemented.
[0017] 3. Beneficial effects of the present invention
[0018] The present invention proposes the concept of opaque predicates without size constraints, and provides a method for constructing opaque predicates to increase the difficulty of reverse attacks. The opaque predicates constructed based on this method can cause attackers to mistakenly identify opaque predicates as ordinary predicates, thereby mistakenly executing false branches of the program. In addition, the strength, elasticity and execution cost of the obfuscated program are tested and analyzed. The experimental results show that the opaque predicates constructed using the method of the present invention have high strength, high elasticity and low execution cost. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 It is a flow chart of the present invention. DETAILED DESCRIPTION
[0020] The following is a clear and complete description of the technical solutions in the examples of the present invention in conjunction with the accompanying drawings in the examples of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the protection scope of the present invention.
[0021] The examples of the present invention will be described in further detail below with reference to the accompanying drawings.
[0022] Example 1
[0023] The method of the present invention can not only realize the execution logic relationship of the obfuscated program, but also greatly improve the control flow strength of the program and effectively resist the reverse analysis of the program.
[0024] Specifically: input the function to be protected func(int par,…), and output the opaque predicate op. Figure 1 , step 101, select the function func(int par,…) with integer parameter par. Step 102, construct an integer array a[] of length M, where M>1, and assign a value to each array element, that is, a[]={0,1,2,…,M-1}. Step 103, construct an integer variable s, and assign a[a[par%(M-1)+1]], that is, s=a[a[par%(M-1)+1]]. Step 104, construct an opaque predicate op based on variable s and parameter par, that is, s!=par%(M-1)+1. The steps of constructing the opaque predicate method are as follows.
[0025] Method 1: Opaque predicate construction method
[0026] Input: function to be protected func(int par,…)
[0027] Output: opaque predicate op
[0028] Step 1, obtain the integer parameter par in the function to be protected func(int par,…);
[0029] Step 2, construct an integer array and assign initial values: int a[] = {0, 1, 2, ..., M-1}, where M>1;
[0030] Step 3, construct an integer variable and assign a value: int s = a[a[par%(M-1)+1]];
[0031] Step 4, construct the opaque predicate op:s!=par%(M-1)+1.
[0032] An example is given below, which shows that an opaque predicate is constructed based on unobfuscated code to implement code protection using the present invention, as shown below.
[0033] Before obfuscation
[0034]
[0035] After obfuscation
[0036]
[0037]
[0038] As can be seen from the above example, the main function main(int x) of the program receives a formal parameter x. First, the input variable x is clearly defined as an integer variable. Then, the array inta[]={0,1,2,3,4,5,6,7,8,9} is defined using the integer method. Next, the variable int s=a[a[x%9+1]]. Finally, the opaque predicate s!=x%9+1 is constructed, and the false control flow y=x+2; is inserted. In the above obfuscated program, the conditions constructed based on the opaque predicate can never be met, but when the attacker solves the line s!=x%9+1 through reverse engineering, he will get an incorrect solution and mistakenly regard s!=x%9+1 as a normal predicate, thereby executing the false control flow y=x+2;, causing the reverse analysis result to be wrong. Therefore, the method of the present invention can achieve a good program protection effect.
[0039] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method for constructing opaque predicates without size constraints, which is used to obfuscate program logic and resist program reverse analysis, characterized by: (1) Construct an integer array whose initial value is an increasing positive integer starting from 0 and with a step length of 1. The number of array elements is not less than 2. (2) Read the integer parameter from the function to be protected; (3) constructing an integer variable related to the parameter of the function to be protected and the array; (4) Constructing a conditional inequality expression between the integer variable and the parameter of the function, wherein the conditional inequality expression is a always false opaque predicate.
2. The method for constructing an opaque predicate without size constraints according to claim 1, characterized in that: The integer array a[], i.e., int a[], has array element initial values of: increasing positive integers starting from 0 with a step length of 1, M>1, M is a positive integer greater than 1, i.e., int a[]={0,1,2,…,i,i+1,…M-1}.
3. The method for constructing an opaque predicate without size constraints according to claim 2, characterized in that: Reading parameters from the function to be protected means reading the integer parameter par from the function to be protected func(int par,…).
4. The method for constructing an opaque predicate without size constraints according to claim 3, characterized in that Constructing the integer variable specifically includes: constructing an integer variable s=f(par,a[]) related to the parameter par of the function to be protected func(int par,...) and the array a[], wherein f(par,a[])=a[a[par%(M-1)+1]].
5. The method for constructing an opaque predicate without size constraints according to claim 4, characterized in that The conditional inequality expression is: s!=par%(M-1)+1.
6. A method system for constructing an opaque predicate without size constraints, comprising a memory and a processor, wherein the memory stores a computer program, characterized in that; When the processor executes the computer program, the method steps according to any one of claims 1 to 5 are implemented.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method steps described in any one of claims 1 to 5 are implemented.
