A method, device, equipment and storage medium for detecting attack behavior
By obtaining and filtering the system call combination information from the ring buffer, and inputting it into the abstract syntax tree for detection, it solves the problems of insufficient timeliness of attack behavior detection and log tampering bypass in the existing technology, and achieves faster and more accurate attack behavior. detection.
Patent Information
- Application Number
- CN202311377258.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-23
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2043-10-23
AI Technical Summary
Existing host attack behavior detection methods lag in timeliness, and attackers can bypass detection by deleting or tampering with logs.
By obtaining the system call combination information that has been filtered by rules, rule supplementation and form mapping from the ring buffer as the data to be detected, and inputting it into the pre-built abstract syntax tree for detection, the data associated with the detection results is extracted to supplement the output data. Attack detection is directly based on system call combination information.
It improves the timeliness of attack behavior detection, prevents attackers from bypassing detection by deleting or tampering with logs, and improves the traceability of attack detection.
Smart Images

Figure CN117744071B
Abstract
Description
Technical Field
[0001] The present application relates to the field of network security technology, and in particular to an attack behavior detection method, device, equipment and storage medium. Background Art
[0002] Host (host usually refers to various types of servers including bare metal servers, virtual machines and cloud servers) security defense is an important part of the network security attack and defense system. Since various business systems are running on the host and key business data is stored, host security defense is often the last line of defense in the face of network attacks. The failure of host defense means that important business systems are affected or data leakage occurs. When the host is attacked, accurately and timely discovering the attack behavior, quickly collecting attack information, and clarifying the consequences of the attack are important prerequisites for subsequent defense response and defense tracing. Therefore, accurate detection of host attack behavior is a key technology and core capability of the host security defense system.
[0003] Existing methods for host attack behavior detection are mainly divided into flow-based attack behavior detection and log-based attack behavior detection from the detection dimension. When using the flow-based attack behavior detection method for attack behavior detection, when the attacker successfully invades the node, whether it is tampering with the system's key configuration files or stealing sensitive data, the attack traffic detection mechanism can be bypassed. The defect of the attack behavior detection based on system logs is that the judgment of the attack behavior comes from the system log data, and the system log data is often generated after the attack behavior occurs. At the same time, the system log data cannot fully reflect all system call combination information. As a result, the attack detection based on the system log will first lag in detection timeliness, and it is easy for attackers to successfully bypass the attack detection by deleting or tampering with the logs.
[0004] Therefore, how to improve the timeliness of attack behavior detection while preventing attackers from bypassing attack detection by deleting or tampering with logs is a technical problem that technicians in this field urgently need to solve. Summary of the invention
[0005] Based on the above problems, the present application provides an attack behavior detection method, apparatus, device and storage medium, which can improve the timeliness of attack behavior detection and prevent attackers from bypassing attack detection by deleting or tampering with logs.
[0006] The embodiments of the present application disclose the following technical solutions:
[0007] A method for detecting attack behavior, the method comprising:
[0008] Acquire mapping data from the ring buffer as data to be detected, wherein the mapping data is system call combination information that has been filtered, supplemented and formally mapped by rules;
[0009] Performing supplementary rule filtering on the data to be detected to obtain filtered data;
[0010] Inputting the filtered data into a pre-constructed abstract syntax tree to obtain a detection result;
[0011] extracting data associated with the detection result from the mapping data as supplementary data;
[0012] The detection result is supplemented with the supplementary data to obtain a complete output result of the attack behavior detection.
[0013] In a possible implementation, before obtaining the pre-processed system call combination information as the data to be detected through the ring buffer, the method further includes:
[0014] Obtain the system call combination information through the hook system call list;
[0015] According to the parsed data of the attack behavior detection rule file, the system call combination information is subjected to the rule filtering and rule supplementation to obtain filtering supplement data;
[0016] Performing the formal mapping on the filtered supplementary data to obtain the mapped data;
[0017] The mapping data is stored in the ring buffer.
[0018] In a possible implementation manner, storing the mapping data in the ring buffer includes:
[0019] identifying a byte size of the mapping data;
[0020] When the byte size of the mapping data is less than or equal to the target byte size, storing the mapping data in the ring buffer is performed.
[0021] In a possible implementation, the method further includes:
[0022] When the byte size of the mapping data is greater than the target byte size, the mapping data is discarded.
[0023] In a possible implementation, the obtaining the system call combination information through the hook system call list includes:
[0024] Get the preliminary system call combination information through the hook system call list;
[0025] The preliminary system call combination information is supplemented to obtain the system call combination information.
[0026] In a possible implementation, the process of constructing the pre-constructed abstract syntax tree includes:
[0027] Get the attack behavior detection rule file;
[0028] Parsing the attack behavior detection rule file to obtain parsed data;
[0029] Convert the parsed data into the abstract syntax tree.
[0030] An attack behavior detection device, the device comprising:
[0031] A first acquisition unit is used to acquire mapping data from the ring buffer as data to be detected, wherein the mapping data is system call combination information that has been filtered, supplemented and formally mapped by rules;
[0032] A rule filtering unit, used for performing rule filtering on the data to be detected to obtain filtered data;
[0033] An input unit, used for inputting the filtered data into a pre-built abstract syntax tree to obtain a detection result;
[0034] an extraction unit, configured to extract data associated with the detection result from the mapping data as supplementary data;
[0035] The output data supplement unit is used to use the supplementary data to supplement the output data of the detection result to obtain a complete output result of the attack behavior detection.
[0036] In a possible implementation manner, the device further includes:
[0037] A second acquisition unit is used to acquire the system call combination information through a hook system call list;
[0038] A rule filtering and supplementing unit, configured to perform the rule filtering and rule supplementing on the system call combination information according to the parsed data of the attack behavior detection rule file to obtain filtering supplement data;
[0039] a form mapping unit, configured to perform the form mapping on the filtering supplementary data to obtain the mapping data;
[0040] A storage unit is used to store the mapping data in the ring buffer.
[0041] An attack behavior detection device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the attack behavior detection method described above is implemented.
[0042] A computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device executes the attack behavior detection method as described above.
[0043] Compared with the prior art, this application has the following beneficial effects:
[0044] The present application provides an attack behavior detection method, device, equipment and storage medium. Specifically, when executing the attack behavior detection method provided by the embodiment of the present application, first, mapping data can be obtained from the ring buffer as the data to be detected, wherein the mapping data is the system call combination information that has been filtered, supplemented and formally mapped. Next, the data to be detected is filtered by supplementary rules to obtain filtered data, and the filtered data is input into a pre-built abstract syntax tree to obtain a detection result. Then, data associated with the detection result is extracted from the mapping data as supplementary data. The supplementary data is then used to supplement the output data of the detection result to obtain a complete output result of the attack behavior detection. The present application directly performs attack detection based on the system call combination information to improve the timeliness of the detection, and at the same time, directly performing attack detection based on the system call combination information can prevent attackers from bypassing the attack detection by deleting or tampering with the log. In addition, performing attack detection directly based on source information such as system call combination information can also improve the traceability capability of attack detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solutions in this embodiment or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0046] Figure 1 A schematic diagram of an exemplary application scenario provided for an embodiment of the present application;
[0047] Figure 2 A method flow chart of an attack behavior detection method provided in an embodiment of the present application;
[0048] Figure 3 A schematic diagram of the structure of an attack behavior detection device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0049] In order to enable those skilled in the art to better understand the present application, the following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0050] To facilitate understanding of the technical solutions provided by the embodiments of the present application, the background technology involved in the embodiments of the present application will be described below.
[0051] Host (host usually refers to various types of servers including bare metal servers, virtual machines and cloud servers) security defense is an important part of the network security attack and defense system. Since various business systems are running on the host and key business data is stored, host security defense is often the last line of defense in the face of network attacks. The failure of host defense means that important business systems are affected or data leakage occurs. When the host is attacked, accurately and timely discovering the attack behavior, quickly collecting attack information, and clarifying the consequences of the attack are important prerequisites for subsequent defense response and defense tracing. Therefore, accurate detection of host attack behavior is a key technology and core capability of the host security defense system.
[0052] Existing methods for host attack behavior detection are mainly divided into flow-based attack behavior detection and log-based attack behavior detection from the detection dimension. First, the flow-based attack behavior detection method, regardless of whether the method used to detect attack traffic is based on features, rules or machine learning models, can only detect attack behaviors implemented between nodes through network communication. When the attacker successfully invades the node, whether it is tampering with the key configuration files of the system or stealing sensitive data, the attack traffic detection mechanism can be bypassed. Secondly, the detection mechanism of attack behavior detection based on system logs has the defect that the judgment of attack behavior comes from system log data (wherein, system log data is usually used to record the operating status, abnormal conditions and important events of the operating system, including the execution of system calls, error information, resource allocation, etc. When recording system call combination information, system log data can only reflect part of the call system call combination information.), and system log data is often generated after the attack behavior occurs. At the same time, system log data cannot fully reflect all system call combination information, which leads to the fact that the attack detection based on system logs will lag in detection timeliness, and it is easy for attackers to successfully bypass attack detection by deleting or tampering with logs.
[0053] In order to solve this problem, an attack behavior detection method, device, equipment and storage medium are provided in an embodiment of the present application. First, the system call combination information that has been filtered, supplemented and formally mapped by rules, that is, mapping data, is obtained from the ring buffer as the data to be detected, and the data to be detected is filtered by supplementing the rules to obtain the filtered data. Then the filtered data is input into a pre-built abstract syntax tree to obtain the detection result, and the data associated with the detection result is extracted from the mapping data as supplementary data. Then, the output data of the detection result is supplemented with the supplementary data to obtain the complete output result of the attack behavior detection. The present application directly performs attack detection based on the system call combination information to improve the timeliness of the detection. At the same time, the attack detection directly based on the system call combination information can prevent the attacker from bypassing the attack detection by deleting or tampering with the log. In addition, attack detection directly based on the source information such as the system call combination information can also improve the traceability capability of the attack detection.
[0054] In order to facilitate understanding of the attack behavior detection method provided in the embodiment of the present application, Figure 1 See the example scenario shown in the figure. Figure 1 , which is a framework diagram of an exemplary application scenario provided in an embodiment of the present application.
[0055] First, the attack behavior detection system obtains mapping data from the ring buffer 110 as the data to be detected. The mapping data can be understood as the system call combination information that has been filtered, supplemented and formally mapped by rules; the system call combination information refers to the combination of system calls monitored and collected in the attack behavior detection; the ring buffer (RingBuffer), also known as a circular buffer or a ring queue, is a commonly used data structure. The ring buffer is used to store and manage data in a fixed-size buffer. Then, the supplementary rule filter 120 is used to filter the data to be detected by supplementary rules to obtain filtered data. Then, the filtered data is input into the pre-constructed abstract syntax tree 130 to perform attack behavior detection to obtain the detection result; the detection result includes the judgment of the attack behavior, the name of the attack behavior, the classification of the attack behavior, the attack source information, the attack time and the possible impact; and the data associated with the detection result is extracted from the mapping data as supplementary data. Finally, the detection results are supplemented with the supplementary data to obtain the complete output results of the attack behavior detection; the complete output results of the attack behavior detection include the determination of the attack behavior, the name of the attack behavior, the classification of the attack behavior, the attack source information, the attack time, the possible impact, the detailed description, the detailed description, the threat level and the recommended measures, etc., which can improve the timeliness of the detection and prevent attackers from bypassing the attack detection by deleting or tampering with the logs. It can also improve the traceability of the attack detection.
[0056] Those skilled in the art will understand that Figure 1The framework diagram shown is only an example in which the embodiments of the present application can be implemented. The scope of application of the embodiments of the present application is not limited by any aspect of the framework.
[0057] 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 application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0058] See also Figure 2 , which is a method flow chart of an attack behavior detection method provided by an embodiment of the present application, such as Figure 2 As shown, the attack behavior detection method may include steps S201-S205:
[0059] S201: Acquire mapping data from the ring buffer as data to be detected, wherein the mapping data is system call combination information that has been filtered, supplemented and formally mapped by rules.
[0060] Because the user state and kernel state cannot communicate directly, the attack behavior detection system needs to use a ring buffer to obtain system call combination information that has undergone rule filtering, rule supplementation, and form mapping.
[0061] User mode and kernel mode are two different operating modes in the operating system, which are used to distinguish codes running at different privilege levels.
[0062] User Mode: In user mode, programs run at a lower privilege level and can only access limited resources and perform restricted operations. Code in user mode is usually an application or user process, such as a text editor, browser, etc. In user mode, programs cannot directly access underlying hardware devices or execute privileged instructions. If a user mode program needs to perform privileged operations or access restricted resources, it must request support from kernel mode through a system call.
[0063] Kernel Mode: Kernel Mode is a high privilege level of the operating system. Only the operating system kernel can run in kernel mode. In kernel mode, the operating system has full control over all system resources and privileged instructions. Kernel mode can execute privileged instructions, directly access hardware devices, and manage system resources. When a user program requests to perform a privileged operation, the processor switches to kernel mode and transfers the request to the operating system kernel. Kernel mode code is usually part of the operating system kernel and is used for core functions such as managing system resources, scheduling tasks, and handling interrupts.
[0064] Among them, the ring buffer, also known as a circular buffer or a ring queue, is a commonly used data structure used to store and manage data in a fixed-size buffer. It organizes data in a ring-like manner and can efficiently reuse the buffer space.
[0065] In a possible implementation, the system call combination information refers to the combination of system calls detected and collected in attack behavior detection. Specifically, the system call combination information includes the following aspects:
[0066] Process class: involves system calls such as process creation, termination, and state change, such as fork, clone, execve, execveat, vfork, etc.
[0067] File class: system calls involving opening, closing, reading, writing, and modifying files, such as fcntl, open, creat, close, read, write, dup, dup2, chown, chmod, chroot, mkdir, etc.
[0068] System control class: system calls involving system control and configuration, such as ioctl, sysinfo, stime, create_module, delete_module, init_module, etc.
[0069] Memory management class: involves system calls such as memory allocation, release, mapping, such as mmap, munmap, mremap, brk, sbrk, shmctl, shmat, etc.
[0070] Network class: system calls related to network communication and operations, such as setdomainname, sethostid, sethostname, socket, bind, connect, accept, send, sendto, recv, recvfrom, listen, etc.
[0071] User management class: system calls involving user account management and permission settings, such as getuid, setuid, getgid, setgid, etc.
[0072] Signal communication category: system calls involving signal communication between processes, such as kill, signal, sigaction, etc.
[0073] Pipeline class: system calls involving pipeline communication and operations, such as pipe, fifo, etc.
[0074] The above only lists a part of the system call combination information, which may actually include other more subdivided categories of system calls. Attack behavior detection can identify possible abnormal behaviors or malicious attack behaviors by monitoring and analyzing the combination of these system calls.
[0075] In a possible implementation, before obtaining the pre-processed system call combination information as the data to be detected through the ring buffer, the method further includes A1-A4:
[0076] A1: Obtain the system call combination information through the hook system call list.
[0077] By obtaining the system call combination information through the hook system call list before storing the system call combination information in the ring buffer, the system call combination information can be intercepted and processed before or after the system call is executed. By obtaining the system call combination information through the hook system call list, necessary filtering and supplementation can be performed before storing it in the ring buffer to ensure the quality and integrity of the stored data as much as possible.
[0078] Among them, the hook system (HOOK system) is a commonly used technology in computer programming, which allows the program to intercept and modify the original code or the behavior of the operating system. By using the hook system, developers can inject custom code before or after a specific event to modify the behavior of the program.
[0079] In a possible implementation, the system call combination information is obtained through the hook system call list, including B1-B2:
[0080] B1: Get the preliminary system call combination information through the hook system call list.
[0081] In the HOOK system call list, the obtained system call information can be summarized for further analysis and processing. For example, the sequence information of different system calls can be recorded to obtain preliminary system call combination information.
[0082] B2: Supplement the preliminary system call combination information to obtain the system call combination information.
[0083] By supplementing the preliminary system call combination information, more complete and detailed system call combination information can be obtained. The supplemented information may include timestamps, timing relationships, etc., to generate the system call combination information.
[0084] Here are the important reasons why supplemental information is important:
[0085] Timestamp: By adding a timestamp to each system call, the specific time when the system call occurred can be recorded. This is very important for analyzing the order and timing relationship of system calls to determine the execution order and interval time of system calls. Timestamps can also be used to analyze system call latency, response time, and performance issues.
[0086] Timing relationship: By recording the timing relationship of system calls, you can build the execution process of system calls and understand the dependencies and impact relationships between system calls. This is very helpful for analyzing concurrent system calls and the execution order of important system calls.
[0087] System call combination information: By combining supplementary timestamps, timing relationships and other information with preliminary system call combination information, more comprehensive and detailed system call combination information can be generated. This information can be provided to security and system administrators for analyzing system behavior, detecting abnormal operations, identifying potential security issues, etc.
[0088] The purpose of supplementary information is to better understand the operation of the system and provide a more accurate and comprehensive data basis for subsequent system call analysis and troubleshooting.
[0089] A2: performing the rule filtering and rule supplementing on the system call combination information according to the parsed data of the attack behavior detection rule file to obtain filtering supplement data.
[0090] The purpose of filtering and supplementing the system call combination information based on the parsed data of the attack behavior detection rule file is to further ensure that the data stored in the ring buffer meets the expected security requirements. The attack behavior detection rule file contains descriptions and matching rules for various attack behavior characteristics. These rules can be used to filter and supplement the system call combination information to facilitate the abstract syntax tree to filter out potential security risks and abnormal behaviors.
[0091] Parsing data of attack behavior detection rule files refers to parsing the rule text into token form, that is, word segmentation form. For example, for signature rule files, pattern matching methods such as regular expressions can be used for segmentation and parsing.
[0092] The reason for filtering the system call combination information by rules is that there are many types of system call combination information, but not all system call combination information is related to the attack behavior in the attack behavior detection rule file. Therefore, it is necessary to filter the system call combination information by rules according to the parsed data of the attack behavior detection rule file to obtain data related to the attack behavior. For example, assuming that there are 100 kinds of attack behaviors in the attack behavior detection rule file, there are 136 kinds of system call combination information involved in the 100 kinds of attack behaviors, and there are 400 kinds of system call combination information of the entire system currently obtained through HOOK, and only 136 kinds of them are currently concerned. At this time, these 136 kinds of system call combination information can be filtered out from these 400 kinds.
[0093] The reason for supplementing the system call combination information with rules is that the information to be outputted based on the parsed data of the rule file may not be comprehensive enough, and the system call combination information needs to be supplemented with rules based on the parsed data of the attack behavior detection rule file. To continue with the above example, there are 136 types of system call combination information involved in the current 100 attack behaviors, and the information to be outputted based on the parsed data of the rule file may not all come from these 136 types of system call combination information. It may also be necessary to know the context when the system call occurs. In this case, the system call combination information needs to be supplemented with rules.
[0094] In a possible implementation, an attack behavior detection rule file is a file for specifying detection rules and policies for a specific security event. It usually contains a series of features or patterns for identifying malicious behaviors or attack activities and triggering corresponding response measures.
[0095] Specifically, an attack behavior detection rule file may include the following:
[0096] Rule Name: The name of the rule is used to describe the security event or attack type that the rule involves.
[0097] Rule description: The rule description contains information about the purpose of the rule, scope of application, triggering conditions, etc.
[0098] Detection rules: This part of the rules defines the characteristics, rule syntax, and algorithms used to detect specific security events or attacks. For example, detection rules can be implemented using regular expressions, keyword matching, pattern matching, etc.
[0099] Response strategy: When a specific security event or attack is detected, the rule file can specify the corresponding response strategy. For example, you can choose to record logs, block intrusions, send alarms (send notifications), remotely kick out, etc.
[0100] Attack behavior detection rule files can be used in security devices such as network security protection systems and intrusion detection systems to detect incoming or outgoing data and promptly discover and respond to potential security threats. Different rule files can be customized for specific security events or attack types to improve detection accuracy and response efficiency.
[0101] A3: Performing the formal mapping on the filtered supplementary data to obtain the mapping data.
[0102] The filtered supplementary data obtained above may have different forms, which may make the filtered supplementary data difficult to process, analyze and display. Mapping the filtered data in form can make the data easier to process, analyze and display, thereby meeting different needs and application scenarios.
[0103] Take the same type of system calls as an example. For example, execve and execveat are both system calls that control process startup and execution. These two system call functions have similar functions and are used to load and execute a new executable file. The difference between them is that execve can only use files in the current directory to start a process, while execveat can use files in any directory to start a process. Therefore, it is necessary to abstractly map the two system calls execve and execveat into one category. Other similar situations include system calls to open or create files (open, openat, openat2), system calls to create child processes (clone, clone2, clone3), etc.
[0104] A4: Store the mapping data in the ring buffer.
[0105] After the above processing, in order to facilitate the acquisition of mapping data by user state and kernel state, attack behavior detection can upload the mapping data to the ring buffer for storage.
[0106] In a possible implementation, storing the mapping data in the ring buffer includes C1-C2:
[0107] C1: Identify the byte size of the mapping data.
[0108] If the data to be written is larger than the remaining available data space, the buffer area will overflow, which will lead to security vulnerabilities and system crashes. Therefore, the byte size of the mapped data needs to be identified and judged before storing it in the ring buffer.
[0109] The target byte size refers to the remaining space in the ring buffer that can be used to store the mapped data. The method for calculating the remaining available space in the ring buffer is as follows:
[0110] First, determine the total size of the ring buffer: First, you need to know the total size of the ring buffer, usually in bytes. You can get this value based on system design or specific implementation.
[0111] Then, calculate the byte size of the stored data: traverse the ring buffer and calculate the sum of the byte sizes of the stored mapping data. If the data in the ring buffer is arranged in a continuous storage manner, the byte size of the stored data can be calculated by the position of the head and tail pointers.
[0112] Next, calculate the remaining available space size: subtract the byte size of the stored data from the total size of the ring buffer to get the remaining available space size.
[0113] C2: When the byte size of the mapping data is less than or equal to the target byte size, storing the mapping data in the ring buffer is performed.
[0114] When the byte size of the mapped data is less than or equal to the target byte size, the mapped data can be stored at the start or end of the ring buffer using pointer operations or array subscript indexing.
[0115] In a possible implementation, the method further includes:
[0116] When the byte size of the mapping data is greater than the target byte size, the mapping data is discarded.
[0117] If the data to be written is larger than the remaining available data space, the buffer area will overflow, resulting in security vulnerabilities and system crashes.
[0118] The size of the mapped data is actually very small. Generally, only when the system is subjected to a brute force attack will the byte size of the mapped data be larger than the remaining available data space of the ring buffer (i.e., the target byte size). In this case, the mapped data can be directly discarded.
[0119] S202: Perform supplementary rule filtering on the data to be detected to obtain filtered data.
[0120] In order to improve the detection efficiency of the abstract syntax tree, before inputting the data to be detected into the pre-built abstract syntax tree, it is also necessary to filter the data to be detected using the defined rules according to the supplementary rules in the mapping data according to the parsed data of the attack behavior detection rule file. According to the type and matching method of the rule, the data to be detected can be traversed one by one, and the rule matching operation can be performed on each data. Filtering is performed to obtain filtered data, which can reduce the amount of data processed by the abstract syntax tree when detecting filtered data, and reduce the delay of the abstract syntax tree in the detection process.
[0121] S203: Input the filtered data into a pre-constructed abstract syntax tree to obtain a detection result.
[0122] After the filtered data to be tested is provided as input to the constructed abstract syntax tree, the abstract syntax tree will use a traversal algorithm (such as depth-first search or breadth-first search) to traverse each node of the abstract syntax tree in a predetermined order. Then the abstract syntax tree performs semantic analysis and detection operations on each node during the traversal process. According to specific needs, specific operations can be performed on each node, such as conditional judgment, variable assignment, function call, etc. By executing the corresponding semantic analysis rules and detection logic, it is determined whether the node meets the requirements and generates the corresponding detection results.
[0123] The detection results include: determination of attack behavior, name of attack behavior, type of attack behavior, affected entities, attack source information, attack time, and possible impact, etc.
[0124] Determination of aggressive behavior: yes or no.
[0125] Attack behavior name: generally includes the main attack method used by the attack behavior, such as DirtyPipe vulnerability escalation attack, Polkit vulnerability escalation attack, PHP Trojan file upload attack, MySQL command execution attack, etc.
[0126] Attack behavior type: The type of attack behavior, such as information reconnaissance, privilege escalation, command execution, and information theft.
[0127] Affected Entity: The target or entity that is attacked, such as a server, application, network device, etc.
[0128] Attack source information: the source IP address, port, or other identification information of the attack behavior.
[0129] Attack Time: The timestamp when the attack was detected.
[0130] Possible impact: The damage or impact that an attack could cause.
[0131] In a possible implementation, the construction process of the pre-constructed abstract syntax tree includes D1-D3:
[0132] D1: Obtain the attack behavior detection rule file.
[0133] By obtaining the attack behavior detection rule file, you can obtain specific rule definitions and configuration information, including attack types, rule conditions, threshold settings, etc. These rules describe the characteristics of malicious behaviors or attack patterns and the corresponding matching logic. These attack behavior detection rule files are an important basis for guiding attack behavior detection.
[0134] D2: Parsing the attack behavior detection rule file to obtain parsed data.
[0135] Parsing the attack behavior detection rule file into a token sequence allows for lexical analysis. Lexical analysis is a step in the compilation process that converts the input character stream into meaningful morphemes (Tokens). Through lexical analysis, basic units such as words, symbols, and identifiers in the rule file can be identified, providing a basis for subsequent syntax analysis and other processing processes.
[0136] D3: Convert the parsed data into the abstract syntax tree.
[0137] After obtaining the parsed data, the attack behavior detection system needs to convert the parsed data (Token) into an Abstract Syntax Tree (AST) by following the steps below:
[0138] Define a node class: First, define a node class that represents each node in the AST. A node class usually contains two main member variables: node value and child node list. The node value represents the logical structure of the current node, which can be an operator such as AND, OR, NOT, or other types in the rule file. The child node list stores the child nodes of the current node.
[0139] Traversing the Token sequence: Next, use the traversal algorithm to traverse the Token sequence. During the traversal process, the corresponding logical structure is determined according to the current Token type, and the corresponding node object is created.
[0140] Build AST: Then, according to the order and logical relationship of the token sequence, the node objects are organized into an abstract syntax tree. During the construction process, the parent-child relationship between nodes is determined according to the priority and association between tokens, thus forming an AST with a hierarchical structure.
[0141] Sub-node connection: According to the agreement in the Token sequence, the corresponding sub-node is added to the sub-node list of the parent node. In this way, the hierarchical relationship and logical structure between nodes can be stored in the AST.
[0142] Return the root node: Finally, return the root node of the AST as the entry to the entire abstract syntax tree.
[0143] S204: Extracting data associated with the detection result from the mapping data as supplementary data.
[0144] To extract data associated with the test result from the mapping data as supplementary data, first, determine how to associate the test result with the mapping data. This may involve a matching relationship between certain attributes or identifiers in the test result and attributes or identifiers in the mapping data. For example, a common unique identifier or certain attribute values can be used for matching. Then traverse the mapping data and check each entry or record one by one. According to the selected association method, find the mapping data entry associated with the test result. Once the mapping data entry associated with the test result is found, extract the required related data according to the requirements. This can include extracting the value of a specific attribute or the entire entry itself from the entry, depending on the supplementary data the user wishes to obtain.
[0145] For example, if the detection result only contains process-class data indicating attack behavior, the supplementary data extracted from the mapping data may include information such as process identifier, process name, user, thread, timestamp, and file name.
[0146] Specifically, according to the process identifier contained in the detection result, information related to the process identifier can be found from the mapping data, such as process name, user, thread, and timestamp. In addition, if the attack behavior involves file reading and writing operations, the corresponding file name information can also be extracted from the mapping data.
[0147] In one possible implementation, the process class detection results can be supplemented with data from system calls such as <clone, clone3, fork, vfork, execve, execveat, close, etresuid, setsid, setuid, setgid, setpgid, setresgid, setsid, capset, chdir, chroot, prctl, fchdir>.
[0148] The network detection results can be supplemented with data from system calls such as <socket, bind, getsockopt, connect, accept>.
[0149] It should be noted that by extracting supplementary data and using it to supplement the output data, the attack behavior can be better analyzed and understood, but the accuracy and security of the supplementary data must also be ensured. At the same time, attention should also be paid to protecting user privacy and sensitive information to avoid leaking sensitive information.
[0150] S205: Using the supplementary data to supplement the output data of the detection result to obtain a complete output result of the attack behavior detection.
[0151] After obtaining the supplementary data related to the detection results, the data can be used to supplement the output data of the detection results to obtain the complete output results of the attack behavior detection. By combining this information with the detection results, a more comprehensive and specific description and analysis can be provided to help users further understand and judge whether there is an attack behavior.
[0152] The use of supplementary data to supplement the output data of the detection results to obtain the output results of the attack behavior can be carried out in the following steps: First, the supplementary data is merged into the detection results to enrich the output results. The specific operation method depends on the structure and format of the data. For example, the supplementary data can be added to the detection results as a new attribute, or the supplementary data can be merged with the existing attributes. Then, based on the addition of the supplementary data, the output results of the attack behavior are generated. This may include operations such as classifying, scoring, and marking the detection results to determine whether there is an attack behavior and provide relevant information. Finally, the generated output results are displayed and presented for users to understand and use. The results can be displayed in the form of charts, text reports, visual interfaces, etc., so that users can understand the detected attack behaviors more intuitively.
[0153] In one possible implementation, the complete output results of attack behavior detection may include: determination of attack behavior, attack behavior name, attack behavior type, affected entities, attack source information, attack time, possible impact, detailed description, abnormal behavior, threat level, and recommended measures, etc.
[0154] Detailed description: A detailed description of the attack behavior, including the steps, purpose, and means of the attack.
[0155] Abnormal behavior: Compare aggressive behavior with normal behavior and point out the abnormality of aggressive behavior.
[0156] Threat Level: An assessment of the degree of threat posed by an attack, usually divided into low, medium, and high levels.
[0157] Recommended measures: Provide corresponding suggestions and recommended countermeasures for detected attack behaviors, including patching vulnerabilities, enhancing security policies, etc.
[0158] Based on the contents of S201-S205, it can be known that the system call combination information, i.e., mapping data, which has been filtered by rules, supplemented by rules, and formally mapped is first obtained from the ring buffer as the data to be detected, and the data to be detected is filtered by supplementary rules to obtain the filtered data. Next, the filtered data is input into a pre-constructed abstract syntax tree to obtain the detection result, and the data associated with the detection result is extracted from the mapping data as supplementary data. Finally, the detection result is supplemented with the output data using the supplementary data to obtain the complete output result of the attack behavior detection. The present application directly performs attack detection based on the system call combination information to improve the timeliness of detection. At the same time, performing attack detection directly based on the system call combination information can prevent attackers from bypassing the attack detection by deleting or tampering with logs. In addition, performing attack detection directly based on source information such as the system call combination information can also improve the traceability capability of the attack detection.
[0159] See also Figure 3 , Figure 3 This is a schematic diagram of the structure of an attack behavior detection device provided in an embodiment of the present application. Figure 3 As shown, the attack behavior detection device includes:
[0160] The first acquisition unit 301 is used to acquire mapping data from the ring buffer as the data to be detected, wherein the mapping data is the system call combination information after rule filtering, rule supplementation and formal mapping;
[0161] A rule filtering unit 302, configured to perform rule filtering on the data to be detected to obtain filtered data;
[0162] An input unit 303, used for inputting the filtered data into a pre-built abstract syntax tree to obtain a detection result;
[0163] An extraction unit 304, configured to extract data associated with the detection result from the mapping data as supplementary data;
[0164] The output data supplementation unit 305 is used to supplement the output data of the detection result with the supplementary data to obtain a complete output result of the attack behavior detection.
[0165] In a possible implementation manner, the device further includes:
[0166] A second acquisition unit is used to acquire the system call combination information through a hook system call list;
[0167] A rule filtering and supplementing unit, configured to perform the rule filtering and rule supplementing on the system call combination information according to the parsed data of the attack behavior detection rule file to obtain filtering supplement data;
[0168] a form mapping unit, configured to perform the form mapping on the filtering supplementary data to obtain the mapping data;
[0169] A storage unit is used to store the mapping data in the ring buffer.
[0170] In a possible implementation, the storage unit includes:
[0171] an identification unit, used for identifying the byte size of the mapping data;
[0172] An execution unit is configured to execute the step of storing the mapping data in the ring buffer when the byte size of the mapping data is less than or equal to the target byte size.
[0173] In a possible implementation manner, the device further includes:
[0174] A discarding unit is used to discard the mapping data when the byte size of the mapping data is greater than the target byte size.
[0175] In a possible implementation manner, the device further includes:
[0176] A third acquisition unit is used to acquire an attack behavior detection rule file;
[0177] A parsing unit, used for parsing the attack behavior detection rule file to obtain parsed data;
[0178] The data conversion unit is used to convert the parsed data into the abstract syntax tree.
[0179] In a possible implementation manner, the first acquiring unit includes:
[0180] A fourth acquisition unit is used to acquire preliminary system call combination information through a hook system call list;
[0181] An information supplement unit is used to supplement the preliminary system call combination information to obtain the system call combination information.
[0182] In addition, an embodiment of the present application also provides an attack behavior detection device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the attack behavior detection method described above is implemented.
[0183] In addition, an embodiment of the present application further provides a computer-readable storage medium, in which instructions are stored. When the instructions are executed on a terminal device, the terminal device executes the attack behavior detection method as described above.
[0184] The embodiment of the present application provides an attack behavior detection device, which first uses the first acquisition unit 301 to obtain mapping data from the ring buffer as the data to be detected, wherein the mapping data is the system call combination information that has been filtered by rules, supplemented by rules, and formally mapped, and the rule filtering unit 302 is used to filter the data to be detected by rules to obtain the filtered data. The input unit 303 inputs the filtered data into the pre-constructed abstract syntax tree to obtain the detection result. Then, the extraction unit 304 is used to extract the data associated with the detection result from the mapping data as supplementary data, so that the output data supplement unit 305 can use the supplementary data to supplement the output data of the detection result to obtain the complete output result of the attack behavior detection. The present application directly performs attack detection based on the system call combination information to improve the timeliness of the detection, and at the same time, directly performs attack detection based on the system call combination information to prevent the attacker from bypassing the attack detection by deleting or tampering with the log. In addition, directly performing attack detection based on the source information such as the system call combination information can also improve the traceability capability of the attack detection.
[0185] The above is a detailed introduction to an attack behavior detection method, device, equipment and storage medium provided by the present application. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the embodiments can refer to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can refer to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.
[0186] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0187] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0188] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0189] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for detecting attack behavior, characterized in that: The method comprises: Acquire mapping data from the ring buffer as data to be detected, wherein the mapping data is system call combination information that has been filtered, supplemented and formally mapped by rules; Performing supplementary rule filtering on the data to be detected to obtain filtered data; Inputting the filtered data into a pre-constructed abstract syntax tree to obtain a detection result; extracting data associated with the detection result from the mapping data as supplementary data; Using the supplementary data to supplement the output data of the detection result to obtain a complete output result of the attack behavior detection; The filtering of the to-be-detected data by supplementary rules to obtain filtered data includes: According to the rules defined in the parsed data of the attack behavior detection rule file, the data to be detected is filtered to obtain the filtered data; wherein the attack behavior detection rule file includes a rule name, a rule description, a detection rule, and a response strategy; The system call combination information performs the rule filtering and the rule supplementation according to the parsed data of the attack behavior detection rule file.
2. The method according to claim 1, characterized in that Before acquiring the mapping data from the ring buffer as the data to be detected, the method further includes: Obtain the system call combination information through the hook system call list; According to the parsed data of the attack behavior detection rule file, the system call combination information is subjected to the rule filtering and rule supplementation to obtain filtering supplement data; Performing the formal mapping on the filtered supplementary data to obtain the mapped data; The mapping data is stored in the ring buffer.
3. The method according to claim 2, characterized in that The storing the mapping data in the ring buffer comprises: identifying a byte size of the mapping data; When the byte size of the mapping data is less than or equal to the target byte size, storing the mapping data in the ring buffer is performed.
4. The method according to claim 3, characterized in that The method further comprises: When the byte size of the mapping data is greater than the target byte size, the mapping data is discarded.
5. The method according to claim 2, characterized in that: The obtaining of the system call combination information through the hook system call list includes: Get the preliminary system call combination information through the hook system call list; The preliminary system call combination information is supplemented to obtain the system call combination information.
6. The method according to claim 1, characterized in that The construction process of the pre-constructed abstract syntax tree includes: Get the attack behavior detection rule file; Parsing the attack behavior detection rule file to obtain parsed data; Convert the parsed data into the abstract syntax tree.
7. An attack behavior detection device, characterized in that: The device comprises: A first acquisition unit is used to acquire mapping data from the ring buffer as data to be detected, wherein the mapping data is system call combination information that has been filtered, supplemented and formally mapped by rules; A rule filtering unit, used for filtering the data to be detected by supplementary rules to obtain filtered data; An input unit, used for inputting the filtered data into a pre-built abstract syntax tree to obtain a detection result; an extraction unit, configured to extract data associated with the detection result from the mapping data as supplementary data; An output data supplement unit, used to supplement the output data of the detection result with the supplementary data to obtain a complete output result of the attack behavior detection; The filtering of the to-be-detected data by supplementary rules to obtain filtered data includes: According to the rules defined in the parsed data of the attack behavior detection rule file, the data to be detected is filtered to obtain the filtered data; wherein the attack behavior detection rule file includes a rule name, a rule description, a detection rule, and a response strategy; The system call combination information performs the rule filtering and the rule supplementation according to the parsed data of the attack behavior detection rule file.
8. The device according to claim 7, characterized in that The device also includes: A second acquisition unit is used to acquire the system call combination information through a hook system call list; A rule filtering and supplementing unit, configured to perform the rule filtering and rule supplementing on the system call combination information according to the parsed data of the attack behavior detection rule file to obtain filtering supplement data; a form mapping unit, configured to perform the form mapping on the filtering supplementary data to obtain the mapping data; The storage unit is used to store the mapping data in the ring buffer.
9. An attack behavior detection device, characterized in that: include: 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 attack behavior detection method according to any one of claims 1 to 6 is implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed on the terminal device, the terminal device executes the attack behavior detection method according to any one of claims 1 to 6.
Citation Information
Patent Citations
A malicious program detection system and method based on VMI
CN109240807A
Extensible intelligent contract vulnerability detection method
CN110659494A
Linux system calling event collection and caching device and method
CN111597089A
Attack detection method and device, model training method and device, server and storage medium
CN112989348A
Active defense method and device of vehicle-mounted system, electronic equipment and storage medium
CN116842516A
