Cross-architecture cryptographic algorithm identification method and system based on IR2Vec
Through the combination of IR2Vec word vector model and LLVM, the problem of low recognition rate of traditional cryptographic algorithm recognition methods in cross-architecture is solved, and efficient and accurate cryptographic algorithm recognition is achieved, which is suitable for the needs of the modern software industry.
Patent Information
- Application Number
- CN202111328689.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-10
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2041-11-10
AI Technical Summary
Traditional cryptographic algorithm recognition methods cannot effectively identify password algorithms that do not contain obvious keywords, cannot be recognized across architectures, has a low recognition rate, cannot accurately identify specific algorithm types, and cannot cope with confusion and optimization strategies.
Using a cross-architecture cryptographic algorithm recognition method based on IR2Vec, binary program files are converted into intermediate languages through LLVM, and vector representation is generated using the trained IR2Vec word vector model, and the similarity of vector representation is calculated to identify cryptographic algorithms, including sample data processing, Target data processing and similarity measurement module realizes the identification of cross-architecture cryptographic algorithms.
It improves the accuracy and effectiveness of password algorithm recognition, can identify password algorithms under different architectures, improves the recognition rate, and is suitable for the needs of the modern software industry.
Smart Images

Figure CN114254613B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of network security, and in particular relates to a cross-architecture cryptographic algorithm identification method and system based on IR2Vec. Background Art
[0002] Reverse analysis technology is a common technology used by malicious code writers. By reverse analyzing existing programs and mining the algorithm logic and key data contained in the programs, software piracy and even vulnerability-based hacker attacks can be effectively implemented. According to a software survey released by the Business Software Alliance (BSA) in 2018, up to 36% of installed software worldwide is not legally authorized, posing a great threat to the software industry and user information security. Encrypting information using cryptographic algorithms is a common technology for information protection. However, some hackers use encryption technology to encrypt malware, making it impossible for antivirus software or information security personnel to obtain their destructive information. After identifying the cryptographic algorithm used in the malware and then decrypting it, the work difficulty of information security personnel will be greatly reduced.
[0003] Traditional cryptographic algorithm recognition methods include keyword-based recognition (such as s-boxes), which is more effective for methods containing special characters, but cannot effectively identify cryptographic algorithms that do not contain obvious keywords; recognition methods based on control flow graphs and data flow graphs cannot cope with obfuscation and optimization strategies; for classified recognition of cryptographic algorithms, it can only confirm that a certain type of cryptographic algorithm is included, and cannot accurately identify the specific type of algorithm. Obviously, traditional cryptographic algorithm recognition methods can no longer meet the needs of normal information security personnel, and algorithm innovation is particularly important. For this reason, an efficient and accurate cryptographic algorithm recognition method is urgently needed, which is the primary problem to be solved at present. Summary of the invention
[0004] To this end, the present invention provides a cross-architecture cryptographic algorithm recognition method and system based on IR2Vec to solve the problems that traditional cryptographic algorithms cannot be recognized across architectures and have low recognition rates.
[0005] According to the design scheme provided by the present invention, a cross-architecture cryptographic algorithm identification method based on IR2Vec is provided, which includes the following contents:
[0006] Collect binary program files generated by known cryptographic algorithms under different architectures and / or using different compilation options, use the collected binary program files as a data set, use LLVM to convert the binary program files in the data set into an intermediate language, and use the trained IR2Vec word vector model to generate the corresponding standard vector representation of the data set by learning contextual semantics;
[0007] Use LLVM to convert the target binary program file into an intermediate language, and use the trained IR2Vec word vector model to generate a vector representation of the target binary program file by learning contextual semantics;
[0008] The target binary program file cryptographic algorithm is identified based on the similarity between the vector representation of the target binary program file and the standard vector representation.
[0009] As a cross-architecture cryptographic algorithm identification method based on IR2Vec of the present invention, further, the known cryptographic algorithms at least include: cryptographic algorithms in crypto++ and openssl cryptographic algorithm libraries, and known custom cryptographic algorithms.
[0010] As a cross-architecture cryptographic algorithm recognition method based on IR2Vec of the present invention, further, in the process of converting the binary program file into an intermediate language using LLVM, an intermediate language file containing only the function body of the entry function is generated by decompilation.
[0011] As a cross-architecture cryptographic algorithm identification method based on IR2Vec of the present invention, further, when generating an intermediate language file, by finding the function entry, traversing inside the function, inlining the external function to the function call, and storing it according to the function body.
[0012] As a cross-architecture cryptographic algorithm recognition method based on IR2Vec of the present invention, further, LLVM is used to convert it into an intermediate language. First, the intermediate language is normalized to generate a unified IR2Vec word vector model input.
[0013] As a cross-architecture cryptographic algorithm recognition method based on IR2Vec of the present invention, further, the IR2Vec word vector model is constructed based on the skip-gram model of word2vec. The IR2Vec word vector model maps sentences in the intermediate language to the vector space, and predicts the semantics of the context of the central sentence by moving the sliding window and utilizing the semantics of the central sentence of the sliding window.
[0014] As a cross-architecture cryptographic algorithm identification method based on IR2Vec of the present invention, the cosine distance is further used to calculate the similarity value between vector representations, and the similarity between the target file cryptographic algorithm and the known cryptographic algorithm is measured according to the size of the similarity value.
[0015] Furthermore, the present invention also provides a cross-architecture cryptographic algorithm recognition system based on IR2Vec, comprising: a sample data processing module, a target data processing module and a similarity measurement module, wherein:
[0016] The sample data processing module is used to collect binary program files generated by known cryptographic algorithms under different architectures and / or using different compilation options, use the collected binary program files as data sets, use LLVM to convert the binary program files in the data sets into intermediate languages, and use the trained IR2Vec word vector model to generate the corresponding standard vector representation of the data set by learning context semantics;
[0017] The target data processing module converts the target binary program file into an intermediate language using LLVM, and generates a vector representation of the target binary program file by learning contextual semantics through the trained IR2Vec word vector model;
[0018] The similarity measurement module identifies the target binary program file cryptographic algorithm based on the similarity between the vector representation of the target binary program file and the standard vector representation.
[0019] Beneficial effects of the present invention:
[0020] Based on the traditional natural language similarity recognition algorithm, the present invention uses a unified intermediate code in different front-end and back-end of the LLVM architecture to convert binary files under different architectures into LL files and perform similarity recognition, thereby realizing cross-architecture cryptographic algorithm similarity recognition. While ensuring the cryptographic algorithm recognition rate, the cryptographic algorithm recognition effect is improved, and it has good application prospects. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 This is a schematic diagram of the cross-architecture cryptographic algorithm identification method process based on IR2Vec in the embodiment;
[0022] Figure 2 This is a block diagram showing the principle of cryptographic algorithm identification in the embodiment;
[0023] Figure 3 This is a schematic diagram of the LL intermediate language file normalization process in the embodiment;
[0024] Figure 4 This is a schematic diagram of data conversion within the IR2Vec model in the embodiment;
[0025] Figure 5 It is an illustration of the principle of the IR2VEC model in the embodiment. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solutions and advantages of the present invention clearer and more understandable, the present invention is further described in detail below in conjunction with the accompanying drawings and technical solutions.
[0027] Traditional static cryptographic algorithm identification methods mainly use static constants, signatures, and simple control flow graphs and data flow graphs to identify cryptographic algorithms. This method can only identify codes with low obfuscation and optimization levels, and it is difficult to identify cryptographic algorithms with high obfuscation levels. In addition, it is unable to identify programs under different architectures, which does not meet the needs of the development of the software industry. This embodiment of the present invention provides a cross-architecture cryptographic algorithm identification method based on IR2Vec, see Figure 1 As shown, it contains the following contents:
[0028] S101, collecting binary program files generated by known cryptographic algorithms under different architectures and / or using different compilation options, using the collected binary program files as a data set, using LLVM to convert the binary program files in the data set into an intermediate language, and using the trained IR2Vec word vector model to generate a standard vector representation corresponding to the data set by learning context semantics;
[0029] S102, using LLVM to convert the target binary program file into an intermediate language, and using the trained IR2Vec word vector model to generate a vector representation of the target binary program file by learning context semantics;
[0030] S103, identifying the target binary program file cryptographic algorithm based on the similarity between the vector representation of the target binary program file and the standard vector representation.
[0031] In order to identify cryptographic algorithms in binary programs under different architectures, different compilers, and different optimization schemes, the binary languages of different architectures are converted into intermediate languages using LLVM, and their semantic relationships are learned through IR2Vec to generate different vectors. The vectors of each possible cryptographic algorithm are calculated to determine whether they are of the same type, so as to solve the problem that traditional cryptographic recognition cannot identify cryptographic algorithms under cross-architectures.
[0032] As a cross-architecture cryptographic algorithm identification method based on IR2Vec in an embodiment of the present invention, further, the known cryptographic algorithms at least include: cryptographic algorithms in crypto++ and openssl cryptographic algorithm libraries, and known custom cryptographic algorithms. Further, in the process of converting the binary program file into an intermediate language using LLVM, an intermediate language file containing only the function body of the entry function is generated by decompiling. Further, when generating the intermediate language file, by finding the function entry, traversing inside the function, inlining the external function to the function call, and storing it according to the function body.
[0033] The crypto++ and openssl cryptographic algorithm libraries and other custom cryptographic algorithms are used in different architectures with different compilation options to generate binary files, which are used as data sets and then converted into a normalized intermediate language. Figure 2 As shown in the figure, the binary file is decompiled into LL intermediate language through LLVM-Retdec. The intermediate language formats converted under different architectures are slightly different, so it needs to be normalized to facilitate input into the IR2Vec model. The normalization of LL files under the three architectures of X86, MIPS, and Arm in the figure can be referred to Figure 3 As shown. The LL file decompiled under the MIPS architecture is a streamlined instruction with fewer function bodies and no global variables. The entire file is traversed to find the main function entry. If there is an external function call, the external function is inlined to the function call. The function body in the LL file decompiled under the Arm architecture is most similar to the source code, with strong readability, and basically corresponds to the function body in the source code. The entire file is traversed, the file is divided according to the define string, stored according to the function body, the main function entry is found, and the main function is entered for traversal. At the external function call, the corresponding function body is found according to the function name, and the corresponding function body is inlined to the function call. The LL file decompiled under the X86 architecture has poor readability and many function calls, which is not conducive to the later semantic recognition. Traverse the entire file; the file is divided according to the define string, stored according to the function body, the entry_point function entry is found, and the entry_point function is traversed. At the external function call, the corresponding function body is found according to the function name, and the corresponding function body is inlined to the function call. Finally, the LL files generated by decompilation of MIPS, Arm and x86 architectures are normalized into one LL file that only contains the function body of the entry function.
[0034] By using the low-level virtual machine LLVM to convert binary programs under different architectures into a unified intermediate language, the problem that programs under different architectures cannot recognize each other is solved; by using semantic relationship learning to replace the simple judgment of data flow and control flow in traditional recognition methods, it is possible to identify deep semantic relationships in the program and improve its recognition accuracy. In traditional cryptographic algorithm recognition, the recognition rate of cryptographic algorithms implemented by calling multiple functions is low. In this case, starting from the working mechanism of intermediate language and semantic learning, based on the function inlining of intermediate language, the problem can be well solved through function inlining at the intermediate language level.
[0035] As a cross-architecture cryptographic algorithm recognition method based on IR2Vec in an embodiment of the present invention, further, LLVM is used to convert it into an intermediate language. First, the intermediate language is normalized to generate a unified IR2Vec word vector model input.
[0036] By using the normalization of the intermediate language and the classification mechanism of the cryptographic algorithm semantic vector, the functions with similar functions but inconsistent expressions under different architectures are normalized so that the languages of each architecture can understand each other. The normalized language is semantically learned under IR2Vec to achieve program understanding of binary programs under different architectures. This helps reverse analysis and protects computer security. Binary programs under different architectures are converted into intermediate languages. At this level, the programs are inlined and normalized. The normalized intermediate language is input into IR2Vec to be converted into the corresponding vector for semantic learning. The distance between the semantic vector and the known cryptographic algorithm vector is calculated to achieve classification and identification of cryptographic algorithms.
[0037] As a cross-architecture cryptographic algorithm recognition method based on IR2Vec in an embodiment of the present invention, further, an IR2Vec word vector model is constructed based on the skip-gram model of word2vec, and the IR2Vec word vector model maps sentences in the intermediate language to the vector space, and by moving the sliding window, the semantics of the central sentence of the sliding window is used to predict the semantics of the context of the central sentence. Further, the cosine distance is used to calculate the similarity between the vector representations, and the similarity between the target file cryptographic algorithm and the known cryptographic algorithm is measured according to the size of the similarity value.
[0038] After pre-training, a matrix containing each word of the intermediate language is generated in the hidden layer. Each value of the matrix can represent the meaning of each feature. The operator or operand of each instruction input in the data set is converted into a vector. If there are multiple operands, the vectors are summed and averaged, and then concatenated with the operator vector; the concatenated vector is stored as the vector of the entire instruction, and then the next instruction is predicted through the trained hidden matrix and activation function. See Figure 4 and 5 As shown in Figure 1, at the intermediate language level, the program predicts the semantics of the context of the central sentence based on the semantics of the central sentence in the window by moving the sliding window. The sentences in the LL file are mapped to the vector space, and the context semantics of the central sentence is calculated based on the central word and the hidden layer matrix. On this basis, the vector values of the two files to be compared are [A 1 ,A 2 ,A 3 ,....A n ],[B 1 ,B 2 ,B 3 ,...,B n ], through the cosine distance formula Calculate and get the similarity value. The smaller the angle between the vector values, the larger the cosine value, which proves that the similarity is greater.
[0039] Furthermore, based on the above method, an embodiment of the present invention also provides a cross-architecture cryptographic algorithm recognition system based on IR2Vec, comprising: a sample data processing module, a target data processing module and a similarity measurement module, wherein:
[0040] The sample data processing module is used to collect binary program files generated by known cryptographic algorithms under different architectures and / or using different compilation options, use the collected binary program files as data sets, use LLVM to convert the binary program files in the data sets into intermediate languages, and use the trained IR2Vec word vector model to generate the corresponding standard vector representation of the data set by learning context semantics;
[0041] The target data processing module converts the target binary program file into an intermediate language using LLVM, and generates a vector representation of the target binary program file by learning contextual semantics through the trained IR2Vec word vector model;
[0042] The similarity measurement module identifies the target binary program file cryptographic algorithm based on the similarity between the vector representation of the target binary program file and the standard vector representation.
[0043] Based on the traditional natural language similarity recognition algorithm, this solution uses a unified intermediate code with different front-end and back-end of the LLVM architecture to convert binary files under different architectures into LL files for similarity recognition, thereby achieving the effect of cross-architecture cryptographic algorithm recognition. The modules can also be integrated and unsupervised learning methods can be used to realize the classification and recognition of cryptographic algorithms, which is convenient for application in actual scenarios.
[0044] Unless otherwise specifically stated, the relative steps, numerical expressions and values of the components and steps set forth in these embodiments do not limit the scope of the present invention.
[0045] Based on the above system, an embodiment of the present invention further provides a server, comprising: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement the above method.
[0046] Based on the above system, an embodiment of the present invention further provides a computer-readable medium on which a computer program is stored, wherein the program implements the above method when executed by a processor.
[0047] The device provided in the embodiment of the present invention has the same implementation principle and technical effects as those of the aforementioned system embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding contents in the aforementioned system embodiment.
[0048] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described system and device can refer to the corresponding process in the aforementioned system embodiment, and will not be repeated here.
[0049] In all examples shown and described herein, any specific values should be interpreted as merely exemplary and not as limiting, and thus other examples of the exemplary embodiments may have different values.
[0050] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0051] The flow charts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the systems, systems and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0052] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and systems can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.
[0053] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0054] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the system described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0055] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and 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 cross-architecture cryptographic algorithm identification method based on IR2Vec, characterized in that: Contains the following: Collect binary program files generated by known cryptographic algorithms under different architectures and / or using different compilation options, use the collected binary program files as a data set, use LLVM to convert the binary program files in the data set into an intermediate language, and use the trained IR2Vec word vector model to generate the corresponding standard vector representation of the data set by learning contextual semantics; The target binary program file is converted into an intermediate language using LLVM, and the vector representation of the target binary program file is generated by learning context semantics through the trained IR2Vec word vector model; wherein, the target binary program file is converted into an intermediate language using LLVM, and the function entry is found, the internal function is traversed, the external function is inlined and extended to the function call, and the function body is stored, and the intermediate language file containing only the function body of the entry function is generated by decompilation; the IR2Vec word vector model is built based on the skip-gram model of word2vec, and the IR2Vec word vector model maps the sentences in the intermediate language to the vector space, and by moving the sliding window, the semantics of the central sentence of the sliding window is used to predict the semantics of the context of the central sentence; The target binary program file cryptographic algorithm is identified based on the similarity between the vector representation of the target binary program file and the standard vector representation.
2. The cross-architecture cryptographic algorithm identification method based on IR2Vec according to claim 1, characterized in that: The known cryptographic algorithms include at least: cryptographic algorithms in the crypto++ and openssl cryptographic algorithm libraries, and known custom cryptographic algorithms.
3. The cross-architecture cryptographic algorithm identification method based on IR2Vec according to claim 1, characterized in that: Use LLVM to convert it into an intermediate language. First, normalize the intermediate language to generate a unified IR2Vec word vector model input.
4. The cross-architecture cryptographic algorithm identification method based on IR2Vec according to claim 1, characterized in that: The cosine distance is used to calculate the similarity between vector representations, and the similarity between the target file cryptographic algorithm and the known cryptographic algorithm is measured based on the size of the similarity value.
5. A cross-architecture cryptographic algorithm recognition system based on IR2Vec, characterized in that: It includes: sample data processing module, target data processing module and similarity measurement module, among which, The sample data processing module is used to collect binary program files generated by known cryptographic algorithms under different architectures and / or using different compilation options, use the collected binary program files as data sets, use LLVM to convert the binary program files in the data sets into intermediate languages, and use the trained IR2Vec word vector model to generate the corresponding standard vector representation of the data set by learning context semantics; The target data processing module uses LLVM to convert the target binary program file into an intermediate language, and generates a vector representation of the target binary program file by learning context semantics through the trained IR2Vec word vector model; wherein, the target binary program file is converted into an intermediate language by using LLVM, and the function entry is found, the internal function is traversed, the external function is inlined and extended to the function call, and the function body is stored, and an intermediate language file containing only the function body of the entry function is generated by decompilation; the IR2Vec word vector model is built based on the skip-gram model of word2vec, and the IR2Vec word vector model maps the sentences in the intermediate language to the vector space, and by moving the sliding window, the semantics of the central sentence of the sliding window is used to predict the semantics of the context of the central sentence; The similarity measurement module identifies the target binary program file cryptographic algorithm based on the similarity between the vector representation of the target binary program file and the standard vector representation.
6. A server, comprising: one or more processors; A storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors execute the method according to any one of claims 1 to 4.
7. A computer-readable medium storing a computer program executed by a processor, wherein the computer program is used to execute the method according to any one of claims 1 to 4.
