Data processing method and related apparatus

By extracting key content from network traffic using a content extraction model, the complexity and security issues of modifying regular expressions are resolved, achieving efficient and accurate traffic analysis.

CN122293346APending Publication Date: 2026-06-26TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411934275.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-24
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

In existing NDR technologies, modifying regular expressions is complex and prone to introducing errors, leading to false positives and false negatives. It also poses security risks, affecting the accuracy of network traffic analysis and system stability.

Method used

A content extraction model is used to generate target prompt content by combining target prompt templates and content prompt text. The trained content extraction model is then used to extract key target content for traffic analysis.

Benefits of technology

It improves the accuracy and efficiency of network traffic analysis, avoids the security issues of regular expressions, and can output accurate key information when network attack methods are updated, reducing ambiguity and vagueness in information transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122293346A_ABST
    Figure CN122293346A_ABST
Patent Text Reader

Abstract

This application relates to the field of computer technology, providing a data processing method and related apparatus to improve the accuracy of traffic analysis. The method includes: acquiring target network traffic; generating target prompt content for the target network traffic using a target prompt template; inputting the target prompt content into a trained content extraction model to obtain target key content, which represents the content in the target network traffic that conforms to the characteristics of abnormal traffic; and finally, performing traffic analysis on the target network traffic based on the target key content to obtain traffic analysis results. Utilizing the model's generalization ability, abnormal traffic can be accurately detected when facing new network attacks, thereby triggering alerts for abnormal traffic.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and provides a data processing method and related apparatus. Background Technology

[0002] Network Detection and Response (NDR) is an automated network security solution that analyzes network traffic to detect and alert on potential security threats in real time.

[0003] In related technologies, NDR is implemented based on regular expressions. Specifically, regular expressions are pre-defined for fields of interest to various network attacks. Then, the regular expressions are matched against the network traffic to determine whether the network traffic is abnormal traffic indicating a network attack, and alerts are issued for abnormal traffic.

[0004] However, as cyberattack methods continue to evolve, regular expressions may need to be modified frequently. But the syntax of regular expressions is relatively complex, and modifying them can easily introduce errors, leading to false positives or false negatives, which affects the accuracy of the analysis.

[0005] In addition, there are security issues when using regular expressions. For example, attackers can construct specific input strings to cause the regular expression engine to get stuck in an infinite loop, thereby consuming a lot of CPU resources and eventually causing the system to crash or become unresponsive. Summary of the Invention

[0006] This application provides a data processing method and related apparatus to improve the accuracy of network traffic analysis while avoiding security issues caused by regular expressions.

[0007] On one hand, embodiments of this application provide a data processing method, including:

[0008] Obtain target network traffic and obtain a target prompt template set for the traffic type of the target network traffic. The target prompt template includes content prompt text, which is used to prompt the field to which the key content associated with the traffic type belongs.

[0009] According to the target prompt template, the target network traffic and the content prompt text are combined to generate the corresponding target prompt content;

[0010] The target prompt content is input into a trained content extraction model to obtain the target key content, which represents: the content in the target network traffic that conforms to the traffic characteristics of abnormal traffic;

[0011] Based on the key content of the target, traffic analysis is performed on the target network traffic to obtain traffic analysis results.

[0012] On one hand, embodiments of this application provide a data processing apparatus, including:

[0013] A traffic acquisition unit is used to acquire target network traffic and acquire a target prompt template set for the traffic type of the target network traffic. The target prompt template includes content prompt text, which is used to prompt the field to which the key content associated with the traffic type belongs.

[0014] The information combination unit is used to combine the target network traffic and the content prompt text according to the target prompt template to generate corresponding target prompt content;

[0015] The content extraction unit is used to input the target prompt content into the trained content extraction model to obtain the target key content, wherein the target key content represents: the content in the target network traffic that conforms to the traffic characteristics of abnormal traffic;

[0016] The traffic analysis unit is used to perform traffic analysis on the target network traffic based on the target key content and obtain traffic analysis results.

[0017] In one possible implementation, when combining the target network traffic and the content prompt text according to the target prompt template to generate the corresponding target prompt content, the information combination unit is specifically used for:

[0018] According to the set traffic segmentation method, the target network traffic is segmented to obtain multiple traffic segments, and according to the target prompt template, the multiple traffic segments and the content prompt text are combined to generate corresponding prompt segments.

[0019] When the target prompt content is input into the trained content extraction model to obtain the target key content, the content extraction unit is specifically used for:

[0020] The generated multiple prompt fragments are input into the content extraction model to obtain the corresponding fragment key content, and the target key content is obtained based on the obtained fragment key content.

[0021] In one possible implementation, when the target network traffic is segmented according to a set traffic segmentation method to obtain multiple traffic segments, the information combination unit is specifically used for:

[0022] According to the set segment length and segment extraction interval, starting from the beginning of the target network traffic, corresponding traffic segments are sequentially extracted from the request traffic, wherein the segment extraction interval is less than the segment length.

[0023] In one possible implementation, when obtaining the target key content based on the obtained key content of multiple fragments, the content extraction unit is specifically used for:

[0024] Based on the segment order of the multiple traffic segments in the target network traffic, determine the content order among the key content of the multiple segments;

[0025] Based on the order of the content, the key content of the multiple segments is combined to obtain the target key content.

[0026] In one possible implementation, if the target network traffic is request traffic, the traffic acquisition unit is further configured to acquire response traffic returned in response to the request traffic;

[0027] The content extraction unit is also used to extract key response content from the response traffic using a response prompt template set for the response traffic.

[0028] The traffic analysis unit is specifically used to perform traffic analysis on the request traffic based on the target key content and the response key content, and to obtain traffic analysis results.

[0029] In one possible implementation, when performing traffic analysis on the request traffic based on the target key content and the response key content to obtain the traffic analysis results, the traffic analysis unit is specifically used for:

[0030] Obtain a preset analysis prompt template, the analysis prompt template includes analysis prompt text, the content prompt text is used to prompt: output the traffic analysis result of whether the request traffic belongs to abnormal traffic;

[0031] According to the content order set in the analysis prompt template, the analysis prompt text, target key content, and response key content are combined to obtain the analysis text;

[0032] The analyzed text is input into the trained analysis model to obtain traffic analysis results.

[0033] In one possible implementation, the traffic analysis unit is also used for:

[0034] The traffic information of various abnormal traffic types is obtained from a knowledge base that records traffic information of various abnormal traffic types. Each piece of traffic information in the knowledge base is used to characterize the field to which the key content in the corresponding type of abnormal traffic belongs.

[0035] The traffic information of various abnormal traffic types is added to the analysis text, and the analysis text with the added information is input into the trained analysis model to obtain the traffic analysis results.

[0036] In one possible implementation, when the target prompt content is input into a trained content extraction model to obtain the target key content, the content extraction unit is specifically used for:

[0037] Using the content extraction model, perform the following steps:

[0038] According to the set text encoding method, multiple text elements in the target network traffic are encoded to obtain corresponding content features; and, according to the text encoding method, the content prompt text is encoded to obtain prompt features.

[0039] Based on the obtained content features and prompt features, the target key content is selected from the multiple text elements.

[0040] In one possible implementation, the target prompt content further includes pre-analysis information, which is used to prompt the output format of the content extraction model and to instruct the content extraction model to provide inference logic for outputting the target extracted content; then the content extraction unit is further used for:

[0041] According to the output format, output the selected target key content and the reasoning logic for selecting the target content.

[0042] In one possible implementation, the content extraction model is trained in the following manner:

[0043] Obtain a traffic sample set, where each traffic sample in the traffic sample set is labeled with corresponding real key content;

[0044] Using the aforementioned traffic sample set, the pre-trained large language model is fine-tuned until the training termination condition is met. During each iteration of the fine-tuning training, the following steps are performed:

[0045] Using the large language model, content is extracted from each traffic sample input during this iteration to obtain the corresponding key sample content;

[0046] Based on the sample key content and real key content corresponding to each traffic sample, the model loss value is determined, and the parameters are tuned based on the model loss value.

[0047] On one hand, an electronic device is provided, including a processor and a memory, wherein the memory stores a computer program that, when executed by the processor, causes the processor to perform the steps of the above-described method.

[0048] On one hand, a computer-readable storage medium is provided, comprising a computer program that, when run on an electronic device, causes the electronic device to perform the steps of any of the methods described above.

[0049] On one hand, a computer program product is provided, the program product including a computer program stored in a computer-readable storage medium, wherein a processor of an electronic device reads from the computer-readable storage medium and executes the computer program, causing the electronic device to perform the steps of any of the methods described above.

[0050] In this embodiment, firstly, the target prompt content is extracted to obtain key target content, and then traffic analysis is performed on the target network traffic to obtain traffic analysis results. By extracting key content, core information that helps distinguish between abnormal and normal traffic can be retained, reducing ambiguity and vagueness in information transmission, removing interference from irrelevant content, and improving the accuracy of traffic analysis. Simultaneously, extracting key content also avoids information overload, thus improving the efficiency of traffic analysis.

