A binary software component composition detection method, system and storage medium
By combining preset string comparison and feature extraction data, the problem of fast detection speed but narrow coverage in existing binary software component analysis technology is solved, achieving higher analysis accuracy and applicability, and is suitable for symbolic features. Scarcity, rare calling relationships.
Patent Information
- Application Number
- CN202411051563.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-01
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2044-08-01
AI Technical Summary
Existing binary software component analysis technology has problems such as symbol erasure, string confusion and encryption, resulting in fast detection speed but narrow technical coverage, high false alarm rate, and can only target function or symbol feature information, lacking diversity and accuracy. .
Obtain initial candidate software through preset string comparison processing, judge extreme similarity based on tag type and number of tags, generate software output signals, and then improve analysis accuracy and applicability through multiple preset string comparisons, combined with feature extraction data Complementary analysis is performed with the function call diagram.
It improves the accuracy and coverage of binary software component analysis, has a wider application, can maintain high accuracy when symbol features are sparse, and call relationships are sparse, and provides more accurate and comprehensive analysis results.
Smart Images

Figure CN118568005B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of network security testing, and in particular to a binary software component composition detection method, system and storage medium. Background Art
[0002] In software development activities, development methods based on open source components may bring various risks such as license infringement and introduction of external vulnerabilities. The currently widely used binary-level software component analysis technology uses feature information such as function symbols, import and export symbols, strings, constants, and direct numbers within the binary or function to match features between files, thereby analyzing similar binary files. This method is simple and direct, but binary software can perform symbol erasure, string obfuscation and encryption during compilation, or even the software does not contain enough rich symbol feature information. Or the binary file only contains specific strings but no actual code, resulting in false positives. This coarse-grained method has fast detection speed, technical limitations, and narrow technical coverage.
[0003] The above-mentioned similar detection technologies either identify components from the perspective of binary file-level features or from the perspective of binary function-level features, and have different advantages and disadvantages in different scenarios. However, these two types of binary analysis methods have little effect when used independently in software component analysis. Summary of the invention
[0004] In order to improve the analysis of binary software components and improve the applicability of software analysis, the present application provides a binary software component composition detection method, system and storage medium.
[0005] In a first aspect, the present application provides a binary software component composition detection method, which adopts the following technical solution:
[0006] A binary software component composition detection method comprises the following steps:
[0007] Obtaining a file to be detected, and subjecting the file to be detected to a preset character string comparison process to obtain a plurality of groups of initial candidate software;
[0008] Acquire a corresponding label type according to the initial candidate software, and acquire a label marking count corresponding to the initial candidate software according to the label type;
[0009] Compare the number of times the label is marked with a preset number to obtain a marking result corresponding to the initial candidate software, and determine whether the marking result is extremely similar;
[0010] If the marking result is extremely similar, a software output signal is generated, and the initial candidate software with the marking result being extremely similar is output according to the software output signal.
[0011] By adopting the above technical scheme, the file to be processed is processed through a preset character string to obtain several groups of initial candidate software, the corresponding label type is obtained according to the initial candidate software, and the label marking times corresponding to the initial candidate software are obtained according to the label type; the label marking times are compared with the preset times to obtain the marking results corresponding to the initial candidate software, and it is determined whether the marking results are extremely similar; if the marking results are extremely similar, a software output signal is generated, and the initial candidate software with extremely similar marking results is output according to the software output signal. By making the marking results extremely similar, extremely similar marking results are obtained by comparing different preset character strings, thereby improving the analysis of binary software components and improving the applicability of software analysis.
[0012] In one embodiment, the preset character string is stored in a preset regular version database, and the process of subjecting the to-be-detected file to the preset character string comparison process to obtain a plurality of groups of initial candidate software includes the following steps:
[0013] Acquire several groups of temporary candidate software according to the to-be-detected file, and acquire feature extraction data based on binary feature extraction according to the temporary candidate software, wherein the feature extraction data includes character string data;
[0014] Traversing the data to be compared corresponding to the string data in sequence, and matching the data to be compared in a preset regular version database;
[0015] If there is a matching result in the preset official version database, the data to be compared corresponding to the temporary candidate software is marked to obtain the initial candidate software.
[0016] In one embodiment, the preset character string is stored in a preset vector database, and the process of subjecting the to-be-detected file to the preset character string comparison to obtain a plurality of groups of initial candidate software includes the following steps:
[0017] Acquire several groups of functions to be tested according to the files to be tested, and input the functions to be tested into a preset model to obtain similarity values corresponding to the functions to be tested;
[0018] Sort the functions to be tested according to the similarity values, and obtain the number of occurrences of the functions to be tested in the comparison results;
[0019] Initial candidate software is screened according to the number of occurrences and preset marking rules.
[0020] In one embodiment, the preset string is stored in a preset string index database, and the process of subjecting the to-be-detected file to the preset string comparison process to obtain a plurality of groups of initial candidate software includes the following steps:
[0021] Acquire several groups of temporary candidate software according to the file to be detected, and search the character string data corresponding to the temporary candidate software in the preset character string index database to obtain character string results;
[0022] The temporary candidate software are sorted according to the character string results, and a specified number of the sorted temporary candidate software are used as the initial candidate software.
[0023] In one embodiment, the label type includes a first label, the feature extraction data also includes a function call relationship graph, and before determining whether the labeling result is extremely similar, the following steps are also included:
[0024] Acquire several groups of candidate software according to the file to be detected, and determine whether the label type corresponding to the candidate software is the first label;
[0025] If the tag type corresponding to the candidate software is the first tag, traversing the candidate software based on the function call relationship graph to obtain an associated function pair corresponding to the candidate software;
[0026] Acquire a valid function pair based on the candidate software and the associated function pair, and compare the valid function pair with a preset matching number;
[0027] If the valid function pairs exceed the preset matching number, the marking result of the candidate software is marked as extremely similar.
[0028] By adopting the above technical solution, the candidate software can be maximized. It is also necessary to further process the highly similar and generally similar initial candidate software to improve the screening accuracy of the initial candidate software. It is necessary to continue marking the initial candidate software with different labels to improve the accuracy of the obtained initial candidate software.
[0029] In one embodiment, traversing the candidate software based on the function call relationship graph to obtain associated function pairs corresponding to the candidate software includes the following steps:
[0030] Determine whether the label type corresponding to the initial candidate software is the first label;
[0031] If the label type corresponding to the initial candidate software is the first label, obtaining the function to be tested corresponding to the candidate software based on the Hungarian algorithm;
[0032] According to the vector value corresponding to the function to be tested, the candidate software corresponding to the maximum value is screened out from the vector value as the associated function pair.
[0033] In one embodiment, after determining whether the tag type corresponding to the initial candidate software is the first tag, the following steps are further included:
[0034] If the label type corresponding to the initial candidate software is not the first label, vector calculation is performed on the function to be tested and the candidate software function in sequence to obtain a vector calculation value;
[0035] The function to be tested corresponding to the largest vector calculation value is used as an associated function pair corresponding to the candidate software function, and the candidate software corresponding to the candidate software function is marked as a first label.
[0036] In one embodiment, the feature extraction data further includes binary import and export symbols, and the label type includes a second label and a third label, comprising the following steps:
[0037] Acquire several groups of temporary candidate software according to the to-be-detected file, and determine whether the label type corresponding to the candidate software is the second label and the third label;
[0038] If the label type corresponding to the candidate software is not the second label or the third label, obtaining the corresponding binary import and export symbol according to the function to be tested;
[0039] Obtaining the number of identical symbols according to the function to be tested and the temporary candidate software, and determining whether the number of identical symbols is less than a preset symbol;
[0040] If the number of identical symbols is not less than the preset number of symbols, the temporary candidate software is used as the candidate software.
[0041] In a second aspect, the present application provides a binary software component composition detection system, which adopts the following technical solution:
[0042] A binary software component composition detection system, comprising:
[0043] A file acquisition module, the file acquisition module is used to acquire the file to be detected, and perform a preset character string comparison process on the file to be detected to obtain several groups of initial candidate software;
[0044] A label marking module, the label marking module is used to obtain a corresponding label type according to the initial candidate software, and obtain a label marking number corresponding to the initial candidate software according to the label type;
[0045] A data comparison module, the data comparison module is used to compare the label marking times with a preset times to obtain the marking results corresponding to the initial candidate software, and determine whether the marking results are extremely similar;
[0046] The result processing module is used to generate a software output signal if the marking result is extremely similar, and output the initial candidate software whose marking result is extremely similar according to the software output signal.
[0047] By adopting the above technical solution and using multiple features of binary files, it still has a high accuracy rate when facing sparse symbol features, sparse call relationships and sparse similar functions. The software component analysis of binary files has a wider range of applications and a higher coverage rate. Candidate software is obtained through multiple methods, which solves the problem that the existing technology only analyzes binary components for functions and symbol feature information. During the analysis, multiple methods are used to complement each other, making the analysis results more accurate and comprehensive.
[0048] In a third aspect, the present application provides a storage medium, which adopts the following technical solution:
[0049] A storage medium storing at least one instruction, at least one program, a code set or an instruction set, wherein the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by a processor to implement the binary software component composition detection method as described in the first aspect.
[0050] In summary, the present application includes at least one of the following beneficial technical effects:
[0051] 1. Process the file to be processed through a preset character string to obtain several groups of initial candidate software, obtain the corresponding label type according to the initial candidate software, and obtain the label marking times corresponding to the initial candidate software according to the label type; compare the label marking times with the preset times to obtain the marking results corresponding to the initial candidate software, and judge whether the marking results are extremely similar; if the marking results are extremely similar, generate a software output signal, and output the initial candidate software with extremely similar marking results according to the software output signal, and obtain extremely similar marking results by comparing different preset character strings through the extremely similar marking results, so as to improve the analysis of binary software components and improve the applicability of software analysis;
[0052] 2. In order to maximize the number of candidate software, it is necessary to further process the highly similar and generally similar initial candidate software to improve the screening accuracy of the initial candidate software. It is necessary to continue to mark the initial candidate software with different labels to improve the accuracy of the initial candidate software obtained;
[0053] 3. This system uses multiple features of binary files, and still has a high accuracy rate when facing sparse symbol features, sparse call relationships, and sparse similar functions. The software component analysis of binary files has a wider range of applications and a higher coverage rate. It obtains candidate software through multiple methods, which solves the problem that the existing technology only analyzes binary components for functions and symbol feature information. It complements each other in multiple ways during analysis, making the analysis results more accurate and comprehensive. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 It is a block diagram of a binary software component composition detection method provided in an embodiment of the present application;
[0055] Figure 2 It is a block diagram of a method for obtaining initial candidate software provided in an embodiment of the present application;
[0056] Figure 3 It is a block diagram of another method for detecting binary software component composition provided by an embodiment of the present application;
[0057] Figure 4 It is a schematic diagram of the calling relationship between a group of functions to be tested and candidate functions provided in an embodiment of the present application;
[0058] Figure 5 is a schematic diagram of the calling relationship between another set of functions to be tested and candidate functions provided in an embodiment of the present application;
[0059] Figure 6 It is a calculation diagram of the effective function pair provided in the embodiment of the present application. DETAILED DESCRIPTION
[0060] To more clearly understand the purpose, technical solutions and advantages of the present application, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments. However, it should be understood by those of ordinary skill in the art that the present application can be implemented without these details. In some cases, in order to avoid unnecessary descriptions that make various aspects of the present application obscure, well-known methods, processes, systems, components and / or circuits that have been described at a higher level will not be described in detail. For those of ordinary skill in the art, it is obvious that various changes can be made to the embodiments disclosed in the present application, and without departing from the principles and scope of the present application, the general principles defined in the present application can be applied to other embodiments and application scenarios. Therefore, the present application is not limited to the embodiments shown, but conforms to the broadest scope consistent with the scope claimed for protection of the present application.
[0061] The embodiment of the present application discloses a binary software component composition detection method, which is applied to a binary software component composition detection system. The system includes a feature extraction module, an AI model training module, and a database establishment module. The feature extraction module is used to extract features of files that need to be detected. The specific extracted features include binary intra-function symbols, binary import and export symbols, binary ASCII strings, binary function call relationship diagrams, basic block instruction features within functions, basic block relationship flow diagrams within functions, strings within functions, constants within functions, and direct numbers within functions.
[0062] It should be noted here that the AI model training module specifically compiles the function source code of the file to be detected using different compilation parameters on different platforms. The function source code consists of multiple functions from different open source projects. Different platforms include: operating systems, including but not limited to Linux, Windows, Darwin, processor architectures including but not limited to X86, ARM, MIPS, Loongarch, Sunway, S390X, PowerPC, Sparc, RISC-V, and any combination of an operating system and any processor is a platform. Different compilation parameters include: compilers including but not limited to GCC, Clang, VisualStudio, TCC, compilation optimization parameters including but not limited to O0, O1, O2, O3, and security compilation options including but not limited to stack protection, GOT table protection, randomization, Fortify Source. Any compiler, any compilation optimization parameter, and any combination of security compilation options is a compilation parameter.
[0063] Exemplarily, assuming that the number of function source codes is X, the number of platforms is Y, and the number of compilation parameters is Z, the X function source codes are compiled through Y platforms and Z compilation parameters, and finally N=X*Y*Z binary functions are obtained, also known as N different conditions of the function. Extract the basic block instruction features, basic block relationship flow chart, string, constant and direct number features of each binary function, and vectorize the above features to obtain the vector features of each function. Establish a neural network model, which uses the function name as a label for unattended training. The model capability is: embed any two function vector features from different conditions, calculate the COSINE distance of the two embedded vectors, and obtain the similarity. If the similarity is greater than 0.5, the two function vectors are considered to be similar, and the closer to 1, the higher the similarity. Finally, an AI model that can judge the similarity of two functions is obtained. The database establishment module can mainly establish multiple databases, including a regular version database, a function vector database and a string inverted index database.
[0064] In addition, the binary software component composition detection system also includes a processor, which obtains the corresponding data obtained by the above-mentioned modules to perform binary analysis on the file to be detected, thereby obtaining the component result of the file to be detected.
[0065] like Figure 1 As shown, a binary software component composition detection method includes the following steps:
[0066] S100, obtaining a file to be detected, and subjecting the file to be detected to a preset character string comparison process to obtain a plurality of groups of initial candidate software.
[0067] Among them, the file to be detected represents a file that needs to be analyzed for software components. The processor obtains the file to be detected and processes the file to be detected through a preset string comparison to obtain initial candidate software. The preset string comparison here is to compare the program code of the file to be detected to obtain initial candidate software with different labels.
[0068] It should be noted here that the preset string comparison specifically compares the file to be detected with the files in the preset database, and the preset database stores binary data of various characteristics, thereby facilitating the comparison of the file to be detected.
[0069] S200, obtaining a corresponding label type according to the initial candidate software, and obtaining a label marking count corresponding to the initial candidate software according to the label type.
[0070] The label type represents the type of label obtained by the initial candidate software after the preset string comparison. The label type includes the first label, the second label and the third label, which represent the labels formed under different preset string comparisons. In this embodiment, the first label is set as the REGEX label, the second label is set as the VECTOR label, and the third label is set as the INDEX label. The label marking times represent the total number of labels currently corresponding to the initial candidate software.
[0071] Exemplarily, assuming that the initial candidate software A has the first label and the second label, the number of label markings corresponding to the initial candidate software A is 2. assuming that the initial candidate software B has the first label, the second label and the third label, the number of label markings corresponding to the initial candidate software B is 3.
[0072] S300, comparing the number of times of label marking with a preset number to obtain the marking result corresponding to the initial candidate software, and determining whether the marking result is extremely similar.
[0073] The preset number of times represents the number of times set in advance. In this embodiment, the preset number of times is set to 3 times. The marking result represents the detection result obtained after comparing the number of times of label marking of the initial candidate software. The marking results include extremely similar, highly similar and generally similar. Specifically, it is the similarity between the initial candidate software and the existing software.
[0074] The specific judgment method of the labeling result is that the initial candidate software with three labels is marked as extremely similar. The initial candidate software with two labels is marked as highly similar. The initial candidate software with one label is marked as generally similar.
[0075] S400: If the marking result is extremely similar, a software output signal is generated, and the initial candidate software with the marking result being extremely similar is output according to the software output signal.
[0076] Among them, the software output signal represents the detection result output signal of the file to be detected. Specifically, when the processor determines that the marking result of the initial candidate software is extremely similar, the initial candidate software is output to prompt the operator that the code detection of the initial candidate software is extremely similar.
[0077] It should be noted here that if the processor determines that the marking result of the initial candidate software is generally similar or highly similar, the processor does not generate a corresponding signal.
[0078] In one embodiment, the preset database includes a preset regular version database, and the preset string comparison specifically includes comparison in the preset regular version database. The preset regular version database specifically collects binary files of known software such as open source software and proprietary software, extracts strings containing software version numbers, and generates regular expressions for extracting version numbers, such as "GNU Wget 1.21.3", and the corresponding regular expression is "GNU Wget (\d\.\d+\.\d+)". By detecting temporary candidate software in the file to be detected, matching results of different temporary candidate software in the preset regular version database can be obtained, thereby screening out initial candidate software.
[0079] Reference Figure 2 , the file to be detected is subjected to preset string comparison processing to obtain several groups of initial candidate software, including the following steps:
[0080] S110, obtaining a plurality of groups of temporary candidate software according to the file to be detected, and obtaining feature extraction data based on binary feature extraction according to the temporary candidate software, wherein the feature extraction data includes character string data.
[0081] S120, traversing the data to be compared corresponding to the character string data in sequence, and matching the data to be compared in a preset regular version database.
[0082] S130: If there is a matching result in the preset official version database, the to-be-compared data corresponding to the temporary candidate software is marked to obtain the initial candidate software.
[0083] Among them, the temporary candidate software represents a temporary file obtained based on the file to be detected, which is mainly used to match the preset string in the preset regular version database. The feature extraction data represents the data for feature extraction of the file to be detected, and the feature extraction data includes string data. The string data is compared with the preset string set in advance in the preset regular version database, and then the matching result between the string data and the preset string is obtained. The data to be compared represents the actual data corresponding to the string data.
[0084] Specifically, feature extraction data is obtained based on binary feature extraction of temporary candidate software. Binary feature extraction specifically imports the binary file corresponding to the file to be detected into the feature extraction module, and then obtains the feature extraction data corresponding to each temporary candidate software of the file to be detected. The feature extraction data specifically includes binary intra-function symbols, binary import and export symbols, binary ASCII strings, binary function call relationship diagrams, basic block instruction features within functions, basic block relationship flow diagrams within functions, strings within functions, constants within functions, and direct numbers within functions.
[0085] What needs to be explained here is that regarding feature extraction of temporary candidate software, the existing technology is specifically used, and no further elaboration will be made here.
[0086] Specifically, the data to be compared corresponding to the temporary candidate software is marked to obtain the initial candidate software. Here, the data to be compared is marked mainly by marking the temporary candidate software as the first label, that is, marking the temporary candidate software as the initial candidate software with the REGEX label.
[0087] Specific acquisition method: The processor obtains the file to be detected and imports the file to be detected into the feature extraction module, obtains the feature extraction data through the feature extraction module, and then the processor traverses the data to be compared corresponding to the string data in turn, and matches the data to be compared in the preset legal version database. If there is a matching result in the preset legal version database, the data to be compared corresponding to the temporary candidate software is marked to obtain the initial candidate software.
[0088] It should be noted here that if the feature extraction data corresponding to the temporary candidate software does not obtain a corresponding matching result in the preset regular version database, the processor will not mark the temporary candidate software, and the temporary candidate software will not be used as the initial candidate software.
[0089] Specifically, each piece of data in the binary ASCII string is traversed and matched with the regular expression in the regular version database. If a match exists, the corresponding software name and version number are output as the initial candidate software, and each candidate software is labeled with a REGEX tag.
[0090] In one embodiment, the preset database includes a preset regular version database, and the preset string comparison also includes comparison in a preset vector database. The preset vector database mainly collects binary files of known software including open source software, proprietary software, etc., extracts vector features of functions in each binary file, and uses a trained model for vector embedding. Establish entity relationships from software to binary files, binary files to functions, and functions to software. Import the embedded vector and entity relationship data into the vector database, establish a vector index of IVF_FLAT, and set the number of units N-List to 4096. Use approximate neighbor retrieval ANN (Approximate Nearest Neighbor) to search for similar function vectors. Compared with one-to-one comparison of vectors, the search speed is greatly improved.
[0091] The files to be detected are compared with preset strings to obtain several groups of initial candidate software, including the following steps:
[0092] S140, obtaining a plurality of groups of functions to be tested according to the files to be tested, and inputting the functions to be tested into a preset model to obtain similarity values corresponding to the functions to be tested.
[0093] S150, sorting the functions to be tested according to the similarity values, and obtaining the number of occurrences of the functions to be tested in the comparison results.
[0094] S160, screening initial candidate software according to the number of occurrences and preset marking rules.
[0095] Among them, the function to be tested represents the function to be tested obtained based on the file to be tested, and the function to be tested can be the function corresponding to the temporary candidate software. The preset model represents the AI model built in advance. The AI model uses the feature extraction module to extract features from the file to be tested, and then can obtain the basic block instruction features, basic block relationship flow charts, strings, constants, and direct numbers in the function to be tested. Then, the function to be tested is compared with the preset vector database to obtain the similarity value corresponding to the function to be tested, thereby obtaining the initial candidate software with a higher similarity value.
[0096] The similarity value mentioned here is the similarity value of the candidate function obtained by comparing the function to be tested in the preset model, and the number of occurrences represents the number of times the candidate function appears.
[0097] Exemplarily, the processor inputs all function vectors of the binary file to be tested into the AI model training module for model embedding. In this embodiment, there are X functions to be tested. The approximate nearest neighbor search algorithm HNSW (HierarchicalNavigable Small Word) is used for vector fuzzy retrieval. TOP-K is set to 512, the number of access units N-Probe (less than or equal to N-List) is set to 256, and sorted according to similarity, a total of 512*X candidate functions and 512*X function pairs are obtained. The results are counted, the number of occurrences of each temporary candidate software in the results is recorded, and sorted by the number of occurrences, the 256 temporary candidate software and corresponding versions with the most occurrences are retained, and the results with less than 10 occurrences and the number of occurrences divided by X less than 0.1 are discarded. The remaining ones are used as initial candidate software, and each candidate software is labeled with VECTOR.
[0098] In one of the embodiments, the preset database includes a preset string index database, and the preset string comparison also includes comparison in the preset string index database. The specific operation of the string inverted index database collects binary files of known software including open source software and proprietary software, and collectively refers to binary intrinsic function symbols, binary import and export symbols, and binary ASCII strings as string features, which can all be expressed in the form of strings. Each string is parsed, different weights are set according to the value of the string content, each string is segmented and an inverted index is created, a string inverted index database is established, and entity relationships between software to binary files, binary files to strings, and strings to inverted indexes are established.
[0099] The judgment method of the string value includes but is not limited to the following rules: If the string length is less than 3 characters, it is set to no value and the weight is 0. If the string is a statement, such as "Copyright (C) 2015 Free Software Foundation, Inc.", it is set to a general value and the weight is 0.5. If the string is a word, such as "redistribute", it is set to a low value and the weight is 0.1. If the string contains the software name, such as "GNU Wget Originally written by Hrvoje Niksic", it is set to a high value and the weight is 0.7. If the string contains the version number of the current software, such as "v2.5.6", it is set to a high value and the weight is 0.7. If the string contains network protocols, email addresses, domain name IP, etc., such as "https: / / ", "ftp: / / ", "169.21.31.1", "user@admin.com", "www.zlib.net", etc., it is set to a high value and the weight is 0.7. The total binary score of each software is calculated as follows: the score of each string is 1*(1+weight), and the total score is the sum of all string scores. To create an inverted string index, you need to segment the string according to blank characters, dashes (-), and underscores (_). Create an inverted index for the segmentation results. Each segmentation result is an inverted index, so that any segmentation result can be associated with the complete string.
[0100] The files to be detected are compared with preset strings to obtain several groups of initial candidate software, including the following steps:
[0101] S170, obtaining a plurality of groups of temporary candidate software according to the file to be detected, and searching the character string data corresponding to the temporary candidate software in a preset character string index database to obtain a character string result.
[0102] S180, sorting the temporary candidate software according to the character string results, and taking a specified number of sorted temporary candidate software as initial candidate software.
[0103] Search the binary ASCII string in the preset string index database. The method to determine whether the string matches is: for partially matched string results, if the number of segmented words is greater than 3, the strings are required to have 90% content similarity; if the number of segmented words is less than 3, the strings are required to be completely consistent. For a matched string result, its score is the string length * (1 + weight), and the weight is calculated in advance when building the preset string index database. According to the search result statistics and the score of each software binary file in the preset string index database, the score must not be less than 50% of the total binary score of each software. The 256 results with the highest scores are retained as the initial candidate software, and each candidate software is labeled with INDEX.
[0104] Summarize the initial candidate software obtained in the first three steps above and merge the three results. For the initial candidate software with three labels, mark it as extremely similar; for the initial candidate software with two labels, mark it as highly similar; for the initial candidate software with one label, mark it as generally similar. For the extremely similar candidate software, it can be directly used as the detection result. In the future, in order to maximize the candidate software, it is necessary to further process the highly similar and generally similar initial candidate software.
[0105] Reference Figure 3 In one embodiment, the label type includes a first label, the feature extraction data also includes a function call relationship graph, and before determining whether the labeling result is extremely similar, the following steps are also included:
[0106] S500, obtaining a plurality of groups of candidate software according to the file to be detected, and determining whether the label type corresponding to the candidate software is the first label.
[0107] S600: If the tag type corresponding to the candidate software is the first tag, traverse the candidate software based on the function call relationship graph to obtain an associated function pair corresponding to the candidate software.
[0108] S700, obtaining valid function pairs based on the candidate software and the associated function pairs, and comparing the valid function pairs with a preset matching quantity.
[0109] S800: If the number of valid function pairs exceeds a preset matching number, the marking result of the candidate software is marked as extremely similar.
[0110] The function call relationship graph represents the feature extraction data of the feature extraction module for the file to be detected, and specifically, the processor obtains the function call relationship graph extracted by the feature extraction module. The associated function pair represents the function pair formed by the function to be detected calling the candidate function.
[0111] Exemplary, combined Figure 4 and Figure 5 , assuming that the function of the binary to be tested is A1, referred to as the function to be tested, assuming that the function in the candidate software is A2, referred to as the candidate function, if there is a function to be tested A1 calling B1, and the candidate function A2 calling B2, and there is (B1, B2) in the function pair, it means that B1 and B2 are similar functions, and there is a solid line between AB, if there is a function to be tested A1 calling C1, and the candidate function A2 calling C2, and there is (C1, C2) in the function pair, then there is a solid line between AC, and the solid line is the common edge of the two graphs. Calculate the common edges of all function pairs. If the number of common edges is greater than or equal to 5, the function pair is determined to be a valid function pair. The preset matching number represents the number of common edges of the lowest valid function pair that is extremely similar. In this embodiment, the preset matching number is set to 10.
[0112] Exemplary, combined Figure 4 , Figure 5 and Figure 6 , currently all candidate software have VECTOR labels, and the function call relationship graphs are compared respectively. Traverse the function pairs associated with the candidate software. In the remaining function pairs, merge the two relationship graphs with A1-A2 as the vertex, with vertex A and dotted lines as the missing parts. If there is a function A1 to be tested that calls B1, the candidate function A2 calls B2, and there is (B1, B2) in the function pair, then AB is a solid line, which is implemented as the common edge of the two graphs. If there is a function A1 to be tested that calls C1, the candidate function A2 calls C2, and there is (C1, C2) in the function pair, then AC is a solid line, which is implemented as the common edge of the two graphs. And so on, calculate the common edges of all function pairs. For each function pair with a number of common edges greater than or equal to 5, it is called a valid match. For candidate software with the VECTOR label whose number of valid matches exceeds 10, it is marked as extremely similar candidate software and can be directly used as the detection result.
[0113] In one embodiment, traversing the candidate software based on the function call relationship graph to obtain the associated function pairs corresponding to the candidate software includes the following steps:
[0114] S610: Determine whether the label type corresponding to the initial candidate software is the first label.
[0115] S620: If the label type corresponding to the initial candidate software is the first label, the candidate software is subjected to the Hungarian algorithm to obtain the function to be tested corresponding to the candidate software.
[0116] S630, based on the vector value corresponding to the function to be tested, select the candidate software corresponding to the maximum value in the vector value as the associated function pair.
[0117] For candidate software with VECTOR tags, similar function recall is performed to mine more similar function pairs. Using the Hungarian algorithm, COSINE calculation is performed on the vectors of each function to be tested and the candidate software function, and the function with the largest COSINE is retained as the candidate function to obtain X function pairs. This solves the problem that the number of function pairs is not as good as the full match due to approximate fuzzy search during HNSW. This step enables each candidate software with VECTOR tags to maximize the number of function pairs that are matched.
[0118] In one embodiment, after determining whether the tag type corresponding to the initial candidate software is the first tag, the following steps are also included:
[0119] S510: If the label type corresponding to the initial candidate software is not the first label, vector calculation is performed on the function to be tested and the candidate software function in sequence to obtain a vector calculation value.
[0120] S520: Use the function to be tested corresponding to the maximum vector calculation value as an associated function pair corresponding to the candidate software function, and mark the candidate software corresponding to the candidate software function as a first label.
[0121] For candidate software without VECTOR tags, use the Hungarian algorithm to perform COSINE calculations on the vectors of each function to be tested and the candidate software function, retain the function with the largest COSINE as the candidate function, and obtain X function pairs. And add VECTOR tags to the candidate software. This step ensures that each candidate software has candidate functions, especially for software with only a small number of functions, which are discarded due to their low ranking during the initial candidate matching. This move allows such candidate software to still obtain function pairs when it only has INDEX tags or REGEX tags, increasing the coverage of candidate software.
[0122] In one embodiment, the feature extraction data further includes binary import and export symbols, and the label type includes a second label and a third label, and the following steps are included:
[0123] A plurality of groups of temporary candidate software are obtained according to the file to be detected, and it is determined whether the label type corresponding to the candidate software is the second label and the third label.
[0124] If the label type corresponding to the candidate software is not the second label or the third label, the corresponding binary import and export symbols are obtained according to the function to be tested.
[0125] The number of identical symbols is obtained according to the function to be tested and the temporary candidate software, and it is determined whether the number of identical symbols is less than a preset symbol.
[0126] If the number of identical symbols is not less than the preset symbols, the temporary candidate software is used as the candidate software.
[0127] For candidate software without REGEX and INDEX tags, compare their function import symbols and export symbols, collectively referred to as symbols. If there are more than or equal to 20 identical symbols, add the SYMBOL tag to the candidate software. This step allows some software that is abandoned after ranking when obtaining the initial candidate software due to insufficient string features to continue to match, thereby increasing the coverage of candidate software.
[0128] The implementation principle is:
[0129] The processor obtains the file to be detected and processes the file to be detected through a preset string comparison to obtain initial candidate software. The preset string comparison here is to compare the program code of the file to be detected to obtain initial candidate software with different labels.
[0130] The processor obtains the corresponding tag type according to the initial candidate software, and obtains the tag marking times corresponding to the initial candidate software according to the tag type, compares the tag marking times with the preset times to obtain the marking results corresponding to the initial candidate software, and determines whether the marking results are extremely similar.
[0131] When the processor determines that the marking result of the initial candidate software is extremely similar, the initial candidate software is output to prompt the operator that the code detection of the initial candidate software is extremely similar. If the processor determines that the marking result of the initial candidate software is generally similar or highly similar, the result processing module does not generate a corresponding signal.
[0132] The embodiment of the present application also discloses a binary software component composition detection system.
[0133] A binary software component composition detection system includes a file acquisition module, a label marking module, a data comparison module and a result processing module. The file acquisition module is used to obtain the file to be detected, and the file to be detected is subjected to preset string comparison processing to obtain several groups of initial candidate software. The label marking module is used to obtain the corresponding label type according to the initial candidate software, and obtain the label marking times corresponding to the initial candidate software according to the label type. The data comparison module is used to compare the label marking times with the preset times to obtain the marking results corresponding to the initial candidate software, and determine whether the marking results are extremely similar. If the marking results are extremely similar, the result processing module is used to generate a software output signal, and output the initial candidate software with extremely similar marking results according to the software output signal. If the marking results are generally similar or highly similar, the result processing module does not generate a corresponding signal.
[0134] The other functions performed in the above-mentioned file acquisition module, label marking module, data comparison module and result processing module as well as the technical details of each function are the same or similar to the corresponding features in the binary software component composition detection method described above, so they will not be repeated here.
[0135] An embodiment of the present application also discloses a storage medium, which stores at least one instruction, at least one program, code set or instruction set, and the at least one instruction, at least one program, code set or instruction set is loaded and executed by a processor to implement a binary software component composition detection method.
[0136] It should be understood that although the steps in the flowchart of the accompanying drawings are shown in sequence according to the instructions of the arrows, these steps are not necessarily performed in the order indicated by the arrows. Unless otherwise clearly stated in this document, the execution of these steps is not strictly limited in order and can be performed in other orders.
[0137] The above are all preferred embodiments of the present application, and the protection scope of the present application is not limited thereto. Therefore, any equivalent changes made according to the structure, shape, and principle of the present application should be included in the protection scope of the present application.
Claims
1. A binary software component composition detection method, characterized in that: The following steps are involved: Obtaining a file to be detected, and subjecting the file to be detected to a preset string comparison process to obtain a plurality of groups of initial candidate software, wherein the file to be detected represents a file that needs to be subjected to software component analysis; The preset character string is stored in the preset regular version database, and the file to be detected is subjected to the preset character string comparison process to obtain a plurality of groups of initial candidate software, including the following steps: Acquire a plurality of groups of temporary candidate software according to the file to be detected, and acquire feature extraction data based on binary feature extraction according to the temporary candidate software, wherein the feature extraction data includes string data, wherein the temporary candidate software represents a temporary file acquired according to the file to be detected; Traversing the data to be compared corresponding to the string data in sequence, and matching the data to be compared in a preset regular version database; If there is a matching result in the preset legitimate version database, marking the to-be-compared data corresponding to the temporary candidate software to obtain the initial candidate software; Acquire a corresponding label type according to the initial candidate software, and acquire a label marking count corresponding to the initial candidate software according to the label type; Compare the number of times the label is marked with a preset number to obtain a marking result corresponding to the initial candidate software, and determine whether the marking result is extremely similar; If the marking result is extremely similar, a software output signal is generated, and the initial candidate software with the marking result being extremely similar is output according to the software output signal.
2. The binary software component composition detection method according to claim 1, characterized in that: The preset character string is stored in a preset vector database, and the file to be detected is subjected to preset character string comparison processing to obtain a plurality of groups of initial candidate software, including the following steps: Acquire several groups of functions to be tested according to the files to be tested, and input the functions to be tested into a preset model to obtain similarity values corresponding to the functions to be tested; Sort the functions to be tested according to the similarity values, and obtain the number of occurrences of the functions to be tested in the comparison results; Initial candidate software is screened according to the number of occurrences and preset marking rules.
3. The binary software component composition detection method according to claim 1, characterized in that: The preset character string is stored in a preset character string index database, and the file to be detected is subjected to preset character string comparison processing to obtain a plurality of groups of initial candidate software, including the following steps: Acquire several groups of temporary candidate software according to the file to be detected, and search the character string data corresponding to the temporary candidate software in the preset character string index database to obtain character string results; The temporary candidate software are sorted according to the character string results, and a specified number of the sorted temporary candidate software are used as the initial candidate software.
4. The binary software component composition detection method according to claim 1, characterized in that: The label type includes a first label, the feature extraction data also includes a function call relationship diagram, and before determining whether the labeling result is extremely similar, the following steps are also included: Acquire several groups of candidate software according to the file to be detected, and determine whether the label type corresponding to the candidate software is the first label; If the tag type corresponding to the candidate software is the first tag, traversing the candidate software based on the function call relationship graph to obtain an associated function pair corresponding to the candidate software; Acquire a valid function pair based on the candidate software and the associated function pair, and compare the valid function pair with a preset matching number; If the valid function pairs exceed the preset matching quantity, the marking result of the candidate software is marked as extremely similar.
5. The binary software component composition detection method according to claim 4, characterized in that: The step of traversing the candidate software based on the function call relationship graph to obtain associated function pairs corresponding to the candidate software comprises the following steps: Determine whether the label type corresponding to the initial candidate software is the first label; If the label type corresponding to the initial candidate software is the first label, obtaining the function to be tested corresponding to the candidate software based on the Hungarian algorithm; According to the vector value corresponding to the function to be tested, the candidate software corresponding to the maximum value is screened out from the vector value as the associated function pair.
6. The binary software component composition detection method according to claim 5, characterized in that: After determining whether the label type corresponding to the initial candidate software is the first label, the following steps are also included: If the label type corresponding to the initial candidate software is not the first label, vector calculation is performed on the function to be tested and the candidate software function in sequence to obtain a vector calculation value; The function to be tested corresponding to the largest vector calculation value is used as an associated function pair corresponding to the candidate software function, and the candidate software corresponding to the candidate software function is marked as a first label.
7. The binary software component composition detection method according to claim 5, characterized in that: The feature extraction data also includes binary import and export symbols, and the label type includes a second label and a third label, including the following steps: Acquire several groups of temporary candidate software according to the to-be-detected file, and determine whether the label type corresponding to the candidate software is the second label and the third label; If the label type corresponding to the candidate software is not the second label or the third label, obtaining the corresponding binary import and export symbol according to the function to be tested; Obtaining the number of identical symbols according to the function to be tested and the temporary candidate software, and determining whether the number of identical symbols is less than a preset symbol; If the number of identical symbols is not less than the preset number of symbols, the temporary candidate software is used as the candidate software.
8. A binary software component composition detection system, characterized in that: include: The file acquisition module is used to acquire the file to be detected, and to compare the file to be detected with a preset string to obtain a plurality of groups of initial candidate software, wherein the file to be detected represents a file that needs to be analyzed for software components, and the preset string is stored in the comparison including a preset regular version database, and the file to be detected is compared with the preset string to obtain a plurality of groups of initial candidate software, including the following steps: Acquire a plurality of groups of temporary candidate software according to the file to be detected, and acquire feature extraction data based on binary feature extraction according to the temporary candidate software, wherein the feature extraction data includes string data, wherein the temporary candidate software represents a temporary file acquired according to the file to be detected; Traversing the data to be compared corresponding to the string data in sequence, and matching the data to be compared in a preset regular version database; If there is a matching result in the preset legitimate version database, marking the to-be-compared data corresponding to the temporary candidate software to obtain the initial candidate software; A label marking module, the label marking module is used to obtain a corresponding label type according to the initial candidate software, and obtain a label marking number corresponding to the initial candidate software according to the label type; A data comparison module, the data comparison module is used to compare the label marking times with a preset times to obtain the marking results corresponding to the initial candidate software, and determine whether the marking results are extremely similar; The result processing module is used to generate a software output signal if the marking result is extremely similar, and output the initial candidate software whose marking result is extremely similar according to the software output signal.
9. A storage medium, characterized in that: The storage medium stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the binary software component composition detection method as described in any one of claims 1-7.
Citation Information
Patent Citations
Software component analysis method and device based on binary file and medium
CN116149669A
Binary code open source component identification method and system based on intermediate expression
CN116432622A
