RTOS file white list loading control method based on APIHOOK

By using APIHOOK technology in RTOS to intercept and match the digest value of executable files, the problem of lack of whitelist loading control in embedded real-time applications is solved, and the security and compatibility of embedded systems are improved.

CN118606928APending Publication Date: 2024-09-06CHINA NUCLEAR CONTROL SYST ENG +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410654690.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-24
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

The existing technology lacks whitelist loading control technology for embedded real-time applications and cannot effectively resist malicious code attacks in embedded systems.

Method used

Use APIHOOK technology to install hooks in RTOS to intercept the loading of executable files to be loaded, and use the digest algorithm to calculate and match the digest values ​​in the whitelist to achieve loading control of executable files.

Benefits of technology

It realizes whitelist loading control of embedded real-time applications, effectively resists malicious code attacks, improves system security and compatibility, and avoids the need for frequent network upgrades.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118606928A
    Figure CN118606928A
Patent Text Reader

Abstract

The invention discloses an APIHOOK-based RTOS file white list loading control method, and relates to the technical field of white list loading control, and the method comprises the following steps: establishing a white list; adopting an APIHOOK technology, installing a hook on an API (Application Program Interface) for loading the to-be-loaded executable file on the RTOS, and intercepting the loading of the to-be-loaded executable file; adopting a digest algorithm to calculate and intercept a digest value of the executable file to be loaded; matching the abstract value of the executable file to be loaded with the abstract value stored in the white list to obtain a matching result; the matching result is matching or mismatching; and when the matching result is that the to-be-loaded executable file is matched, executing the to-be-loaded executable file. According to the invention, white list loading control for the embedded real-time application is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of whitelist loading control, and in particular to an RTOS file whitelist loading control method based on APIHOOK. Background Art

[0002] The current industrial control system host security protection is mainly based on whitelist file loading control technology. Whitelist loading control has the advantages of not requiring frequent upgrades and being able to resist some zero-day vulnerability attacks. However, the current whitelist loading control software in the industry is only for desktop applications, and lacks whitelist loading control technology for embedded real-time applications. Summary of the invention

[0003] The purpose of the present invention is to provide an RTOS file whitelist loading control method based on APIHOOK, which realizes whitelist loading control for embedded real-time applications.

[0004] To achieve the above object, the present invention provides the following solutions:

[0005] An APIHOOK-based RTOS file whitelist loading control method, comprising:

[0006] Create a whitelist;

[0007] Using APIHOOK technology, a hook is installed on the API of the RTOS that loads the executable file to be loaded, intercepting the loading of the executable file to be loaded;

[0008] A digest algorithm is used to calculate the digest value of the executable file to be loaded;

[0009] Matching the digest value of the executable file to be loaded with the digest value stored in the whitelist to obtain a matching result; the matching result is a match or a mismatch;

[0010] When the matching result is a match, the executable file to be loaded is executed.

[0011] Optionally, create a whitelist including:

[0012] Use the file system scanning method to create a whitelist.

[0013] Optionally, a file system scanning method is used to create a whitelist, including:

[0014] Scan all executable files in the file system of the protected object and add all executable files to the whitelist;

[0015] Determine the summary value of each executable file in the whitelist and create a file summary value list;

[0016] Duplicate values ​​are merged;

[0017] Create a quick lookup table in the whitelist.

[0018] Optionally, determine the digest value of each executable file in the whitelist, and create a file digest value list, including:

[0019] Use the md5 method or the sha256 method to calculate the digest value of each executable file in the whitelist;

[0020] A file summary value list is created based on the summary value of each executable file in the whitelist.

[0021] Optionally, duplicate values ​​are collapsed, including:

[0022] Merge multiple digest values ​​belonging to the same executable file and retain one digest value.

[0023] Optionally, the APIHOOK technology is used to install a hook on the API of the RTOS that loads the executable file to be loaded, so as to intercept the loading of the executable file to be loaded, including:

[0024] The hook function is called, and the parameters of the API of the executable file to be loaded are obtained by using the hook function, and the parameters are modified so that the API loses the opportunity to be executed, thereby realizing the loading of the executable file to be loaded.