[0051] Secondly, by using a content extraction model to extract the target prompt content, compared to field matching using regular expressions, the content extraction model extracts key content from the target traffic model, avoiding the security issues caused by regular expressions. Furthermore, because the model has a certain generalization ability, it can output relatively accurate target key content even as network attack methods are constantly updated, thereby improving the accuracy of traffic analysis.

[0052] Finally, the target network traffic and content prompt text are combined according to the target prompt template to generate corresponding target prompt content. By guiding the content extraction model to focus on the fields through the prompt template, the content extraction model can output high-quality target key content, thereby further improving the accuracy of traffic analysis.

[0053] Other features and advantages of this application will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description

[0054] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0055] Figure 1 This is a schematic diagram illustrating the application scenario provided in the embodiments of this application;

[0056] Figure 2 This is a flowchart illustrating the data processing method provided in the embodiments of this application;

[0057] Figure 3 This is a logical diagram illustrating the data processing procedure provided in the embodiments of this application;

[0058] Figure 4 This is a flowchart illustrating the segmentation process provided in the embodiments of this application;

[0059] Figure 5 This is a logical diagram illustrating a target key content extraction process provided in an embodiment of this application;

[0060] Figure 6 This is a logical diagram illustrating another target key content extraction process provided in the embodiments of this application;

[0061] Figure 7 This is a logical diagram illustrating the response key content extraction process provided in the embodiments of this application;

[0062] Figure 8 This is a logical diagram illustrating the analysis process provided in the embodiments of this application;

[0063] Figure 9 This is a flowchart illustrating the content extraction process provided in the embodiments of this application;

[0064] Figure 10 This is a schematic diagram of the content extraction model provided in the embodiments of this application;

[0065] Figure 11 This is a flowchart illustrating the content extraction model training method provided in the embodiments of this application;

[0066] Figure 12 This is a flowchart illustrating the analysis model training method provided in the embodiments of this application;

[0067] Figure 13 This is a logical diagram illustrating the data processing procedure provided in the embodiments of this application;

[0068] Figure 14 This is a schematic diagram of the structure of a data processing device provided in an embodiment of this application;

[0069] Figure 15 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0070] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application. Unless otherwise specified, the embodiments and features in the embodiments of this application can be arbitrarily combined with each other. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than that shown here.

[0071] To facilitate understanding of the technical solutions provided in the embodiments of this application, some key terms used in the embodiments of this application will be explained below:

[0072] A language model is a model used to model natural language, aiming to predict the next word or character in a given text sequence. Language models can be used for various natural language processing tasks, such as semantic extraction, text generation, machine translation, and speech recognition. Currently, Transformer-based pre-trained language models (PLMs) are common in various natural language processing tasks and usually achieve good results. Common pre-trained language models include Bidirectional Encoder Representation from Transformers (BERT) and Generative Pre-Trained Transformer (GPT) models.

[0073] Large Language Model (LLP): Also known as a large model, natural language model, or large-scale language model, it refers to a natural language processing model with a large number of parameters and training data. The training process of a large language model typically employs unsupervised learning, meaning it is trained on a large-scale text corpus to learn the probability distribution and rules of language. During training, a large language model usually uses a language model as the objective function, optimizing the model parameters by maximizing the prediction probability of the next word. For example, the GPT series models based on the Transformer model structure are trained on large-scale corpora and can generate high-quality natural language text, such as articles and dialogues.

[0074] A pre-trained model is a model trained on a large-scale corpus, typically using unsupervised learning methods such as autoencoders and language models. The basic idea of ​​a pre-trained model is to leverage a large corpus and, through unsupervised learning, allow the model to learn a wealth of general knowledge and patterns, thus serving as a foundational model for various natural language processing tasks.

[0075] Transformer is a common deep learning model architecture widely used in natural language processing, computer vision (CV), and speech processing. Originally proposed as a sequence-to-sequence model architecture for machine translation, it consists of an encoder and a decoder. Both the encoder and decoder are composed of a series of identical Transformer blocks, each consisting of at least a multi-head self-attention layer and a feedforward neural network layer. Currently, Transformer has become a commonly used architecture in natural language processing and is frequently used as a pre-trained model. Besides language-related applications, Transformer is also applied in computer vision, audio processing, and other fields.

[0076] Prompt learning is a natural language generation technique based on human prompts. It aims to better utilize the knowledge of pre-trained language models by adding extra text to the input, thereby improving the quality and efficiency of the final generated text. The basic idea is to provide a human prompt or a partial generated result during the generation process, called a prompt token (or prompt text). This token represents a command or instruction, instructing the language model to perform an action or generate output, allowing the model to continue generating text based on this. Prompt learning can be applied to various natural language generation tasks, such as text summarization, machine translation, and dialogue generation. It helps the model better understand the context and language of the generation task, resulting in more accurate and natural text. This improves the quality and efficiency of the generation model while reducing its generation space, thus increasing both efficiency and speed.

[0077] Fine-tuning, also known as fine-tuning training, refers to further training a pre-trained model using a specific dataset to adapt it to a particular task or domain. This is also called adaptive training, ultimately improving the model's performance on specific tasks. The process of prompt learning often involves fine-tuning the model to better understand the prompt text and the context of the generation task, thus producing more accurate and natural text. For example, one method of fine-tuning is supervised fine-tuning (SFT).

[0078] Network Detection and Response (NDR): An automated network security solution that analyzes network traffic to detect and alert on potential security threats in real time.

[0079] In related technologies, NDR is implemented based on regular expressions. Specifically, regular expressions are pre-defined for fields of interest to various network attacks. Then, the regular expressions are compared with the network traffic to determine whether the network traffic is abnormal traffic indicating a network attack, and alerts are issued for abnormal traffic.

[0080] However, with the continuous evolution of cyberattack techniques, regular expressions may need frequent modification. The syntax of regular expressions is relatively complex, and modifications can easily introduce errors, leading to false positives or false negatives, thus affecting the accuracy of analysis. Furthermore, using regular expressions presents security risks. For example, attackers can construct specific input strings to cause the regular expression engine to enter an infinite backtracking loop, consuming significant CPU resources and ultimately causing system crashes or slow response times.

[0081] Based on this, this application provides a data processing method in which: target network traffic is acquired, and a target prompt template set for the traffic type of the target network traffic is acquired. The target prompt template includes content prompt text, which is used to indicate the field to which the key content associated with the traffic type belongs; the target network traffic and the content prompt text are combined according to the target prompt template to generate corresponding target prompt content; the target prompt content is input into a trained content extraction model to obtain target key content, which represents: content in the target network traffic that conforms to the traffic characteristics of abnormal traffic; and traffic analysis is performed on the target network traffic based on the target key content to obtain traffic analysis results.

[0082] In the above method, firstly, compared to field matching using regular expressions, extracting key content from the target traffic model through a content extraction model avoids the security issues associated with regular expressions. Furthermore, due to the model's generalization ability, it can output relatively accurate target key content even as network attack methods evolve, thereby improving the accuracy of traffic analysis. Secondly, extracting key content from the target network traffic before conducting traffic analysis retains core information that helps distinguish between abnormal and normal traffic, reducing ambiguity and vagueness in information transmission, removing irrelevant content from the analysis results, and improving the accuracy of traffic analysis. Simultaneously, extracting key content avoids information overload, thus improving the efficiency of traffic analysis.

[0083] Furthermore, by guiding the content extraction model to focus on specific fields using prompt templates, the model can output high-quality target content, thereby further improving the accuracy of traffic analysis.

[0084] The following is a brief introduction to the application scenarios to which the technical solutions of the embodiments of this application are applicable. It should be noted that the application scenarios described below are only for illustrating the embodiments of this application and are not intended to limit the scope. In specific implementation, the technical solutions provided by the embodiments of this application can be flexibly applied according to actual needs.

[0085] See Figure 1The diagram shown is an application scenario provided by an embodiment of this application. In this scenario, a terminal device 101 and a server 102 may be included.

[0086] Terminal device 101 can be, for example, a mobile phone, tablet computer (PAD), laptop computer, desktop computer, smart home appliance (such as smart TV), smart in-vehicle device, smart wearable device, and aircraft. Server 102 can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, i.e., content delivery network (CDN), and big data and artificial intelligence platforms, but is not limited to these.

[0087] The data processing method in this embodiment can be executed independently by either terminal device 101 or server 102, and the model training method can also be executed independently by either terminal device 101 or server 102. The model training method and data processing method can be executed by the same or different devices. For example, in terminal device 101, a pre-trained large language model can be fine-tuned using a collected traffic sample set to obtain a trained content extraction model and analysis model. Then, terminal device 101 uses the trained content extraction model and analysis model to perform network traffic analysis on the target network traffic. Alternatively, the above process can be executed by server 102. As another example, server 102 can also use a collected traffic sample set to fine-tune a pre-trained large language model to obtain a trained content extraction model and analysis model. Then, the trained content extraction model and analysis model can be deployed to terminal device 101, and terminal device 101 can use the trained content extraction model and analysis model to perform data processing on the target network traffic. Of course, some processes of model training or data processing can be implemented by the terminal device 101, and some processes can be implemented by the server 102. The two cooperate to realize the model training or data processing process. In practical applications, specific configurations can be made according to the situation, and this application does not make specific limitations here.

