Log data acquisition method and device, equipment and storage medium
By obtaining and analyzing the IP data stream and original log data stream of the target client, and using preset mapping status and key partition processing, log data streams that meet the target time conditions are obtained in real time, solving the problem that traditional log collection methods cannot cover all attack scenarios. , achieving precise monitoring of network activities and timely response to security threats.
Patent Information
- Application Number
- CN202411016712.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-26
- Publication Date
- 2024-10-15
AI Technical Summary
Traditional log collection methods cannot cover all attack scenarios, and there is a risk of missed and false positives. It is difficult to fully understand the operating status and security risks of the system, and fails to detect potential security risks and abnormal behaviors in a timely manner.
By obtaining the Internet protocol address IP data stream and original log data stream of the target client, using the preset mapping status to determine the target time condition, key partition processing and data parsing processing, extracting the IP address and log data, generating the connection data stream, and obtaining the satisfaction in real time Target log data flow with target time conditions to accurately locate and identify possible attack behaviors.
It realizes real-time monitoring of network traffic, timely discovery of potential threats and attacks, improves the ability to monitor and analyze network activities, and ensures system security and timely response to defense measures.
Smart Images

Figure CN118784336A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a log data acquisition method, device, equipment and storage medium. Background Art
[0002] In common data security management processes, for example, when using network security monitoring systems, intrusion detection systems, firewalls, log management systems and other systems, when the system detects abnormal behavior, security events or alarm rule triggers, the system will generate corresponding alarm information and record it in the log for subsequent analysis, processing and response.
[0003] In related solutions, the main method is to collect log information related to alarm behaviors by defining rules in advance. Once the rule conditions are triggered, the relevant log information is collected for analysis. However, traditional log collection methods cannot cover all attack scenarios, and there are risks of missed reports and false reports. It is difficult to fully understand the operating status and security risks of the system, which is not conducive to discovering potential security risks and abnormal behaviors. Summary of the invention
[0004] The embodiments of the present application provide a log data acquisition method, apparatus, device and storage medium, which can solve the technical problem of how to more comprehensively and efficiently acquire log data related to network attack behaviors.
[0005] In a first aspect, an embodiment of the present application provides a method for obtaining log data, including:
[0006] Get the target client's Internet Protocol address IP data stream and raw log data stream.
[0007] The target time condition is determined according to the preset mapping state corresponding to the IP data stream. The preset mapping state is used to indicate that the target user terminal has a time range corresponding to a preset attack operation. The target time condition includes: a target timestamp and a target time range value.
[0008] Obtain a target log data stream that meets the target time condition from the original log data stream.
[0009] In one implementation, the IP data stream and the original log data stream are respectively partitioned by key to obtain a keyed IP data stream and a keyed log data stream; the keyed IP data stream and the keyed log data stream are connected to generate a connected data stream; and a preset mapping state corresponding to the IP data stream is determined according to the connected data stream.
[0010] In one implementation, data parsing is performed on the IP data stream and the original log data stream to extract the IP address corresponding to the IP data stream and the IP address corresponding to the original log data stream; the IP data stream is partitioned by key according to the IP address corresponding to the IP data stream to obtain a keyed IP data stream; the original log data stream is partitioned by key according to the IP address corresponding to the original log data stream to obtain a keyed log data stream.
[0011] In one implementation, determining the preset mapping state corresponding to the IP data stream according to the connection data stream includes: querying the connection data stream for a preset IP address, the preset IP address being an IP address in the IP data stream of the target user end obtained again;
[0012] If the preset IP address is not found in the connection data stream, a preset mapping state corresponding to the preset IP address is created according to the preset IP address, the first preset timestamp and the first preset time range; the first preset timestamp is used to indicate the start time of the target user terminal corresponding to the preset IP address to perform the preset attack operation, and the first preset time range is used to indicate the duration of the target user terminal corresponding to the preset IP address to perform the preset attack operation;
[0013] If the preset IP address is queried in the connection data stream, the first preset timestamp is updated using the second preset timestamp and / or the first preset time range is updated using the second preset time range to obtain a preset mapping state; the second preset timestamp is used to indicate the start time when the target user terminal corresponding to the preset IP address executes the preset attack operation again, and the second preset time range is used to indicate the duration when the target user terminal corresponding to the preset IP address executes the preset attack operation again.
[0014] In one implementation, obtaining a target log data stream that meets a target time condition from an original log data stream includes: obtaining a timestamp corresponding to the original log data stream; determining whether the timestamp corresponding to the original log data stream is consistent with the target timestamp;
[0015] When the timestamp corresponding to the original log data stream is inconsistent with the target timestamp, the absolute value of the difference between the timestamp of the original log data stream and the target timestamp is calculated to obtain the target time difference;
[0016] When the target time difference value is less than or equal to the target time range value, the original log data stream is determined as the target log data stream.
[0017] In one implementation, when the timestamp corresponding to the original log data stream is consistent with the target timestamp, the original log data stream is determined as the target log data stream.
[0018] In one implementation, obtaining the Internet Protocol address IP data stream and the original log data stream of the target user terminal includes: configuring a distributed message processing system connector in a distributed stream computing engine; and obtaining the IP data stream and the original log data stream from the distributed message processing system using the distributed message processing system connector.
[0019] In a second aspect, an embodiment of the present application provides a log data acquisition device, which has the function of implementing the method in the first aspect or any possible implementation thereof. Specifically, the device includes a unit that implements the method in the first aspect or any possible implementation thereof.
[0020] In one embodiment, the device comprises:
[0021] The acquisition unit is used to acquire the Internet Protocol address IP data stream and the original log data stream of the target user end.
[0022] The processing unit is used to determine the target time condition according to the preset mapping state corresponding to the IP data stream, the preset mapping state is used to indicate that the target user terminal has a time range corresponding to the preset attack operation, and the target time condition includes: a target timestamp and a target time range value.
[0023] The processing unit is further configured to obtain a target log data stream that meets a target time condition from the original log data stream.
[0024] In a third aspect, an embodiment of the present application provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the computer device implements a method according to any one of the implementation modes of the first aspect.
[0025] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a computer device, the computer device implements the method of any one of the implementation methods of the first aspect above.
[0026] In a fifth aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on a computer device, the computer device executes a method of any one of the implementation modes of the first aspect above.
[0027] Compared with the prior art, the embodiments of the present application have the following beneficial effects: by acquiring IP data streams and original log data streams, network data and detailed log information of the target user end, such as IP addresses, network traffic, attack events, etc., can be collected; acquiring these data streams in real time helps to monitor the network traffic of the target user end in real time, detect abnormal behaviors, and conduct real-time analysis, thereby timely discovering potential threats and attack behaviors; using preset mapping states to determine the time range corresponding to preset attack operations that may exist on the target user end helps the system to accurately locate and analyze potential attack behaviors; by acquiring target log data streams that meet the target time conditions, possible attack behaviors can be more accurately located and identified, which helps to monitor network activities in real time, discover security threats and respond in a timely manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 This is a log data relationship diagram of an attacker provided in an embodiment of the present application.
[0029] Figure 2 It is a flow chart of a log data acquisition method provided in an embodiment of the present application.
[0030] Figure 3 It is a schematic diagram of a scenario of key partition processing provided in an embodiment of the present application.
[0031] Figure 4 It is a flow chart of a method of partitioning IP data streams and original log data streams by key provided in an embodiment of the present application.
[0032] Figure 5 It is a flow chart of another log data acquisition method provided in an embodiment of the present application.
[0033] Figure 6 This is a logical diagram for implementing screening and matching of Log-keyed data streams using map states, provided in an embodiment of the present application.
[0034] Figure 7 It is a structural diagram of a log data acquisition device provided in an embodiment of the present application.
[0035] Figure 8 It is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0036] Cyber attacks refer to malicious acts against network systems, services or data, with the purpose of destroying, invading, stealing information or violating network security. Common cyber attacks include but are not limited to the following main types:
[0037] Denial of Service (DoS) attack: The attacker sends a large number of requests or malicious traffic to the target system in order to exhaust system resources, cause service unavailability, or prevent normal users from accessing the target system.
[0038] Distributed Denial of Service (DDoS): Similar to DoS attacks, but DDoS attacks are launched by a large number of hosts distributed around the world, making them more difficult to defend and prevent.
[0039] Malware: includes computer viruses, worms, Trojans and other malicious software used to infect, damage, steal information or control of target systems.
[0040] Phishing: Attackers disguise themselves as legitimate organizations or individuals and use false information or links to trick users into providing sensitive information, such as passwords, account numbers, etc.
[0041] Targeted Attacks: Attacks directed at specific targets, usually highly customized and covert, aimed at obtaining key information or control of the target system.
[0042] Ransomware attacks: encrypt files or systems and then blackmail victims to pay a ransom to unlock the infected systems or data.
[0043] Side Channel Attacks: Obtain sensitive information by exploiting the physical characteristics or imperfect implementation of the target system, such as power consumption, electromagnetic leakage, etc.
[0044] These network attacks may lead to serious consequences such as system vulnerabilities being exploited, data leakage or system paralysis. Therefore, timely detection and defense of such attacks are crucial for network security.
[0045] In order to more comprehensively and accurately characterize the attacker's profile and activity patterns, it is necessary to obtain as comprehensive log data as possible from the attacker. Figure 1 Let me introduce it in detail.
[0046] Figure 1 This is a log data relationship diagram of an attacker provided in an embodiment of the present application.
[0047] like Figure 1 As shown, according to the division method of the present application, the attacker's log data can be divided into log data that causes alarm behavior, alarm data within a preset time range, and full log data according to the size of the range.
[0048] In traditional solutions, the attacker's network attack behavior is often analyzed only according to pre-set rules and only for the log data that causes alarm behavior. However, this method cannot grasp all the attacker's attack behaviors, because the pre-set rules have a lag and can be easily circumvented by the attacker. It is difficult to grasp the complete attack pattern only by relying on the log data that causes alarm behavior, which can easily lead to a large number of loopholes in the user's security protection.
[0049] In response to the above problems, this application proposes a log acquisition method that can obtain more comprehensive log data of attackers in real time, thereby improving users' protection against attack behaviors.
[0050] In order to further illustrate the technical solution of the present application, specific embodiments are provided below.
[0051] Figure 2 It is a flow chart of a log data acquisition method provided in an embodiment of the present application.
[0052] like Figure 2 As shown, the above method includes the following steps S201 to S203.
[0053] S201, obtaining the Internet Protocol address IP data stream and the original log data stream of the target user terminal.
[0054] IP data stream refers to a number of data packets transmitted in the network, which contains a series of information of the target user end, such as IP address, port number, etc. The specific information can be set according to the actual situation and is not limited here.
[0055] The original log data stream refers to the unprocessed or unparsed log data stream generated by the target user. These original log data can record information such as attack events, user operations, network traffic, etc., and can be used for security monitoring, troubleshooting, performance analysis, etc.
[0056] For example, suppose there is a network security device that collects IP address information of different target users and generates IP data flow records. At the same time, the device also collects raw log data flows, which contain detailed log information generated by different target users.
[0057] By acquiring these data streams in real time, they can be used to monitor the network traffic of the target user end in real time, detect abnormal behavior, and perform real-time analysis.
[0058] S202: Determine a target time condition according to a preset mapping state corresponding to the IP data stream.
[0059] The preset mapping state is used to indicate that a time range corresponding to a preset attack operation exists on the target user end, and the target time condition includes: a target timestamp and a target time range value.
[0060] The preset map state can show the time range corresponding to the network attack operation mentioned above (or other network attack behaviors) on the target user side. Specifically, State refers to the data accumulated by the application during its processing, and map State is used to store key-value pair type State.
[0061] Using the preset map state can help the system determine the target time conditions and then locate and analyze potential attack behaviors.
[0062] Timestamp refers to the information that marks the specific time point or moment when the attack behavior occurs in the data record. Timestamp can be used to determine the order and time interval of the attack behavior.
[0063] The time range indicates the range of duration of the attack behavior, which can be the time interval or event duration allowed within a period of time. It is understood that the specific timestamp and time range vary according to the actual attack behavior, and are not specifically limited here.
[0064] In other words, the target time condition is determined according to the preset mapping state corresponding to the IP data stream, so that the system can accurately locate and identify possible attack operations on the target user end, which is conducive to further analysis and processing.
[0065] S203: Acquire a target log data stream that meets a target time condition from the original log data stream.
[0066] Target log data streams can be used to analyze and audit network activities, helping to determine the source, target, and scope of impact of attacks so as to conduct event tracing and source analysis.
[0067] By filtering and extracting relevant log data that meets the target time conditions, possible attack behaviors can be more accurately located and identified, which helps to respond to and handle security incidents in a timely manner. By obtaining the target log data stream that meets the target time conditions in real time, network activities can be monitored in real time, potential security threats can be discovered, and security warning mechanisms can be triggered to take corresponding defensive measures in a timely manner.
[0068] The above-mentioned log acquisition method can collect the network data and detailed log information of the target user end, including IP address, network traffic, attack events, etc., by acquiring IP data streams and original log data streams. Real-time acquisition of these data streams is helpful for real-time monitoring of the network traffic of the target user end, detecting abnormal behaviors, and performing real-time analysis, so as to timely discover potential threats and attack behaviors; using the preset mapping state to determine the time range corresponding to the preset attack operation that may exist in the target user end is helpful for the system to accurately locate and analyze potential attack behaviors; by acquiring the target log data stream that meets the target time condition, possible attack behaviors can be more accurately located and identified, which is helpful for real-time monitoring of network activities, discovering security threats and responding in time.
[0069] In other words, by acquiring and analyzing the network data and log information of the target user end, real-time monitoring and detection of attack behaviors can be achieved, and potential security threats can be discovered in a timely manner. By determining the target time conditions and extracting the target log data that meets the conditions, possible attack behaviors can be identified more accurately, helping the system to quickly locate the problem and take necessary security measures. By deeply analyzing and tracing the log data related to the attack behavior, it is helpful to determine the source, target and scope of the attack, conduct event tracing and accurate analysis, and help the system take corresponding security defense measures in a timely manner to ensure the security of the system and data.
[0070] It can be understood that compared with the traditional solution of only obtaining the log data of the alarm triggering behavior according to the pre-set alarm rules, the log data can be obtained in a targeted manner by determining the start time and duration of the attacker's attack behavior according to the preset map state. In other words, the present application can obtain the corresponding log data according to the attack behavior of different attackers, and at the same time expand the time span of the log data, that is, more log data is obtained, and the attack behavior of each attacker can be comprehensively evaluated, which is beneficial to the subsequent data security protection.
[0071] In one implementation, the IP data stream and the original log data stream are respectively partitioned by key to obtain a keyed IP data stream and a keyed log data stream; the keyed IP data stream and the keyed log data stream are connected to generate a connected data stream; and a preset mapping state corresponding to the IP data stream is determined according to the connected data stream.
[0072] KeyBy processing is to divide data into different partitions or groups based on specific key values in the data (such as IP addresses or other identifiers). This helps improve the efficiency of data processing so that data with the same key value can be assigned to the same processing unit.
[0073] Combine the following Figure 3 Let me introduce it in detail.
[0074] Figure 3 It is a schematic diagram of a scenario of key partition processing provided in an embodiment of the present application.
[0075] like Figure 3 As shown, data cells with the same color represent that the data have the same key value, and data cells with different colors represent that the key values of the data are different. After key partitioning (which can also be understood as classification by key value), data with the same key value is divided into the same area, and data with different key values occupy different areas.
[0076] Keying usually refers to the operation of processing, grouping or connecting data according to a key value or key information. Keying can achieve more sophisticated control and organization of data, making processing more efficient and orderly.
[0077] Connecting data streams means connecting two or more data streams according to preset association conditions to generate a new data stream. For example, the connection between data can be established based on a common key value or other association information.
[0078] Through the above method, IP data and log data with the same IP address are associated, which is conducive to providing more complete information for subsequent analysis.
[0079] By analyzing and processing the connection data stream, the preset mapping state corresponding to the IP data stream can be determined, which can help the system identify and mark the time conditions related to the preset attack operations, providing support for further security analysis and response.
[0080] In one implementation, data parsing is performed on the IP data stream and the original log data stream to extract the IP address corresponding to the IP data stream and the IP address corresponding to the original log data stream; the IP data stream is partitioned by key according to the IP address corresponding to the IP data stream to obtain a keyed IP data stream; the original log data stream is partitioned by key according to the IP address corresponding to the original log data stream to obtain a keyed log data stream.
[0081] As an example but not limitation, the IP data stream may be parsed in JSON format to extract the IP address field, the IP acquisition timestamp field, and the log acquisition time range (duration) field.
[0082] As an example but not limitation, the Log data stream may be parsed in JSON format to extract the IP address field, the log generation timestamp field, and the log acquisition time range field.
[0083] It can also be understood that the IP data stream and the Log data stream are partitioned by key according to the IP address field to obtain the IP keyed data stream and the Log keyed data stream, and the IP keyed data stream and the Log keyed data stream are connected to obtain the IP-Log keyed connection data stream.
[0084] Combine the following Figure 4 Let me introduce it in detail.
[0085] Figure 4 It is a flow chart of a method of partitioning IP data streams and original log data streams by key provided in an embodiment of the present application.
[0086] like Figure 4 As shown in part (A), when an IP data stream is obtained, assuming that the IP data stream includes two IP addresses, IP-1 and IP-2, key partitioning is performed according to the IP addresses, and the IP data from IP-1 is stored in one partition, and the IP data from IP-2 is stored in another partition.
[0087] Similarly, if Figure 4 As shown in part (B) of the figure, when the Log data stream is obtained, assuming that the Log data stream includes Log data from two IP addresses, IP-1 and IP-2, key partitioning is performed according to the IP address, and the Log-1 data from IP-1 is stored in one partition, and the Log-2 data from IP-2 is stored in another partition.
[0088] By parsing the IP data stream and the original log data stream, extracting the corresponding IP addresses, and then performing key partitioning based on these IP addresses, it is possible to achieve refined processing and organization of the data so that data with the same IP address can be aggregated together. This allows for a better understanding and analysis of the relationship between the data, and the discovery of potential correlation patterns or anomalies. At the same time, it also helps to improve the efficiency and performance of data processing.
[0089] In other words, after the IP data stream and the Log data stream are partitioned by key according to the IP field, the data of the same IP will be divided into the same partition, which is conducive to the subsequent setting of parallelism parameters to improve the processing efficiency of the program. It also makes the map state corresponding to the same IP address only need to store the relevant information of the same IP, simplifying the subsequent log matching judgment logic.
[0090] In one implementation, determining a preset mapping state corresponding to an IP data stream according to a connection data stream includes:
[0091] Querying a preset IP address in the connection data stream, where the preset IP address is the IP address in the IP data stream of the target user end obtained again;
[0092] If the preset IP address is not found in the connection data stream, a preset mapping state corresponding to the preset IP address is created according to the preset IP address, the first preset timestamp and the first preset time range; the first preset timestamp is used to indicate the start time of the target user terminal corresponding to the preset IP address to perform the preset attack operation, and the first preset time range is used to indicate the duration of the target user terminal corresponding to the preset IP address to perform the preset attack operation;
[0093] If the preset IP address is queried in the connection data stream, the first preset timestamp is updated using the second preset timestamp and / or the first preset time range is updated using the second preset time range to obtain a preset mapping state; the second preset timestamp is used to indicate the start time when the target user terminal corresponding to the preset IP address executes the preset attack operation again, and the second preset time range is used to indicate the duration when the target user terminal corresponding to the preset IP address executes the preset attack operation again.
[0094] The following is an introduction with specific examples.
[0095] It can be understood that when an IP address first enters the IP data stream, a map state is created for the IP address.
[0096] For example, you can construct the following map state with the IP address "192.168.2.9":
[0097] {
[0098] "ip":"192.168.2.9",
[0099] "timestamp":1719536473013,
[0100] "duration":300
[0101] }.
[0102] Among them, ip represents the identity of the attacker, timestamp and duration represent the acquisition of all logs of the attacker 192.168.2.9 within the time range of duration (for example, 300 seconds) starting from the timestamp moment (for example, 1719536473013) milliseconds.
[0103] If the IP data stream is obtained again, the IP address obtained again can be queried in the connection data stream. If a certain IP address has never appeared before, a corresponding map state is created for the IP address according to the above.
[0104] If an IP address has appeared in the previous IP data stream, and a data with the same IP address and a timestamp value of 1719536573013 milliseconds and a duration of 500 seconds is received after a period of time, the new timestamp and time range are used to overwrite the old timestamp and time range, and the map status is updated as follows:
[0105] {
[0106] "ip":"192.168.2.9",
[0107] "timestamp":1719536573013,
[0108] "duration":500
[0109] }.
[0110] The updated map status indicates that all logs of the attacker with IP address 192.168.2.9 within the duration of 500 seconds are counted starting from timestamp 1719536573013.
[0111] It can be understood that in the process of obtaining logs within the time range specified by the attacker from the Log data stream, the IP data stream actually plays the role of log filtering. The corresponding Log data is obtained by using the timing timestamp and time range fields stored in the map state corresponding to the IP data stream and required for matching the Log data stream, and the log data that is not within the above time period is filtered out from the source of data acquisition. Furthermore, the map state can be continuously updated to ensure that users can configure the attacker IP for which logs need to be obtained on demand, which is conducive to subsequent data maintenance and updating, and can be adjusted in real time based on the actual attacker's state, improving the rigidity of obtaining log data by relying on only one or several fixed rules.
[0112] In one implementation, a target log data stream that meets a target time condition is obtained from an original log data stream, including: obtaining a timestamp corresponding to the original log data stream; determining whether the timestamp corresponding to the original log data stream is consistent with the target timestamp; when the timestamp corresponding to the original log data stream is inconsistent with the target timestamp, calculating the absolute value of the difference between the timestamp of the original log data stream and the target timestamp to obtain a target time difference; when the target time difference is less than or equal to a target time range value, determining the original log data stream as the target log data stream.
[0113] The following is a specific example to describe how to determine the target log data stream.
[0114] According to the IP-Log keyed connection data stream, obtain the timestamp and time range duration in the map state corresponding to the attacker's IP address.
[0115] Take the map state in the above text as an example, assuming that the timestamp of the attacker's IP is 1719536473013 milliseconds, the time range is 300 seconds, and the timestamp of the log data is 1719536593013 milliseconds. It can be clearly seen that the values of these two timestamps are inconsistent, so the target time difference is further calculated.
[0116] Calculate the difference between the timestamp 1719536473013 milliseconds of the attacker's IP in the IP-Log keyed connection data stream and the timestamp 1719536593013 milliseconds of the Log data, and the result is:
[0117] 1719536593013-1719536473013=120000 milliseconds=120 seconds.
[0118] Since the difference between the timestamp of the attacker's IP and the timestamp of the log data is 120 seconds and less than 300 seconds, the log is considered to meet the judgment criteria and will be pushed downstream for further processing.
[0119] It is understandable that in some cases, in order to obtain more log data of the attacker, the data before the timestamp corresponding to the IP data can also be obtained. In this case, the target difference is a negative number, and the log data within a certain time range before the timestamp corresponding to the IP data can be determined by taking the absolute value. The specific time range can be set according to the actual situation and is not limited here.
[0120] By obtaining the target log data stream that meets the target time condition from the original log data stream, time condition filtering of the log data can be implemented, that is, only the log data that meets the target time condition is selected. By matching the timestamp and the target time range value, it is possible to verify whether the time information of the log data meets expectations, thereby improving the credibility and accuracy of the data and determining whether to identify the original log data stream as the target log data stream. This helps to screen out valid log data within the target time range and reduce unnecessary data processing and analysis.
[0121] In one implementation, when the timestamp corresponding to the original log data stream is consistent with the target timestamp, the original log data stream is determined as the target log data stream.
[0122] It can be understood that the above calculation process is how to determine the target log data when the timestamp corresponding to the original log data stream is inconsistent with the target timestamp. If the timestamp corresponding to the original log data stream is consistent with the target timestamp, there is no need to perform subsequent calculation processes, and the original log data can be directly identified as the target log data.
[0123] This simplifies the logical judgment process, avoids unnecessary time difference calculations and range judgment processes, reduces the system's computing overhead and resource consumption, speeds up data processing and response time, and improves processing real-time and response efficiency.
[0124] Improve response speed: By directly identifying the log data with consistent timestamps as the target log data, the data processing speed and response time can be accelerated. It avoids unnecessary calculation steps, and can identify and process the target log data faster, improving the real-time performance and response speed of the system.
[0125] In one implementation, obtaining the Internet Protocol address IP data stream and the original log data stream of the target user terminal includes: configuring a distributed message processing system connector in a distributed stream computing engine; and obtaining the IP data stream and the original log data stream from the distributed message processing system using the distributed message processing system connector.
[0126] Distributed stream computing engine refers to the Apache Flink streaming computing framework. Flink supports high-performance, low-latency distributed stream processing applications, provides state management, fault tolerance, event time processing and other functions, and is suitable for real-time data processing and streaming computing scenarios.
[0127] The distributed message processing system connector refers to the Kafka connector. In Flink, the Kafka connector is a component used to connect Flink with the Apache Kafka message queue. It allows Flink applications to read data streams from Kafka topics or write data to Kafka topics.
[0128] Distributed message processing system refers to Kafka, which is a distributed streaming data processing platform used to build real-time data pipelines and stream processing applications. Its advantages are high throughput, persistence, and scalability, and it is suitable for data collection, transmission, and processing.
[0129] Specifically, configure the Kafka connector in the Flink application and specify the relevant information for connecting to the Kafka cluster, such as the host address, port number, topic name, etc. The Internet Protocol address IP data stream and the original log data stream of the target user end are obtained from the Kafka topic through the Kafka connector.
[0130] Through Flink and Kafka connectors, IP data streams and raw log data streams can be acquired and processed in real time, supporting real-time data processing and streaming computing. Using Kafka as a message queue and acquiring data streams through connectors, an end-to-end data pipeline can be built to achieve data transmission and processing. Flink, as a streaming computing engine, combined with the Kafka connector, can achieve high-performance, low-latency data processing, which is suitable for large-scale data stream processing scenarios and can greatly improve data processing efficiency.
[0131] In one implementation, the Hongmeng system can be used to implement the log data acquisition method mentioned above.
[0132] HarmonyOS is a distributed operating system for multiple devices. It has cross-terminal capabilities and can run on multiple devices. Combined with Flink and Kafka, it can achieve cross-platform real-time data processing and streaming computing. HarmonyOS provides a distributed architecture design. When used in combination with Flink and Kafka, it can achieve distributed data processing and message delivery, and support system expansion and upgrades.
[0133] The combined use of Hongmeng system, Flink and Kafka can achieve cross-platform, real-time and high-performance data processing, improve the reliability and scalability of the system, and is suitable for large-scale data processing and distributed computing scenarios.
[0134] In addition, other commonly used operating systems may also be used to implement the above log acquisition method. The specific operating system user may select according to actual conditions, and is not limited here.
[0135] Combine the following Figure 5 This article will give an overall introduction to the log data acquisition method mentioned above.
[0136] Figure 5 It is a flowchart of another log data acquisition method provided in an embodiment of the present application.
[0137] like Figure 5 As shown, Figure 5 The process includes the following steps S501 to S511.
[0138] S501: parse the IP data stream.
[0139] S502: Extract fields such as IP from the IP data stream.
[0140] S503, partition the IP data stream by IP.
[0141] S504: parse the Log data stream.
[0142] S505: Extract fields such as IP from the Log data stream.
[0143] S506: partition the Log data stream by key according to IP.
[0144] S507: Connect stream operations.
[0145] S508: Map state creation.
[0146] S509: Initialize or update the map state.
[0147] S510: Whether the timestamp difference satisfies the condition.
[0148] S511. When the timestamp difference meets the conditions, the log data is captured and pushed.
[0149] The above steps are described in detail below with reference to specific examples.
[0150] Assume that the alarm platform needs to obtain all activity logs of an attacker whose IP-1 is 127.0.0.1 and IP-2 is 127.0.0.2 within the past 500 seconds in order to profile the attacker. Therefore, the relevant information is configured on the front-end page.
[0151] Based on the above front-end configuration, the back-end sends the following configuration information about IP-1 and IP-2 to the Kafka message middleware, as shown below:
[0152] IP-1:
[0153] {
[0154] "taskID":"893158b0-66fa-41a5-a0b4-29b3e4227dab",
[0155] "IP":"127.0.0.1",
[0156] "timestamp":1719536473013,
[0157] "duration":500
[0158] }.
[0159] IP-2:
[0160] {
[0161] "taskID":"893158b0-66fa-41a5-a0b4-29b3e4227 dab",
[0162] "IP":"127.0.0.2",
[0163] "timestamp":1719536473013,
[0164] "duration":500
[0165] }.
[0166] The data warehouse obtains the data in the above IP data stream from Kafka, and obtains the following log data Log-1 and Log-2 from the Log data stream.
[0167] To determine whether the obtained log data meets the matching judgment conditions based on the attacker's IP information, it is necessary to parse the above IP data and Log data separately and extract relevant fields. Combined with the above, it will not be repeated here.
[0168] The IP data stream and the Log data stream are respectively partitioned by key according to the IP field to obtain the IP keyed data stream and the Log keyed data stream.
[0169] Perform the connect operation on the IP keyed data stream and the Log keyed data stream to obtain the IP-Log keyed connected data stream. The main purpose of the connect operation here is to let the IP keyed data stream and the Log keyed data stream share the map state. Specifically, the map state in the IP keyed data stream is used to implement the screening and matching logic of the Log keyed data stream. Figure 6 Let me introduce it in detail.
[0170] Figure 6 This is a logical diagram for implementing screening and matching of Log-keyed data streams using map states, provided in an embodiment of the present application.
[0171] like Figure 6 As shown, the corresponding IP data and Log data are stored in the same partition using the connection operation, and then the process function is used to match and filter the Log data according to the corresponding map state. Finally, the Log data that meets the target time condition is determined as the target log data and output.
[0172] After the connect operation, IP-1 and Log-1 as well as IP-2 and Log-2 are respectively divided into the same partition. Here, IP-1 and Log-1 are taken as an example to illustrate the log matching judgment process.
[0173] Combined with the above, according to the data of IP-1, the timestamp field value in the map status of IP is 1719536473013 milliseconds, the log filtering range is 500 seconds, and the timestamp field value of Log-1 is 1719536873.013 seconds. The difference between the two is no more than 500 seconds. Therefore, Log-1 meets the log judgment criteria, so Log-1 will be sent downstream.
[0174] In summary, this application converts the timeliness filtering condition (filtering logs within a specified time period) into a judgment condition of the moment (timestamp) when obtaining logs. It only needs to adjust a time range parameter, and there is no need to generate filtering rules in advance, which simplifies the matching logic and improves the matching efficiency. It is simple and easy to use and suitable for obtaining logs associated with various alarms. At the same time, the concept of map state is introduced, so that the log filtering conditions can be perfectly compatible with the front-end configuration information, which is very friendly to the platform users' full log filtering and attacker profiling needs.
[0175] The above mainly introduces the method of the embodiment of the present application in conjunction with the accompanying drawings. It should be understood that although the various steps in the flowcharts involved in the embodiments described above are shown in sequence, these steps are not necessarily performed in sequence in the order shown in the figure. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be performed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the embodiments described above may include multiple steps or multiple stages, and these steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these steps or stages is not necessarily performed in sequence, but can be performed in turn or alternately with other steps or at least a part of the steps or stages in other steps. A device of an embodiment of the present application is introduced below in conjunction with the accompanying drawings. For simplicity, when introducing the device below, it will be appropriately omitted, and the relevant content can refer to the relevant description in the method above, and will not be repeated.
[0176] Figure 7 It is a structural diagram of a log data acquisition device provided in an embodiment of the present application.
[0177] like Figure 7 As shown, the device 1000 includes the following units.
[0178] The acquisition unit 1001 is used to acquire the Internet Protocol address IP data stream and the original log data stream of the target user terminal.
[0179] The processing unit 1002 is used to determine the target time condition according to the preset mapping state corresponding to the IP data stream. The preset mapping state is used to indicate that the target user terminal has a time range corresponding to a preset attack operation. The target time condition includes: a target timestamp and a target time range value.
[0180] The processing unit 1002 is further configured to obtain a target log data stream that meets a target time condition from the original log data stream.
[0181] In one implementation, the device 1000 further includes a storage unit 1003, which can be used to store instructions and / or data, so as to implement the method in the above embodiment.
[0182] In one implementation, the processing unit 1002 is also used to perform key partitioning processing on the IP data stream and the original log data stream, respectively, to obtain a keyed IP data stream and a keyed log data stream; connect the keyed IP data stream and the keyed log data stream to generate a connected data stream; and determine a preset mapping state corresponding to the IP data stream based on the connected data stream.
[0183] It can be understood that by partitioning the data stream by key, data records with the same key value can be assigned to the same partition, thereby facilitating data association and connection, and improving data relevance and readability. The connection operation of the keyed IP data stream and the keyed log data stream can quickly locate and query the data records corresponding to a specific key value, improving the efficiency of data query and retrieval. The generation of connected data streams can reduce unnecessary data transmission and processing, avoid frequent data transmission between different data streams, and reduce network overhead and resource consumption.
[0184] In one implementation, the processing unit 1002 is also used to perform data parsing on the IP data stream and the original log data stream to extract the IP address corresponding to the IP data stream and the IP address corresponding to the original log data stream; perform key partitioning on the IP data stream according to the IP address corresponding to the IP data stream to obtain a keyed IP data stream; perform key partitioning on the original log data stream according to the IP address corresponding to the original log data stream to obtain a keyed log data stream.
[0185] It can be understood that by partitioning the data stream by key, the subsequent data processing process can be simplified, making data processing clearer and more efficient. The generated keyed IP data stream and keyed log data stream can improve the performance of data query, and quickly locate and query the data records corresponding to a specific IP address. Partitioning by IP address can better support data analysis and statistics, and facilitate the aggregation and analysis of data for a specific IP address.
[0186] In one implementation, the processing unit 1002 is further configured to determine, according to the connection data stream, a preset mapping state corresponding to the IP data stream, including: querying a preset IP address in the connection data stream, the preset IP address being an IP address in the IP data stream of the target user end obtained again;
[0187] If the preset IP address is not found in the connection data stream, a preset mapping state corresponding to the preset IP address is created according to the preset IP address, the first preset timestamp and the first preset time range; the first preset timestamp is used to indicate the start time of the target user terminal corresponding to the preset IP address to perform the preset attack operation, and the first preset time range is used to indicate the duration of the target user terminal corresponding to the preset IP address to perform the preset attack operation;
[0188] If the preset IP address is queried in the connection data stream, the first preset timestamp is updated using the second preset timestamp and / or the first preset time range is updated using the second preset time range to obtain a preset mapping state; the second preset timestamp is used to indicate the start time when the target user terminal corresponding to the preset IP address executes the preset attack operation again, and the second preset time range is used to indicate the duration when the target user terminal corresponding to the preset IP address executes the preset attack operation again.
[0189] It can be understood that by querying and updating the preset mapping state, the preset attack behavior of the target user terminal can be dynamically tracked and updated, so that the data status is kept up to date and accurate. By creating or updating the preset mapping state based on the preset IP address and timestamp information, the activities of the target user terminal can be monitored in real time, and potential attack behaviors can be discovered and responded to in a timely manner. By updating and maintaining the preset mapping state, the occurrence of false alarms can be reduced, and the accuracy and reliability of the detection of preset attack behaviors can be improved. Dynamically updating the preset mapping state can avoid repeated processing of all data, save computing resources and time costs, and improve system performance and efficiency. By real-time monitoring and updating the preset mapping state, it is possible to quickly respond to changes in the behavior of the target user terminal and reduce the impact of attacks on the system.
[0190] In one implementation, the processing unit 1002 is also used to obtain a target log data stream that meets the target time condition from the original log data stream, including: obtaining a timestamp corresponding to the original log data stream; determining whether the timestamp corresponding to the original log data stream is consistent with the target timestamp; when the timestamp corresponding to the original log data stream is inconsistent with the target timestamp, calculating the absolute value of the difference between the timestamp of the original log data stream and the target timestamp to obtain a target time difference; when the target time difference is less than or equal to the target time range value, determining the original log data stream as the target log data stream.
[0191] It can be understood that this method can process the original log data stream in real time, make judgments based on the matching of timestamps, and achieve fast and accurate data stream classification. Through the comparison and difference calculation of timestamps, the target log data stream that meets the conditions can be automatically identified, reducing manual intervention and improving processing efficiency. Through accurate matching and automatic identification, complex processing of all data can be avoided, saving computing resources and time costs, and improving system efficiency.
[0192] In one implementation, the processing unit 1002 is further configured to, when a timestamp corresponding to the original log data stream is consistent with a target timestamp, determine the original log data stream as a target log data stream.
[0193] It can be understood that when the timestamps are consistent, the original log data stream is directly determined as the target log data stream, which is simple and efficient, reduces additional timestamp comparison and difference calculation steps, and improves processing speed and efficiency.
[0194] In one implementation, the acquisition unit 1001 is also used to obtain the Internet Protocol address IP data stream and the original log data stream of the target user terminal, including: configuring a distributed message processing system connector in the distributed stream computing engine; using the distributed message processing system connector to obtain the IP data stream and the original log data stream from the distributed message processing system.
[0195] It can be understood that in this way, real-time processing and analysis of data can be achieved, the timeliness and real-time nature of data processing can be guaranteed, the risk of data loss and errors can be reduced, and the stability and reliability of the system can be improved. Using the distributed message processing system connector, the processing capacity of the system can be easily expanded, supporting the processing of large-scale data streams and meeting the expansion needs of the system. At the same time, flexible configuration options are provided, and data processing processes and rules can be customized according to needs to meet the needs of different business scenarios and improve the flexibility and adaptability of the system. Rapid data transmission and processing can be achieved, and efficient collaboration and data exchange between systems can be promoted.
[0196] It should be noted that the information interaction, execution process and other contents between the above-mentioned units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0197] Figure 8 Schematic diagram of the structure of the computer device provided in the embodiment of the present application. Figure 8 As shown, the computer device 3000 of this embodiment includes: at least one processor 3100 ( Figure 8Only one) processor, memory 3200, and a computer program 3210 stored in the memory 3200 and executable on at least one processor 3100 are shown. When the processor 3100 executes the computer program 3210, the computer device implements the steps in the above embodiments.
[0198] The processor 3100 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 gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.
[0199] The memory 3200 may be an internal storage unit of the computer device 3000 in some embodiments, such as a hard disk or memory of the computer device 3000. The memory 3200 may also be an external storage device of the computer device 3000 in other embodiments, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the computer device 3000. Further, the memory 3200 may also include both an internal storage unit of the computer device 3000 and an external storage device. The memory 3200 is used to store an operating system, an application program, a boot loader (Boot Loader) data, and other programs, such as a program code of a computer program, etc. The memory 3200 may also be used to temporarily store data that has been output or is to be output.
[0200] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the division of the above-mentioned functional units is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units in the embodiment can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0201] The embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a computer device, the computer device can implement the steps in the above-mentioned method embodiments.
[0202] The embodiment of the present application provides a computer program product. When the computer program product is executed on a computer device, the computer device can implement the above-mentioned methods.
[0203] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the computer device can implement the steps of the above-mentioned various method embodiments. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera / terminal device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0204] It should be understood that the size of the sequence number of each step in the above-described embodiment does not mean the order of execution, and the order of execution of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiment of the present application. In the description, for the purpose of explanation rather than for limitation, specific details such as specific system structure, technology and the like are proposed, so as to thoroughly understand the embodiment of the present application. However, it should be clear to those skilled in the art that the present application can also be implemented in other embodiments without these specific details. In other cases, the detailed description of well-known systems, devices, circuits and methods is omitted to prevent unnecessary details from hindering the description of the present application.
[0205] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0206] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0207] Additionally, in the specification of the present application and the description of the appended claims, the terms “include,” “comprise,” “have,” and their variations all mean “including but not limited to,” unless otherwise specifically emphasized.
[0208] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0209] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0210] In the embodiments provided in the present application, it should be understood that the disclosed devices, computer equipment and methods can be implemented in other ways. For example, the device and computer equipment embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0211] 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 log data acquisition method, characterized in that: include: Obtain the Internet Protocol address IP data stream and original log data stream of the target user end; Determine a target time condition according to a preset mapping state corresponding to the IP data stream, wherein the preset mapping state is used to indicate that the target user terminal has a time range corresponding to a preset attack operation, and the target time condition includes: a target timestamp and a target time range value; A target log data stream that meets the target time condition is obtained from the original log data stream.
2. The method according to claim 1, characterized in that The method further comprises: Performing key partitioning processing on the IP data stream and the original log data stream respectively to obtain a keyed IP data stream and a keyed log data stream; Connecting the keyed IP data stream and the keyed log data stream to generate a connection data stream; A preset mapping state corresponding to the IP data flow is determined according to the connection data flow.
3. The method according to claim 2, characterized in that The method further comprises: Performing data parsing processing on the IP data stream and the original log data stream, extracting the IP address corresponding to the IP data stream and the IP address corresponding to the original log data stream; Performing key partitioning processing on the IP data stream according to the IP address corresponding to the IP data stream to obtain a keyed IP data stream; The original log data stream is partitioned by key according to the IP address corresponding to the original log data stream to obtain a keyed log data stream.
4. The method according to claim 2, characterized in that: The determining, according to the connection data stream, a preset mapping state corresponding to the IP data stream comprises: Querying a preset IP address in the connection data stream, where the preset IP address is the IP address in the IP data stream of the target user terminal obtained again; If the preset IP address is not found in the connection data stream, the preset mapping state corresponding to the preset IP address is created according to the preset IP address, a first preset timestamp and a first preset time range; the first preset timestamp is used to indicate the start time when the target user terminal corresponding to the preset IP address executes the preset attack operation, and the first preset time range is used to indicate the duration of the target user terminal corresponding to the preset IP address executing the preset attack operation; If the preset IP address is queried in the connection data stream, the first preset timestamp is updated using the second preset timestamp and / or the first preset time range is updated using the second preset time range to obtain the preset mapping state; the second preset timestamp is used to indicate the start time when the target user terminal corresponding to the preset IP address executes the preset attack operation again, and the second preset time range is used to indicate the duration when the target user terminal corresponding to the preset IP address executes the preset attack operation again.
5. The method according to any one of claims 1 to 4, characterized in that The step of acquiring a target log data stream that meets the target time condition from the original log data stream includes: Obtaining the timestamp corresponding to the original log data stream; Determine whether the timestamp corresponding to the original log data stream is consistent with the target timestamp; When the timestamp corresponding to the original log data stream is inconsistent with the target timestamp, calculating the absolute value of the difference between the timestamp of the original log data stream and the target timestamp to obtain a target time difference; When the target time difference value is less than or equal to the target time range value, the original log data stream is determined as the target log data stream.
6. The method according to claim 5, characterized in that The method further comprises: When the timestamp corresponding to the original log data stream is consistent with the target timestamp, the original log data stream is determined as the target log data stream.
7. The method according to claim 1, characterized in that The step of obtaining the Internet Protocol address IP data stream and the original log data stream of the target user terminal includes: Configure the distributed message processing system connector in the distributed stream computing engine; The IP data stream and the original log data stream are obtained from the distributed message processing system using the distributed message processing system connector.
8. A log data acquisition device, characterized in that: include: An acquisition unit, used for acquiring an Internet Protocol address IP data stream and an original log data stream of a target user terminal; A processing unit, configured to determine a target time condition according to a preset mapping state corresponding to the IP data stream, wherein the preset mapping state is used to indicate that the target user terminal has a time range corresponding to a preset attack operation, and the target time condition includes: a target timestamp and a target time range value; The processing unit is further configured to obtain a target log data stream that meets the target time condition from the original log data stream.
9. A computer device, characterized in that: The computer device comprises 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 computer device implements the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a computer device, the method according to any one of claims 1 to 7 is implemented.