[0025] Optionally, matching the digest value of the executable file to be loaded with the digest value stored in the whitelist to obtain a matching result includes:

[0026] The quick lookup table is used to match the digest value of the executable file to be loaded with the digest value stored in the whitelist to obtain a matching result.

[0027] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:

[0028] The invention discloses an RTOS file whitelist loading control method based on APIHOOK, which establishes a whitelist; adopts the APIHOOK technology to install a hook on the API of the RTOS for loading an executable file to be loaded, so as to intercept the loading of the executable file to be loaded; adopts a digest algorithm to calculate the digest value of the intercepted executable file to be loaded; matches the digest value of the executable file to be loaded with the digest value stored in the whitelist to obtain a matching result; the matching result is a match or a mismatch; when the matching result is a match, the executable file to be loaded is executed, thereby realizing whitelist loading control for embedded real-time applications. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0030] Figure 1 A schematic flow chart of an RTOS file whitelist loading control method based on APIHOOK provided in Example 1 of the present invention;

[0031] Figure 2 This is a schematic diagram of the whitelist establishment process;

[0032] Figure 3 This is a schematic diagram of the whitelist protection process;

[0033] Figure 4 This is a schematic diagram of the implementation of the whitelist initialization phase;

[0034] Figure 5 This is a schematic diagram of the implementation process after enabling loading interception. DETAILED DESCRIPTION

[0035] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0036] The purpose of the present invention is to provide an RTOS file whitelist loading control method based on APIHOOK, aiming to realize whitelist loading control for embedded real-time applications.

[0037] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0038] Example 1

[0039] like Figure 1-Figure 5 As shown, the RTOS file whitelist loading control method based on APIHOOK in this embodiment includes:

[0040] Step 1: Create a whitelist.

[0041] As an optional implementation, step 1 includes:

[0042] Step 11: Use the file system scanning method to create a whitelist.

[0043] Specifically, the file system scanning method will immediately perform executable file scanning covering the entire file system of the protected object after installing the host whitelist software, identifying various types of executable files, including PE files such as exe, ocx, dll, com, etc. under Windows, and all ELF format files under Linux. When the scan is completed, all types of files will be included in the whitelist, and the summary value of each file will be calculated (using methods such as md5 or sha256), and then the system will enter the interception protection mode. In this mode, the loading and execution of any file needs to match the summary value in the whitelist, and binary files that do not meet the whitelist match will be refused to execute.

[0044] As an optional implementation, step 11 includes:

[0045] Step 111: Scan all executable files in the protected object file system and add all executable files to the whitelist.

[0046] Specifically, when scanning executable files, it is necessary to consider avoiding the problem of recursive circular directories. That is, in some versions of the Linux file system, there are hard links to the upper directory in the lower or multiple directories, so recursive traversal will cause an infinite loop. Here, it is necessary to consider the identification and prevention of such phenomena during the recursive directory traversal process.

[0047] Step 112: Determine the summary value of each executable file in the whitelist and create a file summary value list.

[0048] As an optional implementation, step 112 includes:

[0049] Step 1121: Calculate the digest value of each executable file in the whitelist using the md5 method or the sha256 method.

[0050] Step 1122: Create a file summary value list based on the summary value of each executable file in the whitelist.

[0051] Step 113: Merge duplicate values.

[0052] As an optional implementation, step 113 includes:

[0053] Merge multiple digest values ​​belonging to the same executable file and retain one digest value.

[0054] Specifically, when establishing a list of file summary values, it is necessary to consider the possibility of "database collision" in the algorithm. When such a problem occurs, a special secondary identification of the relevant files is required. Duplicate value merging mainly takes into account that the same binary file may be distributed in different file paths, and there may be multiple copies of binary files in the file system. In such cases, it is necessary to merge duplicate summary values, and only one summary value is retained for multiple identical files.

[0055] Step 114: Create a quick lookup table in the whitelist.

[0056] Specifically, the quick lookup table is established to facilitate the improvement of system execution efficiency after whitelist protection is enabled.

[0057] In fact, the method of establishing a whitelist also includes: a file loading self-learning method.