[0088] Both server 102 and terminal device 101 may include one or more processors, memory, and I / O interfaces for interaction. Furthermore, server 102 may be configured with a database for storing trained model parameters. The memory of both server 102 and terminal device 101 may also store program instructions required for execution in the data processing method provided in this embodiment. These program instructions, when executed by the processor, can be used to implement the data processing or model training process provided in this embodiment.

[0089] When the data processing and model training processes are executed independently by server 102 or terminal device 101, the above application scenario can also include only a single device, server 102 or terminal device 101. Alternatively, server 102 and terminal device 101 can be considered as the same device. Of course, when the data processing and model training processes are executed jointly by server 102 and terminal device 101, server 102 and terminal device 101 can also be the same device. That is, server 102 and terminal device 101 can be different functional modules of the same device, or virtual devices virtualized from the same physical device.

[0090] In some implementations, a user can trigger network traffic analysis for a target network traffic through a terminal device 101. The server 102 uses the data processing method of this application embodiment to perform network traffic analysis on the target network traffic, generate traffic analysis results, and return them to the terminal device 101 for presentation.

[0091] In this embodiment, the terminal device 101 and the server 102 can communicate directly or indirectly through one or more networks. This network can be a wired network or a wireless network; for example, the wireless network can be a mobile cellular network or a Wireless-Fidelity (WIFI) network, and of course, it can be other possible networks. This embodiment does not limit this. It should be noted that... Figure 1 The examples shown are merely illustrative; in reality, the number of terminal devices and servers is unlimited and is not specifically limited in the embodiments of this application.

[0092] The data processing method provided by the exemplary embodiments of this application will be described below with reference to the accompanying drawings and the application scenarios described above. It should be noted that the application scenarios described above are only shown to facilitate understanding of the spirit and principles of this application, and the embodiments of this application are not limited in any way.

[0093] See Figure 2 The diagram shown illustrates a flowchart of a large-model-based question-answering method provided in this application. This method can be executed by an electronic device, which may be a terminal device or a server. The specific process is as follows:

[0094] S201. Obtain the target network traffic and obtain the target prompt template set for the traffic type of the target network traffic. The target prompt template includes content prompt text, which is used to prompt the field to which the key content associated with the traffic type belongs.

[0095] Target network traffic refers to the network traffic used for traffic analysis. Target network traffic can be either request traffic or response traffic; that is, the traffic type is either request traffic or response traffic. Request traffic refers to network traffic sent from the client to the server. Response traffic refers to network traffic sent from the server to the client.

[0096] Target hint templates are used to suggest which aspects of information in the target network traffic the content extraction model should focus on, thereby guiding the content extraction model to extract these aspects of information from the target network traffic, and helping the model generate more accurate output.

[0097] Fields are the various components of the target network traffic. The fields containing the key information associated with the traffic type are the information that needs to be focused on in the target network traffic. Considering that the information that needs to be focused on is different for request traffic and response traffic, the fields containing the key information associated with request traffic and response traffic can be different.

[0098] Request traffic typically consists of three parts: the request line, request headers, and request body. Each part contains different fields to describe the specific information of the request. The request line indicates the operation the client wants to perform and the target resource, usually containing basic request information such as the request method, the path to the target resource, and the HTTP version. The request headers convey additional information about the request to help the server understand the client's needs and respond accordingly. For example, the request headers may contain detailed information about the client, the requested resource, caching policies, authentication information, etc. The request body contains the actual data the client wants to send to the server. It should be noted that not all requests have a request body; only certain request methods (such as POST, PUT, and PATCH) carry a request body. The content of the request body can be form data, JSON, XML, files, etc.

[0099] The key content associated with the request traffic belongs to fields including, but not limited to, one or more of the following: request header fields, upload content fields in the request body, sensitive fields such as username and password in the request body.

[0100] For example, the content of the requested traffic is as follows:

[0101] POST / upload HTTP / 1.1

[0102] User-Agent:Mozilla / 5.0(Windows NT 10.0; Win64; x64)

[0103] Accept:text / html

[0104] ...

[0105] username='abcd*****0'

[0106] password"='abcd*****0'

[0107] ……

[0108] The request line is named "POST / upload HTTP / 1.1". POST indicates that data is being submitted to the server, " / upload" indicates the target resource path, and "HTTP / 1.1" indicates the version of the Hypertext Transfer Protocol (HTTP). "User-Agent:Mozilla / 5.0 (Windows NT 10.0; Win64; x64)" and "Accept:text / html" are both headers. User-Agent indicates the client's software name and version, and Accept informs the server of the types of content the client can accept (e.g., application / json, text / html). The request body contains "name = 'abcd*****0'" and "pass = 'abcd*****0'". username represents the username, and password represents the password.

[0109] Suppose that the fields associated with the critical content of the request traffic include: request header fields, upload content fields in the request body, and sensitive fields such as username and password in the request body. Based on the fields suggested in the content prompt text, the target critical content may include the content "User-Agent:Mozilla / 5.0 (Windows NT 10.0; Win64; x64)" and "Accept:text / html" in the request header, and may also include the content "password" = 'abcd*****0' in the request body.

[0110] It should be noted that in the embodiments of this application, the content prompt text does not need to indicate all the fields to which the key content belongs. It may only include some of the fields to which the key content belongs. For example, the content prompt text gives some traffic characteristics of various abnormal traffic. Each type of abnormal traffic refers to network traffic that is subject to a type of network attack, such as injection attacks, file upload attacks, cross-site scripting attacks, etc. The traffic characteristic of a type of abnormal traffic is: content that can distinguish this type of abnormal traffic from normal traffic.

[0111] Because large models have strong generalization capabilities, even if not all fields of the key content are explicitly specified, i.e., the content prompt text provides some traffic characteristics of various abnormal traffic, large models can still use the traffic characteristics of various abnormal traffic learned during model training to extract content from the target network traffic and generate relatively accurate target key content.

[0112] For example, injection attacks involve inputting malicious code or commands into the client to exploit application vulnerabilities and perform unauthorized operations. Common injection attacks include Structured Query Language (SQL) injection, command injection, and XPath injection. The warning text could include statements like, "Injection attacks require attention to code or similar content in the target network traffic," without necessarily providing specific injection attack traffic characteristics. Similarly, the warning text could include statements like, "File upload attacks require attention to the file type and garbled characters, as garbled characters may contain Base64 or similar code," to indicate the traffic characteristics of file upload attacks. Likewise, for various types of abnormal traffic, the warning text can indicate the corresponding traffic characteristics.

[0113] For response traffic, it typically consists of three parts: response header, response line, and response body. Each part contains different fields to describe the specific information of the response. The response header contains metadata returned by the server, such as content type and content length; the response line contains the protocol version, status code, and description; and the response body contains the actual data returned, such as documents or images. For example, the fields associated with key content in response traffic may include, but are not limited to, one or more of the following: fields related to device information, fields related to business-sensitive data, and fields related to command execution.

[0114] In one possible implementation, the target hint template also includes pre-analysis information, which can be used to indicate the output format of the content extraction model. The output format refers to the data format in which the target extracted content is output; for example, the pre-analysis information may specify that the data format of the output target extracted content is JSON.

[0115] In one possible implementation, the pre-analysis information can also be used to instruct the content extraction model to provide the reasoning logic for the output target extracted content. For example, the reasoning format in the pre-analysis information can make the target extracted content obtained through logical reasoning more accurate by requiring the content model to provide the logical reasoning process.

[0116] In one possible implementation, the pre-analysis information can be used to indicate the output format of the content extraction model and the inference logic by which the content extraction model provides the output target extracted content.

[0117] For example, the pre-analysis information is: "Please extract the content from the input network traffic and output the following: [Inference process]; Request traffic: [Target network traffic in JSON format]; Suspicious content: [Target key content in JSON format]".

[0118] In one possible implementation, the target prompt template can also include contextual information, such as the first few sentences or paragraphs of the input text. The model can use this contextual information to predict subsequent words or sentences, ensuring that the generated content is logical and contextually appropriate. Contextual information helps the model understand the background of the question and generate more targeted answers, thus helping the model produce more accurate output. For example, the contextual information could be, "Assuming you are a traffic analysis expert, please extract suspicious content from the following target network traffic."

[0119] In one possible implementation, the target hint template can also include negative hints. Negative hints refer to content that should not be considered. By telling the model what content should not appear in the output, negative hints help avoid generating unexpected or sensitive content. For example, a negative hint could be "Content from technical blogs should be ignored."

[0120] In one possible implementation, if the target network traffic is request traffic, then the target prompt template is a prompt template set for request traffic; a prompt template set for request traffic can also be called a request prompt template. If the target network traffic is response traffic, then the target prompt template is a prompt template set for response traffic; a request template set for response traffic can also be called a response prompt template. Both request and response prompt templates, in addition to the content prompt text, can include one or more of the following: pre-analysis information, context information, and negative prompts. The content of each piece of information in the request and response prompt templates can be the same or different.

