Binary executable file similarity analysis method, system, electronic device and storage medium
By calculating the hash value of the assembly code of the binary executable file, the problem of low efficiency of directly using the full information of the assembly code is solved, fast similarity analysis is realized, and the analysis efficiency and accuracy of binary files are improved.
Patent Information
- Application Number
- CN202210493048.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-07
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2042-05-07
AI Technical Summary
When analyzing binary executable files, directly using functions to assemble the entire code is inefficient and difficult to store and query quickly.
By performing dimensionality reduction on the assembly function information in the assembly code, the hash value is obtained, and the hash value is used to calculate the similarity between the binary executable file and the sample file to improve analysis efficiency.
Quickly determine the similarity of binary executable files through hash value comparison, which improves analysis efficiency, simplifies the complexity of comparing features, and enhances the accuracy of analysis.
Smart Images

Figure CN115017878B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of binary file analysis, and in particular to a binary executable file similarity analysis method, system, electronic device and storage medium. Background Art
[0002] In computer science, a control flow graph (CFG) is a mathematical representation of graphs that indicates the flow of all paths taken during the execution of a computer program. In a machine language assembly scenario, the assembly code of a function can be represented by a control flow graph. A control flow graph can contain one or more basic blocks, and each basic block can contain one or more assembly codes.
[0003] However, the inventors of the present application discovered during the process of implementing the present invention that, when analyzing binary executable files, if the entire amount of function assembly code information is directly used for storage and query, the efficiency is relatively low. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a binary executable file similarity analysis method, system, electronic device and storage medium, which can improve the analysis efficiency of binary executable files to a certain extent.
[0005] In order to achieve the above-mentioned invention object, the following technical scheme is adopted:
[0006] In a first aspect, an embodiment of the present invention provides a binary executable file similarity analysis method, the method comprising the steps of: obtaining assembly code of a binary executable file to be analyzed; performing dimensionality reduction processing on assembly function information carried by the assembly code to obtain a corresponding hash value; and determining the similarity between the binary executable file to be analyzed and a sample file based on the hash value.
[0007] Optionally, the assembly function information includes: a mnemonic and an operand, and the assembly code includes a plurality of instructions;
[0008] The dimensionality reduction process is performed on the assembly function information carried by the assembly code to obtain the corresponding hash value, which includes:
[0009] Taking the first instruction as the starting point, performing iterative operations in sequence according to the mnemonics and operands carried in the first instruction, and converting the assembly code into a control flow graph; the control flow graph includes: basic blocks and edge features;
[0010] Based on a depth-first traversal algorithm, all basic blocks in the control flow graph and all basic blocks within a predetermined node length from a corresponding basic block are calculated in sequence;
[0011] Each basic block and all basic blocks within a predetermined node length from the basic block form a group of control flow subgraphs to obtain multiple groups of control flow subgraphs; the number of control flow subgraphs contained in each group of control flow subgraphs is the same as the predetermined node length;
[0012] Based on the obtained multiple groups of control flow subgraphs, hash values corresponding to edge features of the control flow graph are calculated, and hash values corresponding to mnemonics and operands carried in each instruction contained in the control flow graph are calculated.
[0013] Optionally, the calculating, based on the obtained multiple groups of control flow subgraphs, hash values corresponding to edge features of the control flow graphs includes:
[0014] Topological sorting is performed based on the edge features of each control flow subgraph; the edge features include: incoming edges, outgoing edges and self-loops;
[0015] According to the result of the topological sorting, a prime number is selected for hash calculation to obtain an identity identification code for each control flow subgraph; the identity identification code is used to uniquely identify the control flow subgraph to distinguish different control flow subgraphs;
[0016] For each control flow subgraph, calculate the hash value corresponding to the edge feature;
[0017] Taking one of the control flow subgraphs as the calculation starting point, all hash values are superimposed and updated to obtain the hash value of the edge feature of the control flow graph.
[0018] Optionally, the operand is an immediate number;
[0019] Based on the obtained multiple groups of control flow subgraphs, calculating the hash value corresponding to the mnemonics and operands carried in each instruction included in the control flow graph comprises:
[0020] Traversing the instructions contained in the multiple control flow subgraphs of the control flow graph, and extracting the immediate value in each instruction;
[0021] Performing a hash operation on the immediate number to obtain a hash value corresponding to the immediate number;
[0022] Taking the first obtained hash value as the starting point, the hash values corresponding to all the obtained immediate numbers are superimposed and updated to obtain the hash value of the immediate number feature of the control flow graph.
[0023] Optionally, based on the obtained multiple groups of control flow subgraphs, calculating the hash value corresponding to the mnemonics and operands carried in each instruction included in the control flow graph includes:
[0024] Traversing the instructions contained in the multiple control flow subgraphs of the control flow graph, and extracting the mnemonics in each instruction;
[0025] Performing a hash operation on the mnemonic to obtain a hash value corresponding to the mnemonic;
[0026] Taking the first obtained hash value as a starting point, the hash values corresponding to all the obtained mnemonics are superimposed and updated to obtain the hash values of the mnemonics of the control flow graph.
[0027] Optionally, determining the similarity between the binary executable file to be analyzed and the sample file based on the hash value includes: performing weighted calculation on the hash value obtained by dimensionality reduction processing of the assembly function information to obtain a comprehensive hash value; storing the comprehensive hash value in a sample file feature library; and upon receiving a binary executable file similarity analysis instruction, determining the similarity between the binary executable file to be analyzed and the sample file based on the sample file feature library.
[0028] Optionally, the operand is an immediate number; the hash value corresponding to the edge feature, the hash value corresponding to the immediate number, or the hash value corresponding to the mnemonic is a pair of two hash values, one of which is a weighted hash value.
[0029] In a second aspect, an embodiment of the present invention further provides a binary executable file similarity analysis system, comprising an acquisition program unit for acquiring the assembly code of the binary executable file to be analyzed; a processing program unit for performing dimensionality reduction processing on the assembly function information carried by the assembly code to obtain a corresponding hash value; and a comparison program unit for determining the similarity between the binary executable file to be analyzed and a sample file according to the hash value.
[0030] In a third aspect, an embodiment of the present invention provides an electronic device, comprising: one or more processors; a memory; one or more executable programs are stored in the memory, and the one or more processors read the executable program code stored in the memory, and run a binary executable file similarity analysis system corresponding to the executable program code, so as to execute any binary executable file similarity analysis method described in the first aspect.
[0031] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement any binary executable file similarity analysis method described in the first aspect.
[0032] The binary executable file similarity analysis method, system, electronic device and storage medium provided by the embodiment of the present invention, after obtaining the assembly code of the binary executable file to be analyzed, performs dimensionality reduction processing on the assembly function information carried by the assembly code to obtain the corresponding hash value; and determines the similarity between the binary executable file to be analyzed and the sample file according to the hash value. In this way, by performing dimensionality reduction processing on the assembly function information such as operands and mnemonics in the assembly code, it is transformed into an integer of a fixed length, i.e., a hash value, which is used to represent the operands and mnemonics and other features of the function assembly code, and then directly compares the fixed-length integer with the sample file feature library, the similarity of the binary executable file can be quickly compared and determined. Compared with the existing binary executable file analysis method that directly uses the full amount of function assembly code information for storage and query, the analysis efficiency of binary executable files can be improved to a certain extent. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0034] Figure 1 A schematic diagram of a process for analyzing similarity of binary executable files according to an embodiment of the present invention;
[0035] Figure 2 It is a schematic flow chart of a method for similarity analysis of binary executable files according to another embodiment of the present invention;
[0036] Figure 3 This is a schematic flow chart of a method for similarity analysis of binary executable files according to yet another embodiment of the present invention;
[0037] Figure 4 This is a schematic block diagram of the architecture of a binary executable file similarity analysis system according to an embodiment of the present invention;
[0038] Figure 5 The present invention is a schematic block diagram of another embodiment of the electronic device of the present invention. DETAILED DESCRIPTION
[0039] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0040] It should be clear that the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0041] The binary executable file similarity analysis method provided by the embodiment of the present invention can be applied to network security analysis scenarios, such as malicious code source tracing analysis, binary executable file corresponding software dependency library analysis, etc. By performing dimensionality reduction processing on the assembly function information carried by the assembly code of the binary executable file to be analyzed, the corresponding hash value is obtained, and the similarity comparison of the binary executable files is performed based on the hash value, so that the similarity of the binary executable files can be quickly compared.
[0042] It should be noted that the method can be solidified in a certain manufactured physical product in the form of software, and when the user uses the product, the method flow of the present application can be reproduced.
[0043] Figure 1 FIG. 1 is a flow chart of a method for analyzing similarity of binary executable files according to an embodiment of the present invention; Figure 1 As shown, the similarity analysis method of the binary executable file to be analyzed may include the steps of:
[0044] S110: Obtain assembly code of the binary executable file to be analyzed.
[0045] In this embodiment, the assembly code may also be referred to as assembly instructions, which are coded instruction sequences used in assembly language to represent electronic computers, microprocessors, microcontrollers or other programmable devices in symbolic language. In the assembly code, mnemonics are generally used to replace the opcodes (Opcodes, used to instruct the machine what to do) of machine instructions, and address symbols (Symbols) or labels (Labels) are used to replace the addresses of instructions or operands.
[0046] Generally, machine instructions are presented in binary form, and the assembly code can be obtained by disassembling the binary machine instructions. After obtaining the assembly code, the assembly function information carried by the assembly code needs to be extracted.
[0047] S120: Perform dimensionality reduction processing on the assembly function information carried by the assembly code to obtain a corresponding hash value.
[0048] The assembly function information carried by the assembly code may include: a mnemonic (sometimes also called an operator) and an operand, where the operand is the object pointed to by the operator. For example, when the operator is used to instruct the machine to perform a comparison operation, the operand specifies two values for comparison.
[0049] Depending on the mnemonic, the specific content of the operand may be different. For example, when the operator is used to instruct the machine to perform an immediate addressing operation, the corresponding operand is an immediate number.
[0050] Operands can be constants, characters, strings, function calls, subscript expressions, member selectors, complex expressions and other function features.
[0051] The specific method of performing the dimensionality reduction process is to calculate the hash value corresponding to the assembly function information, wherein the hash operation can convert a data into a flag, and the flag has a very close relationship with each byte of the source data.
[0052] like Figure 2 and Figure 3 As shown, in some embodiments, the assembly function information includes: a mnemonic and an operand, and the assembly code includes a plurality of instructions;
[0053] The step of performing dimensionality reduction processing on the assembly function information carried by the assembly code to obtain a corresponding hash value (step S120) includes:
[0054] S112, taking the first instruction as the starting point, performing iterative operations in sequence according to the mnemonics and operands carried in the first instruction, and converting the assembly code into a control flow graph.
[0055] The control flow graph (CFG) includes: basic blocks and edge features; a control flow graph has an entry and an exit, wherein the first instruction can correspond to the entry of the control flow graph. After the entry of the control flow graph is specified, all basic blocks (also called nodes) and edge features representing the relationship between the basic blocks are automatically calculated in sequence and iteratively to construct a control flow graph.
[0056] In this embodiment, the basic blocks in the assembly code and the relationship between the basic blocks are continuously iteratively calculated, including the incoming edges and outgoing edges, to form a control flow graph.
[0057] When the operand is an immediate number, before executing step S112, the method further includes: optimizing the immediate number, specifically: converting the immediate number of a specific value into a type identifier of the immediate number;
[0058] For example, in an instruction mov rax,[0x100000], the program virtual address 0x100000 is a string "some strings", then the immediate value of the assembly code is optimized to mov rax,"some strings". In this way, compared with the previous immediate value of the specific value, the optimized immediate value is more characteristic and convenient for subsequent calculations.
[0059] In order to improve processing efficiency and eliminate interference, in some embodiments, after obtaining the assembly code, the method further includes: deleting or ignoring meaningless codes in the assembly code; for example, deleting codes in the code that are irrelevant to the assembly function information feature extraction, such as nop in x86 CPU, etc. In this way, data processing efficiency can be improved.
[0060] Step S114: Based on a depth-first traversal algorithm, all basic blocks in the control flow graph and all basic blocks within a predetermined node length from a corresponding basic block are calculated in sequence.
[0061] The predetermined node length is measured by the number of nodes. For example, if the predetermined node length is 3, it means the distance between 3 nodes.
[0062] The depth-first traversal algorithm is also called the depth-first search algorithm: an algorithm for traversing or searching a tree or graph; the algorithm searches the branches of the tree as deeply as possible.
[0063] Step S116, each basic block and all basic blocks within a predetermined node length from the basic block constitute a group of control flow subgraphs to obtain multiple groups of control flow subgraphs; the number of control flow subgraphs contained in each group of control flow subgraphs is the same as the predetermined node length;.
[0064] Exemplarily, the predetermined node length is 3 nodes; then, for the first basic block, the basic blocks that are 1, 2 and 3 nodes away from the first basic block and the relationship between them are calculated to obtain a first group of control flow subgraphs, which includes 3 control flow subgraphs; then, taking the second basic block as a reference point, repeatedly calculate the basic blocks that are 1, 2 and 3 nodes away from the second basic block and the relationship between them to obtain a second group of control flow subgraphs, which also includes 3 control flow subgraphs; repeat the above steps of calculating the first basic block to obtain the control flow subgraph, and so on, until all basic blocks in the control flow graph are iteratively calculated to obtain multiple groups of control flow subgraphs.
[0065] S118. Based on the obtained multiple groups of control flow subgraphs, calculate the hash values corresponding to the edge features of the control flow graph, and calculate the hash values corresponding to the mnemonics and operands carried in each instruction contained in the control flow graph.
[0066] In this embodiment, by converting the assembly code into a control flow graph and then calculating the hash value corresponding to the assembly function information, the dimension reduction processing of the function information feature is achieved, which is helpful to simplify the complexity of the comparison feature for the subsequent similarity comparison.
[0067] Among them, for the assembly code, the edge feature in the converted control flow graph is actually also a function feature in the assembly function information.
[0068] S130: Determine the similarity between the binary executable file to be analyzed and the sample file according to the hash value.
[0069] Specifically, determining the similarity between the binary executable file to be analyzed and the sample file according to the hash value (S130) can be performed by comparing the hash value with a sample file feature library to obtain the similarity between the binary executable file to be analyzed and the sample file.
[0070] It can be understood that, according to different application scenarios of the technical solution of the present invention, the results obtained from the similarity analysis of binary executable files can be applied to scenarios such as sandbox sample analysis, malware code analysis, and software dependency library analysis corresponding to binary executable files.
[0071] In this embodiment, there is no limitation on the specific application scenario, but no matter what scenario it is applied to, as long as the similarity analysis solution provided in the present invention is utilized, it is within the protection scope defined in this embodiment.
[0072] Exemplarily, when applied to sandbox sample analysis, a sample feature library corresponding to the application environment is pre-established based on automated analysis of the application environment. When automatically analyzing the sample, the above steps S110 to S130 are performed on the acquired binary executable file to quickly obtain a similarity result. Based on the similarity result, it is determined whether the sample is malicious code, thereby avoiding manual intervention to modify the sandbox environment and improving the efficiency and accuracy of automated analysis.
[0073] In some embodiments, in step S118, calculating the hash value corresponding to the edge feature of the control flow graph based on the obtained multiple groups of control flow subgraphs includes: performing topological sorting based on the edge features of each control flow subgraph; the edge features include: input edges, output edges and self-loops.
[0074] Among them, topological sorting means: a linear sorting of its vertices, so that for each directed edge uv from vertex u to vertex v, u is before v in the sorting.
[0075] According to the result of the topological sorting, a prime number is selected for hash calculation to obtain an identity document of each control flow subgraph; the identity document (ID) is used to uniquely identify the control flow subgraph to distinguish different control flow subgraphs;
[0076] For each subgraph, there may be three types of edges: incoming edges, outgoing edges, and self-loops. These three types of edges are topologically sorted separately, and finally a large prime number (for example, 3, 5, 7, etc.) is used to perform hash calculation on the result of the topological sorting to obtain a unique ID to distinguish different subgraphs.
[0077] For each control flow subgraph, calculate the hash value corresponding to the edge feature;
[0078] In some embodiments, for each subgraph, the hash value appears in pairs, and preferably two hash values are calculated, one is a weighted hash value with the number of occurrences of the subgraph, and the other is a hash value without the number of occurrences.
[0079] Taking one of the control flow subgraphs as the calculation starting point, all hash values are superimposed and updated to obtain the hash value of the edge feature of the control flow graph.
[0080] In this embodiment, by continuously superimposing and updating the hash values of the above control flow subgraphs, a hash value representing the edge features of the control flow graph is obtained, which facilitates improving the efficiency of similarity analysis of binary executable files compared to full information comparison.
[0081] Please see Figure 3 As shown, in some embodiments, the operand is an immediate number;
[0082] In step S118, the step of calculating the hash value corresponding to the mnemonics and operands carried in each instruction included in the control flow graph based on the multiple control flow subgraphs includes:
[0083] The instructions contained in the multiple control flow subgraphs of the control flow graph are traversed to extract the immediate values in each instruction; the immediate values are hashed to obtain the hash values corresponding to the immediate values; the hash values corresponding to all the immediate values are superimposed and updated with the first hash value obtained as the starting point to obtain the hash value of the immediate value feature of the control flow graph.
[0084] In this embodiment, by traversing the instructions of all control flow subgraphs in the control flow graph, the immediate number in each instruction is extracted, and its hash value is calculated to achieve dimensionality reduction processing of the immediate number feature.
[0085] After calculating the hash of an immediate number, the immediate number is continuously hashed and updated to obtain a hash value representing the immediate number characteristics of the control flow graph.
[0086] The hash values in this embodiment also appear in pairs, one is a weighted hash value carrying the number of occurrences of the control flow subgraph, and the other is an unweighted hash value.
[0087] Regarding the calculation of the hash value corresponding to the mnemonic, specifically, the calculation of the hash value corresponding to the mnemonic and the operand carried in each instruction contained in the control flow graph based on the obtained multiple groups of control flow subgraphs includes: traversing the instructions contained in the multiple control flow subgraphs of the control flow graph, extracting the mnemonics in each instruction; performing hash operations on the mnemonics to obtain the hash values corresponding to the mnemonics; taking the first hash value obtained as the starting point, superimposing and updating the hash values corresponding to all the mnemonics obtained, and obtaining the hash values corresponding to the mnemonics of the control flow graph. In this embodiment, by traversing all the instructions in the control flow graph, extracting the mnemonics in each instruction, the mnemonics obtained above are continuously hashed, and superimposed and updated to obtain a hash value representing the mnemonic features of the control flow graph, the dimensionality reduction processing of the mnemonics is realized, which is convenient for improving the efficiency of subsequent similarity matching.
[0088] The hash value corresponding to the mnemonic is also a pair of two hash values, one of which is a weighted hash value and the other is an unweighted hash value.
[0089] In some embodiments, determining the similarity between the binary executable file to be analyzed and the sample file according to the hash value includes: performing weighted calculation on the hash value obtained by dimensionality reduction processing of the assembly function information to obtain a comprehensive hash value; storing the comprehensive hash value in a sample file feature library;
[0090] In some embodiments, the comprehensive hash value is a 128-bit integer, which can represent the characteristics of the corresponding function assembly code, so that the similarity of binary executable files can be quickly compared directly through this 128-bit integer.
[0091] Specifically, when performing weighted calculation, the weight value of each assembly function information feature is first obtained. The weight value can be obtained through machine learning or manual tuning.
[0092] By default, the weight of the control flow graph feature is 1.0, the weight of the immediate feature is 3.0, and the weight of the operand feature is 2.0. The hash value of each assembly function information feature obtained in the above embodiment is used to calculate a new hash according to the weight, which is used as the final hash value feature for similarity comparison and stored in the sample file feature library.
[0093] When a binary executable file similarity analysis instruction is received, the similarity between the binary executable file to be analyzed and the sample file is determined based on the sample file feature library.
[0094] Specifically, the hash value features of a large number of sample files stored in the sample file feature library are compared and calculated with the hash value features of the binary file to be analyzed to obtain the similarity between the two, so as to perform further analysis based on the similarity results.
[0095] In an embodiment of the present invention, a hash value feature characterizing the full information of the assembly code is obtained by performing dimensionality reduction processing on the full assembly function information carried in the assembly code, and similarity comparison is performed based on the hash value feature. Compared with a one-by-one comparison based on the full assembly function information, the speed and accuracy of function similarity comparison can be significantly improved.
[0096] Compared with the traditional assembly code similarity analysis method based on the full assembly function information, the binary executable file similarity analysis method provided by the embodiment of the present invention obtains a hash value that can reflect the characteristics of the assembly code after dimensionality reduction processing of the assembly function information, and can still retain most of the characteristics of the function. Compared with the similarity calculation based on the full assembly function information, the obtained hash value is easier to store and index, which is beneficial to improving the similarity calculation efficiency and comparison analysis accuracy of binary executable files.
[0097] Embodiment 2
[0098] Figure 4 This is a schematic block diagram of the binary executable file similarity analysis system architecture according to an embodiment of the present invention. Figure 4 As shown, based on the same technical concept as the embodiments in the aforementioned embodiment one, a binary executable file similarity analysis system is also provided, including: an acquisition program unit 210, used to obtain the assembly code of the binary executable file to be analyzed; a processing program unit 220, which performs dimensionality reduction processing on the assembly function information carried by the assembly code to obtain a corresponding hash value; and a comparison program unit 230, which determines the similarity between the binary executable file to be analyzed and the sample file according to the hash value.
[0099] The system of this embodiment can be used to perform Figure 1The technical solution of the method embodiment shown has similar implementation principles and technical effects to those of the first embodiment, which will not be described in detail here and can be referenced by each other.
[0100] In addition, it is understandable that Figure 4 The system shown is also applicable to the execution step processes of other embodiments in Example 1. For details, please refer to the relevant description of Example 1, which will not be repeated here.
[0101] The binary executable file similarity analysis system provided by the embodiment of the present invention extracts assembly function information from the function assembly code, reduces the assembly function information to a power, obtains a reduced dimension result, and converts the assembly function information of a complex function assembly code into a hash value feature that is basically equivalent and easy to store and compare, thereby improving the efficiency of similarity analysis of binary executable files.
[0102] Embodiment 3
[0103] The present invention also provides an electronic device according to an embodiment, comprising: one or more processors; a memory; one or more executable programs are stored in the memory, and the one or more processors read the executable program code stored in the memory, and run the binary executable file similarity analysis program corresponding to the executable program code, so as to execute the binary executable file similarity analysis method described in any one of the first embodiments.
[0104] Figure 5 FIG. 1 is a schematic diagram of the structure of an embodiment of an electronic device of the present invention, which can implement any method described in Embodiment 1 of the present invention, such as Figure 5 As shown, as an optional embodiment, the above-mentioned electronic device may include: a shell 41, a processor 42, a memory 43, a circuit board 44 and a power supply circuit 45, wherein the circuit board 44 is arranged inside the space enclosed by the shell 41, and the processor 42 and the memory 43 are arranged on the circuit board 44; the power supply circuit 45 is used to supply power to various circuits or devices of the above-mentioned electronic device; the memory 43 is used to store executable program codes; the processor 42 runs the binary executable file analysis system corresponding to the executable program code by reading the executable program code stored in the memory 43, and is used to execute the aforementioned binary executable file similarity analysis method described in any of the first embodiments.
[0105] The specific execution process of the above steps by the processor 42 and the steps further executed by the processor 42 by running the executable program code can be found in the description of the first embodiment of the binary executable file similarity analysis method of the present invention, which will not be repeated here.
[0106] The electronic device exists in various forms, including but not limited to: (1) Mobile communication devices: This type of device is characterized by having mobile communication functions and its main goal is to provide voice and data communications. Such terminals include: smart phones, multimedia phones, functional phones, and low-end phones. (2) Ultra-mobile personal computer devices: This type of device belongs to the category of personal computers, has computing and processing functions, and generally also has mobile Internet access features. Such terminals include: PDA, MID and UMPC devices, such as iPad. (3) Portable entertainment devices: This type of device can display and play multimedia content. Such devices include: audio and video playback modules (such as iPod), handheld game consoles, e-books, as well as smart toys and portable car navigation devices. (4) Servers: Devices that provide computing services. The server's composition includes processors, hard disks, memory, system buses, etc. The server is similar to the general computer architecture, but because it needs to provide highly reliable services, it has higher requirements in terms of processing power, stability, reliability, security, scalability, manageability, etc. (5) Other electronic devices with data interaction functions.
[0107] The present invention also provides a computer-readable storage medium in an embodiment, wherein the computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the binary executable file similarity analysis method described in any one of the above-mentioned embodiments.
[0108] In summary, according to the description of the above embodiments, the binary executable file similarity analysis method disclosed in the embodiments of the present invention obtains a hash value that can reflect the characteristics of the assembly code after dimensionality reduction processing of the assembly function information, and can still retain most of the characteristics of the function. Compared with the similarity calculation of the full amount of assembly function information, the obtained hash value is easier to store and index, which is beneficial to improving the efficiency of binary executable file similarity calculation and the accuracy of comparison analysis.
[0109] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0110] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.
[0111] 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 also be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM).
[0112] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A binary executable file similarity analysis method, characterized in that: The method comprises the steps of: obtaining the assembly code of the binary executable file to be analyzed; Performing dimensionality reduction processing on the assembly function information carried by the assembly code to obtain a corresponding hash value; Determining the similarity between the binary executable file to be analyzed and the sample file according to the hash value; The assembly function information includes: a mnemonic and an operand, and the assembly code includes a plurality of instructions; The dimensionality reduction process is performed on the assembly function information carried by the assembly code to obtain the corresponding hash value, which includes: Taking the first instruction as the starting point, performing iterative operations in sequence according to the mnemonics and operands carried in the first instruction, and converting the assembly code into a control flow graph; the control flow graph includes: basic blocks and edge features; Based on a depth-first traversal algorithm, all basic blocks in the control flow graph and all basic blocks within a predetermined node length from a corresponding basic block are calculated in sequence; Each basic block and all basic blocks within a predetermined node length from the basic block form a group of control flow subgraphs to obtain multiple groups of control flow subgraphs; the number of control flow subgraphs contained in each group of control flow subgraphs is the same as the predetermined node length; Based on the obtained multiple groups of control flow subgraphs, calculate the hash values corresponding to the edge features of the control flow graph, and calculate the hash values corresponding to the mnemonics and operands carried in each instruction contained in the control flow graph; The operand is an immediate number; Based on the obtained multiple groups of control flow subgraphs, calculating the hash value corresponding to the mnemonics and operands carried in each instruction included in the control flow graph comprises: Traversing the instructions contained in the multiple control flow subgraphs of the control flow graph, and extracting the immediate value in each instruction; Performing a hash operation on the immediate number to obtain a hash value corresponding to the immediate number; Taking the first hash value obtained as the starting point, the hash values corresponding to all the obtained immediate numbers are superimposed and updated to obtain the hash value of the immediate number feature of the control flow graph; and, traversing the instructions contained in the plurality of control flow subgraphs of the control flow graph, and extracting the mnemonics in each instruction; Performing a hash operation on the mnemonic to obtain a hash value corresponding to the mnemonic; Taking the first obtained hash value as the starting point, the hash values corresponding to all the obtained mnemonics are superimposed and updated to obtain the hash values of the mnemonics of the control flow graph.
2. The method according to claim 1, characterized in that The step of calculating the hash value corresponding to the edge feature of the control flow graph based on the obtained multiple groups of control flow subgraphs includes: Topological sorting is performed based on the edge features of each control flow subgraph; the edge features include: incoming edges, outgoing edges, and self-loops; According to the result of the topological sorting, a prime number is selected for hash calculation to obtain an identity identification code for each control flow subgraph; the identity identification code is used to uniquely identify the control flow subgraph to distinguish different control flow subgraphs; For each control flow subgraph, calculate the hash value corresponding to the edge feature; Taking one of the control flow subgraphs as the calculation starting point, all hash values are superimposed and updated to obtain the hash value corresponding to the edge feature of the control flow graph.
3. The method according to claim 1, characterized in that Determining the similarity between the binary executable file to be analyzed and the sample file according to the hash value includes: Performing weighted calculation on the hash value obtained by the dimension reduction processing of the assembly function information to obtain a comprehensive hash value; Storing the comprehensive hash value in a sample file feature library; When a binary executable file similarity analysis instruction is received, the similarity between the binary executable file to be analyzed and the sample file is determined based on the sample file feature library.
4. The method according to claim 1, characterized in that: The operand is an immediate number; The hash value corresponding to the edge feature, the hash value corresponding to the immediate number, or the hash value corresponding to the mnemonic is a pair of two hash values, one of which is a weighted hash value.
5. A binary executable file similarity analysis system, characterized in that: include: Obtaining a program unit, used to obtain the assembly code of the binary executable file to be analyzed; A processing program unit performs dimensionality reduction processing on the assembly function information carried by the assembly code to obtain a corresponding hash value; A comparison program unit determines the similarity between the binary executable file to be analyzed and the sample file according to the hash value; The assembly function information includes: a mnemonic and an operand, and the assembly code includes a plurality of instructions; The processing program unit is specifically used for: Taking the first instruction as the starting point, performing iterative operations in sequence according to the mnemonics and operands carried in the first instruction, and converting the assembly code into a control flow graph; the control flow graph includes: basic blocks and edge features; Based on a depth-first traversal algorithm, all basic blocks in the control flow graph and all basic blocks within a predetermined node length from a corresponding basic block are calculated in sequence; Each basic block and all basic blocks within a predetermined node length from the basic block form a group of control flow subgraphs to obtain multiple groups of control flow subgraphs; the number of control flow subgraphs contained in each group of control flow subgraphs is the same as the predetermined node length; Based on the obtained multiple groups of control flow subgraphs, calculate the hash values corresponding to the edge features of the control flow graph, and calculate the hash values corresponding to the mnemonics and operands carried in each instruction contained in the control flow graph; The operand is an immediate number; Based on the obtained multiple groups of control flow subgraphs, calculating the hash value corresponding to the mnemonics and operands carried in each instruction included in the control flow graph comprises: Traversing the instructions contained in the multiple control flow subgraphs of the control flow graph, and extracting the immediate value in each instruction; Performing a hash operation on the immediate number to obtain a hash value corresponding to the immediate number; Taking the first hash value obtained as the starting point, the hash values corresponding to all the obtained immediate numbers are superimposed and updated to obtain the hash value of the immediate number feature of the control flow graph; and, traversing the instructions contained in the plurality of control flow subgraphs of the control flow graph, and extracting the mnemonics in each instruction; Performing a hash operation on the mnemonic to obtain a hash value corresponding to the mnemonic; Taking the first obtained hash value as the starting point, the hash values corresponding to all the obtained mnemonics are superimposed and updated to obtain the hash values of the mnemonics of the control flow graph.
6. An electronic device, characterized in that: include: One or more processors; Memory; One or more executable programs are stored in the memory, and the one or more processors read the executable program code stored in the memory and run the binary executable file similarity analysis system corresponding to the executable program code to execute the binary executable file similarity analysis method described in any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the binary executable file similarity analysis method described in any one of claims 1 to 4.
Citation Information
Patent Citations
Homologous binary code retrieval method and device
CN110414238A
Firmware homology detection method based on multi-dimensional features
CN112084146A
