Software code protection adjusting system and method based on digital encryption technology
By using disassembly, obfuscation algorithms and encryption technologies in the software code protection system, the problem of easy cracking of existing software source code protection is solved, and the high security protection of software code is achieved.
Patent Information
- Application Number
- CN202411695201.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2025-03-14
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing software source code protection mechanism is easily cracked and reverse engineered by hackers, resulting in the threat of the software's intellectual property rights and commercial interests.
A software code protection and adjustment system based on digital encryption technology is adopted. The system includes a code one-time analysis module, a code variable name replacement module, a control flow structure logic transformation module, a basic block position transformation module and a code data encryption module. The security of software code is protected through technical means such as disassembly, obfuscation algorithms and encryption algorithms.
By converting the location, variable name and logical structure of the software code and encrypting it, the security of the software code is significantly improved, preventing hackers from tampering with or copying the code, thus effectively protecting the software's intellectual property rights and commercial interests.
Smart Images

Figure CN119622675A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of program control, and in particular, relates to a software code protection adjustment system and method based on digital encryption technology. Background Art
[0002] Software code protection refers to measures taken to protect the source code and related intellectual property rights of software from unauthorized access, use, copying, modification, dissemination or misappropriation and other infringements; software code is the result of the developer's labor and intellectual property, and has important commercial value and competitive advantages, so its security and legality need to be ensured; the purpose of software code protection is to prevent unauthorized code copying, theft or abuse, in order to safeguard the interests and technical advantages of software developers. Common software code protection measures include: encryption and obfuscation, authorization and license management, digital signatures and access control, etc.; software code protection is an important means to protect software intellectual property rights and commercial interests, and is of great significance to software developers and the development of the industry.
[0003] Chinese patent CN102147595A discloses a software protection method for preventing a digital feedback control system from losing control. The method first determines whether a digital feedback signal can be normally received within a control software cycle, and then determines the correctness of the received signal. If the feedback signal is abnormal, the system outputs a control signal to close the system output in real time to ensure system safety. The system protection method adopted by the present invention is simple, has a small amount of software code, strong real-time performance, and high reliability.
[0004] Existing software source code protection mechanisms include using encryption algorithms to encrypt the code. However, encryption algorithms can be cracked. There is no completely secure encryption algorithm. Hackers can use various technical means to attack encryption algorithms, and hackers can also use reverse engineering technology to analyze and restore the protected software code. By analyzing the logic and structure of the code, hackers can understand the working principle of the software and modify it or create pirated software. Summary of the invention
[0005] In view of the problems in the related art, the present invention proposes a software code protection adjustment system and method based on digital encryption technology to overcome the above technical problems existing in the existing related art.
[0006] In order to solve the above technical problems, the present invention is achieved through the following technical solutions:
[0007] The present invention is a software code protection adjustment method based on digital encryption technology, comprising the following steps:
[0008] S1. Set a binary software code set, use a disassembly tool to disassemble and analyze each binary code in the binary software code set, and obtain a first function basic block set matrix and a first function control flow structure;
[0009] S2, construct an obfuscation algorithm set, wherein the obfuscation algorithm set includes a code variable name obfuscation algorithm, a control flow obfuscation algorithm, and a basic block obfuscation algorithm; the code variable name obfuscation algorithm is used to randomly replace the code variable names in each function basic block in the first function basic block set matrix to obtain a second function basic block set matrix; the control flow obfuscation algorithm is used to sequentially transform the first function control flow structure to obtain a second function control flow structure, and then the logic transformation of each function basic block in the second function basic block set matrix is performed according to the second function control flow structure to obtain a third function basic block set matrix; the basic block obfuscation algorithm is used in combination with the second function control flow structure to perform position transformation on each function basic block in the third function basic block set matrix to obtain a fourth function basic block set matrix;
[0010] The code variable name obfuscation algorithm is preferably the Mersenne Twister algorithm; the basic block obfuscation algorithm is preferably the Fisher-Yates algorithm;
[0011] S3, reading the code data of each basic block in the fourth function basic block set matrix, and performing an encryption operation on the fourth function basic block set matrix using an encryption algorithm to obtain final encrypted code data;
[0012] By using a disassembly tool to disassemble and analyze each binary code in the binary software code set, a first function basic block set matrix and a first function control flow structure are obtained. By analyzing the binary code once, each basic block constituting the code is determined, and the code execution process is determined, which is convenient for subsequent adjustment of the control flow and provides a basis for subsequent adjustment of the position of the basic block. By constructing an obfuscation algorithm set, algorithm support is provided for subsequent replacement of variables in the code, logical transformation of each function basic block, and position transformation of each basic block, and at the same time, the logical structure and position of the code are completely converted, thereby ensuring the security of the code and protecting the source code from being tampered with or copied. Finally, the converted source code is encrypted to further ensure the security of the code.
[0013] Preferably, the S1 comprises the following steps:
[0014] S11, set the binary software code set a = {a 1 ,a 2 ,...,a i,...,a a′}, a i represents the i-th binary software code segment in the binary software code set, a′ represents the total number of binary software code segments in the binary software code set;
[0015] S12, using a disassembly tool to disassemble the binary software code set a={a 1 ,a 2 ,...,a i ,...,a a′}, and performing a disassembly operation on each binary code in the first function and performing an analysis to obtain a first function basic block set matrix and a first function control flow structure; the disassembly tool includes IDA;
[0016] By using a disassembly tool to disassemble and analyze each binary code in the binary software code set, a first function basic block set matrix and a first function control flow structure are obtained. By analyzing the binary code once, the basic blocks that make up the code are determined, and the code execution process is determined at the same time, which facilitates subsequent adjustments to the control flow and provides a basis for subsequent adjustments to the positions of the basic blocks.
[0017] Preferably, the S12 comprises the following steps:
[0018] S121, the disassembly tool uses a linear scanning algorithm to obtain a binary software code set a={a 1 ,a 2 ,...,a i ,...,a a′}The function basic blocks and function control flows of each binary code in;
[0019] The specific steps include:
[0020] S1211, set the binary software code set a={a 1 ,a 2 ,...,a i ,...,a a′} in each code segment does not overlap; according to the binary software code set a={a 1 ,a 2 ,...,a i ,...,a a′}Construct the code function matrix a″ as follows:
[0021]
[0022] Among them: a i ' j′ represents the jth function in the ith binary software code segment in the binary software code set, a i ″′ represents the total number of functions in the ith binary software code segment in the binary software code set;
[0023] S1212, traverse each function in the code function matrix a″ to determine the function basic block and the function control flow, and obtain a first function basic block set matrix and a first function control flow structure;
[0024] Since the functions in the code have different implementation functions, by dividing the source code into functions, each function in the source code can be analyzed separately, thereby improving the accuracy of the analysis and providing an accurate basis for subsequent related conversions of the source code.
[0025] Preferably, determining the function basic block in S1212 specifically includes the following steps:
[0026] S121211. Obtain the starting boundary and the ending boundary of each function in the code function matrix a″;
[0027] S121212, traverse each instruction of each function in the code function matrix a″, and take the first instruction of each function in the code function matrix a″ as the starting position of a basic block;
[0028] S121213, set a i ' j ′The corresponding instruction set is c i ' j , a i ' j ' k Indicates a i ' j ′ in the kth instruction; at the same time, set the current traversal to a i ' j a in ' i ' j ' k Instruction, when a i ' j ' k Jump out of a i ' j 'When the function reaches its end boundary, set a i ' j ' k It is the end instruction of the basic block and exits the basic block; when a i ' j ' k Did not jump out of a i ' j 'The end boundary of the function and ai ' j ' k For a jump instruction, set a i ' j ' k is the end instruction of the basic block and obtains a i ' j ' k The target address of the jump is used as the starting position of another basic block. i ' j ' k Did not jump out of a i ' j 'The end boundary of the function and a i ' j ' k If it is not a jump instruction, continue to traverse a i ' j ' k The next instruction a i ' j ' (k+1) ;when a i ' j ' (k+1) When it is the target instruction for other instructions to jump, a i ' j ' k As the end instruction of a basic block, a i ' j ' (k+1) As the start instruction of a basic block;
[0029] S121214, when a i ' j ' (k+1) When the target instruction is not a jump instruction for other instructions, repeat S12123 until the code function matrix a″ is traversed, and the basic blocks and control flows of all functions in the code function matrix a″ are obtained. The basic blocks of all functions in the code function matrix a″ constitute the first function basic block set matrix c″, as follows:
[0030]
[0031] Where: c i ' j ' indicates a i ' j ′ corresponds to the basic block set, c i ' j ' k Indicates a i ' j The kth basic block in ′, ci ' j ″ means a i ' j The total number of basic blocks in ′;
[0032] By traversing each instruction in each function in the code function matrix, the basic blocks are judged and divided according to the functions of different instructions. At the same time, the running process in the function and between functions is determined according to the jump situation of each instruction, making the division more accurate. The determined process is completely based on the operation of the code, making the obtained code control flow more based on evidence and accuracy.
[0033] Preferably, determining the function control flow in S1212 specifically includes the following steps:
[0034] S121221. Construct a basic block logical structure and a basic block physical structure according to the first function basic block set matrix c″, wherein the basic block logical structure is used to record the jump relationship between each basic block in the first function basic block set matrix c″; and the basic block physical structure is used to record the relative position of each basic block in the first function basic block set matrix c″ in the memory;
[0035] S121222. Set a basic block storage structure, wherein the basic block storage structure includes a starting physical address of a basic block, an ending physical address of a basic block, a pointer to a basic block, a length of the last instruction of a basic block, a jump target basic block, and a basic block where a next address is located;
[0036] S121223, using the basic block storage structure, the basic block logical structure and the basic block physical structure together as a first function control flow structure;
[0037] By taking the basic block storage structure, the basic block logical structure and the basic block physical structure together as the first function control flow structure, and taking the starting physical address of the basic block, the ending physical address of the basic block, the pointer pointing to the basic block, the length of the last instruction of the basic block, the jump target basic block and the basic block where the next address is located as part of the function control flow structure, a comprehensive and accurate description of the program execution process is obtained.
[0038] Preferably, S2 comprises the following steps:
[0039] S21, construct obfuscation algorithm set d = {d 1 ,d 2 ,d 3}, d 1 d 2 and d 3 They represent the code variable name obfuscation algorithm, control flow obfuscation algorithm, and basic block obfuscation algorithm respectively;
[0040] The code variable name obfuscation algorithm is used to randomly replace the variable names in the function basic block;
[0041] S22, using the code variable name obfuscation algorithm to randomly replace the code variable names in each function basic block in the first function basic block set matrix c″ to obtain a second function basic block set matrix;
[0042] S23, using the control flow obfuscation algorithm to sequentially transform the first function control flow structure to obtain a second function control flow structure, and then performing a logical transformation on each function basic block in the second function basic block set matrix according to the second function control flow structure to obtain a third function basic block set matrix;
[0043] S24, using the basic block obfuscation algorithm and cooperating with the second function control flow structure to transform the positions of the function basic blocks in the third function basic block set matrix, to obtain a fourth function basic block set matrix g′, as follows:
[0044]
[0045] Where: g i ' j Represents the original c after position transformation i ' j ′ replaces the basic block at the position;
[0046] A code variable name obfuscation algorithm is used to randomly replace the code variable names in each function basic block in the first function basic block set matrix, so that the variable names of the code have no clear meaning, thereby increasing the difficulty of understanding the logic and meaning of the code, and thus improving the security of the code; a control flow obfuscation algorithm and a basic block obfuscation algorithm are used to adjust the logic and position of the control flow of the code and the basic block of the code respectively, so that the original code logic and code position of the source code are disrupted, making the code as a whole disordered, thereby increasing the difficulty of tampering.
[0047] Preferably, the S23 comprises the following steps:
[0048] S231, adding a control flow obfuscation code block, wherein the content of the obfuscation code block specifically includes the following steps:
[0049] S2311, set control flow slice set d″′={d 1 ″,′d 2 ″′,...,d i ″,′...,d e ″′} and the corresponding control flow slice length set e′={e 1 ′,e′ 2 ,...,ei ′,...,e e ' -1}, d i ″′ represents the i-th control flow slice in the control flow slice set, e represents the total number of control flow slices in the control flow slice set; e i ′ represents the length between the i-th control flow slice and the i+1-th control flow slice in the control flow slice set;
[0050] S2312, adopt the control flow slice set d″′={d 1 ″,′d 2 ″′,...,d i ″,′...,d e Each control flow slice in the '} divides the storage structure, logical structure and physical structure of the basic block to obtain a basic block storage structure fragment set Basic block logic structure fragment set And the basic block physical structure fragment set where e i ″ represents the i-th basic block storage structure fragment; f i represents the logical structure fragment of the i-th basic block; f i ′ represents the physical structure fragment of the i-th basic block; e 1 ″′、e′ 2 ″ and e 3 ″′ respectively represents the total number of basic block storage structure fragments in the basic block storage structure fragment set, the total number of basic block logic structure fragments in the basic block logic structure fragment set, and the total number of basic block physical structure fragments in the basic block physical structure fragment set;
[0051] S2313, store the structure fragment set e″={e 1 ″,e′ 2 ′,...,e i ″,...,e e ″ 1″′}、Basic block logic structure fragment set f={f 1 ,f 2 ,...,f i ,...,f e′2″} and the basic block physical structure fragment set f′={f 1 ′,f 2 ′,...,f i ′,...,f e ″ 3″} to perform a sequence shuffle operation to obtain the final fragment set of the basic block storage structure f″={f 1 ′,′f 2 ″,...,f i′,′...,f e ' 1″ ″}, basic block logical structure final fragment set f″′={f 1 ′,″f 2 ″,′...,f i ′,″...,f e ″ 2″″} and the final fragment set of basic block physical structure g = {g 1 ,g 2 ,...,g i ,...,g e′3″}; f i ″、f i ″′ and g i They respectively represent the i-th basic block storage structure fragment in the final fragment set of the basic block storage structure, the i-th basic block logic structure fragment in the final fragment set of the basic block logic structure, and the i-th basic block physical structure fragment in the final fragment set of the basic block physical structure;
[0052] S232: The final fragment set f″ of the basic block storage structure is 1 ′,′f 2 ″,...,f i ′,′...,f e ' 1″ ″}, basic block logical structure final fragment set f″′={f 1 ′,″f 2 ″,′...,f i ′,″...,f e ″ 2″″} and the final fragment set of basic block physical structure g = {g 1 ,g 2 ,...,g i ,...,g e′3″}Together as the second function control flow structure;
[0053] S233, performing a logical transformation on each function basic block in the second function basic block set matrix according to the second function control flow structure to obtain a third function basic block set matrix;
[0054] By segmenting the original logical structure and data of the source code, the smaller the segmentation granularity, the more disordered and messy the converted code logic will be, thus improving the security of the code.
[0055] Preferably, S3 comprises the following steps:
[0056] S31, reading the code data of each basic block in the fourth function basic block set matrix g′, and recording it as original code data;
[0057] S32, calculating the SHA-256 hash value of the original code data, and then calculating the external key according to the SHA-256 hash value of the original code data to obtain the encryption algorithm external key g″, and using the encryption algorithm external key g″ as the initial value of the chaotic system, wherein the chaotic system includes the Chen hyperchaotic system;
[0058] S33, setting the number of chaotic iterations to g″′ and the current number of iterations to h, inputting the initial value of the chaotic system into the chaotic system for iterative operation, performing a Joseph ring scrambling operation on the original code data during each iteration, and stopping the iteration when h≥g″′ to obtain the scrambled code data;
[0059] S34, performing DNA encoding on the scrambled code data to obtain DNA-encoded code data, and using the DNA-encoded code data as the final encrypted code data;
[0060] The code data of each basic block in the fourth function basic block set matrix is encrypted by adopting an encryption algorithm based on chaotic mapping and DNA sequence operation. The encryption algorithm has good encryption effect and reliable security performance, making the encrypted code more difficult to be tampered with and better protecting the code.
[0061] A software code protection adjustment system based on digital encryption technology, including a code primary analysis module, a code variable name replacement module, a control flow structure logic transformation module, a basic block position transformation module and a code data encryption module;
[0062] The code primary analysis module is used to perform a disassembly operation on each binary code in the binary software code set and perform a primary analysis;
[0063] The code variable name replacement module is used to randomly replace the code variable names in each function basic block in the first function basic block set matrix by using the code variable name obfuscation algorithm;
[0064] The control flow structure logic transformation module is used to sequentially transform the first function control flow structure using the control flow obfuscation algorithm to obtain a second function control flow structure, and then perform logic transformation on each function basic block in the second function basic block set matrix according to the second function control flow structure;
[0065] The basic block position transformation module is used to use the basic block obfuscation algorithm and cooperate with the second function control flow structure to transform the positions of each function basic block in the third function basic block set matrix;
[0066] The code data encryption module is used to perform encryption operation on the fourth function basic block set matrix using an encryption algorithm.
[0067] The present invention has the following beneficial effects:
[0068] 1. In the present invention, a code primary analysis module, a code variable name replacement module, a control flow structure logic transformation module, a basic block position transformation module and a code data encryption module are set; a disassembly tool is used to disassemble and analyze each binary code in the binary software code set, so as to obtain a first function basic block set matrix and a first function control flow structure; by performing a primary analysis on the binary code, each basic block constituting the code is determined, and at the same time, the code execution process is determined, so as to facilitate the subsequent adjustment of the control flow and provide a basis for the subsequent adjustment of the position of the basic block; by constructing an obfuscation algorithm The method set provides algorithm support for the subsequent replacement of variables in the code, logical transformation of each function basic block, and position transformation of each basic block. At the same time, it ensures the complete conversion of the logical structure and position of the code, thereby ensuring the security of the code and protecting the source code from being tampered with or copied; finally, the source code after conversion is encrypted to further ensure the security of the code. By converting the position, variable name and logical structure of the software source code, it is difficult for hackers to analyze and restore the logic and structure of the code, making it difficult to understand the working principle of the software, thereby improving the security of the software.
[0069] 2. In the present invention, by dividing the source code into functions, each function in the source code can be analyzed separately, thereby improving the accuracy of the analysis and providing an accurate basis for the subsequent conversion of the source code; wherein, by traversing each instruction in each function in the code function matrix, the basic blocks are judged and divided according to the effects of different instructions, and at the same time, the running process in the function and between functions is determined according to the jump situation of each instruction, so that the division is more accurate, and the determined process is completely based on the operation of the code, so that the obtained code control flow is more reliable and accurate, and then the basic block storage structure, the basic block logical structure and the basic block physical structure are used together as the first function control flow structure, and the starting physical address of the basic block, the ending physical address of the basic block, the basic block pointer, the length of the last instruction of the basic block, the jump target basic block and the basic block where the next address is located are used as part of the function control flow structure, so that the program execution process is fully and accurately described.
[0070] 3. In the present invention, the code data of each basic block in the fourth function basic block set matrix is encrypted by adopting an encryption algorithm based on chaotic mapping and DNA sequence operation. The encryption algorithm has good encryption effect and reliable security performance, making the encrypted code more difficult to be tampered with and better protecting the code.
[0071] Of course, any product implementing the present invention does not necessarily need to achieve all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] In order to more clearly illustrate the technical solutions of the embodiments of the invention, the drawings required for describing the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the invention. For ordinary technicians in this field, they can also obtain drawings based on these drawings without paying creative work.
[0073] Figure 1 The present invention is a flowchart of a software code protection and adjustment system based on digital encryption technology for protecting software code. DETAILED DESCRIPTION
[0074] The following will be combined with the drawings in the embodiments of the invention to clearly and completely describe the technical solutions in the embodiments of the invention. Obviously, the described embodiments are only part of the embodiments of the invention, not all of the embodiments. Based on the embodiments in the invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the invention.
[0075] In the description of the present invention, it is necessary to understand that the terms "opening", "upper", "lower", "top", "middle", "inside" and the like indicating orientation or positional relationship are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the components or elements referred to must have a specific orientation, be constructed and operate in a specific orientation, and therefore cannot be understood as limiting the invention.
[0076] The present invention is a software code protection adjustment method based on digital encryption technology, comprising the following steps:
[0077] S1. Set a binary software code set, use a disassembly tool to disassemble and analyze each binary code in the binary software code set, and obtain a first function basic block set matrix and a first function control flow structure;
[0078] The S1 comprises the following steps:
[0079] S11, set the binary software code set a = {a 1 ,a 2 ,...,a i ,...,a a′}, a i represents the i-th binary software code segment in the binary software code set, a′ represents the total number of binary software code segments in the binary software code set;
[0080] S12, using a disassembly tool to disassemble the binary software code set a={a 1 ,a 2 ,...,a i ,...,a a′}, and performing a disassembly operation on each binary code in the first function and performing an analysis to obtain a first function basic block set matrix and a first function control flow structure; the disassembly tool includes IDA;
[0081] The S12 comprises the following steps:
[0082] S121, the disassembly tool uses a linear scanning algorithm to obtain a binary software code set a={a 1 ,a 2 ,...,a i ,...,a a′}The function basic blocks and function control flows of each binary code in;
[0083] The specific steps include:
[0084] S1211, set the binary software code set a={a 1 ,a 2 ,...,a i ,...,a a′} in each code segment does not overlap; according to the binary software code set a={a 1 ,a 2 ,...,a i ,...,a a′}Construct the code function matrix a″ as follows:
[0085]
[0086] Among them: a i ' j ′ represents the jth function in the ith binary software code segment in the binary software code set, a i ″′ represents the total number of functions in the ith binary software code segment in the binary software code set;
[0087] S1212, traverse each function in the code function matrix a″ to determine the function basic block and the function control flow, and obtain a first function basic block set matrix and a first function control flow structure;
[0088] Determining the function basic block in S1212 specifically includes the following steps:
[0089] S121211. Obtain the starting boundary and the ending boundary of each function in the code function matrix a″;
[0090] S121212, traverse each instruction of each function in the code function matrix a″, and take the first instruction of each function in the code function matrix a″ as the starting position of a basic block;
[0091] S121213, set a i ' j ′The corresponding instruction set is c i ' j , a i ' j ' k Indicates a i ' j ′ in the kth instruction; at the same time, set the current traversal to a i ' j a in ' i ' j ' k Instruction, when a i ' j ' k Jump out of a i ' j 'When the function reaches its end boundary, set a i ' j ' k It is the end instruction of the basic block and exits the basic block; when a i ' j ' k Did not jump out of a i ' j 'The end boundary of the function and a i ' j ' k For a jump instruction, set a i ' j ' k is the end instruction of the basic block and obtains a i ' j ' k The target address of the jump is used as the starting position of another basic block. i ' j ' k Did not jump out of a i ' j 'The end boundary of the function and a i ' j ' k If it is not a jump instruction, continue to traverse a i ' j ' k The next instruction a i ' j '(k+1) ;when a i ' j ' (k+1) When it is the target instruction for other instructions to jump, a i ' j ' k As the end instruction of a basic block, a i ' j ' (k+1) As the start instruction of a basic block;
[0092] S121214, when a i ' j ' (k+1) When the target instruction is not a jump instruction for other instructions, repeat S12123 until the code function matrix a″ is traversed, and the basic blocks and control flows of all functions in the code function matrix a″ are obtained. The basic blocks of all functions in the code function matrix a″ constitute the first function basic block set matrix c″, as follows:
[0093]
[0094] Where: c i ' j ' indicates a i ' j ′ corresponds to the basic block set, c i ' j ' k Indicates a i ' j The kth basic block in ′, c i ' j ″ means a i ' j The total number of basic blocks in ′;
[0095] Determining the function control flow in S1212 specifically includes the following steps:
[0096] S121221. Construct a basic block logical structure and a basic block physical structure according to the first function basic block set matrix c″, wherein the basic block logical structure is used to record the jump relationship between each basic block in the first function basic block set matrix c″; and the basic block physical structure is used to record the relative position of each basic block in the first function basic block set matrix c″ in the memory;
[0097] S121222. Set a basic block storage structure, wherein the basic block storage structure includes a starting physical address of a basic block, an ending physical address of a basic block, a pointer to a basic block, a length of the last instruction of a basic block, a jump target basic block, and a basic block where a next address is located;
[0098] S121223, using the basic block storage structure, the basic block logical structure and the basic block physical structure together as a first function control flow structure;
[0099] S2, construct an obfuscation algorithm set, wherein the obfuscation algorithm set includes a code variable name obfuscation algorithm, a control flow obfuscation algorithm, and a basic block obfuscation algorithm; the code variable name obfuscation algorithm is used to randomly replace the code variable names in each function basic block in the first function basic block set matrix to obtain a second function basic block set matrix; the control flow obfuscation algorithm is used to sequentially transform the first function control flow structure to obtain a second function control flow structure, and then the logic transformation of each function basic block in the second function basic block set matrix is performed according to the second function control flow structure to obtain a third function basic block set matrix; the basic block obfuscation algorithm is used in combination with the second function control flow structure to perform position transformation on each function basic block in the third function basic block set matrix to obtain a fourth function basic block set matrix;
[0100] The S2 comprises the following steps:
[0101] S21, construct obfuscation algorithm set d = {d 1 ,d 2 ,d 3}, d 1 d 2 and d 3 They represent a code variable name obfuscation algorithm, a control flow obfuscation algorithm, and a basic block obfuscation algorithm respectively; the code variable name obfuscation algorithm is used to randomly replace the variable names in the function basic block;
[0102] S22, using the code variable name obfuscation algorithm to randomly replace the code variable names in each function basic block in the first function basic block set matrix c″ to obtain a second function basic block set matrix;
[0103] S23, using the control flow obfuscation algorithm to sequentially transform the first function control flow structure to obtain a second function control flow structure, and then performing a logical transformation on each function basic block in the second function basic block set matrix according to the second function control flow structure to obtain a third function basic block set matrix;
[0104] The S23 comprises the following steps:
[0105] S231, adding a control flow obfuscation code block, wherein the content of the obfuscation code block specifically includes the following steps:
[0106] S2311, set control flow slice set d″′={d 1 ″,′d 2 ″′,...,d i″,′...,d e ″′} and the corresponding control flow slice length set e′={e 1 ′,e′ 2 ,...,e i ′,...,e e ' -1}, d i ″′ represents the i-th control flow slice in the control flow slice set, e represents the total number of control flow slices in the control flow slice set; e i ′ represents the length between the i-th control flow slice and the i+1-th control flow slice in the control flow slice set;
[0107] S2312, adopt the control flow slice set d″′={d 1 ″,′d 2 ″′,...,d i ″,′...,d e Each control flow slice in the '} divides the storage structure, logical structure and physical structure of the basic block to obtain a basic block storage structure fragment set Basic block logic structure fragment set And the basic block physical structure fragment set where e i ″ represents the i-th basic block storage structure fragment; f i represents the logical structure fragment of the i-th basic block; f i ′ represents the physical structure fragment of the i-th basic block; e 1 ″′、e′ 2 ″ and e 3 ″′ respectively represents the total number of basic block storage structure fragments in the basic block storage structure fragment set, the total number of basic block logic structure fragments in the basic block logic structure fragment set, and the total number of basic block physical structure fragments in the basic block physical structure fragment set;
[0108] S2313: Storing structure fragments for basic blocks Basic block logic structure fragment set And the basic block physical structure fragment set Perform a sequential shuffle operation to obtain the final fragment set of the basic block storage structure Basic block logic structure final fragment set And the final set of basic block physical structures f i ″、f i ″′ and g iThey respectively represent the i-th basic block storage structure fragment in the final fragment set of the basic block storage structure, the i-th basic block logic structure fragment in the final fragment set of the basic block logic structure, and the i-th basic block physical structure fragment in the final fragment set of the basic block physical structure;
[0109] S232: The basic block storage structure final fragment set Basic block logic structure final fragment set And the final set of basic block physical structures Together they serve as a second function control flow structure;
[0110] S233, performing a logical transformation on each function basic block in the second function basic block set matrix according to the second function control flow structure to obtain a third function basic block set matrix;
[0111] S24, using the basic block obfuscation algorithm and cooperating with the second function control flow structure to transform the positions of the function basic blocks in the third function basic block set matrix, to obtain a fourth function basic block set matrix g′, as follows:
[0112]
[0113] Where: g i ' j Represents the original c after position transformation i ' j ′ replaces the basic block at the position;
[0114] S3, reading the code data of each basic block in the fourth function basic block set matrix, and performing an encryption operation on the fourth function basic block set matrix using an encryption algorithm to obtain final encrypted code data;
[0115] The S3 comprises the following steps:
[0116] S31, reading the code data of each basic block in the fourth function basic block set matrix g′, and recording it as original code data;
[0117] S32, calculating the SHA-256 hash value of the original code data, and then calculating the external key according to the SHA-256 hash value of the original code data to obtain the encryption algorithm external key g″, and using the encryption algorithm external key g″ as the initial value of the chaotic system, wherein the chaotic system includes the Chen hyperchaotic system;
[0118] S33, setting the number of chaotic iterations to g″′ and the current number of iterations to h, inputting the initial value of the chaotic system into the chaotic system for iterative operation, performing a Joseph ring scrambling operation on the original code data during each iteration, and stopping the iteration when h≥g″′ to obtain the scrambled code data;
[0119] S34, DNA encoding is performed on the scrambled code data to obtain DNA-encoded code data, and the DNA-encoded code data is used as the final encrypted code data.
[0120] A software code protection adjustment system based on digital encryption technology, including a code primary analysis module, a code variable name replacement module, a control flow structure logic transformation module, a basic block position transformation module and a code data encryption module;
[0121] The code primary analysis module is used to perform a disassembly operation on each binary code in the binary software code set and perform a primary analysis;
[0122] The code variable name replacement module is used to randomly replace the code variable names in each function basic block in the first function basic block set matrix by using the code variable name obfuscation algorithm;
[0123] The control flow structure logic transformation module is used to sequentially transform the first function control flow structure using the control flow obfuscation algorithm to obtain a second function control flow structure, and then perform logic transformation on each function basic block in the second function basic block set matrix according to the second function control flow structure;
[0124] The basic block position transformation module is used to use the basic block obfuscation algorithm and cooperate with the second function control flow structure to transform the positions of each function basic block in the third function basic block set matrix;
[0125] The code data encryption module is used to perform encryption operation on the fourth function basic block set matrix using an encryption algorithm.
[0126] In the description of this specification, the description with reference to the terms "one embodiment", "example", "specific example", etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0127] The preferred embodiments of the invention disclosed above are only used to help explain the invention. The preferred embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the invention, so that those skilled in the art can understand and use the invention well.
Claims
1. A software code protection adjustment method based on digital encryption technology, characterized in that: The following steps are involved: S1. Set a binary software code set, use a disassembly tool to disassemble and analyze each binary code in the binary software code set, and obtain a first function basic block set matrix and a first function control flow structure; S2, construct an obfuscation algorithm set, wherein the obfuscation algorithm set includes a code variable name obfuscation algorithm, a control flow obfuscation algorithm, and a basic block obfuscation algorithm; the code variable name obfuscation algorithm is used to randomly replace the code variable names in each function basic block in the first function basic block set matrix to obtain a second function basic block set matrix; the control flow obfuscation algorithm is used to sequentially transform the first function control flow structure to obtain a second function control flow structure, and then the logic transformation of each function basic block in the second function basic block set matrix is performed according to the second function control flow structure to obtain a third function basic block set matrix; the basic block obfuscation algorithm is used in combination with the second function control flow structure to perform position transformation on each function basic block in the third function basic block set matrix to obtain a fourth function basic block set matrix; S3. Read the code data of each basic block in the fourth function basic block set matrix, and use an encryption algorithm to perform an encryption operation on the fourth function basic block set matrix to obtain final encrypted code data.
2. The software code protection adjustment method based on digital encryption technology according to claim 1 is characterized in that: The S1 comprises the following steps: S11, set the binary software code set a={a1, a2, ..., a i ,...,a a′ }, a i represents the i-th binary software code segment in the binary software code set, a′ represents the total number of binary software code segments in the binary software code set; S12, using a disassembly tool to disassemble the binary software code set a={a1, a2, ..., a i ,...,a a′ } perform a disassembly operation and an analysis on each binary code in the first function to obtain a first function basic block set matrix and a first function control flow structure; the disassembly tool includes IDA.
3. The software code protection adjustment method based on digital encryption technology according to claim 2 is characterized in that: The S12 comprises the following steps: S121, the disassembly tool uses a linear scanning algorithm to obtain a binary software code set a={a1, a2, ..., a i ,...,a a′ }The function basic blocks and function control flows of each binary code in; The specific steps include: S1211, set the binary software code set a={a1, a2, ..., a i ,...,a a′ }, the positions of the function codes in the various code segments do not overlap; according to the binary software code set a={a1, a2, ..., a i ,...,a a′ }Construct the code function matrix a″ as follows: Among them: a i ' j ′ represents the jth function in the ith binary software code segment in the binary software code set, a i ″′ represents the total number of functions in the ith binary software code segment in the binary software code set; S1212. Traverse each function in the code function matrix a″ to determine function basic blocks and function control flows, and obtain a first function basic block set matrix and a first function control flow structure.
4. The software code protection adjustment method based on digital encryption technology according to claim 3 is characterized in that: Determining the function basic block in S1212 specifically includes the following steps: S121211. Obtain the starting boundary and the ending boundary of each function in the code function matrix a″; S121212, traverse each instruction of each function in the code function matrix a″, and take the first instruction of each function in the code function matrix a″ as the starting position of a basic block; S121213, set a i ' j ′The corresponding instruction set is c i ' j , c i ' j ={a i ' j ′1,a i ' j ′2,...,a i ' j ' k ,...,a i ' j ' cij }, a i ' j ' k Indicates a i ' j ′ in the kth instruction; at the same time, set the current traversal to a i ' j a in ' i ' j ' k Instruction, when a i ' j ' k Jump out of a i ' j 'When the function reaches its end boundary, set a i ' j ' k It is the end instruction of the basic block and exits the basic block; when a i ' j ' k Did not jump out of a i ' j 'The end boundary of the function and a i ' j ' k For a jump instruction, set a i ' j ' k is the end instruction of the basic block and obtains a i ' j ' k The target address of the jump is used as the starting position of another basic block. i ' j ' k Did not jump out of a i ' j 'The end boundary of the function and a i ' j ' k If it is not a jump instruction, continue to traverse a i ' j ' k The next instruction a i ' j ' (k+1) ;when a i ' j ' (k+1) When it is the target instruction for other instructions to jump, a i ' j ' k As the end instruction of a basic block, a i ' j ' (k+1) As the start instruction of a basic block; S121214, when a i ' j ' (k+1) When the target instruction is not a jump instruction for other instructions, repeat S12123 until the code function matrix a″ is traversed, and the basic blocks and control flows of all functions in the code function matrix a″ are obtained. The basic blocks of all functions in the code function matrix a″ constitute the first function basic block set matrix c″, as follows: Where: c i ' j ' indicates a i ' j ′ corresponds to the basic block set, c i ' j ′={c i ' j ′1,c i ' j ′2,...,c i ' j ' k ,...,c i ' j ' ci′j″ },c i ' j ' k Indicates a i ' j The kth basic block in ′, c i ' j ″ means a i ' j The total number of basic blocks in ′.
5. The software code protection adjustment method based on digital encryption technology according to claim 3 is characterized in that: Determining the function control flow in S1212 specifically includes the following steps: S121221. Construct a basic block logical structure and a basic block physical structure according to the first function basic block set matrix c″, wherein the basic block logical structure is used to record the jump relationship between each basic block in the first function basic block set matrix c″; and the basic block physical structure is used to record the relative position of each basic block in the first function basic block set matrix c″ in the memory; S121222. Set a basic block storage structure, wherein the basic block storage structure includes a starting physical address of a basic block, an ending physical address of a basic block, a pointer to a basic block, a length of the last instruction of a basic block, a jump target basic block, and a basic block where a next address is located; S121223. Take the basic block storage structure, the basic block logical structure and the basic block physical structure together as a first function control flow structure.
6. The software code protection adjustment method based on digital encryption technology according to claim 1, characterized in that: The S2 comprises the following steps: S21, constructing an obfuscation algorithm set d = {d1, d2, d3}, where d1, d2 and d3 represent a code variable name obfuscation algorithm, a control flow obfuscation algorithm and a basic block obfuscation algorithm respectively; the code variable name obfuscation algorithm is used to randomly replace variable names in a function basic block; S22, using the code variable name obfuscation algorithm to randomly replace the code variable names in each function basic block in the first function basic block set matrix c″ to obtain a second function basic block set matrix; S23, using the control flow obfuscation algorithm to sequentially transform the first function control flow structure to obtain a second function control flow structure, and then performing a logical transformation on each function basic block in the second function basic block set matrix according to the second function control flow structure to obtain a third function basic block set matrix; S24, using the basic block obfuscation algorithm and cooperating with the second function control flow structure to transform the positions of the function basic blocks in the third function basic block set matrix, to obtain a fourth function basic block set matrix g′, as follows: Where: g i ' j Represents the original c after position transformation i ' j ’ is the replacement basic block at the position.
7. The software code protection adjustment method based on digital encryption technology according to claim 6 is characterized in that: The S23 comprises the following steps: S231, adding a control flow obfuscation code block, wherein the content of the obfuscation code block specifically includes the following steps: S2311, set control flow slice set d″′={d1″,′d2″′,...,d i ″,′...,d e ″′} and the corresponding control flow slice length set e′={e1′,e′2,...,e i ′,...,e e ' -1 }, d i ″′ represents the i-th control flow slice in the control flow slice set, e represents the total number of control flow slices in the control flow slice set; e i ′ represents the length between the i-th control flow slice and the i+1-th control flow slice in the control flow slice set; S2312, adopt the control flow slice set d″′={d1″,′d2″′,...,d i ″,′...,d e Each control flow slice in ″′} divides the storage structure, logical structure and physical structure of the basic block to obtain a basic block storage structure fragment set e″={e1″,e′2′,...,e i ″,...,e e ″ 1″′ }、Basic block logical structure fragment set f={f1,f2,...,f i ,...,f e′2″ } and the basic block physical structure fragment set f′={f1′,f2′,...,f i ′,...,f e ″ 3″ }, where e i ″ represents the i-th basic block storage structure fragment; f i represents the logical structure fragment of the i-th basic block; f i ′ represents the i-th basic block physical structure fragment; e1″′, e′2″ and e3″′ respectively represent the total number of basic block storage structure fragments in the basic block storage structure fragment set, the total number of basic block logical structure fragments in the basic block logical structure fragment set and the total number of basic block physical structure fragments in the basic block physical structure fragment set; S2313, store the structure fragment set e″={e1″,e′2′,...,e i ″,...,e e ″ 1″′ }、Basic block logical structure fragment set f={f1,f2,...,f i ,...,f e′2″ } and the basic block physical structure fragment set f′={f1′,f2′,...,f i ′,...,f e ″ 3″ } to perform a sequential shuffle operation to obtain the final fragment set of the basic block storage structure f″={f1′,′f2″,...,f i ′,′...,f e ' 1″ ″}, the final fragment set of basic block logical structure f″′={f1′,″f2″,′...,f i ′,″...,f e ″ 2″″ } and the final fragment set of basic block physical structure g = {g1,g2,...,g i ,...,g e′3″ }; f i ″、f i ″′ and g i They respectively represent the i-th basic block storage structure fragment in the final fragment set of the basic block storage structure, the i-th basic block logic structure fragment in the final fragment set of the basic block logic structure, and the i-th basic block physical structure fragment in the final fragment set of the basic block physical structure; S232, the basic block storage structure final fragment set f″={f1′,′f2″,...,f i ′,′...,f e ' 1″ ″}, the final fragment set of basic block logical structure f″′={f1′,″f2″,′...,f i ′,″...,f e ″ 2″″ } and the final fragment set of basic block physical structure g = {g1,g2,...,g i ,...,g e′3″ }Together as the second function control flow structure; S233. Perform a logical transformation on each function basic block in the second function basic block set matrix according to the second function control flow structure to obtain a third function basic block set matrix.
8. The software code protection adjustment method based on digital encryption technology according to claim 1 is characterized in that: The S3 comprises the following steps: S31, reading the code data of each basic block in the fourth function basic block set matrix g′, and recording it as original code data; S32, calculating the SHA-256 hash value of the original code data, and then calculating the external key according to the SHA-256 hash value of the original code data to obtain the encryption algorithm external key g″, and using the encryption algorithm external key g″ as the initial value of the chaotic system, wherein the chaotic system includes the Chen hyperchaotic system; S33, setting the number of chaotic iterations to g″′ and the current number of iterations to h, inputting the initial value of the chaotic system into the chaotic system for iterative operation, performing a Joseph ring scrambling operation on the original code data during each iteration, and stopping the iteration when h≥g″′ to obtain the scrambled code data; S34, DNA encoding is performed on the scrambled code data to obtain DNA-encoded code data, and the DNA-encoded code data is used as the final encrypted code data.
9. A system for implementing the software code protection adjustment method based on digital encryption technology as described in any one of claims 1 to 8, characterized in that: It includes a code one-time analysis module, a code variable name replacement module, a control flow structure logic transformation module, a basic block position transformation module and a code data encryption module; The code primary analysis module is used to perform a disassembly operation on each binary code in the binary software code set and perform a primary analysis; The code variable name replacement module is used to randomly replace the code variable names in each function basic block in the first function basic block set matrix by using the code variable name obfuscation algorithm; The control flow structure logic transformation module is used to sequentially transform the first function control flow structure using the control flow obfuscation algorithm to obtain a second function control flow structure, and then perform logic transformation on each function basic block in the second function basic block set matrix according to the second function control flow structure; The basic block position transformation module is used to use the basic block obfuscation algorithm and cooperate with the second function control flow structure to transform the positions of each function basic block in the third function basic block set matrix; The code data encryption module is used to perform encryption operation on the fourth function basic block set matrix using an encryption algorithm.
Citation Information
Patent Citations
Software protection method for preventing digital feedback control system from being out of control
CN102147595A