[0121] For example, since request traffic typically contains more critical content than response traffic, request prompt templates can include content prompt text, pre-analysis information, and contextual information. Response prompt templates, on the other hand, include content prompt text, pre-analysis information, contextual information, and negative prompts. The negative prompts reduce the impact of irrelevant content in the response traffic on the analysis results. For instance, in a request prompt template, the content prompt text might be: "Injection attacks require attention to code or similar code in the target network traffic; file upload attacks require attention to the file type and garbled characters, as garbled characters may contain Base64 or similar code." The pre-analysis information might be: "Please extract content from the input network traffic and output the following: [Reasoning Process]; Request Traffic: [Target Network Traffic in JSON Format]; Suspicious Content: [Target Key Content in JSON Format]." The contextual information might be: "Assuming you are a traffic analysis expert, please extract suspicious content from the following target network traffic." In the response prompt template, the content prompt text is "Please pay attention to fields related to device information, fields related to business-sensitive data, and fields related to command execution in the response body," the pre-analysis information is "Please extract content from the input network traffic and output the following: [Reasoning process]; Request traffic: [Target network traffic in JSON format]; Suspicious content: [Target key content in JSON format]," the context information is "Assuming you are a traffic analysis expert, please extract suspicious content from the following target network traffic," and the negative prompt is "The content of technical blogs should be ignored." S202. According to the target prompt template, combine the target network traffic and content prompt text to generate the corresponding target prompt content.

[0122] In one possible scenario, if the target prompt template only includes content prompt text, then the target network traffic and content prompt text are combined according to the target prompt template to generate the corresponding target prompt content.

[0123] In another possible scenario, if the target prompt template includes other information besides the content prompt text, such as prior analysis information, context information, negative prompts, etc., then the target network traffic, content prompt text, and other information in the target prompt template are combined according to the target prompt template to generate the corresponding target prompt content.

[0124] S203. Input the target prompt content into the trained content extraction model to obtain the target key content. The target key content is represented as: the content in the target network traffic that meets the traffic characteristics of abnormal traffic.

[0125] S204. Based on the key content of the target, perform traffic analysis on the target network traffic and obtain the traffic analysis results.

[0126] The traffic analysis results may include abnormal traffic assessment results, which indicate whether the target network traffic is abnormal. If the target network traffic is abnormal, the traffic analysis results may also include processing suggestions for the target network traffic.

[0127] See Figure 3 As shown, this is a logical diagram of a traffic analysis process provided in an embodiment of this application. The target network traffic is request traffic, and the target prompt template is "Please extract the content of the [target network traffic] and output the following content: "[Inference process]; Request traffic: [Target network traffic in JSON format]; Suspicious content: [Target key content in JSON format]". During the content extraction process, injection attacks need to focus on the code or similar code in the target network traffic, while file upload attacks need to focus on the file type and garbled characters of the uploaded file. Then, according to the target prompt template, the target network traffic and the content prompt text are combined to generate the corresponding target prompt content. Then, the target prompt content is input into the trained content extraction model to obtain the target key content. Finally, based on the target key content, traffic analysis is performed on the target network traffic to obtain the traffic analysis results.

[0128] In some implementations, considering that excessively long network traffic can affect the accuracy of content extraction, in this embodiment of the application, the target network traffic can be segmented, and then content extraction can be performed on the multiple traffic segments obtained from the segmentation, thereby obtaining the key content in the target network traffic.

[0129] Specifically, based on the target prompt template, the target network traffic and content prompt text are combined to generate the corresponding target prompt content, including:

[0130] Based on the set traffic segmentation method, the target network traffic is segmented to obtain multiple traffic segments. Then, according to the target prompt template, the multiple traffic segments and content prompt text are combined to generate corresponding prompt segments.

[0131] The target prompts are input into a trained content extraction model to obtain key target content, including:

[0132] The generated prompt fragments are input into the content extraction model to obtain the corresponding key content of the fragments, and the target key content is obtained based on the obtained key content of the multiple fragments.

[0133] In one possible implementation, the traffic segmentation method can be: starting from the beginning of the target network traffic according to the set segment length and segment truncation interval, extract the corresponding traffic segments sequentially from the target network traffic, wherein the segment truncation interval is less than the segment length.

[0134] The segment length indicates the length of a traffic segment, and the segment truncation interval indicates the truncation interval between two traffic segments. The traffic length of the last traffic segment can be less than the segment length.

[0135] Traffic fragment extraction can be performed on a character-by-character basis or on a text processing unit (token). A token is the smallest processing unit in the content extraction model, and a token can include one or more characters. As an example, target network traffic can be divided into words by spaces or other delimiters (such as commas or periods), and each word is considered a token. For instance, the content "POST / upload HTTP / 1.1" in the target network traffic has the following tokens: 'POST', ' / upload', and 'HTTP / 1.1'.

[0136] For example, if the segment length is set to 2000 characters and the segment truncation interval is 1900 characters, that is, every 2000 characters is divided into a segment, and there are 100 repeated characters between two adjacent traffic segments, then for the target network traffic, the first 2000 characters are the first traffic segment, the 1901st to 3900th characters are the second traffic segment, and so on, multiple traffic segments are obtained.

[0137] For example, if the segment length is set to 512 tokens and the segment truncation interval is 492 tokens, that is, every 512 tokens are divided into a segment, and there are 20 duplicate tokens between two adjacent traffic segments, then for the target network traffic, the first to 512 tokens are the first traffic segment, the 493rd to 1004th tokens are the second traffic segment, and so on, multiple traffic segments are obtained.

[0138] See Figure 4As shown, this is a logical diagram of a traffic segment extraction process provided in an embodiment of this application. Each box in the diagram represents a token. The segment length is set to 10 tokens, and the segment extraction interval is 8 tokens, that is, every 10 tokens are divided into a segment. There are 2 duplicate tokens between two adjacent traffic segments. Therefore, for the target network traffic, starting from the first token, the first traffic segment (traffic segment 1) is extracted according to the segment length. The first traffic segment includes tokens 1 to 10. Then, according to the segment extraction interval, the starting position of the second traffic segment is determined to be the 9th token, and tokens 9 to 18 are extracted as the second traffic segment (traffic segment 2) according to the segment length. After that, according to the segment extraction interval, the starting position of the third traffic segment is determined to be the 17th token. Since there are less than 10 tokens after the 17th token in the target network traffic (tokens 17 to 25), tokens 17 to 25 are directly designated as the third traffic segment (traffic segment 3).

[0139] By truncating segments at intervals shorter than the segment length, overlapping portions can be created within the traffic segments. This helps maintain content coherence, thereby utilizing coherent contextual information to improve the quality of model output.

[0140] The key content of a segment represents the content within a traffic segment that matches the characteristics of abnormal traffic.

[0141] In one possible implementation, multiple traffic segments and content prompt texts are combined according to the target prompt template to generate the corresponding prompt segment. Specifically, each traffic segment is combined with the content prompt text according to the target prompt template to generate the corresponding prompt segment. For the traffic segments, the "[Target Network Traffic]" field in the target prompt template needs to be filled in using the traffic segment.

[0142] When combining each traffic segment with the content prompt text, if the target prompt template only includes the content prompt text, then the target network traffic and the content prompt text are combined directly. If the target prompt template includes other information besides the content prompt text, such as pre-analysis information, context information, negative prompts, etc., then the target network traffic, the content prompt text, and other information in the target prompt template are combined.

[0143] If the target network traffic is request traffic, then a prompt fragment is generated for each traffic segment using the request prompt template. If the target network traffic is response traffic, then a prompt fragment is generated for each traffic segment using the response prompt template. For ease of description, the traffic segments of request traffic are referred to as request traffic segments, and the traffic segments of response traffic are referred to as response traffic segments.

[0144] For example, see Figure 5 As shown, according to the set traffic segmentation method, the target network traffic is segmented to obtain three request traffic segments: traffic segment 1, traffic segment 2, and traffic segment 3. Then, according to the target prompt template, traffic segment 1 and the content prompt text are combined to generate prompt segment 1. Similarly, traffic segment 2 and the content prompt text are combined to generate prompt segment 2. Finally, traffic segment 3 and the content prompt text are combined to generate prompt segment 3. Further, prompt segment 1 is input into the content extraction model to obtain segment key content 1, prompt segment 2 is input into the content extraction model to obtain segment key content 2, and prompt segment 3 is input into the content extraction model to obtain segment key content 3. Finally, based on segment key content 1, segment key content 2, and segment key content 3, the target key content is obtained.

[0145] By extracting key content from each traffic segment, the problem of reduced model output accuracy caused by the traffic process can be avoided, thus ensuring the accuracy of the extracted target key content and improving the accuracy of traffic analysis results.

[0146] One possible implementation involves obtaining the target key content based on multiple obtained fragment key content, including:

