Firmware security detection method and device, terminal equipment and storage medium
By obtaining feature information from the binary file of the firmware and calculating similarity with the features in the preset firmware library, the problem of inaccurate firmware security evaluation in the prior art is solved, and more accurate firmware security detection is achieved.
Patent Information
- Application Number
- CN202410873917.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-11-26
AI Technical Summary
In the prior art, the similarity calculation method of the characteristic information in the calculation firmware and the characteristic information of the known reference firmware is single, and the security of the firmware cannot be accurately evaluated.
By obtaining the features of preset attributes from the binary file of the firmware, combining the features in the preset firmware library, the relative and absolute similarities of the feature values are calculated to generate the security detection results of the firmware.
Improves the accuracy of firmware similarity evaluation and enhances the accuracy of firmware safety detection.
Smart Images

Figure CN119026129A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of industrial control systems, and in particular, relates to a firmware security detection method, apparatus, terminal device, and storage medium. Background Art
[0002] Industrial control system refers to a fully digital, two-way, multi-station network communication system installed in an industrial production environment, which is formed by many intelligent devices. With the development of industrial control systems, the number of network devices in industrial control systems has gradually increased. Because network devices usually perform specified tasks according to the firmware set inside, if there is a security vulnerability in the firmware of any network device, it will pose a threat to the entire industrial control system.
[0003] At present, the Software Composition Analysis (SCA) method is usually used to calculate the similarity between the feature information in the firmware and the feature information of the known reference firmware, and perform security detection based on the similarity. For example, the cosine distance between the feature information in the firmware and the feature information of the reference firmware is calculated as the above similarity.
[0004] However, the above similarity calculation method is relatively simple and cannot accurately determine the similarity between two firmwares. Furthermore, it is impossible to accurately evaluate the security of the firmware based on the similarity. Summary of the invention
[0005] The embodiments of the present application provide a firmware security detection method, apparatus, terminal device and storage medium, which can solve the problem that the calculation method of the similarity between the feature information in the existing computing firmware and the feature information of the known reference firmware is single and the similarity accuracy is low.
[0006] In a first aspect, an embodiment of the present application provides a firmware security detection method, the method comprising:
[0007] Obtain a first characteristic of a preset attribute from a binary file in the firmware;
[0008] Determining a relative similarity between the first feature and the second feature based on a first number of feature values that appear in common in the first feature and the second feature; the second feature is a feature corresponding to a preset attribute in a preset firmware library;
[0009] Determining an absolute similarity between the first feature and the second feature based on a second number of feature values in the first feature and the second feature where the feature values appear at the same positions;
[0010] Generate firmware security detection results based on relative similarity and absolute similarity.
[0011] In a second aspect, an embodiment of the present application provides a firmware security detection device, the device comprising:
[0012] An acquisition module, used for acquiring a first feature of a preset attribute from a binary file in the firmware;
[0013] A first determination module is used to determine the relative similarity between the first feature and the second feature based on a first number of feature values that appear in both the first feature and the second feature; the second feature is a feature corresponding to a preset attribute in a preset firmware library;
[0014] A second determination module, configured to determine the absolute similarity between the first feature and the second feature based on a second number of feature values in the first feature and the second feature where the feature values appear at the same positions;
[0015] The generation module is used to generate security detection results of the firmware according to relative similarity and absolute similarity.
[0016] In a third aspect, an embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method of the first aspect described above when executing the computer program.
[0017] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the method of the first aspect described above is implemented.
[0018] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a terminal device, enables the terminal device to execute the method of the first aspect.
[0019] Compared with the prior art, the embodiment of the present application has the following beneficial effects: the terminal device can obtain the first feature of the preset attribute from the binary file in the firmware, and determine the second feature corresponding to the same preset attribute from the preset firmware library. Then, because the first number is the number of feature values that appear in the first feature and the second feature, it can be considered that the size of the first number can reflect the similarity of the first feature to the second feature to a certain extent. Therefore, the terminal device can determine the relative similarity of the first feature and the second feature based on the first number of feature values that appear in the first feature and the second feature. At the same time, because the second number is the number of feature values in the first feature and the second feature that are the same and the positions where the feature values appear are also the same. It can be understood that when the feature values at all the same positions in the first feature and the second feature are the same, it can be considered that the first feature is completely consistent with the second feature. Therefore, it can be considered that the size of the second number can reflect the absolute similarity between the first feature and the second feature. Furthermore, the terminal device can determine the absolute similarity between the first feature and the second feature based on the second number. Finally, the terminal device can accurately generate the security detection result of the firmware by combining the relative similarity and the absolute similarity to improve the accuracy of the similarity between the determined first feature and the second feature, thereby improving the accuracy of the generated firmware security detection result. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0021] Figure 1 This is a flowchart of a firmware security detection method provided in an embodiment of the present application;
[0022] Figure 2 It is a structural schematic diagram of a firmware security detection device provided by an embodiment of the present application;
[0023] Figure 3 It is a structural diagram of a terminal device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0024] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0025] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0026] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0027] In order to accurately determine the similarity between two firmwares and improve the accuracy of firmware security assessment based on similarity, an embodiment of the present application provides a firmware security detection method, which can be applied to terminal devices such as tablet computers, laptops, ultra-mobile personal computers (UMPCs), netbooks, etc. The embodiment of the present application does not impose any restrictions on the specific type of terminal devices.
[0028] See also Figure 1 , Figure 1 A flowchart of a firmware security detection method provided in an embodiment of the present application is shown, and the method includes the following steps:
[0029] S101: Acquire a first feature of a preset attribute from a binary file in a firmware.
[0030] In the application, the above firmware is the firmware to be evaluated for security in the network device. The network device can upload the firmware to be evaluated for security to the terminal device, and then the terminal device executes the firmware security detection method. Alternatively, the terminal device executes the firmware security detection method on its own internal firmware, which is not limited.
[0031] After acquiring the firmware, the terminal device can decompress all compressed files in the firmware to obtain the above binary file. Exemplarily, the terminal device can parse the firmware in an automatic recursive manner to decompress all compressed files in the firmware.
[0032] It is understandable that the size of the firmware is usually relatively large. When uploading the firmware to the terminal device, in order to improve the upload efficiency of the firmware, the network device needs to compress the firmware. Therefore, the terminal device needs to decompress the received firmware to obtain the above binary file.
[0033] It should be noted that after the firmware is parsed, the files in the firmware usually include multiple types such as source code files, binary files and text files. Since the similarity calculation method of source code files and text files is an existing method, this embodiment mainly improves the similarity calculation method of binary files.
[0034] Among them, after parsing the firmware, the terminal device can also classify and display all files in the firmware, as well as display security detection results, without limitation.
[0035] In the application, the above preset attributes include but are not limited to one or more preset attributes such as the firmware name, version, function name, hash value of the binary file, etc., and are not limited to this.
[0036] S102: Determine a relative similarity between the first feature and the second feature based on a first number of feature values that appear in both the first feature and the second feature; the second feature is a feature corresponding to a preset attribute in a preset firmware library.
[0037] In the application, in order to perform security detection on the firmware, it is necessary to obtain the second feature corresponding to the same preset attribute from the existing preset firmware library. Among them, the preset firmware library usually stores a large number of reference firmwares. At this time, when executing the firmware security detection method, the second feature of the preset attribute can be obtained from each firmware for comparison to generate the similarity between the first feature and the second feature.
[0038] Exemplarily, in the preset firmware library, it usually includes multiple versions of firmware, at this time, the terminal device can obtain the second feature of the preset attribute from each version of the firmware, and then calculate the similarity and analyze the security detection results of the firmware.
[0039] It is understandable that the data of the binary files in different versions of firmware are different. If the second feature of the preset attribute is randomly obtained from the preset firmware, it is easy to increase the misjudgment rate when the terminal device executes the firmware security detection method. Therefore, the terminal device can obtain the second feature of the preset attribute from each firmware in each preset firmware library.
[0040] It should be added that the version of the firmware corresponding to the maximum value of the similarity in the preset firmware library is consistent with the version of the firmware whose security is to be evaluated. Furthermore, the terminal device can analyze the component information and security detection results in the firmware whose security is to be evaluated based on the firmware with homology information determined from the preset firmware library.
[0041] In one embodiment, the preset firmware library can be a firmware library covering multiple code hosting platforms. The code hosting platform is a Git-based online code hosting service for software developers. It is a cloud-based code warehouse with functions such as security management, member / authority management, branch protection / merging, online editing, and statistical services. It aims to solve software developers' problems in cross-regional collaboration, multi-branch concurrency, code version management, and security.
[0042] The code hosting platforms include but are not limited to GitHub, GitLab, BitBucket, Gitee, Codeberg, etc. The preset firmware library can cover more than 80,000 C / C++ open source projects, 50 million JAVA open source projects, and more than 200 million fingerprint features to provide basic data support when calculating the similarity of firmware.
[0043] In the application, the first number is the number of eigenvalues that appear together in the first feature and the second feature. For example, when the first eigenvalues included in the first feature are abcde in sequence, and the second eigenvalues included in the second feature are bcdee in sequence, it can be considered that the eigenvalues that appear together are bcde. That is, it can be considered that the first number of eigenvalues that appear together is 4.
[0044] It can be understood that, since the first number is the number of feature values that appear together in the first feature and the second feature, it can be considered that the size of the first number can reflect the similarity of the first feature to the second feature to a certain extent.
[0045] Based on this, as an example, the terminal device may determine the intersection of the first feature value included in the first feature and the second feature value included in the second feature to obtain a first quantity, and then determine the relative similarity based on the first quantity.
[0046] Exemplarily, the terminal device may use the multiple first feature values included in the first feature as a group of strings, and the multiple second feature values included in the second feature as another group of strings. Then, the first quantity is determined by finding the intersection of the two strings using C language or JAVA language. In this embodiment, the method for determining the first quantity is not limited.
[0047] The terminal device may determine a first ratio of the first quantity to the number of first feature values included in the first feature as the relative similarity, or determine a second ratio of the first quantity to the number of second feature values included in the second feature as the relative similarity.
[0048] However, there is usually a certain relative deviation when determining the relative similarity only based on the first ratio of the first quantity to the first eigenvalue quantity, or only based on the second ratio of the first quantity to the second eigenvalue quantity.
[0049] Specifically, when the first number is small, if the number of first eigenvalues or the number of second eigenvalues is also small, the calculated relative similarity will also be large. And, when the first number is large, if the number of first eigenvalues or the number of second eigenvalues is also large, the calculated relative similarity will also be small.
[0050] Based on this, in order to reasonably quantify the relative similarity between the first feature and the second feature, the terminal device calculates a first ratio of the first quantity to the first eigenvalue quantity of the first eigenvalue; and calculates a second ratio of the first quantity to the second eigenvalue quantity of the second eigenvalue. Finally, the product of the first ratio and the second ratio is determined as the relative similarity. Furthermore, the relative similarity is accurately determined by combining the first eigenvalue quantity and the second eigenvalue quantity.
[0051] In another embodiment, the terminal device may also determine the sum of the first ratio and the second ratio as the relative similarity. In this embodiment, the method for determining the relative similarity based on the first ratio and the second ratio is not limited.
[0052] S103: Determine the absolute similarity between the first feature and the second feature based on a second number of feature values in the first feature and the second feature whose feature values appear at the same positions.
[0053] In an application, if the above eigenvalues and the positions where the eigenvalues appear are the same, it can be considered that the position of the first eigenvalue in the first feature is the same as the position of the second eigenvalue in the second feature, and the first eigenvalue is also the same as the second eigenvalue.
[0054] The terminal device may traverse each first feature and second feature, and determine in turn whether the first feature value at each position in the first feature is equal to the second feature value at the same position in the second feature. If they are equal, 1 is added to the second number until the traversal is completed.
[0055] For example, when the first eigenvalues included in the first feature are abcde, and the second eigenvalues included in the second feature are abcdd, it can be considered that the positions of the first eigenvalues abcdd in the first feature are the first, second, third, and fourth, respectively. And, the positions of the second eigenvalues in the second feature are also the first, second, third, and fourth, respectively. That is, not only the eigenvalues are the same, but also the feature positions are the same. Based on this, it can be considered that the second number is 4.
[0056] It should be noted that, unlike counting the first number, when determining the first number in S102, only the number of eigenvalues that co-occur in the first feature and the second feature is counted. For example, when the first eigenvalues included in the first feature are abcde in sequence, and the second eigenvalues included in the second feature are dabcd in sequence, the first number is still 4, and the second number is confirmed to be 0.
[0057] It can be understood that since the second number is the number of the first feature and the second feature with the same eigenvalue and the same position of the eigenvalue, it can be understood that when the eigenvalues at all the same positions in the first feature and the second feature are the same, it can be considered that the first feature is completely consistent with the second feature. Therefore, it can be considered that the size of the second number can reflect the absolute similarity between the first feature and the second feature.
[0058] In one embodiment, the terminal device may determine the ratio of the second number to the number of first feature values included in the second feature as the above absolute similarity. Alternatively, the terminal device may determine the ratio of the second number to the number of second feature values included in the second feature as the above absolute similarity.
[0059] However, there is usually a certain relative deviation when determining the absolute similarity only based on the ratio of the second quantity to the first eigenvalue quantity, or only based on the ratio of the second quantity to the second eigenvalue quantity.
[0060] Specifically, when the second number is small, if the number of first eigenvalues or the number of second eigenvalues is also small, the calculated absolute similarity will also be large. And, when the second number is large, if the number of first eigenvalues or the number of second eigenvalues is also large, the calculated relative similarity will also be small.
[0061] Based on this, in order to reasonably quantify the absolute similarity between the first feature and the second feature, the terminal device adds the number of first feature values corresponding to the first feature and the number of second feature values corresponding to the second feature to obtain the summed number. Finally, the ratio of the second number of preset multiples to the summed number is determined as the absolute similarity. Furthermore, the absolute similarity is accurately determined by combining the number of first feature values and the number of second feature values.
[0062] The preset multiple can be set according to actual conditions. In this embodiment, the preset multiple can be 2.
[0063] In another embodiment, the terminal device may also determine the absolute similarity based on the ratio of the second number to the first eigenvalue number and the sum of the ratios of the second number to the second eigenvalue number. In this embodiment, the method for determining the absolute similarity based on the second number is not limited.
[0064] S104: Generate a firmware security detection result according to the relative similarity and the absolute similarity.
[0065] In the application, the terminal device can generate the security detection result of the firmware according to the relative similarity and the absolute similarity respectively. For example, when it is judged that the relative similarity is greater than or equal to the preset relative threshold, and the absolute similarity is greater than or equal to the preset absolute threshold, the security detection result is determined to be firmware security. Otherwise, when it is judged that the relative similarity is less than the preset relative threshold, and / or the absolute similarity is less than the preset absolute threshold, the security detection result is determined to be firmware insecure.
[0066] Among them, both the preset relative threshold and the preset absolute threshold can be set according to actual conditions and are not limited to this.
[0067] However, it should be noted that if the relative similarity and absolute similarity are compared with the corresponding thresholds to generate the final security detection result, in actual application scenarios, most of the cases may be that one of the relative similarity and the absolute similarity is greater than or equal to the above threshold. However, when one of the relative similarity and the absolute similarity is greater than or equal to the above threshold, the security of its firmware may also be higher. Based on this, the accuracy of generating the final security detection result by comparing the relative similarity and the absolute similarity with the corresponding thresholds may still be low.
[0068] Based on this, in order to generate the security detection result by integrating the two factors of relative similarity and absolute similarity, in this embodiment, the terminal device can calculate the target similarity between the first feature and the second feature according to the relative similarity and the absolute similarity. Then, when the target similarity is greater than or equal to the preset similarity, the security detection result is determined to be firmware security. Otherwise, when the target similarity is less than the preset similarity, the security detection result is determined to be firmware insecurity.
[0069] The terminal device may determine the sum of the relative similarity and the absolute similarity as the target similarity, or may determine the product of the relative similarity and the absolute similarity as the target similarity, without limitation. The preset similarity may be set according to actual conditions, and for example, the preset similarity may be 95%.
[0070] From the above description, we can see that the target similarity can be calculated using the following formula:
[0071]
[0072] Among them, Q is the target similarity, C is the first number, L1 is the first eigenvalue number, L2 is the second eigenvalue number, and M is the second number.
[0073] It should be added that in order to further accurately calculate the target similarity between the first feature and the second feature, the first feature and the second feature of multiple preset attributes can be obtained for judgment. At this time, the terminal device can calculate the feature similarity corresponding to each preset attribute according to the relative similarity and absolute similarity corresponding to each preset attribute. Then, the average of the multiple feature similarities is determined as the target similarity.
[0074] It should be noted that by using target similarity as the basis for judging whether the firmware is safe or not, the source composition of non-self-developed code in the firmware to be evaluated for security can be obtained. Then, based on the source composition, the known vulnerabilities introduced by the reuse of open source components and their related information can be retrieved from the existing vulnerability knowledge graph. Furthermore, it can be used as a basis for further analysis of whether the vulnerability will pose a security threat to the firmware under test. In this embodiment, only the target similarity of the second feature of the same preset attribute of the firmware to be evaluated for security and the reference firmware in the preset firmware library is determined, and the security detection result is generated based on the relationship between the target similarity and the preset similarity.
[0075] In this embodiment, the terminal device can obtain the first feature of the preset attribute from the binary file in the firmware, and determine the second feature corresponding to the same preset attribute from the preset firmware library. Then, because the first number is the number of feature values that appear in the first feature and the second feature, it can be considered that the size of the first number can reflect the similarity of the first feature to the second feature to a certain extent. Therefore, the terminal device can determine the relative similarity of the first feature and the second feature based on the first number of feature values that appear in the first feature and the second feature. At the same time, because the second number is the number of feature values in the first feature and the second feature that are the same and the positions where the feature values appear are also the same. It can be understood that when the feature values at all the same positions in the first feature and the second feature are the same, it can be considered that the first feature is completely consistent with the second feature. Therefore, it can be considered that the size of the second number can reflect the absolute similarity between the first feature and the second feature. Furthermore, the terminal device can determine the absolute similarity between the first feature and the second feature based on the second number. Finally, the terminal device can accurately generate the security detection result of the firmware by combining the relative similarity and the absolute similarity to improve the accuracy of the similarity between the determined first feature and the second feature, thereby improving the accuracy of the generated firmware security detection result.
[0076] Among them, it should be added that the above-mentioned firmware can be firmware in multiple fields. Exemplarily, the above-mentioned field can be the automotive field, and its firmware can be firmware in devices such as in-vehicle entertainment equipment, communication control systems, diagnostic software update equipment, and software verification equipment; the above-mentioned field can be the communication equipment field, and its firmware can be firmware in wireless devices, switches, servers and other devices; the above-mentioned field can be the transportation facilities field, and its firmware can be firmware in rail transportation equipment and roadside equipment of highways; the above-mentioned field can be the industrial manufacturing field, and its firmware can be firmware in aviation equipment, ship control equipment, robots, engine controllers and other equipment; the above-mentioned field can be the medical equipment field, and its firmware can be firmware in ultrasound equipment, medical imaging equipment, dialysis equipment and other equipment; the above-mentioned field can be the public security field, and its firmware can be firmware in public security command center systems, fire control systems, and civil air defense command systems; the above-mentioned field can be the power equipment field, and its firmware can be firmware in switch cabinets, transformers, circuit breakers and other equipment; the above-mentioned field can be For financial equipment, its firmware can be the firmware in self-service terminals, money counters and other equipment; the above-mentioned field can also be the field of railway equipment, and its firmware can be the firmware in signal lights, train control equipment and other equipment; the above-mentioned field can also be the field of urban rail transit, and its equipment can be the firmware in subway operation systems, vehicle control systems, rail transit signal systems, traffic controllers and other equipment; the above-mentioned field can also be the field of drones, and its firmware can be the firmware in fixed-wing drones, multi-rotor drones and other equipment; the above-mentioned field can also be the field of 3C products, and its firmware can be the firmware in electronic products such as mobile phones and computers; the above-mentioned field can also be the field of LED lighting, and its firmware can be the firmware in LED power supplies, LED controllers and other equipment; the above-mentioned field can also be the field of public utilities, and its firmware can be the firmware in secondary and tertiary water treatment equipment, heat exchangers and other equipment; the above-mentioned field can also be the field of communication equipment, and its firmware can also be the firmware in wireless access equipment, transmission equipment and other equipment.
[0077] See also Figure 2 , Figure 2 Schematic diagram of the structure of a firmware security detection device provided in an embodiment of the present application. The firmware security detection device in this embodiment includes modules for executing Figure 1 For details, please refer to the steps in the corresponding embodiment. Figure 1 as well as Figure 1 For the convenience of explanation, only the parts related to this embodiment are shown. Figure 2 , the firmware security detection device 200 may include: an acquisition module 210, a first determination module 220, a second determination module 230 and a generation module 240, wherein:
[0078] The acquisition module 210 is used to acquire a first feature of a preset attribute from a binary file in the firmware.
[0079] The first determination module 220 is used to determine the relative similarity between the first feature and the second feature based on a first number of feature values that appear in both the first feature and the second feature; the second feature is a feature corresponding to a preset attribute in a preset firmware library.
[0080] The second determination module 230 is configured to determine the absolute similarity between the first feature and the second feature based on a second number of feature values in the first feature and the second feature whose feature values appear at the same positions.
[0081] The generating module 240 is used to generate the security detection result of the firmware according to the relative similarity and the absolute similarity.
[0082] In one embodiment, the first determining module 220 is further configured to:
[0083] An intersection of a first feature value included in the first feature and a second feature value included in the second feature is determined to obtain a first quantity; and a relative similarity is determined based on the first quantity.
[0084] In one embodiment, the first determining module 220:
[0085] A first ratio of the first quantity to the first eigenvalue quantity of the first eigenvalue is calculated; and a second ratio of the first quantity to the second eigenvalue quantity of the second eigenvalue is calculated; and a product of the first ratio and the second ratio is determined as the relative similarity.
[0086] In one embodiment, the second determining module 230 is further configured to:
[0087] The number of first eigenvalues corresponding to the first feature and the number of second eigenvalues corresponding to the second feature are added to obtain a summed number; and the ratio of the second number of a preset multiple to the summed number is determined as the absolute similarity.
[0088] In one embodiment, the generating module 240 is further configured to:
[0089] According to the relative similarity and the absolute similarity, the target similarity between the first feature and the second feature is calculated; if the target similarity is greater than or equal to the preset similarity, the security detection result is determined to be firmware security; if the target similarity is less than the preset similarity, the security detection result is determined to be firmware insecure.
[0090] In one embodiment, the generating module 240 is further configured to:
[0091] The product of the relative similarity and the absolute similarity is determined as the target similarity.
[0092] In one embodiment, there are multiple preset attributes; the generation module 240 is further used to:
[0093] The feature similarity corresponding to each preset attribute is calculated according to the relative similarity and the absolute similarity corresponding to each preset attribute; and the average of multiple feature similarities is determined as the target similarity.
[0094] When it is understood that Figure 2 In the structural diagram of the firmware security detection device shown, each module is used to execute Figure 1 The steps in the corresponding embodiments, and for Figure 1 Each step in the corresponding embodiment has been explained in detail in the above embodiment. Figure 1 as well as Figure 1 The relevant descriptions in the corresponding embodiments are not repeated here.
[0095] Figure 3 Schematic diagram of a terminal device provided by an embodiment of the present application. Figure 3 As shown, the terminal device 300 of this embodiment includes: a processor 310, a memory 320, and a computer program 330 stored in the memory 320 and executable on the processor 310, such as a program of the firmware security detection method. When the processor 310 executes the computer program 330, the steps in each embodiment of the above-mentioned firmware security detection method are implemented, such as Figure 1 Alternatively, the processor 310 implements the above when executing the computer program 330 Figure 2 The functions of each module in the corresponding embodiment are, for example, Figure 2 For details on the functions of each module shown, please refer to Figure 2 Related description in the corresponding embodiment.
[0096] Exemplarily, the computer program 330 may be divided into one or more modules, one or more modules are stored in the memory 320, and are executed by the processor 310 to implement the firmware security detection method provided in the embodiment of the present application. One or more modules may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program 330 in the terminal device 300. For example, the computer program 330 may implement the firmware security detection method provided in the embodiment of the present application.
[0097] The terminal device 300 may include, but is not limited to, a processor 310 and a memory 320. Those skilled in the art will appreciate that Figure 3It is only an example of the terminal device 300 and does not constitute a limitation of the terminal device 300. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal device may also include input and output devices, network access devices, buses, etc.
[0098] The processor 310 may be a central processing unit, or other general-purpose processors, digital signal processors, application-specific integrated circuits, off-the-shelf programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0099] The memory 320 may be an internal storage unit of the terminal device 300, such as a hard disk or memory of the terminal device 300. The memory 320 may also be an external storage device of the terminal device 300, such as a plug-in hard disk, a smart memory card, a flash memory card, etc. equipped on the terminal device 300. Furthermore, the memory 320 may also include both an internal storage unit of the terminal device 300 and an external storage device.
[0100] An embodiment of the present application provides a computer-readable storage medium, which stores a computer program. The computer program is executed by a processor to execute the firmware security detection method in each of the above embodiments.
[0101] An embodiment of the present application provides a computer program product. When the computer program product runs on a terminal device, the terminal device executes the firmware security detection method in each of the above embodiments.
[0102] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A firmware security detection method, It is characterized in that The method comprises: Obtain a first characteristic of a preset attribute from a binary file in the firmware; Determining a relative similarity between the first feature and the second feature based on a first number of feature values that appear in both the first feature and the second feature; the second feature is a feature corresponding to the preset attribute in the preset firmware library; Determining an absolute similarity between the first feature and the second feature based on a second number of the feature values in the first feature and the second feature where the feature values appear at the same positions; A security detection result of the firmware is generated according to the relative similarity and the absolute similarity.
2. The method according to claim 1, It is characterized in that The determining the relative similarity between the first feature and the second feature based on a first number of feature values that co-occur in the first feature and the second feature includes: Determine an intersection of a first eigenvalue included in the first feature and a second eigenvalue included in the second feature to obtain the first quantity; The relative similarity is determined based on the first quantity.
3. The method according to claim 2, It is characterized in that The determining the relative similarity based on the first quantity includes: calculating a first ratio of the first quantity to a first eigenvalue quantity of the first eigenvalue; and, calculating a second ratio of the first number to the second number of eigenvalues of the second eigenvalue; The product of the first ratio and the second ratio is determined as the relative similarity.
4. The method according to claim 1, It is characterized in that The determining the absolute similarity between the first feature and the second feature based on the second number of feature values in the first feature and the second feature where the feature values appear at the same positions includes: Adding the number of first eigenvalues corresponding to the first feature and the number of second eigenvalues corresponding to the second feature to obtain a summed number; The ratio of the second number of preset multiples to the summed number is determined as the absolute similarity.
5. The method according to claim 1, It is characterized in that Generating the security detection result of the firmware according to the relative similarity and the absolute similarity includes: Calculating a target similarity between the first feature and the second feature according to the relative similarity and the absolute similarity; If the target similarity is greater than or equal to a preset similarity, determining that the security detection result is that the firmware is secure; If the target similarity is less than the preset similarity, the security detection result is determined to be that the firmware is unsafe.
6. The method according to claim 5, It is characterized in that The calculating the target similarity between the first feature and the second feature according to the relative similarity and the absolute similarity includes: The product of the relative similarity and the absolute similarity is determined as the target similarity.
7. The method according to claim 5, It is characterized in that The preset attributes include a plurality of attributes; and the generating of the security detection result of the firmware according to the relative similarity and the absolute similarity includes: Calculating the feature similarity corresponding to each of the preset attributes according to the relative similarity and the absolute similarity corresponding to each of the preset attributes; An average value of the plurality of feature similarities is determined as the target similarity.
8. A firmware security detection device, It is characterized in that The device comprises: An acquisition module, used for acquiring a first feature of a preset attribute from a binary file in the firmware; A first determination module, configured to determine a relative similarity between the first feature and the second feature based on a first number of feature values that co-occur in the first feature and the second feature; the second feature being a feature corresponding to the preset attribute in a preset firmware library; A second determination module, configured to determine the absolute similarity between the first feature and the second feature based on a second number of feature values in the first feature and the second feature where the feature values appear at the same positions; A generating module is used to generate a security detection result of the firmware according to the relative similarity and the absolute similarity.
9. A terminal device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing a computer program. It is characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
