Size constraint-free opaque predicate construction method, system and storage medium
Technical Field
The invention relates to the field of information security, in particular to a size-constraint-free opaque predicate construction method, a size-constraint-free opaque predicate construction system and a storage medium.
Background
Opaque predicates are special expressions whose values are known before confusion but are difficult to derive by reverse analysis. Opaque predicates are commonly used in boolean expressions, which include logically true, logically false, and kefir or false forms. The existing scheme generally adopts methods such as mathematical theorem, chaos theory and encryption to construct opaque predicates. For example, opaque predicates are constructed by using the states of congruence equation group solutions, and predicate outputs are judged by adopting Chinese remainder theorem, and internal logic of the predicates can be hidden through complex mathematical transformation, so that the predicate has better static reverse analysis resistance, but the predicate value is fixed in the running process. The chaotic opaque predicates based on En_Logistic mapping have extremely high confidentiality and uncertainty of predicate results. The hyperchaotic opaque predicate construction method based on the two-dimensional hyperchaotic mapping construction converts the predicate solving problem into the solving hyperchaotic problem so as to greatly increase the difficulty of condition judgment. The construction of the N-state opaque predicates through the two-dimensional chaotic mapping has higher security and control flow circulation complexity, but has the problem of lower construction efficiency. And constructing an opaque expression by adopting the two-dimensional tent chaotic mapping, and replacing constants in opaque predicates by using the expression, so that predicate cracking difficulty is increased, and execution cost is low.
Disclosure of Invention
1. Object of the invention
The invention provides a size constraint-free opaque predicate construction method and a size constraint-free opaque predicate construction system, which aim to solve the problems that the existing opaque predicates are generally simpler and have reverse detection, and resist detection attack on the opaque predicates.
2. The invention adopts the technical proposal that
The invention provides an opaque predicate construction method without size constraint, which comprises the following steps:
(1) Constructing an integer array, wherein the initial value of array elements is as follows: starting from 0, the step length is an increasing positive integer of 1, and the number of the arrays is not less than 2;
(2) Reading integer parameters 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) An unequal expression of the integer variable and the parameter of the function is constructed, and the conditional unequal expression is a logically false opaque predicate.
Furthermore, the integer array a [ ], i.e., int a [ ], has the array element initial values of: starting from 0, the step size is an increasing positive integer of 1, M >1, M is a positive integer greater than 1, i.e., int a [ ] = {0,1,2, …, i, i+1, … M-1}.
Further, the integer parameter par is read from the function to be protected, i.e. from the function to be protected func (int par, …).
Further, the construction of the integer variable is specifically: an integer variable s=f (par, a [ ]) is constructed in relation to the parameter par and the array a [ ] of the function func (int par, …) to be protected, wherein f (par, a [ ]) =a [ a [ par% (M-1) +1] ].
Still further, the conditional unequal expression: s-! =par% (M-1) +1.
The invention provides an opaque predicate construction method system without size constraint, which comprises a memory and a processor, wherein the memory stores a computer program, and the processor realizes the steps of the method when executing the computer program.
The present invention proposes a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the method steps.
3. The invention has the beneficial effects that
The invention provides an opaque predicate concept without size constraint, and simultaneously provides an opaque predicate construction method to increase the difficulty of reverse attack. Opaque predicates constructed based on this method can cause an attacker to erroneously identify the opaque predicate as a normal predicate, thereby erroneously executing false branches of a program. In addition, the intensity, the elasticity and the execution cost of the program after confusion are subjected to test analysis, and experimental results show that the opaque predicates constructed by the method have high intensity, high elasticity and lower execution cost.
Drawings
FIG. 1 is a flow chart of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made more apparent and fully by reference to the accompanying drawings, in which embodiments of the invention are shown, and in which it is evident that the embodiments shown are only some, but not all embodiments of the invention. All other embodiments, which can be made by a person skilled in the art without any inventive effort, are intended to be within the scope of the present invention.
Examples of the present invention will be described in further detail below with reference to the accompanying drawings.
Example 1
The method not only can realize the execution logic relation of the confusing program, but also greatly improves the control flow intensity of the program, and effectively resists the reverse analysis of the program.
The method comprises the following steps: the function func (int par, …) to be protected is input, and the opaque predicate op is output. As in fig. 1, step 101, a function func (int par, …) with an integer parameter par is selected. Step 102, an integer array a [ ] of length M is constructed, where M >1, and each array element is assigned a [ ] = {0,1,2, …, M-1}. Step 103, constructing integer variable s, and assigning a [ a [ par% (M-1) +1] ], namely, s=a [ a [ par% (M-1) +1] ]. Step 104, constructing opaque predicates op based on variable s and parameter par, i.e. s-! =par% (M-1) +1. The steps of the method of constructing opaque predicates are as follows.
Method 1 opaque predicate construction method
Input: func (int par …)
And (3) outputting: opaque predicate op
Step 1, obtaining integer parameters par in a function func (int par, …) to be protected;
Step 2, constructing an integer array, and giving an initial value: int a [ ] = {0,1,2, …, M-1}, where M >1;
Step 3, constructing integer variables, and assigning: int s=a [ a [ par% (M-1) +1] ];
Step 4, constructing opaque predicates op: s-! =par% (M-1) +1.
An example is given below that shows the construction of opaque predicates using the present invention to achieve code protection on the basis of unaliased code, as specifically shown below.
Before confusion
After confusion
As can be seen from the above example, the main function main (int x) of the program receives a form parameter x. First, the explicitly input variable x is an integer variable. Then, the process is carried out, defining arrays using integer patterns inta [ ] = {0,1,2,3,4,5,6,7,8,9}. Next, the variable ints=a [ a [ x%9+1] ] is defined. Finally, construct opaque predicate s-! =x% 9+1, and inserts a false control flow y=x+2; . In the above obfuscated procedure, the conditions built based on opaque predicates are never possible to meet, but the attacker is working on s-! When solving for the row =x% 9+1, an erroneous solution will be obtained and the error will be s-! =x% 9+1 is considered as a normal predicate, thus executing a false control flow y=x+2; the reverse analysis result is wrong, so the method can obtain good program protection effect.
The foregoing is only a preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions easily contemplated by those skilled in the art within the scope of the present invention should be included in the scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.