[0147] Based on the segment order of multiple traffic segments in the target network traffic, determine the content order among the key content of the multiple segments;

[0148] Based on the order of the content, combine the key content of multiple segments to obtain the target key content.

[0149] By combining key content from multiple segments in sequence, semantic errors caused by content order can be avoided, improving the semantic accuracy of the target key content. This avoids impacting the subsequent traffic analysis process and improves the accuracy of traffic analysis results.

[0150] To obtain the target key content, one can combine multiple key content segments according to their order. For example, one can directly combine multiple key content segments according to their order and use the combined key content segments as the target key content.

[0151] For example, the target network traffic is divided into traffic segment 1, traffic segment 2, and traffic segment 3. The order of these traffic segments in the target network traffic is: traffic segment 1, traffic segment 2, and traffic segment 3. The key content corresponding to traffic segment 1 is key content 1, the key content corresponding to traffic segment 2 is key content 2, and the key content corresponding to traffic segment 3 is key content 3. Therefore, the content order among the key content segments is: key content 1, key content 2, and key content 3. According to the content order, the three key content segments are combined to obtain the combined key content "Part 1: Key content 1; Part 2: Key content 2; Part 3: Key content 3". The combined key content segment is the target key content.

[0152] As another example, multiple key content segments can be combined according to their order, and the combined key content segments can be input into a content extraction model to obtain the target key content.

[0153] When inputting the combined fragment key content into the content extraction model to obtain the target key content, a target prompt template can also be used in conjunction with the combined fragment key content as input to the content extraction model. For the combined fragment key content, the "[Target Network Traffic]" in the target prompt template needs to be filled in with the combined fragment key content.

[0154] For example, see Figure 6 As shown, after obtaining fragment key content 1, fragment key content 2, and fragment key content 3, the three fragment key contents are combined in the following order (fragment key content 1 first, then fragment key content 2, and finally fragment key content 3) to obtain the combined fragment key content "Part 1: Fragment Key Content 1; Part 2: Fragment Key Content 2; Part 3: Fragment Key Content 3". Then, using a content extraction model, the combined fragment key content is extracted to obtain an output containing the target key content. The output is: "By analyzing xxx and xxx in the traffic, we can find out whether xxx is present, and...; Request content: [Target network traffic in JSON format]; Target key content: [Target key content in JSON format]".

[0155] In the above implementation method, by extracting the key content of multiple segments as a whole, noteworthy key content can be extracted in advance, reducing the possibility of errors in the analysis model output, thereby improving the accuracy of traffic analysis.

[0156] In one possible implementation, considering that the content of the request traffic of some network attacks is similar to that of normal traffic, but the response traffic contains sensitive information, this embodiment of the application can also detect the response traffic returned by the request traffic to determine whether the target network traffic is abnormal traffic.

[0157] Specifically, if the target network traffic is request traffic, the response traffic returned in response to the request traffic can also be obtained. Using the response prompt template set for the response traffic, key response content can be extracted from the response traffic. Furthermore, based on the target key content and the response key content, traffic analysis is performed on the request traffic to obtain the traffic analysis results.

[0158] The response traffic returned in response to the request traffic is obtained before the request traffic is analyzed. Alternatively, the response traffic returned in response to the request traffic can be obtained after the request traffic is obtained, or the request traffic and its corresponding response traffic can be obtained simultaneously.

[0159] Key response content refers to the content in the response traffic that matches the characteristics of abnormal traffic.

[0160] In one possible implementation, when extracting key response content from response traffic using a response prompt template set for the response traffic, the response traffic can be segmented according to a set traffic segmentation method to obtain multiple response traffic segments. Then, according to the prompt template set for the response traffic, the multiple response traffic segments and the content prompt text in the prompt template are combined to generate corresponding prompt segments. After that, the multiple generated prompt segments are input into the content extraction model to obtain the corresponding segment key content. Based on the obtained segment key content, the key response content in the response traffic is obtained.

[0161] When segmenting the response traffic, according to the set segment length and segment extraction interval, starting from the beginning of the target network traffic, corresponding traffic segments are sequentially extracted from the response traffic, where the segment extraction interval is less than the segment length. The segmentation process of the response traffic is the same as that of the target network traffic, and the process of obtaining the key response content of the response traffic is the same as that of obtaining the key content of the target network traffic, so they will not be described again here.

[0162] See Figure 7As shown, according to the set traffic segmentation method, the response traffic is segmented to obtain three traffic segments: traffic segment 4 and traffic segment 5. Following the response prompt template, traffic segment 4 and the content prompt text are combined to generate prompt segment 4. Similarly, traffic segment 5 and the content prompt text are combined to generate prompt segment 5. Then, prompt segment 4 is input into the content extraction model to obtain segment key content 4, and prompt segment 5 is input into the content extraction model to obtain segment key content 5. The segment order of multiple traffic segments in the target network traffic is: traffic segment 4, traffic segment 5. Therefore, the content order among the multiple segment key contents is: segment key content 4, segment key content 5. Following this content order, the two segment key contents are combined to obtain the combined traffic segment "Part 1: Segment Key Content 4; Part 2: Segment Key Content 5". Finally, the combined traffic segment is input into the content extraction model to obtain the response key content.

[0163] In one possible implementation, traffic analysis is performed on the request traffic based on the target key content and response key content to obtain the traffic analysis results, including:

[0164] Obtain a preset analysis prompt template. The analysis prompt template includes analysis prompt text. The content prompt text is used to prompt: output the traffic analysis result to determine whether the request traffic belongs to abnormal traffic.

[0165] According to the content order set in the analysis prompt template, combine the analysis prompt text, target key content, and response key content to obtain the analysis text;

[0166] The analyzed text is input into the trained analysis model to obtain traffic analysis results.

[0167] After obtaining the key target information and key response information, the world knowledge of the analysis model can be used to analyze whether the target network traffic is abnormal.

[0168] The traffic analysis results can not only indicate whether the target network traffic is abnormal, but also whether the abnormal traffic attack was successful, and provide suggestions for handling abnormal traffic.

[0169] For example, the traffic analysis result is: "By focusing on the requests in the request traffic and the responses in the response traffic, we can discover whether the target network traffic is abnormal, because of the analysis process. In summary, the probability of this traffic attack succeeding is low / medium / high, and the attack method used is high. We recommend the following handling suggestions."

[0170] The analysis prompt text is used to indicate under what circumstances a request traffic is considered abnormal traffic by the analysis model. In addition, it can also indicate under what circumstances an abnormal traffic attack is successful. For example, the analysis prompt text could be: "If the request traffic requests sensitive information, and the response traffic carries fields such as server architecture, the attack is considered successful. If the response traffic carries fields such as a technical blog page, the attack is considered unsuccessful."

[0171] In one possible implementation, the analysis prompt template may also include pre-analysis information, which instructs the analysis model on the analysis process of providing output traffic analysis results. The pre-analysis information may also instruct the analysis model to provide processing suggestions after providing traffic analysis results, thereby facilitating the handling of abnormal traffic.

[0172] In some implementations, to further improve model performance, relevant information for network traffic analysis can be provided to the analysis model via an external database. Specifically, traffic information for various types of abnormal traffic is obtained from a knowledge base that records traffic information for different types of abnormal traffic. Each piece of traffic information in the knowledge base is used to represent the field to which the key content of the corresponding type of abnormal traffic belongs. Then, the obtained traffic information for various types of abnormal traffic is added to the analysis text, and the analysis text with the added information is input into the trained analysis model to obtain the traffic analysis results.

[0173] For example, see Figure 8 As shown, this is a logical diagram of a traffic analysis process provided in this application embodiment. The process involves obtaining an analysis prompt template, combining the analysis prompt text, target key content, and response key content according to the template to obtain analysis text, retrieving traffic information for various abnormal traffic types from a knowledge base that records such information, adding this information to the analysis text, and inputting the resulting analysis text into a trained analysis model to obtain the traffic analysis result. The result states that "by focusing on the requests in the request traffic and the responses in the response traffic, it is possible to determine whether the target network traffic is abnormal, because of the analysis process utilizing traffic information from the knowledge base." In summary, the probability of success for this traffic attack is "low / medium / high," and an "attack method" was employed; therefore, "handling suggestions" are recommended.

[0174] By using a knowledge base, as network attacks are constantly updated, the model can extract content by utilizing the traffic information of new network attacks in the knowledge base, thereby improving the quality of the model's output.

[0175] In some implementations, if the content extraction model is a model with long context capabilities, then segmentation of the target network traffic may not be necessary.

[0176] In some implementations, the content extraction model and the analysis model can be the same model, which has both content extraction and analysis capabilities; alternatively, the content extraction model and the analysis model can be different models.

[0177] In some implementations, the content extraction model can be any model capable of extracting content from traffic, such as Generative Pre-Trained (GPT) series models, Transformer, encoder-decoder architecture models, Recurrent Neural Network (RNN), Long Short-Term Memory (LSTM) network, or variants of the aforementioned models.

