A method and system for identifying loop bodies of encryption algorithms based on bit-accurate execution
By reconstructing the ring structure of the encryption algorithm and utilizing Boolean function expressions and input/output bit analysis, accurate identification of the encryption algorithm loop body is achieved, solving the problem of identifying encryption algorithms in malware and improving the accuracy and robustness of identification.
Patent Information
- Application Number
- CN202410562426.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-08
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2044-05-08
AI Technical Summary
Existing technologies struggle to accurately identify encrypted algorithm loops in malware, especially in obfuscated situations, where traditional methods of feature identification are ineffective.
The algorithm reconstructs the wheel structure of the encryption algorithm by using cryptographic components, represents the generation rule of each bit through Boolean function expressions, and uses input-output bit analysis methods to design an input matrix to determine the mapping relationship, thereby achieving precise bit-by-bit analysis.
It enables fine-grained analysis of the loop body of encryption algorithms, accurately identifies encryption algorithm components in malware, and improves the accuracy and robustness of identification.
Smart Images

Figure CN118509202B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cryptography, and in particular to a method and system for identifying a loop body of an encryption algorithm based on bit-accurate execution. Background Art
[0002] The statements in this section merely provide background information related to the present invention and do not necessarily constitute prior art.
[0003] The loop body of a cryptographic algorithm is the main body of the cryptographic algorithm. The encryption algorithm uses the loop body to process data in multiple rounds, and processes the plaintext through linear operations, nonlinear operations, and XOR processing with the key, and finally processes the plaintext into irregular ciphertext. Therefore, the encryption algorithm can be effectively identified by identifying the loop body, but in some applications of the cryptographic algorithm, some obfuscation is often added, such as control obfuscation and data obfuscation. Especially in malware, encryption algorithms are often an important means for hackers to hold computers hostage.
[0004] Nowadays, the recognition of encryption algorithm loops is mostly achieved using technologies such as program analysis, feature analysis, pattern recognition, and machine learning. Such recognition methods are often coarse-grained analysis of algorithm features. Program analysis often analyzes the algorithm control flow and data flow to identify code segments, and often uses feature recognition of the results of encryption algorithms. Pattern recognition technology determines the location of the loop based on the pattern or features of the encryption algorithm. Machine learning learns the features of the algorithm loop through a large number of program sample training.
[0005] Existing technologies often analyze the loop of encryption algorithms through black box judgment, which only analyzes the input and output characteristics of encryption algorithms or identifies the pattern characteristics of encryption algorithms to judge the algorithm. When the algorithm is obfuscated by some malicious means, the previous algorithm characteristics will be disrupted and reorganized. At this time, it is often not feasible to identify the loop of the algorithm through some inherent characteristics. Summary of the invention
[0006] In order to solve the technical problems existing in the above-mentioned background technology, the present invention provides an encryption algorithm loop body identification method and system based on bit-accurate execution. The present invention can determine the encryption algorithm loop body components in a fine-grained manner and analyze the encryption algorithms existing in malware.
[0007] In order to achieve the above object, the present invention adopts the following technical solution:
[0008] A first aspect of the present invention provides a method for identifying a loop body of an encryption algorithm based on bit-accurate execution.
[0009] A method for identifying a loop body of an encryption algorithm based on bit-accurate execution, comprising:
[0010] The encryption algorithm wheel structure is reconstructed and reorganized by using cryptographic components to construct an encryption algorithm structure implemented bit by bit;
[0011] Based on the encryption algorithm structure implemented bit by bit, the generation rule of each bit is expressed by Boolean function expression;
[0012] The input-output bit analysis method is used to design the input matrix, calculate the Boolean function expression, generate the output matrix, obtain the mapping relationship between the Boolean functions and the mapping relationship between the input variables, and judge the algorithm loop body.
[0013] Furthermore, the cryptographic component reconstruction includes: converting the nonlinear transformation S-box and linear operations of common components of the encryption algorithm into unit bit operations.
[0014] Furthermore, the cryptographic component reconstruction also includes: replacing the encryption algorithm round function component with a Boolean function expression.
[0015] Furthermore, the process of expressing the generation rule of each bit using a Boolean function expression includes: reconstructing and analyzing the generation of the S-box, converting the nonlinear operation into a Boolean expression, and obtaining the execution result of each bit through the input value; and then performing a cyclic shift and an XOR operation on each bit in the linear operation according to the bit operation.
[0016] Furthermore, the process of using the input-output bit analysis method includes: designing an input matrix, obtaining an output matrix by bit-accurate execution of a reference program Boolean function expression, analyzing and classifying the matrix, classifying those with the same output true value into one category, performing the same processing on the target program, comparing the output matrices of the two, and classifying the input variables and Boolean function expressions of the loop body operation with the same output matrix into one category through comparison and classification based on the input-output value characteristics of the loop body operation.
[0017] Furthermore, the process of using the input-output bit analysis method also includes: designing a unit matrix input for results of the same class with the same output matrix, setting the input variables of the same class to the unit matrix, setting the input variables of different classes to 1, and calculating the Boolean function expression again until each Boolean function expression and input variable in the algorithm has a one-to-one correspondence.
[0018] Furthermore, when using Boolean function expressions, each type of operation is divided into Boolean functions according to the principle that multiple inputs correspond to one output.
[0019] A second aspect of the present invention provides an encryption algorithm loop body recognition system based on bit-accurate execution.
[0020] A cryptographic algorithm loop body recognition system based on bit-accurate execution, comprising:
[0021] A cryptographic component reconstruction module is configured to: reconstruct a round structure of an encryption algorithm using cryptographic component reconstruction to construct an encryption algorithm structure implemented bit by bit;
[0022] A Boolean function expression calculation module is configured to: based on the encryption algorithm structure implemented bit by bit, express the generation rule of each bit using a Boolean function expression;
[0023] The input-output bit analysis module is configured to: adopt the input-output bit analysis method, design the input matrix, calculate the Boolean function expression, generate the output matrix, obtain the mapping relationship between the Boolean functions and the mapping relationship between the input variables, and judge the algorithm loop body.
[0024] A third aspect of the present invention provides a computer-readable storage medium.
[0025] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps in the encryption algorithm loop body identification method based on bit-accurate execution as described in the first aspect above.
[0026] A fourth aspect of the present invention provides a computer device.
[0027] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps in the encryption algorithm loop body identification method based on bit-accurate execution as described in the first aspect above are implemented.
[0028] Compared with the prior art, the present invention has the following beneficial effects:
[0029] The present invention adopts cryptographic component reconstruction to provide a better input method for the subsequent bit analysis calculation of the encryption algorithm loop body. The Boolean function expression can realize the execution change of the bit-accurate analysis algorithm. The input and output bit analysis method adopted can determine the algorithm component structure in the loop body, thereby realizing fine-grained analysis of the algorithm, accurately identifying the encryption algorithm loop body components and analyzing the encryption algorithm existing in the malware. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.
[0031] Figure 1 It is a flow chart of the encryption algorithm loop body identification method based on bit-accurate execution shown in the present invention. DETAILED DESCRIPTION
[0032] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0033] It should be noted that the following detailed descriptions are all illustrative and intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.
[0034] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit exemplary embodiments according to the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0035] It should be noted that the flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the methods and systems according to various embodiments of the present disclosure. It should be noted that each box in the flowchart or block diagram can represent a module, a program segment, or a part of a code, and the module, program segment, or a part of a code may include one or more executable instructions for implementing the logical functions specified in each embodiment. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, or they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the flowchart and / or block diagram, and the combination of boxes in the flowchart and / or block diagram can be implemented using a dedicated hardware-based system that performs a specified function or operation, or can be implemented using a combination of dedicated hardware and computer instructions.
[0036] Embodiment 1
[0037] The present embodiment provides a method for identifying loop bodies of encryption algorithms based on bit-accurate execution. The present embodiment uses the method applied to a server as an example for illustration. It is understandable that the method can also be applied to a terminal, and can also be applied to a system including a terminal, a server, and a server, and is implemented through the interaction between the terminal and the server. The server can be an independent physical server, or a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network servers, cloud communications, middleware services, domain name services, security services CDN, and big data and artificial intelligence platforms. The terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto. The terminal and the server can be directly or indirectly connected via wired or wireless communication, which is not limited in this application. In the present embodiment, the method includes the following steps:
[0038] The encryption algorithm wheel structure is reconstructed and reorganized by using cryptographic components to construct an encryption algorithm structure implemented bit by bit;
[0039] Based on the encryption algorithm structure implemented bit by bit, the generation rule of each bit is expressed by Boolean function expression;
[0040] The input-output bit analysis method is used to design the input matrix, calculate the Boolean function expression, generate the output matrix, obtain the mapping relationship between the Boolean functions and the mapping relationship between the input variables, and judge the algorithm loop body.
[0041] The present invention redesigns the cryptographic algorithm cryptographic components, converts the group calculation in the cryptographic algorithm into bitwise operation, converts the commonly used nonlinear transformation S-box replacement into Boolean function expression transformation, performs a separate operation on each bit, and distinguishes the execution of each bit. Some linear operations are also converted into bitwise execution, so as to obtain the bit relationship between input and output to analyze the specific changes of the execution operation of each bit.
[0042] The present invention generates an output matrix by designing a unit input matrix to pass the input variables in the encryption algorithm through a specific Boolean function, thereby obtaining the relationship between the input variables and the output variables obtained by executing the Boolean function. Input variables and Boolean functions with the same output characteristics are divided into one category, and then a new round of Boolean function operations are performed by designing a unit matrix according to the characteristics of the same category, and finally the mapping relationship between the Boolean functions and the mapping relationship between the input variables are obtained to realize the judgment of the algorithm loop body.
[0043] The cryptographic component reconstruction described in the present invention can provide a better input method for the subsequent bit analysis calculation of the encryption algorithm loop body. The application of Boolean functions can realize the execution changes of the bit-accurate analysis algorithm. The bit analysis method can determine the algorithm component structure in the loop body to achieve fine-grained analysis of the algorithm.
[0044] like Figure 1 As shown, the cryptographic component reconstruction proposed in the present invention refers to converting the components in the original cryptographic algorithm, such as the S-box, which is an 8-bit input and 8-bit output operation, into unit-bit operations, generating a Boolean function expression for the structure of the S-box, and expressing the generation rule of each bit using a Boolean function, thereby forming the input-output relationship of each bit operation. Similarly, for some linear operations, such as circular left shift, column confusion, and XOR operations, unit-bit operations are also used to replace the original operations, and each type of operation is divided into Boolean functions according to the principle that multiple inputs correspond to one output. Thereby separating multiple Boolean functions. Commonly used encryption algorithms use 128-bit bit input, and then analyze different bit inputs according to the structure of the cryptographic component.
[0045] In the input-output bit analysis method, the loop body in the target to be analyzed is reconstructed into a Boolean expression F (there are multiple Boolean functions f1, f2...) using a unit bit input matrix to store the output matrix. Then the loop body to be analyzed is divided into a Boolean function G (there are multiple Boolean functions g1, g2...) and a single bit input is used to obtain the same output matrix, and the output bit matrices of the two functions are compared. For example, each bit in a 32-bit register is defined as a Boolean variable, each variable is set to 1 individually, and the rest are 0. Each row in its output matrix corresponds to the result of an input variable. Each column corresponds to the output results corresponding to multiple inputs of a Boolean function. The bit content of each row (output result corresponding to the input variable) contained in the output matrices of F and G is counted. If the two Boolean functions perform the same operation, then the output matrix results must be the same (even if there is data confusion and control confusion, the sum of their output values is unchanged), so a one-to-one corresponding output can always be found, thereby achieving the recognition of the behavior of the two Boolean functions and the classification of the input variable categories.
[0046] When the complete mapping between F and G cannot be found, that is, the Boolean functions and input variables between the two cannot be completely distinguished, a second comparison is performed, and the output results with the same result in the first comparison are grouped together, and the input variables with the same output bits are re-entered, and the input matrix is redesigned, and the input variables that do not exist in this group are set to 1, and the remaining input variables that exist in this group are set to the unit matrix and re-entered, and this group of input variables is substituted into the Boolean function, and then the output results are compared and analyzed, and the input variable mapping and Boolean function mapping are reclassified. Repeat the above steps until all input variables in F and G have found a one-to-one corresponding result. At this time, the mapping of the Boolean function and the mapping of the Boolean variable between the two are obtained.
[0047] Finally, the obtained mapping is redesigned and analyzed, and the corresponding input operations (x and y) and Boolean functions (f and g) are performed to verify the complete mapping of the Boolean function, so as to determine whether the two loop bodies F and G are performing operations for the same purpose.
[0048] Embodiment 2
[0049] This embodiment provides an encryption algorithm loop body recognition system based on bit-accurate execution.
[0050] A cryptographic algorithm loop body recognition system based on bit-accurate execution, comprising:
[0051] A cryptographic component reconstruction module is configured to: reconstruct a round structure of an encryption algorithm using cryptographic component reconstruction to construct an encryption algorithm structure implemented bit by bit;
[0052] A Boolean function expression calculation module is configured to: based on the encryption algorithm structure implemented bit by bit, express the generation rule of each bit using a Boolean function expression;
[0053] The input-output bit analysis module is configured to: adopt the input-output bit analysis method, design the input matrix, calculate the Boolean function expression, generate the output matrix, obtain the mapping relationship between the Boolean functions and the mapping relationship between the input variables, and judge the algorithm loop body.
[0054] It should be noted that the above-mentioned cryptographic component reconstruction module, Boolean function expression calculation module and input / output bit analysis module are the same as the examples and application scenarios implemented by the steps in Embodiment 1, but are not limited to the contents disclosed in Embodiment 1. It should be noted that the above-mentioned modules as part of the system can be executed in a computer system such as a set of computer executable instructions.
[0055] Embodiment 3
[0056] This embodiment provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps in the encryption algorithm loop body identification method based on bit-accurate execution as described in the first embodiment above are implemented.
[0057] Embodiment 4
[0058] This embodiment provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the steps in the encryption algorithm loop body identification method based on bit-accurate execution as described in the first embodiment are implemented.
[0059] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of hardware embodiments, software embodiments, or embodiments combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer-usable program code.
[0060] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0061] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0062] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0063] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0064] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for identifying loop bodies of encryption algorithms based on bit-accurate execution, characterized in that: include: The encryption algorithm wheel structure is reconstructed and reorganized by using cryptographic components to construct an encryption algorithm structure implemented bit by bit; Based on the encryption algorithm structure implemented bit by bit, the generation rule of each bit is expressed by Boolean function expression; Using the input-output bit analysis method, the input matrix is designed, the Boolean function expression is calculated, the output matrix is generated, the mapping relationship between the Boolean functions and the mapping relationship between the input variables are obtained, and the algorithm loop body is judged; The process of using the input-output bit analysis method includes: designing an input matrix, obtaining an output matrix by bit-accurately executing the Boolean function expression of the reference program, analyzing and classifying the matrix, classifying the matrixes with the same output true value into one category, performing the same processing on the target program, comparing the output matrices of the two, and classifying the input variables and Boolean function expressions of the loop body operation with the same output matrix into one category through comparison and classification according to the input-output value characteristics of the loop body operation; For the results of the same class with the same output matrix, design the unit matrix input, set the input variables of the same class to the unit matrix, set the input variables of different classes to 1, and calculate the Boolean function expression again until each Boolean function expression and input variable in the algorithm has a one-to-one correspondence.
2. The encryption algorithm loop body identification method based on bit-accurate execution according to claim 1 is characterized in that: The cryptographic component reconstruction includes: nonlinearly transforming the S-box of the common components of the encryption algorithm and converting the linear operation into unit bit operation.
3. The encryption algorithm loop body identification method based on bit-accurate execution according to claim 1 is characterized in that: The cryptographic component reconstruction also includes: using a Boolean function expression to replace the encryption algorithm round function component.
4. The encryption algorithm loop body identification method based on bit-accurate execution according to claim 1 is characterized in that: The process of expressing the generation rule of each bit using a Boolean function expression includes: reconstructing and analyzing the generation of the S box, converting the nonlinear operation into a Boolean expression, and obtaining the execution result of each bit through the input value; and then performing a cyclic shift and an XOR operation on each bit in the linear operation according to the bit operation.
5. The encryption algorithm loop body identification method based on bit-accurate execution according to claim 1 is characterized in that: When using Boolean function expressions, each type of operation is divided into Boolean functions according to the principle that multiple inputs correspond to one output.
6. A cryptographic algorithm loop body recognition system based on bit-accurate execution, characterized in that: include: A cryptographic component reconstruction module is configured to: reconstruct a round structure of an encryption algorithm using cryptographic component reconstruction to construct an encryption algorithm structure implemented bit by bit; A Boolean function expression calculation module is configured to: based on the encryption algorithm structure implemented bit by bit, express the generation rule of each bit using a Boolean function expression; An input-output bit analysis module is configured to: adopt an input-output bit analysis method, design an input matrix, calculate the Boolean function expression, generate an output matrix, obtain the mapping relationship between Boolean functions and the mapping relationship between input variables, and realize the judgment of the algorithm loop body; The process of using the input-output bit analysis method includes: designing an input matrix, obtaining an output matrix by bit-accurately executing the Boolean function expression of the reference program, analyzing and classifying the matrix, classifying the matrixes with the same output true value into one category, performing the same processing on the target program, comparing the output matrices of the two, and classifying the input variables and Boolean function expressions of the loop body operation with the same output matrix into one category through comparison and classification according to the input-output value characteristics of the loop body operation; For the results of the same class with the same output matrix, design the unit matrix input, set the input variables of the same class to the unit matrix, set the input variables of different classes to 1, and calculate the Boolean function expression again until each Boolean function expression and input variable in the algorithm has a one-to-one correspondence.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps in the encryption algorithm loop body identification method based on bit-accurate execution as described in any one of claims 1 to 5 are implemented.
8. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps in the encryption algorithm loop body identification method based on bit-accurate execution as described in any one of claims 1 to 5 are implemented.