[0058] After installing the host whitelist software, the whitelist software first executes the learning mode, that is, detects the files loaded and executed by the system and records them. After the control system installs the whitelist software and runs in the learning mode for a certain period of time, the whitelist will record all executable files loaded and executed by the control system within a limited time, and simultaneously calculate the summary value of the file. The administrator can put these files in the whitelist and then turn on the interception control mode. In this mode, the loading and execution of any file needs to match the summary value in the whitelist, and binary files that do not meet the whitelist match will be rejected.

[0059] However, the file loading self-learning method has the following defects: it is difficult to ensure that all executable files (including dynamic libraries) that the control system depends on for normal operation are given the opportunity to execute during the operation time of the learning mode, which leads to incompleteness in the establishment of the whitelist, resulting in potential compatibility risks during the long-term operation of the system.

[0060] Step 2: Use APIHOOK technology to install a hook on the API of the RTOS that loads the executable file to be loaded, and intercept the loading of the executable file to be loaded.

[0061] Specifically, APIHOOK is an application programming interface hook function (Application ProgrammingInterface Hook), and RTOS is an embedded real-time operating system (Real Time Operating System).

[0062] As an optional implementation, step 2 includes:

[0063] The hook function is called, and the parameters of the API of the executable file to be loaded are obtained by using the hook function, and the parameters are modified so that the API loses the opportunity to be executed, thereby realizing the loading of the executable file to be loaded.

[0064] Specifically, the hook function is called, and the hook function is used to obtain the parameters of the API of the executable file to be loaded, and the parameters are modified to make the API lose the opportunity to be executed, thereby realizing the loading of the executable file to be loaded as the HOOK method.

[0065] The HOOK method is intended to install a hook function for a specific API function of the system, that is, the hook function is called first when a certain API function is called. The hook function can obtain all parameters of the API and can make the API lose the opportunity to be executed by modifying the parameters. To use this method to carry out executable file loading control, it is necessary to first obtain the file loading API of the relevant operating system and install the hook function for it through the system SDK. The hook function needs to complete the digest value calculation and whitelist matching of the loaded file. If the match is successful, the subsequent loading and execution are allowed, and if the match is unsuccessful, the subsequent loading and execution are rejected.

[0066] The characteristic of the HOOK method is that it can completely prevent the loading of malicious files.

[0067] In fact, in addition to the HOOK method, file loading control measures also include: regular scanning method.

[0068] Periodic scanning method The periodic scanning method scans all executable files loaded in the system memory at a specific period, reversely searches the loaded disk file, and matches the summary value of the file to see if it exists in the whitelist. If not, the relevant system API is called to kill the relevant process.

[0069] The disadvantage of the periodic scanning method is that the malicious code has already obtained a short execution opportunity during the scanning cycle. For malicious files that are completely intended to destroy related systems rather than to retain memory for long-term monitoring, the short execution opportunity is enough to cause immeasurable damage to the system. During the research process, a simple destruction program was developed, which can destroy important system files from the time the program is executed to the time it is killed through a simple system call. At the same time, malicious code often takes necessary functions to prevent itself from being terminated, such as turning off the response to a specific signal. Killing a process often easily leads to a decrease in system stability.

[0070] Step 3: Use a digest algorithm to calculate the digest value of the executable file to be loaded.

[0071] Step 4: Match the digest value of the executable file to be loaded with the digest value stored in the whitelist to obtain a matching result; the matching result is a match or a mismatch.

[0072] As an optional implementation, step 4 includes:

[0073] The quick lookup table is used to match the digest value of the executable file to be loaded with the digest value stored in the whitelist to obtain a matching result.

[0074] Specifically, step 4 is whitelist protection, and the whitelist protection part is mainly divided into HOOK interception of file loading information, calculation of file summary value, Hash search and matching, and interception and release. The main calculations of this part are distributed in the HOOK function of the file loading API function, which objectively requires the algorithm to have extremely high efficiency. The summary value calculation requires reading all the file information in the external memory and calculating the file summary value. For files in the log file system, this process can establish a file summary value calculation list and use whether the file timestamp is modified to determine whether it needs to be recalculated. Hash search uses the summary value to calculate the hash value combined with a quick search table to quickly realize the whitelist matching in the memory. For files that need to be intercepted, the system uses the Hook function to modify the parameter structure pointed to by the API's incoming pointer, causing the API execution to fail, and the protection system needs to record logs.