[0178] See Figure 9 The diagram illustrates a content extraction traffic method using a content extraction model, as provided in this embodiment of the application. The content extraction model performs the following steps to obtain the target key content:

[0179] S901. According to the set text encoding method, encode multiple text elements in the target network traffic to obtain the corresponding content features.

[0180] In this embodiment, each text element in the target prompt content can be encoded individually to obtain a text encoding feature for each text element. These text encoding features are then concatenated to obtain the final content feature. Alternatively, the text elements of the target prompt content can be concatenated according to a certain format and then encoded as a whole to obtain text encoding features. These text encoding features can also be referred to as text representations, text representations, or text representation vectors, etc. A text element can be the smallest processing unit in the content extraction model.

[0181] Text encoding can be implemented using a text encoder, which can employ any possible encoder structure, such as the encoding part of a GPT model, Transformer, encoder-decoder, RNN, or LSTM. Taking the Transformer as an example, it can more efficiently capture long-range dependencies in sequence data. See also... Figure 10The diagram shown illustrates the model structure of a Transformer. A Transformer consists of multiple encoders and decoders, with the encoders arranged in a cascaded structure. A single-layer or multi-layer encoder structure can be used. Figure 10 The encoder structure shown within the dashed box extracts basic features from each text unit (such as word segments or words) in the text content, then superimposes them with their corresponding positional information. The superimposed content feature vector is input into the encoder, then processed by an attention layer, then by a residual & normalization (add & normal) layer, and finally input into a feedforward network layer. After another residual & normalization layer, the final text encoding features are obtained.

[0182] The attention layer can be a multi-attention layer or a self-attention layer, etc. The feedforward network layer can be a position-wise feed-forward neural network or a multilayer perceptron (MLP), etc. Multiple attention layers and feedforward network layers are stacked together through residual connections and layer normalization. The self-attention layer captures context-related information in the sequence through a self-attention mechanism. The calculation of self-attention involves three weight matrices (query matrix Q, key matrix K, and value matrix V), and the final attention weights are calculated through dot product, scaling, softmax activation, and weighted summation. Layer normalization is used to accelerate model convergence. After the output of each layer, layer normalization is used to normalize it to alleviate the gradient vanishing and exploding problems in the network.

[0183] S902. Encode the content prompt text according to the text encoding method to obtain prompt features. The generation process of prompt features is the same as that of content features, and will not be described again here.

[0184] The encoder outputs a series of hidden states, which contain a complete semantic representation of the input target cue content. Using these hidden states as input to the decoder helps to output high-quality target key content that matches the cue words.

[0185] S903. Based on the obtained content features and prompt features, select the target key content from multiple text elements.

[0186] The process of obtaining the target's key content can be viewed as a process of decoding the input content. Therefore, it can be implemented using a decoder, such as the decoder module of models like GPT or Transformer. For example, see Transformer. Figure 10 As shown, the decoder consists of multiple cascaded decoder blocks with masking mechanisms stacked together. Stacking decoder blocks from multiple Transformers constructs a deeper decoder to improve the model's performance and generalization ability. See also Figure 10 As shown, each decoding block contains the following parts:

[0187] (1) The masked multi-head self-attention layer captures contextual information in the sequence by performing multi-head self-attention computation on the input. The self-attention computation involves three weight matrices (query matrix Q, key matrix K, and value matrix V), and the final attention weights are calculated through dot product, scaling, softmax activation, and weighted summation. The masking mechanism is used to avoid using future information in the self-attention mechanism; that is, a mask is used in the self-attention mechanism to mask the information after the current token, ensuring that the prediction is based only on the information of previous tokens.

[0188] (2) Feedforward Neural Network layer: This part enhances the feature representation ability of each position by performing fully connected layer calculations on the representation of each position.

[0189] (3) Residual connection layer and layer normalization: By performing residual connection between the output of the previous two parts and the input sequence, and performing layer normalization on the result after residual connection, layer normalization is used to normalize the output of each layer, thereby mitigating the gradient vanishing / exploding problem in the network, accelerating the training of the model and improving the performance of the model.

[0190] In one possible implementation, the target prompt content also includes pre-analysis information, which is used to prompt the output format of the content extraction model and to instruct the content extraction model to provide the output target extracted content. Based on the obtained content features and prompt features, after selecting the target key content from multiple text elements, the selected target key content and the inference logic for selecting the target extracted content can be output according to the output format.

[0191] See Figure 11As shown, before executing the above process based on the content extraction model, the content extraction model can be trained using training methods. The training process of the content model is described below. See [link / reference] Figure 11 The diagram shown is a flowchart of a training method provided in an embodiment of this application.

[0192] S1101. Obtain a traffic sample set, where each traffic sample in the traffic sample set is labeled with corresponding real key content.

[0193] In this embodiment, a small-scale traffic sample is used to fine-tune the training of a large language model that has been pre-trained using a large corpus, thereby obtaining the trained analysis model. Each traffic sample in the traffic sample set is labeled with corresponding real key content.

[0194] S1102. Using the traffic sample set, fine-tune the pre-trained large language model until the training termination condition is met.

[0195] Specifically, fine-tuning training is an iterative process that continuously optimizes model parameters to ensure the model meets accuracy requirements. When the current iteration is the first iteration, the model used is the initial model, i.e., the pre-trained large language model. When the current iteration is not the first iteration, the model used is the model after the previous parameter tuning. During each training iteration, some or all traffic samples can be extracted from the traffic sample set and input into the model used in that iteration. For example, random selection can be used, or the traffic sample set can be pre-divided into batches, with one batch of traffic samples input each time. The training is then based on these input traffic samples, meaning that the model used in that iteration can perform forward inference on each traffic sample.

[0196] In this embodiment of the application, a cue learning method can be used to train the help model. The purpose of cue learning is to generate subsequent or other text by inputting certain cue content.

[0197] Since each iteration is similar, we will use one iteration as an example below.

[0198] In each iteration of the fine-tuning training process, the following steps are performed:

[0199] S11021. Using a large language model, extract the content of each traffic sample input during this iteration to obtain the corresponding key sample content.

[0200] The process of obtaining key sample content can be viewed as a process of decoding the input content. Therefore, it can be implemented using a decoder, such as the decoder module of models like GPT or Transformer. For example, see Transformer. Figure 10 As shown, the decoder consists of multiple cascaded decoder blocks with masking mechanisms stacked in series. Stacking decoder blocks from multiple Transformers builds a deeper decoder to improve the model's performance and generalization ability.

[0201] S11022. Determine the model loss value based on the sample key content and the real key content corresponding to each traffic sample.

[0202] In this embodiment of the application, the model loss value can also be calculated using any other possible loss function, such as the cross-entropy loss function, the mean squared error (MSE) loss function, the squared absolute error loss function, the maximum likelihood loss (LHL) function, etc. Of course, other possible loss functions can also be used, and this embodiment of the application does not limit this.

[0203] S11023. Determine whether the iteration termination condition has been met.

[0204] In this embodiment of the application, the iteration termination condition may include at least one of the following conditions:

[0205] (1) The number of iterations reaches the set threshold.

[0206] (2) The model loss value is less than the set loss threshold, or whether the conditional probability is a maximum value multiple times in a row.

[0207] S11024. If the determination process of S11023 is not successful, then the parameters are tuned according to the model loss value, and the next iteration of training is carried out based on the tuned large model.

[0208] In this embodiment, when the number of iterations does not exceed a preset threshold and the model loss value is not less than a preset loss threshold, the determination process in S11023 is negative, meaning the current model is considered not to meet the iteration termination condition, and the model parameters need to be adjusted to continue training. After parameter adjustment, the next iteration training process begins, i.e., it jumps to S11021.

[0209] In one possible implementation, when the model still does not meet the convergence condition, the model weight parameters can be updated using optimization algorithms such as gradient descent or stochastic gradient descent to minimize the objective function mentioned above. The model can then continue training with the updated model weight parameters, enabling it to better predict the results.

[0210] S11025. If the determination process in S11023 is successful, then output the trained content extraction model. This means the current model is considered to have met the convergence condition, model training is complete, and the trained content extraction model is obtained.

[0211] It should be noted that the above-described adjustment method of the model in the embodiments of this application is only one possible adjustment method. Other possible fine-tuning methods for large models can also be used, such as p-tuning, LORA, etc. In practical applications, appropriate fine-tuning methods can be adopted according to the actual scenario and factors such as model size and learning ability.

[0212] In this embodiment of the application, the analysis model can be any model with the ability to extract content from traffic, such as the GPT series model, Transformer, encoder-decoder architecture model, RNN, LSTM, or variant models of the aforementioned models.

[0213] The following section describes the model training process for the analysis model. (See also...) Figure 12 The diagram shown is a flowchart illustrating the model training process of the analysis model.

[0214] S1201. Obtain a traffic sample set, where each traffic sample in the traffic sample set is labeled with the corresponding real traffic type.

[0215] Among them, the real traffic type is either abnormal traffic or normal traffic. For abnormal traffic, specific network attacks can be marked, such as distributed attacks, text upload attacks, injection attacks, etc.

