Embedded device firmware parsing method, device, medium and electronic device
By reading firmware data and calculating information entropy, generating an information entropy result sequence and judging the validity of the parsing results, the problem of being unable to parse non-standard firmware headers in the existing technology is solved, and the applicability and security analysis efficiency of firmware parsing are improved. The safety of the vehicle system is ensured.
Patent Information
- Application Number
- CN202110050102.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-14
- Publication Date
- 2024-08-16
- Estimated Expiration
- 2041-01-14
AI Technical Summary
Existing firmware parsing methods rely on the firmware format structured feature library and cannot effectively parse firmware with non-standard firmware headers, resulting in inaccurate parsing results and difficulty in ensuring vehicle safety.
By reading the firmware data based on the analysis step size and offset, calculating information entropy, generating an information entropy result sequence, and judging whether there is valid information in the analysis results, information entropy is used as the feature evaluation index of the analysis results to improve the applicability and accuracy of the analysis method. Security analysis efficiency.
It achieves effective analysis of non-standard firmware, improves the applicability and safety analysis efficiency of the firmware analysis method, and ensures the safety of vehicle systems.
Smart Images

Figure CN112733151B
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer application technology, and in particular to a method, apparatus, medium and electronic device for analyzing firmware of an embedded device. Background Art
[0002] In recent years, with the rapid development of autonomous driving and Internet of Things technologies, the intelligence and networking of vehicles have been continuously promoted, and the software of embedded smart devices in vehicles has become very complex. The MCUs (Microcontroller Units) of smart cars are components directly related to the vehicle power system, safety protection system and other parts. The MCU includes firmware. Once there is a security problem with the firmware in the MCU, it can directly cause the vehicle to have brake failure, sudden acceleration and other conditions that seriously endanger the safety of the driver and passengers. Therefore, it is very necessary to conduct security analysis on the firmware in the MCU.
[0003] The key to security analysis of embedded device firmware is to parse the firmware in the embedded device. The current firmware parsing methods usually use binwalk, FACT or analysis software and methods derived from the "file-level block fingerprint (File Signature) identification method" to parse the structure of firmware data in embedded devices. However, the analysis software and methods derived from the "file-level block fingerprint (File Signature) identification method" rely on the completeness of the firmware format structured feature library for the firmware parsing results, and cannot provide effective parsing results for firmware with non-standard firmware headers in the firmware format structured feature library. Summary of the invention
[0004] The embodiments of the present application provide an embedded device firmware parsing method, apparatus, medium and electronic device, which can parse the firmware in the embedded device to improve the efficiency of security analysis of program logic.
[0005] In a first aspect, an embodiment of the present application provides a method for parsing firmware of an embedded device, the method comprising:
[0006] Read the firmware data of the firmware to be parsed according to the analysis step and offset;
[0007] Calculating the information entropy of the firmware data read in each analysis step respectively, and storing the information entropy to obtain an information entropy result sequence;
[0008] According to the information entropy result sequence, it is determined whether the parsing result of the firmware to be parsed contains valid information.
[0009] In a second aspect, an embodiment of the present application provides an embedded device firmware parsing device, the device comprising:
[0010] A firmware data reading module, used for reading the firmware data of the firmware to be parsed according to the analysis step and offset;
[0011] An information entropy calculation module, used to respectively calculate the information entropy of the firmware data read in each analysis step, and store the information entropy to obtain an information entropy result sequence;
[0012] The valid information determination module is used to determine whether there is valid information in the parsing result of the firmware to be parsed according to the information entropy result sequence.
[0013] In a third aspect, an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the embedded device firmware parsing method as described in the embodiment of the present application is implemented.
[0014] In a fourth aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the embedded device firmware parsing method as described in the embodiment of the present application is implemented.
[0015] The technical solution provided in the embodiment of the present application reads the firmware data of the firmware to be parsed according to the analysis step and offset; respectively calculates the information entropy of the firmware data read in each of the analysis steps, and stores the information entropy to obtain an information entropy result sequence; and determines whether the parsing result of the firmware to be parsed contains valid information according to the information entropy result sequence. The technical solution provided in the present application reads the firmware data in the firmware to be parsed in a manner that is more in line with the characteristics of the firmware data itself, and uses the information entropy that characterizes the data characteristics of the firmware data itself as the main indicator for the characteristic evaluation of the parsing result, so as to realize the parsing of the firmware to be parsed. The present application proposes an embedded device firmware parsing method based on the characteristics of the firmware data to be parsed, which improves the applicability of the firmware parsing method and effectively improves the efficiency of the security analysis of the program logic. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 It is a flowchart of an embedded device firmware parsing method provided in Embodiment 1 of the present application;
[0017] Figure 2 is a flowchart of another embedded device firmware parsing method provided in Embodiment 2 of the present application;
[0018] Figure 3 It is a structural diagram of an embedded device firmware parsing device provided in Embodiment 3 of the present application;
[0019] Figure 4 It is a structural schematic diagram of an electronic device provided in Example 5 of the present application. DETAILED DESCRIPTION
[0020] The present application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present application, rather than to limit the present application. It should also be noted that, for ease of description, only the parts related to the present application, rather than all structures, are shown in the accompanying drawings.
[0021] It should be mentioned before discussing the exemplary embodiments in more detail that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow charts describe the steps as sequential processes, many of the steps therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of the steps can be rearranged. The process can be terminated when its operation is completed, but can also have additional steps not included in the accompanying drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.
[0022] Embodiment 1
[0023] Figure 1 This is a flowchart of an embedded device firmware parsing method provided in the first embodiment of the present application. This embodiment can be applied to the case of parsing the firmware in an embedded device. The method can be executed by the embedded device firmware parsing device provided in the embodiment of the present application. The device can be implemented by software and / or hardware, and can be integrated into an electronic device running this system.
[0024] like Figure 1 As shown, the embedded device firmware parsing method includes:
[0025] S110. Read the firmware data of the firmware to be parsed according to the analysis step and the offset.
[0026] Firmware refers to the program written into the memory of the embedded device. Firmware data refers to the data file extracted from the firmware to be parsed. Specifically, firmware data can be extracted from the target embedded device carrying the firmware by means of online reading (ISP), simulation debugging (ICE), desoldering (Desoldering) the external memory (Flash) on the motherboard, etc.
[0027] Among them, the analysis step refers to the length of the firmware data read at one time. Exemplarily, when the analysis step is 32 words long, when reading the firmware data of the firmware to be parsed, a segment of firmware data with a length of 32 words is read each time. After reading the firmware data with a length of one analysis step, the starting position of the next firmware data read is determined according to the offset, and this position is the offset address. The analysis step and the offset jointly determine the interval of the firmware data to be read, and all the firmware data is read according to the analysis step and the offset.
[0028] In order to obtain as much valid information as possible from the firmware to be parsed, it is necessary to comprehensively consider the relevant information of the firmware to be parsed. In an optional embodiment, before reading the firmware data of the firmware to be parsed according to the analysis step and offset, the method also includes: obtaining the product configuration information of the firmware to be parsed, and loading the firmware data of the firmware to be parsed; determining the initial analysis step and the initial offset according to the product configuration information and the firmware data.
[0029] Among them, product configuration information refers to descriptive information used to describe the firmware to be parsed and the product that carries the firmware to be parsed. Specifically, the product configuration information includes but is not limited to: product model, controller type, big-endian and small-endian modes, and the system and communication unit running on the firmware. The more comprehensive the product configuration information is, the more likely it is that the firmware data read according to the initial analysis step and initial offset determined by it will include valid information. Before reading the firmware data, the firmware data is first loaded into the firmware security analysis platform. Optionally, according to the size of different firmware data, the parallel loading module can be used to optimize the efficiency of firmware data loading.
[0030] Determine the initial analysis step and initial offset based on product configuration information and firmware data. Optionally, use the register word length (Bytes Width) for embedded device hardware attributes as the initial value of the key variable of the analysis step, and use the improved Binwalk software to obtain the analysis step according to the file length of the firmware data. Among them, Binwalk can automatically complete the scanning of specified files and intelligently discover all suspicious file types and file systems hidden in the files. Binwalk has functions such as text filtering, file extraction, byte comparison and information entropy analysis, and is an essential tool for firmware analysis.
[0031] In an optional embodiment, the firmware to be parsed is firmware in an MCU (Microcontroller Unit).
[0032] MCU has the characteristics of single function, closed system environment, close and direct connection with hardware, and firmware containing control logic expression is difficult to obtain. The firmware of MCU is different from the firmware of consumer-grade smart devices (such as home routers and network cameras). In the process of generating the firmware of MCU, most of them do not need to be processed by file compression, but directly compile the source code through the compilation tool, and then generate the firmware burned in the MCU. The firmware of consumer-grade smart devices is usually stored in the external memory of the device in the form of compressed files, specific file system images, etc., and the firmware data form of MCU is richer. In view of the above-mentioned characteristics of MCU, the firmware parsing method proposed in the embodiment of the present application is closer to the characteristics of the firmware data itself. The firmware parsing method provided in this embodiment can not only parse out the valid information in the MCU firmware, but also can be used to parse the valid information in the MPU (Microprocessor Unit, microprocessor) firmware. In addition, the firmware parsing method proposed in the embodiment of the present invention is applied to GPU (Graphics Processing Unit, Graphics Processing Unit) for parallel firmware data processing, which can improve the efficiency of security analysis of program logic.
[0033] S120, respectively calculating the information entropy of the firmware data read in each analysis step, and storing the information entropy to obtain an information entropy result sequence.
[0034] Among them, information entropy is used to represent the amount of information or the degree of data confusion, and E is used x Representation. Calculate the information entropy of the firmware data read in each analysis step respectively. Specifically, the entropy spectrum of the firmware to be parsed can be obtained through the -E command of Binwalk, and then calculate the information entropy of the firmware data read in each analysis step respectively. It is worth noting that a segment of firmware data with the same length as the analysis step is read in one analysis step. The firmware data in the firmware to be parsed can be divided into multiple firmware data segments according to the analysis step and the offset. Setting the offset to different values may cause intersections between the firmware data segments. It is worth noting that the size of the offset should be less than or equal to the length of the analysis step. By setting it in this way, it can be ensured that all the firmware data of the firmware to be parsed can be read. The number of firmware data segments is not limited here, and it is determined according to the actual situation. Each firmware data segment corresponds to an information entropy. Optionally, the information entropy is stored according to the offset address to obtain the information entropy result sequence [E1, E2, E3…E m Specifically, the information entropy value of the firmware data segment corresponding to the offset address can be stored in the order of increasing offset addresses to obtain an information entropy result sequence. The amount of information entropy in the information entropy result sequence is consistent with the number of times the firmware data in the firmware to be parsed is read.
[0035] In an optional embodiment, before respectively calculating the information entropy of the firmware data read within each analysis step, the method further includes: if the length of the firmware data read within the analysis step is inconsistent with the analysis step, padding the firmware data.
[0036] Since the firmware file length and the analysis step may not completely match, for example, when the analysis step is 32 words long, after multiple readings, only a 16-word firmware data segment is read for the last time. Since the information entropy of the firmware data read within the analysis step needs to be calculated, it is necessary to make the length of the firmware data segment read within each analysis step consistent. If the length of the firmware data read within the analysis step is inconsistent with the analysis step, the firmware data is padded. Specifically, the number 0 can be added to the firmware data to make the firmware data length consistent with the analysis step, thereby completing the calculation of the information entropy of the firmware data read within each analysis step.
[0037] S130. Determine whether the parsing result of the firmware to be parsed contains valid information according to the information entropy result sequence.
[0038] Since information entropy reflects the amount of information, by analyzing the changes in the information entropy values in the entire information entropy result sequence, it is possible to determine whether there are obvious differences in the distribution of information entropy values in different areas of the firmware data, and then determine whether there is valid information in the analysis results.
[0039] Since parsing the firmware is a necessary step in firmware vulnerability mining or firmware security analysis, the firmware parsing results obtained are used as input for the subsequent process of analyzing the program logic in the firmware. In the embodiment of the present application, whether there is valid information in the parsing results of the firmware to be parsed is determined by whether the information included in the parsing results is useful for the subsequent program logic analysis process. Specifically, information such as firmware landmark data, whether the firmware data is encrypted, and the encryption method of the firmware data can be obtained from the parsing results, and then it can be regarded that the parsing results include valid information.
[0040] According to the information entropy result sequence, determine whether there is valid information in the analysis result of the firmware to be analyzed. Specifically, it can be determined whether there is an obvious rising edge in the information entropy result sequence. Exemplarily, the difference between adjacent information entropy values is compared with a difference threshold. If the difference is greater than the difference threshold, it can be determined that there is an obvious rising edge in the information entropy result sequence. Among them, the difference threshold refers to a value pre-set by a technician according to actual conditions, and is not limited here. Exemplarily, the difference threshold can be 0.05.
[0041] The technical solution provided in the embodiment of the present application reads the firmware data of the firmware to be parsed according to the analysis step and offset; respectively calculates the information entropy of the firmware data read in each of the analysis steps, and stores the information entropy to obtain an information entropy result sequence; and determines whether the parsing result of the firmware to be parsed contains valid information according to the information entropy result sequence. The technical solution provided in the present application reads the firmware data in the firmware to be parsed in a manner that is more in line with the characteristics of the firmware data itself, and uses the information entropy that characterizes the data characteristics of the firmware data itself as the main indicator for the characteristic evaluation of the parsing result, so as to realize the parsing of the firmware to be parsed. The present application proposes an embedded device firmware parsing method based on the characteristics of the firmware data to be parsed, which improves the applicability of the firmware parsing method and effectively improves the efficiency of the security analysis of the program logic.
[0042] Embodiment 2
[0043] Figure 2 It is a flowchart of another embedded device firmware parsing method provided in Example 2 of the present application. This embodiment is further optimized on the basis of the above-mentioned embodiment. The specific optimization is to determine whether there is valid information in the parsing result of the firmware to be parsed according to the information entropy result sequence, including at least one of the following: if there is information entropy falling into the first preset numerical range in the information entropy result sequence, it is determined that there is valid information of sensitive information leakage risk in the firmware to be parsed; if there is a second set number of consecutive information entropies in the information entropy result sequence, and the regular fluctuations occur in a specific position of the firmware to be parsed, it is determined that the firmware to be parsed includes valid information of software symbols or debugging information; if there is information entropy not less than the third set numerical value in the information entropy result sequence, it is determined that there is no valid information with encrypted data part in the firmware to be parsed.
[0044] like Figure 2 As shown, the embedded device firmware parsing method includes:
[0045] S210: Read the firmware data of the firmware to be parsed according to the analysis step and the offset.
[0046] S220, respectively calculating the information entropy of the firmware data read within each analysis step, and storing the information entropy to obtain an information entropy result sequence.
[0047] S230: If there is information entropy falling within a first preset value range in the information entropy result sequence, valid information is determined to indicate that there is a risk of sensitive information leakage in the firmware to be parsed.
[0048] Among them, the first preset numerical range is an empirical value set by relevant technical personnel according to actual conditions, which is not limited here and is determined according to actual conditions. For example, the first preset numerical range is (0.45, 0.85], which means the information entropy result sequence [E1, E2, E3...E m ] has an information entropy value E corresponding to any offset address i ∈(0.45, 0.85], indicating that the firmware data of the firmware to be parsed contains a large amount of plaintext data, and there is a risk of sensitive information leakage in the firmware to be parsed.
[0049] S240: If there is a second set number of consecutive regular fluctuations in the information entropy result sequence, and the regular fluctuations occur at a specific position of the firmware to be parsed, it is determined that the firmware to be parsed includes valid information of software symbols or debugging information.
[0050] Among them, the second set number is an empirical value set by relevant technical personnel according to actual conditions, which is not limited here and is determined specifically according to actual conditions. Regular fluctuation refers to the change trend of the information entropy sequence between offset address m and offset address n, and it appears again in the information entropy result sequence, then the change trend of the information entropy sequence is a regular fluctuation. The number of information entropies corresponding to offset address m and offset address n is the second set number. The specific information entropy change trend is not limited here and is determined specifically according to actual conditions. Optionally, the regular fluctuation of the information entropy result sequence is determined by applying statistical analysis on the firmware security analysis platform. Since the firmware data includes information such as the firmware header structure, device identification information, and firmware format identification, and the above information is not disordered in the firmware data, it has a certain arrangement order. Therefore, when it is found that the information entropy result sequence of the firmware data has regular fluctuations, the position where the information entropy regular fluctuation occurs is further judged. If there are regular fluctuations in the information entropy result sequence for a continuous second set number of regular fluctuations, and the regular fluctuations appear at the specific position of the firmware to be parsed, it is determined that the firmware to be parsed includes valid information of software symbols or debugging information.
[0051] S250: If there is an information entropy not less than a third set value in the information entropy result sequence, it is determined that there is no valid information with an encrypted data portion in the firmware to be parsed.
[0052] Among them, the third set value is an empirical value set by relevant technical personnel according to actual conditions, which is not limited here and is determined according to actual conditions. Specifically, the third set value can be set to a larger value. Exemplarily, the third set value is set to 0.98. If there is an information entropy of not less than 0.98 in the information entropy result sequence, that is, there is an information entropy with a value greater than or equal to 0.98 in the information entropy result sequence, it is determined that there is no valid information with an encrypted data part in the firmware to be parsed.
[0053] If, by analyzing the information entropy result sequence of the firmware to be parsed, it is determined that there is no obvious difference in the distribution of information entropy values in different areas of the firmware data, it indicates that there is no valid information in the parsing result of the firmware to be parsed. The reason for the absence of valid information in the parsing result may be that the analysis step size is not compatible with the firmware data, the analysis step size is too large or too small, and the length of the firmware data segment read at one time is too long or too short, making the information entropy difference corresponding to the firmware data segment not obvious. In this case, it is necessary to adjust the analysis step size, adjust the length of the firmware data read at one time, and then parse the firmware to be parsed again according to the embedded device firmware parsing method provided in Example 1 of the present application.
[0054] In order to more accurately determine whether there is valid information in the analysis result, in an optional embodiment, after obtaining the information entropy result sequence, the method also includes: generating an information entropy statistical histogram based on the information entropy result sequence, and displaying the information entropy statistical histogram to the user, so that the user can judge whether there is valid information in the analysis result based on the information entropy statistical histogram.
[0055] The information entropy statistical histogram is a statistical histogram generated based on the information entropy result sequence, the horizontal axis of the information entropy statistical histogram is the offset address, and the vertical axis is the information entropy of the firmware data segment corresponding to the offset address.
[0056] The information entropy statistical histogram is more intuitive than the information entropy result sequence. After the firmware security analysis platform automatically determines whether there is valid information in the analysis result, the information entropy statistical histogram can be sent to the user. The user can judge whether there is an obvious rising edge in the information entropy statistical histogram based on the information entropy statistical histogram, and then judge whether there is valid information in the analysis result.
[0057] In an optional embodiment, after determining that the parsing result of the firmware to be parsed does not contain valid information, the method further includes: adjusting the analysis step length according to a preset rule to update the initial analysis step length.
[0058] Among them, the preset rule refers to a rule that is pre-set by relevant technical personnel according to actual conditions, which is not limited here and is determined specifically according to actual conditions. Exemplarily, the preset rule can be a rule that gradually increases the value of the analysis step. The initial value of the analysis step can be set to a smaller value. After determining that the analysis result of the firmware to be analyzed does not contain valid information, the value of the analysis step can be appropriately increased to obtain the adjusted analysis step, and the initial analysis step is updated with the adjusted analysis step, and then the firmware data is read according to the updated analysis step. Correspondingly, the preset rule can also be a rule that gradually decreases the value of the analysis step. The initial value of the analysis step can be set to a larger value. After determining that the analysis result of the firmware to be analyzed does not contain valid information, the value of the analysis step can be appropriately reduced to obtain the adjusted analysis step, and the initial analysis step is updated with the adjusted analysis step, and then the firmware data is read according to the updated analysis step. Optionally, in addition to increasing or decreasing the analysis step size unidirectionally, an automatic analysis step size adjustment method can also be used to automatically adjust the analysis step size based on the analysis step size, the information entropy result column corresponding to the analysis step size, and a large amount of statistical data of the analysis results.
[0059] Optionally, in addition to judging whether there is valid information in the analysis result based on the value of each information entropy in the information entropy result sequence and the change trend of the information entropy in the sequence, the valid information in the firmware data can also be extracted through the firmware data structure feature identifiers such as the firmware header identifier and the firmware structure identifier in the firmware data. By reading the firmware data, suspected firmware marker data can be extracted. Exemplarily, the extracted data can be BDCfg\x00. The comprehensive firmware data structure feature identifiers and the analysis results of the information entropy result sequence can also correctly identify interference data and provide users with recommended program starting positions and file offsets in the firmware. The program starting position and the file offset in the firmware are of great significance to the software function logic analysis. The correct program starting position and the file offset information in the firmware can prevent large-scale analysis failures due to relative address errors during the program logic analysis.
[0060] The technical solution provided in the embodiment of the present application reads the firmware data of the firmware to be parsed according to the analysis step and offset; respectively calculates the information entropy of the firmware data read in each of the analysis steps, and stores the information entropy to obtain an information entropy result sequence; and determines whether the parsing result of the firmware to be parsed contains valid information according to the information entropy result sequence. The technical solution provided in the present application reads the firmware data in the firmware to be parsed in a manner that is more in line with the characteristics of the firmware data itself, and uses the information entropy that characterizes the data characteristics of the firmware data itself as the main indicator for the characteristic evaluation of the parsing result, so as to realize the parsing of the firmware to be parsed. The present application proposes an embedded device firmware parsing method based on the characteristics of the firmware data to be parsed, which improves the applicability of the firmware parsing method and effectively improves the efficiency of the security analysis of the program logic.
[0061] Embodiment 3
[0062] Figure 3 The third embodiment of the present application provides an embedded device firmware parsing device, which can be applied to the situation of parsing the firmware in the embedded device. The device can be implemented by software and / or hardware, and can be integrated into electronic devices such as smart terminals.
[0063] like Figure 3 As shown, the device may include: a firmware data reading module 310, an information entropy calculation module 320 and a valid information determination module 330.
[0064] The firmware data reading module 310 is used to read the firmware data of the firmware to be parsed according to the analysis step and the offset;
[0065] An information entropy calculation module 320, used to respectively calculate the information entropy of the firmware data read in each analysis step, and store the information entropy to obtain an information entropy result sequence;
[0066] The valid information determination module 330 is used to determine whether the parsing result of the firmware to be parsed contains valid information according to the information entropy result sequence.
[0067] The technical solution provided in the embodiment of the present application reads the firmware data of the firmware to be parsed according to the analysis step and offset; respectively calculates the information entropy of the firmware data read in each of the analysis steps, and stores the information entropy to obtain an information entropy result sequence; and determines whether the parsing result of the firmware to be parsed contains valid information according to the information entropy result sequence. The technical solution provided in the present application reads the firmware data in the firmware to be parsed in a manner that is more in line with the characteristics of the firmware data itself, and uses the information entropy that characterizes the data characteristics of the firmware data itself as the main indicator for the characteristic evaluation of the parsing result, so as to realize the parsing of the firmware to be parsed. The present application proposes an embedded device firmware parsing method based on the characteristics of the firmware data to be parsed, which improves the applicability of the firmware parsing method and effectively improves the efficiency of the security analysis of the program logic.
[0068] Optionally, the device also includes: a firmware data filling module, which is used to fill the firmware data before calculating the information entropy of the firmware data read in each analysis step, if the length of the firmware data read within the analysis step is inconsistent with the analysis step.
[0069] Optionally, the valid information determination module 330 includes at least one of the following valid information determination submodules:
[0070] A first valid information determination submodule, configured to determine valid information indicating that the firmware to be parsed has a risk of sensitive information leakage if there is information entropy falling within a first preset value range in the information entropy result sequence;
[0071] A second valid information determination submodule is used to determine that the firmware to be parsed includes valid information of software symbols or debugging information if there is a second set number of consecutive regular fluctuations in the information entropy result sequence, and the regular fluctuations appear at a specific position of the firmware to be parsed;
[0072] The third valid information determination submodule is used to determine that there is no valid information with an encrypted data part in the firmware to be parsed if there is an information entropy not less than a third set value in the information entropy result sequence.
[0073] Optionally, the device also includes: an information acquisition module, used to obtain product configuration information of the firmware to be parsed and load the firmware data of the firmware to be parsed before reading the firmware data of the firmware to be parsed according to the analysis step and the offset; an initial analysis step and initial offset determination module, used to determine the initial analysis step and the initial offset according to the product configuration information and the firmware data.
[0074] Optionally, the device further includes: an analysis step updating module, configured to adjust the analysis step according to a preset rule to update the initial analysis step after determining that the analysis result of the firmware to be analyzed does not contain valid information.
[0075] Optionally, the device also includes: an information entropy statistical histogram generation module, which is used to generate an information entropy statistical histogram according to the information entropy result sequence after obtaining the information entropy result sequence, and display the information entropy statistical histogram to the user so that the user can judge whether there is valid information in the analysis result based on the information entropy statistical histogram.
[0076] Optionally, the firmware to be parsed is firmware in the MCU.
[0077] An embedded device firmware parsing apparatus provided by an embodiment of the present invention can execute an embedded device firmware parsing method provided by any embodiment of the present invention, and has corresponding functional modules and beneficial effects for executing an embedded device firmware parsing method.
[0078] Embodiment 4
[0079] Embodiment 4 of the present application further provides a storage medium including computer executable instructions, wherein the computer executable instructions are used to execute a method for parsing firmware of an embedded device when executed by a computer processor, the method comprising:
[0080] Read the firmware data of the firmware to be parsed according to the analysis step and offset;
[0081] Calculating the information entropy of the firmware data read in each analysis step respectively, and storing the information entropy to obtain an information entropy result sequence;
[0082] According to the information entropy result sequence, it is determined whether the parsing result of the firmware to be parsed contains valid information.
[0083] Storage media refers to any of various types of memory electronic devices or storage electronic devices. The term "storage medium" is intended to include: installation media, such as CD-ROM, floppy disk or tape device; computer system memory or random access memory, such as DRAM, DDR RAM, SRAM, EDO RAM, Rambus RAM, etc.; non-volatile memory, such as flash memory, magnetic media (such as hard disk or optical storage); registers or other similar types of memory elements, etc. The storage medium may also include other types of memory or combinations thereof. In addition, the storage medium may be located in the computer system in which the program is executed, or may be located in a different second computer system, which is connected to the computer system via a network (such as the Internet). The second computer system can provide program instructions to the computer for execution. The term "storage medium" may include two or more storage media that may reside in different unknowns (for example, in different computer systems connected via a network). The storage medium may store program instructions (for example, embodied as a computer program) that can be executed by one or more processors.
[0084] Of course, the storage medium containing computer executable instructions provided in the embodiment of the present application is not limited to the embedded device firmware parsing operations described above, and can also execute related operations in the embedded device firmware parsing method provided in any embodiment of the present application.
[0085] Embodiment 5
[0086] Embodiment 5 of the present application provides an electronic device, in which the embedded device firmware parsing apparatus provided in the embodiment of the present application can be integrated. The electronic device can be configured in a system, or can be a device that executes part or all of the functions in the system. Figure 4 Schematic diagram of the structure of an electronic device provided in Embodiment 5 of the present application. Figure 4 As shown, this embodiment provides an electronic device 400, which includes: one or more processors 420; a storage device 410, which is used to store one or more programs. When the one or more programs are executed by the one or more processors 420, the one or more processors 420 implement the embedded device firmware parsing method provided in the embodiment of the present application, and the method includes:
[0087] Read the firmware data of the firmware to be parsed according to the analysis step and offset;
[0088] Calculating the information entropy of the firmware data read in each analysis step respectively, and storing the information entropy to obtain an information entropy result sequence;
[0089] According to the information entropy result sequence, it is determined whether the parsing result of the firmware to be parsed contains valid information.
[0090] Of course, those skilled in the art can understand that the processor 420 also implements the technical solution of the embedded device firmware parsing method provided in any embodiment of the present application.
[0091] Figure 4 The electronic device 400 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0092] like Figure 4 As shown, the electronic device 400 includes a processor 420, a storage device 410, an input device 430, and an output device 440; the number of the processor 420 in the electronic device can be one or more. Figure 4 A processor 420 is taken as an example; the processor 420, the storage device 410, the input device 430 and the output device 440 in the electronic device can be connected via a bus or other means. Figure 4 The connection via bus 450 is taken as an example.
[0093] The storage device 410 is a computer-readable storage medium that can be used to store software programs, computer executable programs, and module units, such as program instructions corresponding to the embedded device firmware parsing method in the embodiment of the present application.
[0094] The storage device 410 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the terminal, etc. In addition, the storage device 410 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the storage device 410 may further include a memory remotely arranged relative to the processor 420, and these remote memories may be connected via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0095] The input device 430 may be used to receive input numbers, character information or voice information, and generate key signal input related to user settings and function control of the electronic device. The output device 440 may include electronic devices such as a display screen and a speaker.
[0096] The electronic device provided by the embodiment of the present application can improve the efficiency of security analysis of program logic when parsing the firmware in the embedded device.
[0097] The embedded device firmware parsing apparatus, medium and electronic device provided in the above embodiments can execute the embedded device firmware parsing method provided in any embodiment of the present application, and have the corresponding functional modules and beneficial effects of executing the method. For technical details not described in detail in the above embodiments, please refer to the embedded device firmware parsing method provided in any embodiment of the present application.
[0098] Note that the above are only preferred embodiments of the present application and the technical principles used. Those skilled in the art will understand that the present application is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present application. Therefore, although the present application is described in more detail through the above embodiments, the present application is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the appended claims.
Claims
1. A method for analyzing firmware of an embedded device, It is characterized in that The method comprises: Reading firmware data of the firmware to be parsed according to the analysis step length and the offset; wherein the analysis step length is the length of the firmware data read once, and the length of the offset is less than or equal to the length of the analysis step length; Calculating the information entropy of the firmware data read in each analysis step respectively, and storing the information entropy to obtain an information entropy result sequence; Determining whether the parsing result of the firmware to be parsed contains valid information according to the information entropy result sequence; Determining whether the parsing result of the firmware to be parsed contains valid information according to the information entropy result sequence includes at least one of the following: If there is information entropy falling within a first preset value range in the information entropy result sequence, valid information is determined to indicate that there is a risk of sensitive information leakage in the firmware to be parsed; If there is a second set number of consecutive regular fluctuations in information entropy in the information entropy result sequence, and the regular fluctuations appear at a specific position of the firmware to be parsed, it is determined that the firmware to be parsed includes valid information of software symbols or debugging information; If there is an information entropy not less than a third set value in the information entropy result sequence, it is determined that there is no valid information with an encrypted data portion in the firmware to be parsed; After determining that the parsing result of the firmware to be parsed does not contain valid information, the method further includes: The analysis step size is adjusted according to a preset rule to update the initial analysis step size.
2. The method according to claim 1, It is characterized in that Before respectively calculating the information entropy of the firmware data read in each of the analysis steps, the method further includes: If the length of the firmware data read within the analysis step is inconsistent with the analysis step, the firmware data is padded.
3. The method according to claim 1, It is characterized in that Before reading the firmware data of the firmware to be parsed according to the analysis step and the offset, the method further includes: Obtain product configuration information of the firmware to be parsed, and load firmware data of the firmware to be parsed; An initial analysis step length and an initial offset are determined according to the product configuration information and the firmware data.
4. The method according to claim 1, It is characterized in that After obtaining the information entropy result sequence, the method further includes: An information entropy statistical histogram is generated according to the information entropy result sequence, and the information entropy statistical histogram is displayed to a user so that the user can judge whether there is valid information in the analysis result according to the information entropy statistical histogram.
5. The method according to any one of claims 1 to 4, It is characterized in that The firmware to be parsed is the firmware in the MCU.
6. An embedded device firmware parsing device, It is characterized in that The device comprises: A firmware data reading module, used to read the firmware data of the firmware to be parsed according to the analysis step length and the offset; wherein the analysis step length is the length of the firmware data read at one time, and the length of the offset is less than or equal to the length of the analysis step length; An information entropy calculation module, used to respectively calculate the information entropy of the firmware data read in each analysis step, and store the information entropy to obtain an information entropy result sequence; A valid information determination module, used for determining whether there is valid information in the parsing result of the firmware to be parsed according to the information entropy result sequence; The valid information determination module includes at least one of the following valid information determination submodules: A first valid information determination submodule, configured to determine valid information indicating that the firmware to be parsed has a risk of sensitive information leakage if there is information entropy falling within a first preset value range in the information entropy result sequence; A second valid information determination submodule, configured to determine that the firmware to be parsed includes valid information of software symbols or debugging information if there is a second set number of consecutive regular fluctuations in the information entropy result sequence, and the regular fluctuations occur at a specific position of the firmware to be parsed; A third valid information determination submodule, configured to determine that there is no valid information with an encrypted data portion in the firmware to be parsed if there is an information entropy not less than a third set value in the information entropy result sequence; The device further comprises: an analysis step length updating module, which is used to adjust the analysis step length according to a preset rule to update the initial analysis step length after determining that the analysis result of the firmware to be analyzed does not contain valid information.
7. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the embedded device firmware parsing method according to any one of claims 1 to 5 is implemented.
8. An electronic 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 embedded device firmware parsing method according to any one of claims 1 to 5 is implemented.