[0075] Step 5: When the matching result is a match, the executable file to be loaded is executed.

[0076] The present invention develops a whitelist loading control method for RTOS, which is directly deployed inside a PLC or DCS main controller to establish a malicious code interception barrier for the relevant system.

[0077] Antivirus software mainly identifies malicious code based on the continuously accumulated virus signature database and the "blacklist" matching principle, which leads to the following defects in the system:

[0078] 1) The protection system’s defense against new malicious codes is not timely enough, and its defense against viruses that exploit zero-day vulnerabilities is weak.

[0079] 2) The protection system relies on the virus database upgrade through the network, but the instrumentation and control system cannot connect to the Internet, and it is difficult for the operating system to perform frequent offline updates of virus features through manual means.

[0080] 3) The virus protection system cannot achieve 100% accurate identification. There are not only underreporting problems caused by factors such as untimely virus database upgrades, but also false alarm problems caused by errors in virus feature matching.

[0081] The host protection software based on "white list" is designed based on the defects of traditional anti-virus software and the characteristics of the control system, replacing traditional anti-virus software and effectively preventing the installation or loading and execution of unauthorized software code. The protection system based on white list has the following important features and advantages:

[0082] 1) Effectively defend against APT (advanced persistent threats) and attacks using zero-day vulnerabilities.

[0083] 2) Avoid frequent online and offline upgrades of the system, making it easy to deploy in environments that cannot connect to the Internet, while also reducing the difficulty of operation and maintenance.

[0084] 3) Improve the compatibility of the system and effectively reduce the probability of false positives.

[0085] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0086] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and core idea of ​​the present invention. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.

Claims

1. An RTOS file whitelist loading control method based on APIHOOK, characterized in that: The method comprises: Create a whitelist; Using APIHOOK technology, a hook is installed on the API of the RTOS that loads the executable file to be loaded, intercepting the loading of the executable file to be loaded; A digest algorithm is used to calculate the digest value of the executable file to be loaded; Matching the digest value of the executable file to be loaded with the digest value stored in the whitelist to obtain a matching result; the matching result is a match or a mismatch; When the matching result is a match, the executable file to be loaded is executed.

2. The RTOS file whitelist loading control method based on APIHOOK according to claim 1, characterized in that: Create a whitelist, including: Use file system scanning methods to create a whitelist.

3. The RTOS file whitelist loading control method based on APIHOOK according to claim 1, characterized in that: Use file system scanning methods to create a whitelist, including: Scan all executable files in the protected object's file system and add all executable files to the whitelist; Determine the digest value of each executable file in the whitelist and create a file digest value list; Duplicate values ​​are merged; Create a quick lookup table in the whitelist.

4. The RTOS file whitelist loading control method based on APIHOOK according to claim 3, characterized in that: Determine the digest value of each executable file in the whitelist and create a file digest value list, including: Use the md5 method or sha256 method to calculate the digest value of each executable file in the whitelist; A file digest value list is created based on the digest value of each executable file in the whitelist.

5. The RTOS file whitelist loading control method based on APIHOOK according to claim 3 is characterized in that, Duplicate values ​​are merged, including: Merge multiple digest values ​​belonging to the same executable file and retain one digest value.

6. The RTOS file whitelist loading control method based on APIHOOK according to claim 1, characterized in that: Using APIHOOK technology, a hook is installed on the API of the RTOS that loads the executable file to be loaded, intercepting the loading of the executable file to be loaded, including: The hook function is called, and the parameters of the API of the executable file to be loaded are obtained by using the hook function, and the parameters are modified so that the API loses the opportunity to be executed, thereby realizing the loading of the executable file to be loaded.

7. The RTOS file whitelist loading control method based on APIHOOK according to claim 1, characterized in that: The digest value of the executable file to be loaded is matched with the digest values ​​stored in the whitelist to obtain a matching result, including: The quick lookup table is used to match the digest value of the executable file to be loaded with the digest values ​​stored in the whitelist to obtain a matching result.