[0216] The analysis model can be obtained by fine-tuning a large language model that has been pre-trained using a large corpus, and then using a small-scale traffic sample set.

[0217] S1202. Using the traffic sample set, fine-tune the pre-trained large language model until the training termination condition is met.

[0218] Specifically, fine-tuning training is an iterative process that continuously optimizes model parameters to ensure the model meets accuracy requirements. When the current iteration is the first iteration, the model used is the initial model, i.e., the pre-trained large language model. When the current iteration is not the first iteration, the model used is the model after the previous parameter tuning. In each iteration, some or all traffic samples can be extracted from the traffic sample set and input into the model used in that iteration. Each batch of traffic samples is input, and the training is based on these input traffic samples; that is, the model used in this iteration can perform forward inference on each traffic sample.

[0219] In this embodiment of the application, a cue-based learning method can be used for model training.

[0220] Since each iteration is similar, we will use one iteration as an example below. In each iteration of the fine-tuning training process, the following steps are performed:

[0221] S12021. Using a large language model, analyze each traffic sample input during this iteration to obtain the corresponding predicted traffic type.

[0222] Obtaining the actual traffic type involves decoding the input content, which can be achieved using a decoder, such as the decoder module of models like GPT or Transformer. Taking Transformer as an example, see [link to previous section]. Figure 10 As shown, the decoder consists of multiple cascaded decoder blocks with masking mechanisms stacked in series. Stacking decoder blocks from multiple Transformers builds a deeper decoder to improve the model's performance and generalization ability.

[0223] S12022. Determine the model loss value based on the predicted flow type and the actual flow type corresponding to each flow sample.

[0224] The model loss value can also be calculated using any other possible loss function, such as cross-entropy loss function, mean squared error loss function, squared absolute error loss function, maximum likelihood loss function, etc. Of course, other possible loss functions are also possible, and this application embodiment does not limit this.

[0225] S12023. Determine whether the iteration termination condition has been met.

[0226] In this embodiment of the application, the iteration termination condition may include at least one of the following conditions:

[0227] (1) The number of iterations reaches the set threshold.

[0228] (2) The model loss value is less than the set loss threshold, or whether the conditional probability is a maximum value multiple times in a row.

[0229] S12024. If the determination process of S12023 is negative, then the parameters are tuned based on the model loss value, and the next iteration of training is carried out based on the tuned large model. If the determination process of S12023 is positive, then the trained analysis model is output.

[0230] The technical solution of the embodiment of this application will be described below with an example.

[0231] After performing field matching using regular expressions and other methods, the network traffic that successfully matches the regular expression and requires an alert can be further analyzed using the data processing method provided in this embodiment.

[0232] See Figure 13 NDR alarm data includes request traffic and response traffic. Request traffic is equivalent to target network traffic. After the server obtains the request traffic and the response traffic returned in response to the request traffic, it extracts the content of the request traffic to obtain the corresponding key content of the request, and extracts the content of the response traffic to obtain the corresponding key content of the response. Then, based on the key content of the request and the key content of the response, the traffic analysis results are obtained through the analysis model.

[0233] Specifically, in the process of extracting content from request traffic, the request traffic is segmented according to the set traffic segmentation method to obtain request traffic segment 1 and request traffic segment 2. Then, through the content extraction model, request segment key content 1 of request traffic segment 1 and request segment key content 2 of request traffic segment 2 are obtained. Finally, through the content extraction model, request segment key content 1 and request segment key content 2 are combined to obtain the request key content.

[0234] During the content extraction process for the response traffic, the response traffic is segmented according to the set traffic segmentation method to obtain response traffic segment 1 and response traffic segment 2. Then, through the content extraction model, the key content 1 of the response segment 1 and the key content 2 of the response segment 2 are obtained. Finally, by combining the key content 1 and the key content 2 of the response segment, the key content of the response is obtained.

[0235] Based on the same inventive concept, embodiments of this application provide a data processing apparatus. For example... Figure 14 As shown, this is a schematic diagram of the structure of the data processing device 1400, which may include:

[0236] Traffic acquisition unit 1401 is used to acquire target network traffic and acquire a target prompt template set for the traffic type of the target network traffic. The target prompt template includes content prompt text, which is used to prompt the field to which the key content associated with the traffic type belongs.

[0237] The information combination unit 1402 is used to combine the target network traffic and the content prompt text according to the target prompt template to generate corresponding target prompt content;

[0238] Content extraction unit 1403 is used to input the target prompt content into a trained content extraction model to obtain target key content, wherein the target key content represents: content in the target network traffic that conforms to the traffic characteristics of abnormal traffic;

[0239] The traffic analysis unit 1404 is used to perform traffic analysis on the target network traffic based on the target key content and obtain traffic analysis results.

[0240] In one possible implementation, when the information combination unit 1402 combines the target network traffic and the content prompt text according to the target prompt template to generate the corresponding target prompt content, the information combination unit 1402 is specifically used for:

[0241] According to the set traffic segmentation method, the target network traffic is segmented to obtain multiple traffic segments, and according to the target prompt template, the multiple traffic segments and the content prompt text are combined to generate corresponding prompt segments.

[0242] When inputting the target prompt content into the trained content extraction model to obtain the target key content, the content extraction unit 1403 is specifically used for:

[0243] The generated multiple prompt fragments are input into the content extraction model to obtain the corresponding fragment key content, and the target key content is obtained based on the obtained fragment key content.

[0244] In one possible implementation, when the target network traffic is segmented according to a set traffic segmentation method to obtain multiple traffic segments, the information combination unit 1402 is specifically used for:

[0245] According to the set segment length and segment extraction interval, starting from the beginning of the target network traffic, corresponding traffic segments are sequentially extracted from the request traffic, wherein the segment extraction interval is less than the segment length.

[0246] In one possible implementation, when obtaining the target key content based on the obtained key content of multiple fragments, the content extraction unit 1403 is specifically used for:

[0247] Based on the segment order of the multiple traffic segments in the target network traffic, determine the content order among the key content of the multiple segments;

[0248] Based on the order of the content, the key content of the multiple segments is combined to obtain the target key content.

[0249] In one possible implementation, if the target network traffic is request traffic, the traffic acquisition unit 1401 is further configured to acquire response traffic returned in response to the request traffic;

[0250] The content extraction unit 1403 is also used to extract key response content from the response traffic using a response prompt template set for the response traffic.

[0251] The traffic analysis unit 1404 is specifically used to perform traffic analysis on the request traffic based on the target key content and the response key content, and obtain traffic analysis results.

[0252] In one possible implementation, when performing traffic analysis on the request traffic based on the target key content and the response key content to obtain the traffic analysis results, the traffic analysis unit 1404 is specifically used for:

[0253] Obtain a preset analysis prompt template, the analysis prompt template includes analysis prompt text, the content prompt text is used to prompt: output the traffic analysis result of whether the request traffic belongs to abnormal traffic;

[0254] According to the content order set in the analysis prompt template, the analysis prompt text, target key content, and response key content are combined to obtain the analysis text;

[0255] The analyzed text is input into the trained analysis model to obtain traffic analysis results.

[0256] In one possible implementation, the traffic analysis unit 1404 is also used for:

[0257] The traffic information of various abnormal traffic types is obtained from a knowledge base that records traffic information of various abnormal traffic types. Each piece of traffic information in the knowledge base is used to characterize the field to which the key content in the corresponding type of abnormal traffic belongs.

[0258] The traffic information of various abnormal traffic types is added to the analysis text, and the analysis text with the added information is input into the trained analysis model to obtain the traffic analysis results.

[0259] In one possible implementation, when the target prompt content is input into a trained content extraction model to obtain the target key content, the content extraction unit 1403 is specifically used for:

[0260] Using the content extraction model, perform the following steps:

[0261] According to the set text encoding method, multiple text elements in the target network traffic are encoded to obtain corresponding content features; and, according to the text encoding method, the content prompt text is encoded to obtain prompt features.

[0262] Based on the obtained content features and prompt features, the target key content is selected from the multiple text elements.

[0263] In one possible implementation, the target prompt content further includes pre-analysis information, which is used to prompt the output format of the content extraction model and to instruct the content extraction model to provide inference logic for outputting the target extracted content; then the content extraction unit 1403 is further used for:

[0264] According to the output format, output the selected target key content and the reasoning logic for selecting the target content.

[0265] In one possible implementation, the content extraction model is trained in the following manner:

[0266] Obtain a traffic sample set, where each traffic sample in the traffic sample set is labeled with corresponding real key content;

[0267] Using the aforementioned traffic sample set, the pre-trained large language model is fine-tuned until the training termination condition is met. During each iteration of the fine-tuning training, the following steps are performed:

[0268] Using the large language model, content is extracted from each traffic sample input during this iteration to obtain the corresponding key sample content;

[0269] Based on the sample key content and real key content corresponding to each traffic sample, the model loss value is determined, and the parameters are tuned based on the model loss value.

