User behavior division and alarm association completion method, system and device based on Bash command and medium
By analyzing and associating Bash command data, a user behavior diagram is constructed, which solves the problems of heterogeneous data analysis and alarm association in industrial Internet systems, improves the detection and traceability of high-risk attack events, and enhances network security protection.
Patent Information
- Application Number
- CN202411033846.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-11-12
AI Technical Summary
Heterogeneous data in industrial Internet systems are difficult to analyze, resulting in an increase in false alarms and low-risk alarms, reducing the efficiency of detection and traceability of high-risk attack events, and the difficulty of alarm correlation completion, affecting the level of network security protection.
By analyzing Bash command data, building a command association diagram, generating user behavior, and associating it with the alarm of security devices, using association weights and community division technologies to improve analysis efficiency and accuracy.
It improves the detection and traceability of high-risk cyber attack incidents, reduces the false alarm rate, and enhances the level of network security protection.
Smart Images

Figure CN118944938A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of industrial Internet security, and in particular relates to a method, system, device and medium for user behavior classification and alarm association completion based on Bash commands. Background Art
[0002] With the rapid development of the Industrial Internet, the challenges facing network security are becoming increasingly severe. The Industrial Internet deeply integrates traditional industrial systems with information technology, achieving comprehensive interconnection and interoperability of equipment, networks, and data. However, this also makes industrial control systems an important target for cyber attacks, and network security risks and threats continue to increase.
[0003] Industrial Internet systems generate massive amounts of multi-source heterogeneous data such as alarm logs, operation logs, and host logs every day. These data are characterized by large quantity, diverse types, and wide sources. Most existing security protection systems use strict intrusion detection rules and protection technologies to improve detection accuracy, resulting in a large number of false positives or low-risk alarms, increasing the difficulty of detecting and tracing high-risk attack events, and increasing the workload of security analysts. Industrial Internet systems face the following two challenges in alarm monitoring and high-risk attack event detection:
[0004] 1. Heterogeneous data is difficult to analyze: A large number of security devices from different manufacturers are deployed in the industrial Internet system. The log rules and formats generated by these devices are different, and there are large differences in the semantics of the logs. Massive false positives and low-risk alarms make it difficult for security analysts to intuitively discover the potential correlation between data, thereby reducing the timeliness and accuracy of the analysis of real alarm behaviors. Existing security protection systems are difficult to effectively integrate these multi-source heterogeneous data, resulting in low efficiency in detecting and responding to high-risk attack incidents.
[0005] 2. Difficulty in correlating and completing alarms: Different types of security logs are often scattered across various systems, making it difficult to directly correlate and analyze them. APT attackers often bypass the detection of network security devices by means of encrypted communications and disguised traffic, resulting in a single type of security log being unable to fully reflect the attack behavior. How to correlate user behavior with the alarms generated by security devices and supplement and improve alarm information is the key to improving network security protection. Summary of the invention
[0006] The purpose of the present invention is to propose a method, system, device and medium for user behavior classification and alarm association completion based on Bash commands, so as to solve the problems that existing heterogeneous data are difficult to analyze and alarm association is difficult to complete.
[0007] In order to achieve the above object, the technical solution adopted by the present invention is:
[0008] The present invention provides a method for user behavior classification and alarm association completion based on Bash commands, comprising the following steps:
[0009] Step 1, parsing each Bash command in the acquired target Bash command data to obtain structured data;
[0010] Step 2: construct the association relationship between Bash commands based on the parsed structured data;
[0011] Step 3, based on the association relationship between Bash commands, construct a Bash command association graph;
[0012] Step 4, generating user behavior according to the obtained Bash command association graph;
[0013] Step 5: Correlate the generated user behavior with the alarm generated by the security device.
[0014] Preferably, in step 1, each Bash command in the acquired target Bash command data is parsed to obtain structured data, and the specific method is:
[0015] Bash command parsing rules are set according to word segmentation semantics, and each Bash command is parsed using the parsing rules to obtain structured data.
[0016] Preferably, for Bash commands that do not conform to the parsing rules, a bashlex parsing tool is used in combination with regular expressions to parse and obtain structured data.
[0017] Preferably, in step 2, an association weight is used to measure the correlation between logs, and the calculation formula for defining the association weight between commands is as follows:
[0018]
[0019] Among them, i and j represent two Bash commands, p i Represents the parameter list of Bash command i, n i Indicates the sequence number of Bash command i in the log file; weight ij is the association weight between Bash command i and Bash command j; a is the set hyperparameter.
[0020] Preferably, in step 3, the specific method of constructing the Bash command association graph is:
[0021] Multiple consecutive Bash commands of the same type in structured data are aggregated into one node, and the sum of the association weights between nodes is used as the edge weight to construct a Bash command association graph.
[0022] Preferably, in step 4, the user behavior is generated according to the obtained Bash command association graph, and the specific method is:
[0023] The Bash command association graph is divided into communities to obtain multiple communities, each of which is a user behavior.
[0024] Preferably, in step 5, the generated user behavior is associated with the alarm generated by the security device, specifically by:
[0025] Match the timestamp, source IP, source port, destination IP, and destination port of each network alarm log in the alarm generated by the security device with the user behavior, where:
[0026] If each network alarm log matches a user behavior, the user behavior is associated with the network alarm log;
[0027] If each network alarm log matches multiple user behaviors, the alarm type and alarm payload of the network alarm log are associated and matched with the keywords and entity parameter features of the Bash command in each user behavior, and the user behavior with the highest matching degree is associated with the network alarm log.
[0028] A user behavior classification and alarm association completion system based on Bash commands, including:
[0029] A command parsing unit, used for parsing each Bash command in the acquired target Bash command data to obtain structured data;
[0030] An association relationship building unit is used to build association relationships between Bash commands based on the parsed structured data;
[0031] A correlation graph building unit, used for building a Bash command correlation graph based on correlation relationships between Bash commands;
[0032] A user behavior generating unit, used for generating user behavior according to the obtained Bash command association graph;
[0033] The alarm association and completion unit is used to associate the generated user behavior with the alarm generated by the security device.
[0034] A computer-readable storage medium storing one or more programs, the one or more programs including instructions, which when executed by a computing device, cause the computing device to perform the method described.
[0035] A computing device comprising:
[0036] One or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs include steps for executing the method.
[0037] Compared with the prior art, the present invention has the following beneficial effects:
[0038] The present invention proposes a method for user behavior classification and alarm association completion based on Bash commands. By parsing Bash commands, the method converts them into structured data, constructs a command association graph, and performs community classification to generate user behaviors, thereby helping security personnel to perform batch interpretability analysis of Bash commands. At the same time, the generated user behaviors are associated with the alarms generated by security devices, thereby supplementing the alarm information and improving the detection and tracing capabilities of high-risk network attack events. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 It is a flow chart of the present invention;
[0040] Figure 2 This is a diagram of the Bash command parsing method and results;
[0041] Figure 3 This is a schematic diagram of Bash command parsing results using nmap as an example;
[0042] Figure 4 This is a schematic diagram of the Bash command association graph constructed based on association weights;
[0043] Figure 5 Schematic diagram of user behavior extraction results. DETAILED DESCRIPTION
[0044] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0045] Example 1
[0046] Figure 1 This is an overall flow chart of the user behavior segmentation and alarm association completion method based on Bash commands proposed in the present invention, which shows the main process framework of the method for correlation analysis of host log data and alarm data in the industrial Internet scenario.
[0047] The present invention proposes a method for user behavior division and alarm association completion based on Bash commands. Firstly, Bash commands are parsed in batches and converted into structured data. Secondly, a command association graph is constructed according to the Bash command structured data, and community division is performed to generate user behaviors, so as to help security personnel perform batch interpretability analysis of Bash commands. Finally, the generated user behavior data is matched and associated with the alarm data generated by the security equipment, so as to supplement the alarm data information and greatly improve the detection and tracing capabilities of high-risk network attack events.
[0048] Specifically, the steps include:
[0049] Step 1: Parsing Bash Commands
[0050] The Bash commands are segmented and the words in each command are divided into four categories according to the semantics of the word segmentation: permissions, keywords, options, and parameters.
[0051] According to the operating user of the Bash command and the command permission access control, the execution permission of each command is divided into root and user;
[0052] According to the keywords of Bash commands, the executable files involved in Bash commands are identified, and the commands are further divided into operation types such as file operations (ls, cd, etc.), network connections (ssh, ping, etc.), and process management (ps, top, etc.) according to their corresponding functions.
[0053] Combined with the operation types to which different commands belong, the semantics of Bash commands can be preliminarily extracted and divided. The classification of common Bash command keywords is shown in Table 1. The present invention divides Bash command keywords into 24 categories according to functional semantic information, and the table gives several examples of command keywords contained in each category.
[0054] According to the correspondence between the options and parameters of the Bash command, the specific operation behaviors corresponding to the Bash command can be obtained, such as connecting to the target IP, opening the specified port, editing and executing files, etc.
[0055] like Figure 2 As shown in the figure, this command runs the mikesplain / openvas image with Docker as an administrator, names the container openvas, and maps port 443 in the container to port 443 in the original system.
[0056] Table 1 Classification of common Bash commands
[0057]
[0058]
[0059]
[0060] The present invention organizes dozens of common Bash command types, including keywords: ssh, sshuttle, nmap, apt, apt-get, docker, curl, vim, etc. By setting a parsing rule base for these logs, the user behavior information contained in the logs can be extracted. Figure 3 As shown, the above parameter feature extraction method is applied to a nmap scan blasting log record to extract the target IP, target port, script name and script parameters.
[0061] For Bash commands that do not exist in other rule libraries, the present invention uses the bashlex parsing tool to accurately segment these commands, and parses the "option-parameter" structure in the form of "--option=value" through regular expressions, extracts the semantic information of options and parameters in the log, and stores the parsing results in the database for subsequent analysis of user behavior extraction and associated behavior matching processes.
[0062] Step 2: Build Bash command associations
[0063] In order to extract the effective behavior of users from the massive Bash commands, the present invention uses association weights to measure the correlation between logs.
[0064] The correlation between Bash commands is mainly reflected in two aspects: similar execution time and similar command parameters and entities:
[0065] (1) Logs with similar execution times. For example, after a user executes the ls command to view the file information in the current directory, he or she will usually execute commands such as cd and vim to switch directories and edit files. These operations have obvious logical relationships and should be attributed to a valid operation of the user.
[0066] (2) Commands containing similar parameters and entities. For example, after a user executes a vim operation to modify an executable file, he further runs the file through a python or bash command. There may be a certain interval between the execution times of these logs, but they are related operations on the same object and should also be attributed to a valid operation behavior of the user.
[0067] The calculation formula for defining the association weight between Bash commands is as follows:
[0068]
[0069] Among them, i and j represent two Bash commands, p i Represents the parameter list of Bash command i, ni Indicates the sequence number of Bash command i in the log file; weight ij is the association weight between Bash command i and Bash command j; α is the set hyperparameter.
[0070] Therefore, the closer the execution sequence numbers of two Bash commands in the log file are, the more identical parameters they have, and the greater the association weight.
[0071] Step 3: Build a Bash command association graph
[0072] For massive Bash commands, consecutive commands of the same type are aggregated into one node, and the association weights between nodes are summed as edge weights to construct a Bash command association graph.
[0073] like Figure 4 As shown in the figure, three Bash commands are used as an example to illustrate the association of Bash commands. The three command texts are: wget https: / / ... / LinEnum.sh, ls, and bash LinEnum.sh. Based on the logic of the command sequence, it can be assumed that the attacker first downloaded the malicious script LinEnum.sh from the host through the wget command, then confirmed whether the script was downloaded successfully through the ls command, and finally executed the script through the bash command to launch malicious attack behavior.
[0074] The above Bash command association algorithm not only takes into account the operation logic of the log generation sequence, but also retains the logical relationship between downloading scripts and executing scripts, making the association graph finally constructed more complete, accurate and reliable.
[0075] Step 4: Bash command community segmentation and user behavior generation
[0076] When dividing Bash command communities and generating user behaviors, the Louvain algorithm is used to divide the Bash command association graph into each community, and each community is a valid operation of the user.
[0077] Figure 5The result diagram of user behavior extraction for Bash commands is shown, where cmd_id represents the serial number of the Bash command in the Bash command log file. The user behavior shown in the figure is as follows: the attacker first downloads the malicious script dirty.c from another controlled host in the LAN through the wget command, and then collects the system version information through continuous cat and uname commands. Then the attacker uses the gcc command to compile the dirty.c file. Although there are 7 other logs between the gcc compilation and the download of the file, this algorithm can still capture the correlation between the two logs and divide them into the same user behavior. Finally, the attacker attempts to connect to the 20.209.115.250 host through multiple ftp commands, and sends the file content of flag.txt to the 6666 port of 20.209.115.183 through the nc command, completing an attack process. The log sequence contained in the division result has an obvious logical relationship in the behavior semantic features, which fully describes an attack behavior implemented by the attacker, and verifies the effectiveness of the user behavior extraction algorithm based on host behavior association weight analysis.
[0078] Step 5: Correlate alarm data
[0079] The network connection process initiated by the host in the network environment is mostly generated by certain host operations or command execution processes. For example, when the nmap command is executed on the host to scan the host survival and port openness of the target network segment, the host will generate a large number of connection behaviors and communication traffic. After these abnormal traffic is identified by the security protection equipment, a large number of network alarm logs will be generated. Therefore, there is a characteristic correlation relationship between network alarm logs and host user behavior in certain dimensions that confirms each other.
[0080] First, match the user behavior with the timestamp, source IP, source port, destination IP, and destination port of the network alarm log. If only one user behavior is matched, the user behavior is directly associated with the corresponding network alarm log. If multiple user behaviors are matched, the alarm type and alarm payload of the network alarm log are further associated with the keywords and entity parameter features of the Bash command in the user behavior. The matching rules are shown in Table 2. Associate the user behavior with the highest number of matches with the corresponding network alarm log.
[0081] Table 2 Network alarm and user behavior correlation table (partial)
[0082]
[0083]
[0084] Example 2
[0085] This embodiment provides a Bash command-based user behavior classification and alarm association completion system, which is characterized by including:
[0086] A command parsing unit, used for parsing each Bash command in the acquired target Bash command data to obtain structured data;
[0087] An association relationship building unit is used to build association relationships between Bash commands based on the parsed structured data;
[0088] A correlation graph building unit, used for building a Bash command correlation graph based on correlation relationships between Bash commands;
[0089] The user behavior generating unit is used to generate user behavior according to the obtained Bash command association diagram; the alarm association completion unit is used to associate the generated user behavior with the alarm generated by the security device.
[0090] Example 3
[0091] This embodiment also provides a storage medium, specifically a computer-readable storage medium (Memory), which is a memory device in a terminal device for storing programs and data. It is understandable that the computer-readable storage medium here can include both the built-in storage medium in the terminal device and the extended storage medium supported by the terminal device. The computer-readable storage medium provides a storage space, which stores the operating system of the terminal. In addition, one or more instructions suitable for being loaded and executed by the processor are also stored in the storage space, and these instructions can be one or more computer programs (including program codes). It should be noted that the computer-readable storage medium here can be a high-speed RAM memory, or a non-volatile memory (Non-Volatile Memory), such as at least one disk memory.
[0092] One or more instructions stored in a computer-readable storage medium may be loaded and executed by a processor to implement the corresponding steps of the method in the above embodiment; one or more instructions in a computer-readable storage medium may be loaded and executed by a processor to implement the method.
[0093] Example 4
[0094] A computing device provided in this embodiment, the terminal device includes a processor and a memory, the memory is used to store a computer program, the computer program includes program instructions, and the processor is used to execute the program instructions stored in the computer storage medium. The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc., which are the computing core and control core of the terminal, which are suitable for implementing one or more instructions, and are specifically suitable for loading and executing one or more instructions to implement the corresponding method flow or corresponding functions; the processor described in this embodiment can be used for the operation of the method.
[0095] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for user behavior classification and alarm association completion based on Bash commands, characterized in that: The following steps are involved: Step 1, parsing each Bash command in the acquired target Bash command data to obtain structured data; Step 2: construct the association relationship between Bash commands based on the parsed structured data; Step 3, based on the association relationship between Bash commands, construct a Bash command association graph; Step 4, generating user behavior according to the obtained Bash command association graph; Step 5: Correlate the generated user behavior with the alarm generated by the security device.
2. According to the method of user behavior classification and alarm association completion based on Bash command in claim 1, it is characterized in that: In step 1, each Bash command in the acquired target Bash command data is parsed to obtain structured data. The specific method is: Bash command parsing rules are set according to word segmentation semantics, and each Bash command is parsed using the parsing rules to obtain structured data.
3. According to the method of user behavior classification and alarm association completion based on Bash command in claim 2, it is characterized in that: For Bash commands that do not conform to the parsing rules, the bashlex parsing tool is used in combination with regular expressions to parse and obtain structured data.
4. According to the method of user behavior classification and alarm association completion based on Bash command in claim 1, it is characterized in that: In step 2, the correlation weight is used to measure the correlation between logs. The calculation formula for defining the correlation weight between commands is as follows: Among them, i and j represent two Bash commands, p i Represents the parameter list of Bash command i, n i Indicates the sequence number of Bash command i in the log file; weight ij is the association weight between Bash command i and Bash command j; a is the set hyperparameter.
5. According to the method of user behavior classification and alarm association completion based on Bash command in claim 1, it is characterized in that: In step 3, the specific method of constructing the Bash command association graph is: Multiple consecutive Bash commands of the same type in structured data are aggregated into one node, and the sum of the association weights between nodes is used as the edge weight to construct a Bash command association graph.
6. The method for user behavior classification and alarm association completion based on Bash command according to claim 1, characterized in that: In step 4, user behavior is generated based on the obtained Bash command association graph. The specific method is: The Bash command association graph is divided into communities to obtain multiple communities, each of which is a user behavior.
7. The method for user behavior classification and alarm association completion based on Bash command according to claim 1, characterized in that: In step 5, the generated user behavior is associated with the alarm generated by the security device by: Match the timestamp, source IP, source port, destination IP, and destination port of each network alarm log in the alarm generated by the security device with the user behavior, where: If each network alarm log matches a user behavior, the user behavior is associated with the network alarm log; If each network alarm log matches multiple user behaviors, the alarm type and alarm payload of the network alarm log are associated and matched with the keywords and entity parameter features of the Bash command in each user behavior, and the user behavior with the highest matching degree is associated with the network alarm log.
8. A user behavior classification and alarm association completion system based on Bash commands, characterized in that: include: A command parsing unit, used for parsing each Bash command in the acquired target Bash command data to obtain structured data; An association relationship building unit is used to build association relationships between Bash commands based on the parsed structured data; A correlation graph building unit, used for building a Bash command correlation graph based on correlation relationships between Bash commands; A user behavior generating unit, used for generating user behavior according to the obtained Bash command association graph; The alarm association and completion unit is used to associate the generated user behavior with the alarm generated by the security device.
9. A computer-readable storage medium storing one or more programs, characterized in that: The one or more programs include instructions, which, when executed by a computing device, cause the computing device to perform the method of any one of claims 1 to 7.
10. A computing device, characterized in that include: One or more processors, a memory and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs include steps for executing the method according to any one of claims 1 to 7.
