Obfuscated program generation system for affine determinant programs
By combining modules in the affine determinant program generation system, programs that are difficult to reverse engineering and attack are generated, which solves the problem that the existing technology cannot effectively resist the attacker's gradual understanding of the code and obtain sensitive information, and achieves efficient security improvement.
Patent Information
- Application Number
- CN202111298548.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-04
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2041-11-04
AI Technical Summary
Existing procedural obfuscation techniques cannot effectively resist the risk of attackers gradually understanding code and obtaining sensitive information, and lack the security analysis of mathematical tools and the ability to portray attackers.
An obfuscated program generation system for affine determinant programs is proposed, including re-randomizing modules, adding diagonal modules, adding noise modules and random local replacement modules. Through the combined operation of these modules, programs that are difficult to reverse engineering and attack are generated.
It significantly improves the security of the program, reduces the risk of information leakage, and can withstand all currently known attacks, while the efficiency is not reduced.
Smart Images

Figure CN114021083B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a technology in the field of information security, in particular to an obfuscated program generation system for affine determinant programs. Background Art
[0002] Program obfuscation technology is an important software protection method. Program obfuscation refers to the transformation of the program to be released so that the function of the program does not change after the transformation, but it is more difficult to be statically analyzed and reverse engineered. Most of the existing program obfuscation technologies are implemented through code obfuscation. Code obfuscation technology can be divided into appearance obfuscation, control structure obfuscation, data obfuscation, and preventive obfuscation. Among them: appearance obfuscation mainly includes deletion and renaming. Deletion refers to the deletion of debugging information, comments, unused methods and classes in the program that are not related to execution from the program body. There are many ways to rename, including hash renaming, name exchange, overload induction, etc. Appearance obfuscation is the first line of defense for protecting software and is also the most mature obfuscation technology at present. Almost every obfuscation tool uses the same or similar appearance obfuscation method to varying degrees. The purpose of control structure obfuscation is to make it difficult for attackers to understand the control flow of the program. One way is to add multiple redundant control conditions and code branches that will never be executed; another way is through inlining and outlining, that is, embedding a small program into each program point that is called or abstracting a piece of code that has no logical connection into a program that can be called multiple times. The object of data obfuscation is the data field in the program. Data obfuscation includes merging scalars, splitting variables, reorganizing arrays, modifying inheritance relationships, converting static arrays to procedural arrays, string encryption, etc. Anti-obfuscation methods are usually designed for some dedicated decompilers. This type of obfuscation is very effective for specific decompilers, but there is no anti-obfuscation solution that is effective for every decompilation tool.
[0003] Affine determinant program is a representation of a program. Any program can be represented as an affine determinant program. When a program with n-bit input and one-bit output is represented as an affine determinant program, it will correspond to n+1 matrices, which are recorded as A, B1, B2, ..., B n The way to calculate this output bit from n-bit input is: the initial matrix is recorded as A, and if and only if the i-th input bit is 1, add B i , where i ranges from 1 to n, the resulting matrix can be expressed as A+Σ i x i B i , calculate its determinant, if it is an odd number, the output is 1, if it is an even number, the output is 0.
[0004] Existing program obfuscation technology is still at the stage of combining various decompilation techniques, which does not meet the requirements of cryptographic science. Specifically, there is no corresponding security theory model, no characterization of the attacker's capabilities, the effects of program obfuscation, etc., and no introduction of mathematical tools to analyze the security of the scheme. Although this practice of stacking various techniques together can prevent attackers from understanding the algorithm and structure of the program in a short period of time to a certain extent, it cannot guarantee that attackers cannot gradually unravel the code and obtain the information they want. Summary of the invention
[0005] In view of the above-mentioned deficiencies in the prior art, the present invention proposes an obfuscated program generation system for affine determinant programs. Two programs with the same functions can be made indistinguishable after obfuscation, thereby significantly improving security while minimizing information leakage.
[0006] The present invention is achieved through the following technical solutions:
[0007] The present invention relates to an obfuscated program generation system for an affine determinant program, comprising: a re-randomization module, a diagonal addition module, a noise addition module and a random local replacement module, wherein: the re-randomization module performs left-multiplication and right-multiplication operations on all matrices of the input affine determinant program respectively, and the obtained new affine determinant program can hide information other than the determinant and the rank; the diagonal addition module performs the operation of adding random matrices or zero matrices on the diagonal of all matrices of the input affine determinant program, and the obtained new affine determinant program can prevent attackers from calculating Other formulas can be used to extract information, where x i ∈{0, 1}, the noise adding module adds random noise to each element in all matrices according to the input affine determinant program, and the obtained new affine determinant program can hide the rank information, and the random local replacement adds intermediate nodes and redetermines the connectivity of the edges according to the input branch program or affine determinant program, and the obtained new affine determinant program can hide The information of the determinant.
[0008] Technical Effects
[0009] Compared with the existing random local replacement processing, when the edge in the input branch program or affine determinant program is consistent with a certain input x of the program i , then the edges in the output branching program or affine determinant program are also related to the input x iEven if the edges in the input branch program or affine determinant program are irrelevant to all the inputs of the program, the edges in the output branch program or affine determinant program will still be related to a certain input x. i The program obfuscation scheme that includes the improved local random replacement is the only one that can resist all currently known attacks, and at the same time, this scheme is not less efficient than existing schemes. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] Figure 1 It is a flow chart of the present invention;
[0011] Figure 2 A schematic diagram of a branch procedure in the embodiment;
[0012] Figure 3 for Figure 2 A schematic diagram of a possible result of performing local random replacement on a branching program;
[0013] Figure 4 A schematic diagram of a possible result after improving local random replacement;
[0014] The dotted line in the figure is Figure 3 The difference part. DETAILED DESCRIPTION
[0015] In this embodiment, the conversion relationship between the branch program and the affine determinant program is as follows: the affine determinant program and the branch program can be converted to each other, so these two types of programs can be considered equivalent. Since the branch program can be regarded as a directed acyclic graph, the adjacency matrix of the branch program is an upper triangular matrix, that is, the elements on the diagonal and below the diagonal of the matrix are all 0. Let M(x) represent the adjacency matrix of the branch program. First, change all the elements on the diagonal of M(x) to -1, and then remove the leftmost column and the bottom row of M(x). The new matrix obtained is L(x). Then L(x) can be split into n+1 matrices: when (v in L(x) j , v k ) elements are 0, 1 or -1, then the matrix A (v j , v k ) elements are also 0, 1 or -1 accordingly; when L(x) (v j , v k ) element is x i , then in the matrix A (v j , v k ) elements are 0, and the matrix B i (v j , v k ) element is 1; when L(x) in (v j , v k ) element is Then in the matrix A (v j , v k ) elements are 1, and the matrix B i (c j , v k ) elements are -1; all elements in the matrices not mentioned above are 0.
[0016] For example:
[0017] Random matrix generation function generate_matrix(size,modulus): Each element in the generated matrix is a random positive integer less than modulus.
[0018] Matrix magnification function scale_matrix(matrix,scale,modulus): multiply each element of the first row of the matrix by the coefficient scale, and then modulus.
[0019] Matrix multiplication function multiply_matrix(matrix1,matrix2,modulus): calculates the product of two matrices, that is, matrix1 multiplied by matrix2. The result is still a matrix, and each element of the result matrix must be modulo modulus.
[0020] det(matrix,modulus): Calculates the determinant and modulo the result by modulus.
[0021] like Figure 1 As shown, this embodiment relates to a method for generating an obfuscated program based on the above system, which specifically includes the following steps:
[0022] Step 1: Random local replacement: Let l+1 represent the dimension of the adjacency matrix of the branch program. After adding an intermediate node to any two points in the branch program, the dimension of the new adjacency matrix of the branch program is (l+1)(l+2) / 2, i.e. M'(x). j and v k The middle node is v j,k For convenience, we only consider a 2×2 sub-matrix of M'(x), the rows of which correspond to the v of M'(x) j Row and v j,k The rows and columns correspond to the v of M'(x) j,k Column and v kWhen v in M(x) j and v k The edge between is marked as 1, then the subarray has the following choices. It is recommended to choose the first 4 choices with half the probability, that is, the probability of the first four choices is 1 / 8; and for the last 6, due to x i is uncertain and can actually correspond to any input bit, so there are actually 6n choices, and the probability of each choice is 1 / 12n:
[0023]
[0024] When v in M(x) j and v k If there is no edge between them, the subarray has the following choices. It is recommended to select the first three choices with half the probability, that is, the probability of the first three choices is 1 / 6; and for the last 6 choices, due to x i is uncertain and can actually correspond to any input bit, so there are actually 6n choices, and the probability of each choice is 1 / 12n:
[0025]
[0026] When v in M(x) j and v k The edges between them are labeled x i , then the subarray has the following choices, each with a probability of 1 / 12:
[0027]
[0028] When v in M(x) j and v k The edges between Then the subarray has the following choices, each with a probability of 1 / 12:
[0029]
[0030] Preferably, to improve security, the random local replacement in step 1 can be applied multiple times until the dimension of the matrix exceeds 256. The higher the dimension of the matrix after the random local replacement, the stronger the security, but at the same time the efficiency will be reduced, so it is necessary to decide how many times to repeat the random local replacement according to the actual situation.
[0031] Further preferably, a lightweight version of random local replacement is used, and intermediate nodes are added to all edges whose weights in the original branch program are not 0. For edges whose weights in the original branch program are 0, about l edges are selected to add intermediate nodes, thereby reducing the cost of random local replacement.
[0032] Step 2, add noise processing: determine the modulus p and the range B of the noise, and take the dimension of the matrix in the affine determinant program obtained by local random replacement as l'. When l' is large (in practical applications, this value will be greater than 100), the range B of the noise is l' 5 The number of bits of the modulus p is recommended to be slightly larger than l', and the matrices of the resulting affine determinant program are A', B'1, B'2, ..., B' n , first call generate_matrix(l',B) n+1 times to get the matrices E0, E1, ..., E n , and these matrices are respectively associated with A', B'1, B'2, ..., B' n Add.
[0033] The modulus p is greater than n+1 matrices E0, E1, ..., E n The value of the determinant of the sum being added.
[0034] Step 3, add diagonal processing: call generate_matrix(2,p) 2n times, and calculate the determinant of these matrices through det(). When the matrix is M, the value of the matrix determinant is d, d multiplied by d -1 Modulo p is equal to 1, first calculate d -1 , and then calculate scale_matrix(M,d -1 ,p), and the resulting 2n matrices G1, G2, ..., G n , H1, H2, ..., H n , the determinants of these matrices are all 1. Place the matrix A'+2E0 in the upper left corner of the larger matrix, and place matrices G1, G2, ..., G along the diagonal. n , that is diag(A'+2E0,G1,G2,...,G n ); for each B i '+2E i , put it in the upper left corner of the larger matrix, and put the matrix H in the i-th slot on the diagonal i -G i , the remaining positions are filled with all zero matrices, i.e. diag(B i '+2E i ,0,...,0,H i -G i , 0, ...).
[0035] Step 4: Randomize again: Take the dimension of the matrix in the affine determinant program obtained after the first three steps, that is, l', and call generate_matrix(l',p) twice, and calculate the values of the determinants of the two matrices, that is, d1 and d2, through det(). First calculate and Then calculate the second matrix The two matrices obtained are denoted as R and S respectively, and then the n+1 l”-dimensional square matrices in the affine determinant program are multiplied by R on the left and S on the right, that is, the obfuscated programs are R(diag(A'+2E0, G1, G2, ..., G n ))S and R(diag(B i '+2E i ,0,…,0,H i -G i , 0,…))S.
[0036] After specific practical experiments, the following affine determinant program is used as the input program, corresponding to Figure 2 shown.
[0037]
[0038] After random local replacement, the following intermediate program 1 is obtained, corresponding to Figure 4 shown.
[0039]
[0040]
[0041] After adding noise, we get the following intermediate program 2. The noise range used in this example is {-2, 2}, and the modulus is 1329301. In actual use, a larger noise range is needed to improve security.
[0042]
[0043]
[0044]
[0045] After adding the diagonal, we get the following intermediate program 3.
[0046]
[0047]
[0048]
[0049]
[0050] After re-randomization, the following output program is obtained. R and S are the matrices for left multiplication and right multiplication in the re-randomization process. The matrix R is split into R L and R R The left and right parts, and the remaining matrices are split similarly.
[0051]
[0052]
[0053]
[0054]
[0055]
[0056]
[0057]
[0058]
[0059]
[0060]
[0061]
[0062]
[0063] The output program can be run. The function of the program is x1∨x3, so the output is 0 when x1=x3=0, and the output is 1 in other cases. As shown below, by calculating the output of the program when x1=x2=x3=1 and the output of the program when x1=x3=0, x2=1, it can be seen that the function of the program has not changed after obfuscation.
[0064] f(111)=(det(A″″+B″″1+B″″2+B″″3)mod774180691)mod2=1329301mod2=1,
[0065] f(010)=(det(A″″+B″″2)mod774180691)mod2=12327532mod2=0.
[0066] Finally, three sets of experimental data are given, including the examples just mentioned. The scenarios in which this method can be applied are not limited to these three sets of program parameters. When applying, the noise parameters can also be flexibly selected according to needs. For the last two sets of program parameters, a lightweight version of the random local replacement scheme was selected in the experiment. The experimental data is based on the running performance of this method on a MacBook Pro 2018. In actual industrial production, the time consumption will vary to a certain extent according to the code optimization and the performance of the machine used.
[0067]
[0068]
[0069] Compared with the existing technology, when the edge of the input branch program or affine determinant program is connected to a certain input x of the program i , then the edges in the output branching program or affine determinant program are also related to the input x i Even if the edges in the input branch program or affine determinant program are irrelevant to all the inputs of the program, the edges in the output branch program or affine determinant program will still be related to a certain input x. i The program obfuscation scheme containing the improved random local replacement is the only one that can resist all currently known attacks. At the same time, compared with the existing technology, the efficiency of this method is not reduced. At the same time, a lightweight version of the random local replacement scheme is proposed, which can improve efficiency by reducing security in situations where security is sufficient.
[0070] The above-mentioned specific implementation can be partially adjusted in different ways by those skilled in the art without departing from the principle and purpose of the present invention. The protection scope of the present invention shall be based on the claims and shall not be limited by the above-mentioned specific implementation. Each implementation scheme within its scope shall be subject to the constraints of the present invention.
Claims
1. A method for generating an obfuscated program, characterized in that: against The determinant information includes the following steps: Step 1: Random local replacement: After adding an intermediate node to any two points in the branch program, the dimension of the adjacency matrix of the replaced branch program is (l+1)(l+2) / 2, that is, M'(x), where: l+1 is the dimension of the adjacency matrix of the branch program, and the rows of a 2×2 submatrix of M'(x) correspond to the v of M'(x) j Row and v j,k The rows and columns correspond to the v of M'(x) j,k Column and v k Columns, where: v j,k v j and v k The intermediate node of When v in M(x) j and v k The edges between are marked as 1, then the submatrix is any of the following and the probability of each choice is 1 / 12n: When v in M(x) j and v k If there is no edge between them, then the submatrix is any of the following and the probability of each choice is 1 / 12n: When v in M(x) j and v k The edges between them are labeled x i , then the subarray is any of the following and the probability of each selection is 1 / 12: When v in M(x) j and v k The edges between Then the subarray is any of the following and the probability of each selection is 1 / 12: Step 2: Add noise processing: Take the noise range B as l' 5 , the number of bits of the modulus p is greater than l', and the matrix of the resulting affine determinant program is A', B'1, B'2, ..., B' n , where: l' is the dimension of the matrix in the affine determinant program obtained after local random replacement; call the random matrix generation function generate_matrix(l',B) n+1 times to obtain the matrices E0, E1, ..., E n , and these matrices are respectively connected with A', B'1, B'2, ..., B' n Addition; Step 3, add diagonal processing: call the random matrix generation function generate_matrix(2,p) 2n times, and calculate the determinant of these matrices through det(); When the matrix is M, the value of the matrix determinant is d, d multiplied by d -1 Modulo p is equal to 1, first calculate d -1 , and then call the matrix magnification function scale_matrix(M,d -1 ,p), and the 2n result matrices obtained, that is, G1, G2, …, G with determinants all equal to 1, are n ,H1,H2,…,H n ; Place the matrix A'+2E0 in the upper left corner of the larger matrix, and place the matrices G1, G2, ..., G along the diagonal line. n , that is, diag(A'+2E0,G1,G2,…,G n ), for each B i '+2E i , put it in the upper left corner of the larger matrix, and put the matrix H in the i-th slot on the diagonal i -G i , the remaining positions are filled with all zero matrices, i.e. diag(B i '+2E i ,0,…,0,H i -G i ,0,…); Step 4: Randomize again: Call the random matrix generation function generate_matrix(l',p) twice, and calculate the values of the determinants of the two matrices, i.e. d1 and d2, through det(), where: l' is the dimension of the matrix in the affine determinant program obtained after the first three steps; calculate and Then call the matrix magnification function on the second matrix Get the result matrix R, S, and then multiply the n+1 l"-dimensional square matrices in the affine determinant program by R on the left and S on the right, that is, R(diag(A'+2E0,G1,G2,…,G n ))S,R(diag(B i '+2E i ,0,…,0,H i -G i ,0,…))S.
2. The method for generating an obfuscated program according to claim 1, wherein: To improve security, the random local replacement in step 1 is applied multiple times until the dimension of the matrix exceeds 256.
3. The obfuscated program generation method according to claim 1 or 2, characterized in that: A lightweight version of random local replacement is used, and intermediate nodes are added to all edges whose weights in the original branch program are not 0. For edges whose weights in the original branch program are 0, about l edges are selected to add intermediate nodes, thereby reducing the cost of random local replacement.
4. The obfuscated program generation method according to claim 1, characterized in that: The modulus p is greater than n+1 matrices E0, E1, ..., E n The value of the determinant of the sum being added.
5. An obfuscated program generation system for affine determinant programs implementing the method described in any one of claims 1 to 4, characterized in that: include: A re-randomization module, a diagonal addition module, a noise addition module and a random local replacement module, wherein: the re-randomization module performs left-multiplication and right-multiplication operations on all matrices of the input affine determinant program respectively according to the input affine determinant program, and the obtained new affine determinant program can hide information except the determinant and rank; the diagonal addition module performs the operation of appending random matrices or zero matrices on the diagonal of all matrices according to the input affine determinant program; the noise addition module performs the operation of adding random noise to each element in all matrices according to the input affine determinant program, and the obtained new affine determinant program can hide the rank information; the random local replacement adds intermediate nodes and redetermines the connectivity of the edges according to the input branch program or affine determinant program.