Software integrity detection method, device, electronic device and storage medium
By generating and comparing the verification codes of files before and after software installation, the problem of error judgment of software integrity detection in the prior art is solved, and the accuracy of detection is improved.
Patent Information
- Application Number
- CN202110768819.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-07
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2041-07-07
AI Technical Summary
The prior art may cause incorrect judgments when detecting software integrity, resulting in the inability to accurately identify whether the software has been tampered with or damaged.
By obtaining the initial file before the software installation and the files to be detected after the installation, the initial file verification code and the file verification code to be detected respectively, and the first and second verification codes are generated based on these verification codes. The integrity of the software is judged by comparing the initial file verification code with the file verification code to be detected, as well as the first verification code and the second verification code.
It improves the accuracy of software integrity detection, reduces the possibility of wrong judgments, and ensures accurate evaluation of software integrity.
Smart Images

Figure CN113536309B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software security, and in particular to a method, device, electronic device and storage medium for detecting software integrity. Background Art
[0002] Since files may be tampered or lost during the installation or operation of configuration software, there are often many vulnerabilities in configuration software. When using configuration software, serious consequences may occur, such as malicious destruction of the configuration software's running process, tampering of system resource configuration, malicious files being implanted into the execution program, and key data being stolen. In order to timely discover vulnerabilities in configuration software and avoid problems such as incorrect dynamic link library dependencies, missing binary files, and abnormal basic functions of configuration software, it is necessary to detect the file integrity of the configuration software after installation and during operation.
[0003] In order to implement the file integrity detection of the configuration software, the prior art first encodes the installation software, and after installation, encodes it again when the software needs to be used, and determines whether the software has been modified, damaged, etc. through the matching results of the previous and subsequent encodings, thereby obtaining the detection result of the software integrity. However, in the prior art, when encoding different software, there may be a situation where the encoding results match, which may lead to an erroneous judgment when detecting the integrity of the software.
[0004] There is no effective solution to the technical problem that incorrect judgment may occur when checking the integrity of software in related technologies. Summary of the invention
[0005] In this embodiment, a method, device, electronic device and storage medium for detecting software integrity are provided to solve the problem of possible erroneous judgment when detecting software integrity in related technologies.
[0006] In a first aspect, a method for detecting software integrity is provided in this embodiment, including:
[0007] Acquire multiple initial files, generate multiple initial file verification codes based on the initial files respectively, and generate a first verification code based on the initial files and the initial file verification codes, wherein the initial files include all files before the software to be detected is installed;
[0008] Acquire multiple files to be detected, generate multiple verification codes of the files to be detected based on the files to be detected respectively, and generate a second verification code based on the files to be detected and the verification codes of the files to be detected, wherein the files to be detected are files corresponding to the initial files that are re-acquired after the software to be detected is installed;
[0009] It is determined whether the initial file verification code and the to-be-detected file verification code both match. If they both match, it is further determined whether the first verification code matches the second verification code. If they match, it is determined that the to-be-detected software is complete software.
[0010] In some embodiments, the generating a plurality of initial file verification codes based on the initial file respectively, and generating a first verification code based on the initial file and the initial file verification code comprises:
[0011] Processing the initial file based on a message digest algorithm to generate a plurality of initial file verification codes;
[0012] The initial file and the initial file verification code are processed based on a message digest algorithm to generate the first verification code.
[0013] In some embodiments, generating a first verification code based on the initial file and the initial file verification code includes:
[0014] Saving the initial file and the initial file verification code to an initial file set respectively;
[0015] A first verification code is generated based on the initial file set.
[0016] In some embodiments, the generating a plurality of verification codes of the files to be detected based on the files to be detected respectively, and generating a second verification code based on the files to be detected and the verification codes of the files to be detected includes:
[0017] Processing the file to be detected based on a message digest algorithm to generate a plurality of verification codes of the file to be detected;
[0018] The file to be detected and the verification code of the file to be detected are processed based on a message digest algorithm to generate the second verification code.
[0019] In some embodiments, generating a second verification code based on the file to be detected and the verification code of the file to be detected includes:
[0020] The to-be-detected file and the to-be-detected file verification code are respectively saved in a to-be-detected file set;
[0021] A second verification code is generated based on the set of files to be detected.
[0022] In some embodiments, after respectively determining whether the initial file verification code matches the verification code of the file to be detected, the method further includes:
[0023] If there is no match, the software to be detected is determined to be incomplete software, and the determination result is returned.
[0024] In some embodiments, after determining that the software to be detected is incomplete software, the method further includes:
[0025] The file to be detected is updated based on the initial file.
[0026] In a second aspect, a software integrity detection device is provided in this embodiment, including:
[0027] A first acquisition module is used to acquire multiple initial files, generate multiple initial file verification codes based on the initial files respectively, and generate a first verification code based on the initial files and the initial file verification codes, wherein the initial files include all files accessed during the installation process of the software to be detected;
[0028] A second acquisition module is used to acquire multiple files to be detected, generate multiple verification codes of the files to be detected based on the files to be detected, and generate a second verification code based on the files to be detected and the verification codes of the files to be detected, wherein the files to be detected are files corresponding to the initial files that are re-acquired after the software to be detected is installed;
[0029] The judgment module is used to judge whether the initial file verification code and the verification code of the file to be detected match each other. If they match, it is further judged whether the first verification code matches the second verification code. If they match, it is determined that the software to be detected is complete software.
[0030] In a third aspect, an electronic device is provided in this embodiment, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the software integrity detection method described in the first aspect when executing the computer program.
[0031] In a fourth aspect, a storage medium is provided in this embodiment, on which a computer program is stored, and when the program is executed by a processor, the method for detecting software integrity described in the first aspect is implemented.
[0032] Compared with the related art, the software integrity detection method, device, electronic device and storage medium provided in this embodiment obtain multiple initial files, generate multiple initial file verification codes based on the initial files respectively, and generate a first verification code based on the initial files and the initial file verification code, wherein the initial files include all files accessed during the installation of the software to be detected; obtain multiple files to be detected, generate multiple file verification codes based on the files to be detected respectively, and generate a second verification code based on the files to be detected and the file verification code to be detected, wherein the files to be detected are files corresponding to the initial files re-acquired after the software to be detected is installed; respectively determine whether the initial file verification code and the file verification code to be detected are matched, if they are matched, further determine whether the first verification code and the second verification code are matched, if they are matched, determine that the software to be detected is complete software. The integrity of the software to be detected is determined by the matching relationship between the initial file verification code and the file verification code to be detected and the first verification code and the second verification code, which solves the technical problem that an erroneous judgment may occur when detecting the integrity of the software, and improves the accuracy of software integrity detection.
[0033] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0035] Figure 1 It is a block diagram of the terminal hardware structure of a method for detecting software integrity according to an embodiment of the present invention;
[0036] Figure 2 It is a flowchart of a method for detecting software integrity according to an embodiment of the present invention;
[0037] Figure 3 It is a structural block diagram of a software integrity detection device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0038] In order to more clearly understand the purpose, technical solutions and advantages of the present application, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments.
[0039] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the general meaning understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the", "these" and the like in this application do not represent quantitative restrictions, and they can be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether directly or indirectly. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, "A and / or B" can mean: A exists alone, A and B exist at the same time, and B exists alone. Usually, the character " / " indicates that the objects associated with each other are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0040] The method embodiment provided in this embodiment can be executed in a terminal, a computer or a similar computing device. For example, running on a terminal, Figure 1 FIG. 1 is a hardware structure diagram of a terminal of the software integrity detection method of this embodiment. Figure 1 As shown, the terminal may include one or more ( Figure 1 Only one is shown in the figure) processor 102 and memory 104 for storing data, wherein processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA. The above terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is for illustration only and does not limit the structure of the above terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.
[0041] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the software integrity detection method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the terminal 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.
[0042] The transmission device 106 is used to receive or send data via a network. The above network includes a wireless network provided by the communication provider of the terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.
[0043] See also Figure 2 , Figure 2 FIG. 1 is a flow chart of a method for detecting software integrity according to an embodiment of the present invention. In this embodiment, the method for detecting software integrity includes:
[0044] S202: Acquire multiple initial files, generate multiple initial file verification codes based on the initial files respectively, and generate a first verification code based on the initial files and the initial file verification codes, wherein the initial files include all files before the software to be detected is installed.
[0045] Exemplarily, the initial files of the software to be tested are obtained, each initial file is mapped separately, a unique verification code is generated as the initial file verification code corresponding to each initial file, and then all the initial files and initial file verification codes are mapped as a whole to obtain a first verification code.
[0046] Specifically, the software to be tested is software that needs to be tested for integrity, where the integrity of the software includes two aspects: one is the integrity of the software code itself, including all program files, configuration information, etc. of the software; the other is the integrity of the software's operating environment, such as the software's executable files, configuration files, and attached runtime libraries. If the above content is tampered with, lost, or implanted, it indicates that the software to be tested is incomplete. In one of the specific embodiments, the software to be tested includes configuration software. Configuration software is also called configuration monitoring system software, which refers to special software for data acquisition and control during the control process, and is applied to the software platform and development environment of the monitoring layer of the automatic control system.
[0047] Specifically, the initial files may be all the preparation files before the software to be tested is installed, including various files in the software to be tested and its running environment. Since the initial files have not been installed or run, there is no possibility of tampering, loss, etc., and they can be used as standard files of the software to be tested. In one specific embodiment, the initial files are all the files in the installation package of the software to be tested.
[0048] Specifically, generating the initial file verification code based on the initial file may be to obtain the source code of the initial file, map the source code of the initial file to a code, and generate the initial file verification code. Generating the first verification code based on the initial file and the initial file verification code may be to treat all the initial files and the initial file verification codes as a whole file, and generate the first verification code on this basis. The initial file verification code and the first verification code are used to identify the initial file and the whole file respectively. If the verification code of a certain file matches the initial file verification code or the first verification code, it indicates that the two files are the same.
[0049] S204: Acquire multiple files to be detected, generate multiple file verification codes based on the files to be detected, and generate a second verification code based on the files to be detected and the file verification codes. The files to be detected are files corresponding to the initial files that are re-acquired after the software to be detected is installed.
[0050] Exemplarily, the files to be tested of the software to be tested are obtained, each file to be tested is mapped respectively, a unique verification code is generated as the file verification code to be tested corresponding to each file to be tested, and then all the files to be tested and the file verification codes to be tested are mapped as a whole to obtain a second verification code.
[0051] Specifically, the file to be detected is a file corresponding to the initial file accessed during the operation of the software to be detected, including the files of the software to be detected itself and various files in the operating environment. Specifically, the file to be detected can be a file corresponding to the initial file that is re-acquired after installation, which is used to determine whether the software to be detected has been tampered with, lost, etc. during the installation process; it can also be a file corresponding to the initial file that is re-acquired when the software is running, which is used to determine whether the software to be detected has been tampered with, lost, etc. during the operation process. In one of the specific embodiments, when the software to be detected needs to execute instructions such as compilation, downloading or debugging, the file corresponding to the initial file is obtained as the file to be detected, and then the file verification code and the second verification code of the file to be detected are obtained based on the file to be detected.
[0052] S206: respectively determining whether the initial file verification code and the to-be-detected file verification code both match; if both match, further determining whether the first verification code and the second verification code match; if so, determining that the to-be-detected software is complete software.
[0053] Specifically, the obtained initial file verification code is compared with the verification code of the file to be detected in turn. If each initial file verification code matches the verification code of the file to be detected corresponding to the initial file, it indicates that all the initial files and the files to be detected are the same. It can be understood that in order to avoid the situation where different files have matching codes and thus lead to wrong judgments, a secondary verification is required, that is, the first verification code and the second verification code are compared again. If the first verification code of the initial file and the second verification code of the file to be detected also match, it indicates that the initial file and the file to be detected are the same, and the software to be detected has not been tampered with or lost, that is, the software to be detected is complete software.
[0054] This embodiment obtains multiple initial files, generates multiple initial file verification codes based on the initial files respectively, and generates a first verification code based on the initial files and the initial file verification code, wherein the initial files include all files accessed during the installation of the software to be detected; obtains multiple files to be detected, generates multiple file verification codes based on the files to be detected respectively, and generates a second verification code based on the files to be detected and the file verification code to be detected, wherein the files to be detected are files corresponding to the initial files that are re-acquired after the software to be detected is installed; respectively judges whether the initial file verification code and the file verification code to be detected are matched, and if they are matched, further judges whether the first verification code and the second verification code are matched, and if they are matched, the software to be detected is determined to be complete software. The integrity of the software is determined by the matching relationship between the initial file verification code, the file verification code to be detected, and the first verification code and the second verification code, which solves the technical problem that an erroneous judgment may occur when detecting the integrity of the software, and improves the accuracy of software integrity detection.
[0055] In another embodiment, generating a plurality of initial file verification codes based on the initial files respectively, and generating a first verification code based on the initial files and the initial file verification codes comprises:
[0056] Step 1: Process the initial file based on the message digest algorithm to generate multiple initial file verification codes;
[0057] Step 2: Process the initial file and the initial file verification code based on a message digest algorithm to generate a first verification code.
[0058] Exemplarily, a binary format file of an initial file is obtained, and the binary format file is processed based on a message digest algorithm to generate an initial file check code for each initial file. All binary format files of all initial files and initial file check codes are obtained to generate an overall binary format file, and the overall binary format file is processed based on a message digest algorithm to generate a first check code. Among them, the message digest algorithm refers to mapping input data of any length to generate output data of a fixed length. The input of the message digest algorithm can be of any length. The longer the length, the higher the mapping degree of the input data, and the more secure the output result of the message digest algorithm. At the same time, the output of the message digest algorithm has randomness and uniqueness. Randomness means that the message digest algorithm generates data results in a random manner, but the random manner is not an absolute random manner, because the message digest processing is performed twice on the same input, and the results are the same, and the message digest processing is performed on different inputs, and the results are also different, that is, the message digest algorithm has uniqueness. Therefore, when the file is processed based on the message digest algorithm, if the file is the same, the encoding generated by the message digest algorithm is also the same, otherwise the encoding is different.
[0059] In one of the specific embodiments, the message digest algorithm includes the MD5 algorithm. Specifically, the processing of the binary format file by the MD5 algorithm to generate the check code includes: padding the binary format file, sequentially padding a "1" and several "0"s at the end of the binary format file until the remainder of the binary format file data is equal to 448; then using a 64-bit data to record the length of the binary format file data, and adding the 64-bit data to the end of the binary format file data after the padding; finally, adding 4 defined standard data, performing a cyclic operation on the binary format file data, and obtaining the final encoding result. It should be noted that obtaining the check code in this embodiment is not limited to the message digest algorithm, but also includes a cyclic redundancy check algorithm, a digital signature method, etc., which will not be described in detail in the present invention.
[0060] This embodiment generates an initial file verification code and a first verification code based on a message digest algorithm, respectively. The file can be judged based on the initial file verification code and the first verification code. Only the generated verification codes need to be consistent to determine that the related files are the same. The calculation cost is low, and the mapping method is random and unique. The mapping process does not require a secret key and the generated verification code cannot be reversely decrypted, thereby improving the security of the verification code.
[0061] In another embodiment, generating a first verification code based on the initial file and the initial file verification code includes:
[0062] Step 1: Save the initial file and the initial file verification code to the initial file set respectively;
[0063] Step 2: Generate a first verification code based on the initial file set.
[0064] Specifically, all the initial files and the corresponding initial file verification codes are saved in an initial file set, which can be represented as a folder in the computer, or a whole file composed of all the initial files and the initial file verification codes. Mapping is performed again based on the initial file set to generate a first verification code.
[0065] In one specific embodiment, the initial files include all program files, configuration files, dynamic link files, etc. in the software installation package. The above initial files are mapped respectively to obtain corresponding initial file verification codes, all initial files and initial file verification codes are saved in an initial file list, and the initial file list is mapped again to obtain a first verification code.
[0066] Optionally, after obtaining the first verification code, the initial file list may be encrypted to prevent the initial files in the initial file list and the initial file verification codes from being tampered with or damaged during the software operation.
[0067] This embodiment saves the initial file and the initial file verification code into an initial file set, and maps the initial file set to generate a first verification code. There is no need to first concatenate the initial file and the initial file verification code to generate an overall file and then map them, which shortens the mapping process and improves the generation speed of the first verification code.
[0068] In another embodiment, generating a plurality of verification codes of the files to be detected based on the files to be detected respectively, and generating a second verification code based on the files to be detected and the verification codes of the files to be detected includes:
[0069] Step 1: Process the file to be detected based on the message digest algorithm to generate multiple verification codes of the file to be detected;
[0070] Step 2: Process the file to be detected and the verification code of the file to be detected based on a message digest algorithm to generate a second verification code.
[0071] Exemplarily, a binary format file of a file to be detected is obtained, wherein the file to be detected is a file corresponding to the initial file that is re-obtained after the software is installed. The binary file of the file to be detected is processed based on a message digest algorithm to generate a file verification code for each file to be detected. All files to be detected and the file verification codes to be detected are obtained to generate an overall binary format file, and the overall binary format file is processed based on a message digest algorithm to generate a second verification code.
[0072] This embodiment generates a check code and a second check code for the file to be detected based on a message digest algorithm, respectively, and detects the file to be detected based on the check code and the second check code to determine whether the file to be detected matches the initial file. The calculation cost is low, and the mapping method is random and unique. The mapping process does not require a secret key and the generated check code cannot be reversely decrypted, thereby improving the security of the check code.
[0073] In another embodiment, generating a second verification code based on the file to be detected and the verification code of the file to be detected includes:
[0074] Step 1: Save the files to be detected and the verification codes of the files to be detected into the set of files to be detected respectively;
[0075] Step 2: Generate a second verification code based on the set of files to be detected.
[0076] Specifically, all the files to be detected and the corresponding verification codes of the files to be detected are saved in a set of files to be detected, which can be a folder or a whole file composed of all the files to be detected and the verification codes of the files to be detected. Mapping is performed again based on the set of files to be detected to generate a second verification code.
[0077] In one specific embodiment, the files to be detected include all program files, configuration files, dynamic link files, etc. that are re-obtained after the software is installed. The above files to be detected are mapped respectively to obtain corresponding verification codes of the files to be detected, all the files to be detected and the verification codes of the files to be detected are saved in a list of files to be detected, and the list of files to be detected is mapped again to obtain a second verification code.
[0078] This embodiment saves the file to be detected and the verification code of the file to be detected into an initial file set, and maps the file set to be detected to generate a second verification code. There is no need to first splice the file to be detected and the verification code of the file to be detected to generate an overall file and then map them, which shortens the mapping process and improves the generation speed of the second verification code.
[0079] In another embodiment, after respectively determining whether the initial file verification code and the to-be-detected file verification code both match, the method further includes:
[0080] If there is no match, the software to be tested is determined to be incomplete software and the judgment result is returned.
[0081] Specifically, it is determined whether the initial file verification code matches the file verification code of the file to be detected corresponding to the initial file. If they do not match, it indicates that the initial file is different from the file to be detected, and the file to be detected may be tampered with or lost. If they match, it indicates that the initial file is the same as the file to be detected. At this time, a secondary verification is performed again to determine whether the first verification code matches the second verification code. If they match, the software to be detected is determined to be complete software. If they do not match, the software to be detected is determined to be incomplete software. If the software to be detected is determined to be complete software, then continue to execute subsequent operations, such as executing compilation, downloading, modulation and other instructions; if the software to be detected is determined to be incomplete software, then return the judgment result and inform relevant personnel to carry out subsequent processing.
[0082] In one of the specific embodiments, if the software to be tested is determined to be incomplete software, an error is reported for the software to be tested, and relevant personnel are informed of which files have problems, that is, files in the software to be tested whose encoding is inconsistent with the initial file are returned.
[0083] Optionally, before determining whether the initial file verification code matches the verification code of the file to be detected, the process further includes decrypting the initial file list to obtain the initial file and the initial file verification code.
[0084] Optionally, the software to be detected is detected again based on an active or passive method. Specifically, the manual method is that the relevant personnel actively detect the integrity of the software and execute the method steps of this embodiment. For example, when the software to be detected needs to run certain functions, the integrity of the software to be detected is first detected to avoid problems with the software to be detected that cause program crashes, etc.; the passive detection method can be set to periodically execute the method steps of this embodiment to detect the software to be detected, or it can be set to automatically detect the software to be detected when it needs to execute functions such as compilation and downloading or each time the software is opened.
[0085] In another embodiment, after determining that the software to be detected is incomplete software, the method further includes:
[0086] Update the file to be detected based on the initial file.
[0087] Exemplarily, if the software to be tested is incomplete software, a file to be tested with problems, i.e., a file to be tested whose verification code is inconsistent with the initial file verification code, is obtained, and the file to be tested is replaced with the corresponding initial file. Specifically, the file to be tested with problems is deleted, and the corresponding initial file is saved to the storage location.
[0088] Optionally, the present embodiment can also update the file to be detected manually. Specifically, the display interface returns the file to be detected with problems and its storage address, and the relevant personnel can delete the file to be detected based on the file to be detected and the storage address, and replace it with the initial file corresponding to the file to be detected.
[0089] This embodiment updates the file to be detected based on the initial file. After discovering that the software to be detected is incomplete, the problematic file to be detected is updated in time to repair the vulnerabilities of the software to be detected, avoid malicious program implantation, resource tampering, etc., and improve the security and reliability of the software.
[0090] It should be noted that the steps shown in the above process or the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0091] In this embodiment, a software integrity detection device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. The terms "module", "unit", "subunit", etc. used below can implement a combination of software and / or hardware of predetermined functions. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0092] Figure 3 is a structural block diagram of the software integrity detection device of this embodiment, such as Figure 3 As shown, the device comprises:
[0093] A first acquisition module is used to acquire multiple initial files, generate multiple initial file verification codes based on the initial files respectively, and generate a first verification code based on the initial files and the initial file verification codes, wherein the initial files include all files before the software to be detected is installed;
[0094] The first acquisition module is further used to process the initial file based on the message digest algorithm to generate multiple initial file verification codes;
[0095] Processing the initial file and the initial file verification code based on a message digest algorithm to generate a first verification code;
[0096] The first acquisition module is further used to save the initial file and the initial file verification code to the initial file set respectively;
[0097] Generate a first verification code based on the initial file set;
[0098] A second acquisition module is used to acquire multiple files to be detected, generate multiple verification codes of the files to be detected based on the files to be detected, and generate a second verification code based on the files to be detected and the verification codes of the files to be detected, wherein the files to be detected are files corresponding to the initial files that are re-acquired after the software to be detected is installed;
[0099] The second acquisition module is further used to process the file to be detected based on the message digest algorithm to generate multiple verification codes of the file to be detected;
[0100] Processing the file to be detected and the check code of the file to be detected based on a message digest algorithm to generate a second check code;
[0101] The second acquisition module is further used to save the to-be-detected file and the to-be-detected file verification code to the to-be-detected file set respectively;
[0102] Generate a second verification code based on the set of files to be detected;
[0103] A judgment module is used to judge whether the initial file verification code and the verification code of the file to be detected are matched respectively. If they are matched, it is further judged whether the first verification code and the second verification code match. If they are matched, it is determined that the software to be detected is complete software;
[0104] The software integrity detection device also includes an incomplete software determination module;
[0105] The incomplete software determination module is used to determine that the software to be detected is incomplete software if there is no match, and return the determination result.
[0106] The software integrity detection device also includes an update module;
[0107] The update module is used to update the file to be detected based on the initial file.
[0108] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.
[0109] In this embodiment, an electronic device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0110] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0111] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0112] S1, obtaining a plurality of initial files, generating a plurality of initial file verification codes based on the initial files respectively, and generating a first verification code based on the initial files and the initial file verification codes, wherein the initial files include all files before the software to be detected is installed;
[0113] S2, obtaining a plurality of files to be detected, generating a plurality of verification codes of the files to be detected based on the files to be detected respectively, and generating a second verification code based on the files to be detected and the verification codes of the files to be detected, wherein the files to be detected are files corresponding to the initial files that are re-obtained after the software to be detected is installed;
[0114] S3, respectively judging whether the initial file verification code and the verification code of the file to be detected both match, if both match, further judging whether the first verification code and the second verification code match, if they match, determining that the software to be detected is complete software.
[0115] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and will not be repeated in this embodiment.
[0116] In addition, in combination with the software integrity detection method provided in the above embodiments, a storage medium may be provided in this embodiment to implement the method. The storage medium stores a computer program; when the computer program is executed by a processor, any software integrity detection method in the above embodiments is implemented.
[0117] It should be understood that the specific embodiments described herein are only used to explain the application, rather than to limit it. Based on the embodiments provided in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the protection scope of this application.
[0118] Obviously, the drawings are only some examples or embodiments of the present application. For ordinary technicians in the field, the present application can also be applied to other similar situations based on these drawings without creative work. In addition, it is understandable that although the work done in this development process may be complicated and lengthy, for ordinary technicians in the field, certain changes in design, manufacturing or production based on the technical content disclosed in this application are only conventional technical means and should not be regarded as insufficient content disclosed in this application.
[0119] The term "embodiment" in this application refers to a specific feature, structure or characteristic described in conjunction with the embodiment that can be included in at least one embodiment of the present application. The appearance of this phrase in various locations in the specification does not necessarily mean the same embodiment, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. It is clearly or implicitly understood by those of ordinary skill in the art that the embodiments described in this application can be combined with other embodiments without conflict.
[0120] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of patent protection. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the scope of protection of the present application. Therefore, the scope of protection of the present application shall be subject to the attached claims.
Claims
1. A method for detecting software integrity, characterized in that: include: Acquire multiple initial files, generate multiple initial file verification codes based on the initial files respectively, and generate a first verification code based on the initial files and the initial file verification codes, wherein the initial files include all files before the software to be detected is installed; Acquire multiple files to be detected, generate multiple verification codes of the files to be detected based on the files to be detected respectively, and generate a second verification code based on the files to be detected and the verification codes of the files to be detected, wherein the files to be detected are files corresponding to the initial files that are re-acquired after the software to be detected is installed; Determine whether the initial file verification code and the to-be-detected file verification code both match, if both match, then further determine whether the first verification code matches the second verification code, if they match, then determine that the to-be-detected software is complete software; The generating of the first verification code based on the initial file and the initial file verification code comprises: Saving the initial file and the initial file verification code to an initial file set respectively; Generate a first verification code based on the initial file set; The generating a second verification code based on the file to be detected and the verification code of the file to be detected comprises: The to-be-detected file and the to-be-detected file verification code are respectively saved in a to-be-detected file set; A second verification code is generated based on the set of files to be detected.
2. The software integrity detection method according to claim 1, characterized in that: The generating a plurality of initial file verification codes based on the initial files respectively, and generating a first verification code based on the initial files and the initial file verification codes comprises: Processing the initial file based on a message digest algorithm to generate a plurality of initial file verification codes; The initial file and the initial file verification code are processed based on a message digest algorithm to generate the first verification code.
3. The method for detecting software integrity according to claim 1, characterized in that: The generating a plurality of verification codes of the files to be detected based on the files to be detected respectively, and generating a second verification code based on the files to be detected and the verification codes of the files to be detected comprises: Processing the file to be detected based on a message digest algorithm to generate a plurality of verification codes of the file to be detected; The file to be detected and the verification code of the file to be detected are processed based on a message digest algorithm to generate the second verification code.
4. The software integrity detection method according to claim 1, characterized in that: After respectively determining whether the initial file verification code matches the verification code of the file to be detected, the following further comprises: If there is no match, the software to be detected is determined to be incomplete software, and the determination result is returned.
5. The method for detecting software integrity according to claim 4, characterized in that: After determining that the software to be detected is incomplete software, the following step is further included: The file to be detected is updated based on the initial file.
6. A software integrity detection device, characterized in that: include: A first acquisition module is used to acquire a plurality of initial files, generate a plurality of initial file verification codes based on the initial files respectively, and generate a first verification code based on the initial files and the initial file verification codes, wherein the initial files include all files accessed during the installation process of the software to be detected; A second acquisition module is used to acquire multiple files to be detected, generate multiple verification codes of the files to be detected based on the files to be detected, and generate a second verification code based on the files to be detected and the verification codes of the files to be detected, wherein the files to be detected are files corresponding to the initial files that are re-acquired after the software to be detected is installed; A judgment module, used to judge whether the initial file verification code and the verification code of the file to be detected are both matched, and if they are matched, further judge whether the first verification code and the second verification code match, and if they are matched, determine that the software to be detected is complete software; The first acquisition module is further used to save the initial file and the initial file verification code to the initial file set respectively; Generate a first verification code based on the initial file set; The second acquisition module is further used to save the to-be-detected file and the to-be-detected file verification code to the to-be-detected file set respectively; A second verification code is generated based on the set of files to be detected.
7. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to execute the software integrity detection method according to any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for detecting software integrity according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
File encryption and decryption method, distributed storage system, equipment and storage medium
CN111709038A
File data restoring system and method of computer operating system and software thereof
US20090199039A1