[0270] For ease of description, the above sections are divided into modules (or units) according to their functions and described separately. Of course, in implementing this application, the functions of each module (or unit) can be implemented in one or more software or hardware components.

[0271] Regarding the apparatus in the above embodiments, the specific manner in which each unit executes the request has been described in detail in the embodiments related to the method, and will not be elaborated here.

[0272] Those skilled in the art will understand that various aspects of this application can be implemented as a system, method, or program product. Therefore, various aspects of this application can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software implementations, collectively referred to herein as a "circuit," "module," or "system."

[0273] Based on the same inventive concept, embodiments of this application also provide an electronic device. In one embodiment, the electronic device can be a server or a terminal device. See also... Figure 15 As shown, it is a schematic diagram of the structure of a possible electronic device provided in an embodiment of this application. Figure 15 In the electronic device 1500, there are: processor 1510 and memory 1520.

[0274] The memory 1520 stores a computer program that can be executed by the processor 1510. The processor 1510 can execute the steps of the above data processing method by executing the instructions stored in the memory 1520.

[0275] Memory 1520 may be volatile memory, such as random-access memory (RAM); memory 1520 may also be non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid-state drive (SSD); or memory 1520 may be any other medium capable of carrying or storing desired program code having the form of instructions or data structures and accessible by a computer, but is not limited thereto. Memory 1520 may also be a combination of the above-mentioned memories.

[0276] The processor 1510 may include one or more central processing units (CPUs) or digital processing units, etc. The processor 1510 implements the above-described data processing methods when executing computer programs stored in the memory 1520.

[0277] In some embodiments, the processor 1510 and the memory 1520 may be implemented on the same chip, while in other embodiments they may be implemented on separate chips.

[0278] This application embodiment does not limit the specific connection medium between the processor 1510 and the memory 1520. This application embodiment takes the connection between the processor 1510 and the memory 1520 via a bus as an example. Figure 15 The diagram uses thick lines to describe the connections between other components; these are merely illustrative and not intended to be limiting. Buses can be categorized as address buses, data buses, control buses, etc. For ease of description, Figure 15 It is described using only a thick line, but does not indicate that there is only one bus or one type of bus.

[0279] Based on the same inventive concept, embodiments of this application provide a computer-readable storage medium including a computer program. When the computer program is run on an electronic device, it causes the electronic device to perform the steps of the aforementioned data processing method. In some possible implementations, various aspects of the data processing method provided in this application can also be implemented as a program product including a computer program. When the program product is run on an electronic device, the computer program causes the electronic device to perform the steps of the aforementioned data processing method. For example, the electronic device can perform actions such as... Figure 2 The steps are shown in the figure.

[0280] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable disks, hard disks, RAM, ROM, erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0281] The program product of the embodiments of this application may be a CD-ROM and include a computer program, and may run on an electronic device. However, the program product of this application is not limited thereto. In this document, the readable storage medium may be any tangible medium that contains or stores a computer program that may be used by or in conjunction with a command execution system, apparatus, or device.

[0282] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying a readable computer program. This propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting a computer program for use by or in conjunction with a command execution system, apparatus, or device.

[0283] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0284] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A data processing method, characterized in that, include: Obtain target network traffic and obtain a target prompt template set for the traffic type of the target network traffic. The target prompt template includes content prompt text, which is used to prompt the field to which the key content associated with the traffic type belongs. According to the target prompt template, the target network traffic and the content prompt text are combined to generate the corresponding target prompt content; The target prompt content is input into a trained content extraction model to obtain target key content, which represents the content in the target network traffic that conforms to the traffic characteristics of abnormal traffic; Based on the key content of the target, traffic analysis is performed on the target network traffic to obtain traffic analysis results.

2. The method as described in claim 1, characterized in that, The step of combining the target network traffic and the content prompt text according to the target prompt template to generate corresponding target prompt content includes: According to the set traffic segmentation method, the target network traffic is segmented to obtain multiple traffic segments, and according to the target prompt template, the multiple traffic segments and the content prompt text are combined to generate corresponding prompt segments. The step of inputting the target prompt content into a trained content extraction model to obtain the target key content includes: The generated multiple prompt fragments are input into the content extraction model to obtain the corresponding fragment key content, and the target key content is obtained based on the obtained fragment key content.

3. The method as described in claim 2, characterized in that, The target network traffic is segmented according to a set traffic segmentation method to obtain multiple traffic segments, including: According to the set segment length and segment extraction interval, starting from the beginning of the target network traffic, corresponding traffic segments are sequentially extracted from the request traffic, wherein the segment extraction interval is less than the segment length.

4. The method as described in claim 2, characterized in that, The step of obtaining the target key content based on the obtained key content of multiple fragments includes: Based on the segment order of the multiple traffic segments in the target network traffic, determine the content order among the key content of the multiple segments; Based on the order of the content, the key content of the multiple segments is combined to obtain the target key content.

5. The method according to any one of claims 1-4, characterized in that, If the target network traffic is request traffic, then before performing traffic analysis on the target network traffic based on the target key content and obtaining the traffic analysis results, the process further includes: Obtain the response traffic returned in response to the request traffic, and extract the key response content from the response traffic using the response prompt template set for the response traffic; The step of performing traffic analysis on the target network traffic based on the target key content to obtain traffic analysis results includes: Based on the target key content and the response key content, traffic analysis is performed on the request traffic to obtain traffic analysis results.

6. The method as described in claim 5, characterized in that, The step of performing traffic analysis on the request traffic based on the target key content and the response key content to obtain traffic analysis results includes: Obtain a preset analysis prompt template, the analysis prompt template includes analysis prompt text, the content prompt text is used to prompt: output the traffic analysis result of whether the request traffic belongs to abnormal traffic; According to the content order set in the analysis prompt template, the analysis prompt text, target key content, and response key content are combined to obtain the analysis text; The analyzed text is input into the trained analysis model to obtain traffic analysis results.

7. The method as described in claim 6, characterized in that, Before inputting the analyzed text into the trained analysis model to obtain the traffic analysis results, the process also includes: The traffic information of various abnormal traffic types is obtained from a knowledge base that records traffic information of various abnormal traffic types. Each piece of traffic information in the knowledge base is used to characterize the field to which the key content in the corresponding type of abnormal traffic belongs. The step of inputting the analyzed text into the trained analysis model to obtain traffic analysis results includes: The traffic information of various abnormal traffic types is added to the analysis text, and the analysis text with the added information is input into the trained analysis model to obtain the traffic analysis results.

8. The method according to any one of claims 1-4, characterized in that, The step of inputting the target prompt content into a trained content extraction model to obtain the target key content includes: Using the content extraction model, perform the following steps: According to the set text encoding method, multiple text elements in the target network traffic are encoded to obtain corresponding content features; and, according to the text encoding method, the content prompt text is encoded to obtain prompt features. Based on the obtained content features and prompt features, the target key content is selected from the plurality of text elements.

9. The method as described in claim 8, characterized in that, The target prompt content also includes pre-analysis information, which is used to prompt the output format of the content extraction model and to instruct the content extraction model to provide the reasoning logic for outputting the target extracted content; Based on the obtained content features and prompt features, after selecting the target key content from the plurality of text elements, the process further includes: According to the output format, output the selected target key content and the reasoning logic for selecting the target content.

10. The method according to any one of claims 1-4, characterized in that, The content extraction model was trained in the following way: Obtain a traffic sample set, where each traffic sample in the traffic sample set is labeled with corresponding real key content; Using the aforementioned traffic sample set, the pre-trained large language model is fine-tuned until the training termination condition is met. During each iteration of the fine-tuning training, the following steps are performed: Using the large language model, content is extracted from each traffic sample input during this iteration to obtain the corresponding key sample content; Based on the sample key content and real key content corresponding to each traffic sample, the model loss value is determined, and the parameters are tuned based on the model loss value.

11. A data processing apparatus, characterized in that, include: A traffic acquisition unit is used to acquire target network traffic and acquire a target prompt template set for the traffic type of the target network traffic. The target prompt template includes content prompt text, which is used to prompt the field to which the key content associated with the traffic type belongs. The information combination unit is used to combine the target network traffic and the content prompt text according to the target prompt template to generate corresponding target prompt content; The content extraction unit is used to input the target prompt content into the trained content extraction model to obtain the target key content, wherein the target key content represents: the content in the target network traffic that conforms to the traffic characteristics of abnormal traffic; The traffic analysis unit is used to perform traffic analysis on the target network traffic based on the target key content and obtain traffic analysis results.

12. An electronic device, characterized in that, It includes a processor and a memory, wherein the memory stores a computer program that, when executed by the processor, causes the processor to perform the steps of any of the methods described in claims 1 to 10.

13. A computer-readable storage medium, characterized in that, It includes a computer program that, when run on an electronic device, causes the electronic device to perform the steps of any of the methods described in claims 1 to 10.

14. A computer program product, characterized in that, It includes a computer program stored in a computer-readable storage medium, and a processor of an electronic device reads from and executes the computer program, causing the electronic device to perform the steps of any of the methods described in claims 1 to 10.