Attack detection method, device, equipment and medium
By dividing network data in the attack detection model and performing incremental learning, the problem of low attack detection efficiency in the existing technology is solved, the adaptation to the growth of network data volume and the accuracy of attack behavior identification are improved, and network security is improved. sex.
Patent Information
- Application Number
- CN202410781217.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-18
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-06-18
AI Technical Summary
Existing attack detection models are difficult to adapt to the growth of network data volume, resulting in low attack detection efficiency. Many real attack behaviors are difficult to detect, seriously affecting network security.
An attack detection method is proposed, which obtains network data in the current incremental step, divides it into boundary data and remaining data according to the attack evaluation value, fine-tunes the detection model based on the remaining data, and gradually updates the model to adapt to the increase in data volume. while improving detection efficiency.
Through incremental learning and model fine-tuning, the accuracy and efficiency of attack detection are improved, ensuring that attack behaviors can be accurately identified as the amount of network data increases, and network security is improved.
Smart Images

Figure CN118353723B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of network security technology, and in particular to an attack detection method, device, equipment and medium. Background Art
[0002] A cyber attack refers to any type of offensive action against a computer information system, infrastructure, computer network, or personal computer device. Therefore, detecting cyber attacks is of great significance for maintaining network security. At present, the network data generated in the network is often detected through an attack detection model based on deep learning to detect whether there is an attack behavior.
[0003] In related technologies, attack detection models are difficult to adapt to the growing amount of network data, which will lead to the attack detection model simply classifying network data into attack or normal behavior without sufficient confidence. As the amount of network data gradually increases, more and more real attack behaviors will be difficult to detect, and the efficiency of attack detection will be low, which will seriously affect network security. Summary of the invention
[0004] The main purpose of the embodiments of the present disclosure is to provide an attack detection method, device, equipment and medium, which can improve the efficiency of attack detection.
[0005] To achieve the above objective, a first aspect of an embodiment of the present disclosure provides an attack detection method, including:
[0006] In the current incremental step, a plurality of network data to be detected are obtained, and each of the network data is respectively input into a preset attack detection model to obtain a corresponding attack evaluation value;
[0007] When the attack evaluation value is within a preset boundary range, the relevant network data is taken as first network data and added to the boundary set; otherwise, the relevant network data is taken as second network data and added to the remaining set;
[0008] Fine-tune the attack detection model in the current incremental step based on the second network data in the current remaining set to obtain a fine-tuned attack detection model;
[0009] After the next incremental step arrives, the first network data in the boundary set is input into the fine-tuned attack detection model to obtain a new attack evaluation value, and the attack detection result is determined according to the new attack evaluation value.
[0010] In some embodiments, before acquiring the plurality of network data to be detected, the attack detection method further includes:
[0011] Get multiple historical network data stored in the preset memory;
[0012] An initial attack detection model is trained based on a plurality of historical network data, and the trained attack detection model is used as a preset attack detection model in the current incremental step.
[0013] In some embodiments, the training of the initial attack detection model based on the plurality of historical network data, and using the trained attack detection model as the preset attack detection model in the current incremental step, includes:
[0014] According to the storage time sequence of the historical network data of the plurality of histories, the network data of the plurality of histories are divided into an initial set and a remaining set;
[0015] Training an initial attack detection model based on the plurality of historical network data in the initial set to obtain a trained attack detection model;
[0016] The trained attack detection model is fine-tuned based on the multiple historical network data in the remaining set, and the fine-tuned attack detection model is used as the preset attack detection model in the current incremental step.
[0017] In some embodiments, after taking the relevant network data as the second network data and adding it to the remaining set, the attack detection method further includes:
[0018] When the sizes of the initial set and the remaining set reach the preset memory, deleting the initial set;
[0019] According to the storage time sequence of the plurality of network data in the residual set, part of the network data in the residual set is transferred to the new initial set to obtain an updated initial set, and the residual set after the transfer is used as the updated residual set.
[0020] In some embodiments, when the attack evaluation value is within a preset boundary range, the relevant network data is used as first network data and added to a boundary set; otherwise, the relevant network data is used as second network data and added to a remaining set, including:
[0021] When the attack evaluation value is less than a preset first boundary threshold and greater than a preset second boundary threshold, the relevant network data is taken as first network data and added to the boundary set;
[0022] When the attack evaluation value is greater than or equal to the first boundary threshold, taking the relevant network data as second network data and adding it to the remaining set;
[0023] When the attack evaluation value is less than or equal to the second boundary threshold, the related network data is used as second network data and added to the remaining set.
[0024] In some embodiments, the attack detection result includes normal behavior, boundary behavior and attack behavior; the attack detection method further includes:
[0025] Acquire multiple groups of initial hyperparameters representing different ranges of the attack detection results, and determine an initial first boundary threshold and an initial second boundary threshold respectively according to the multiple groups of initial hyperparameters;
[0026] Based on the initial first boundary threshold and the initial second boundary threshold, determining a normal probability of the sample network data being classified into the normal behavior and an attack probability of the sample network data being classified into the attack behavior;
[0027] Determine a decision cost representing different ranges of the attack detection results based on a weighted sum of the normal probability and the attack probability and each group of the initial hyperparameters;
[0028] Adjust the multiple groups of the initial hyperparameters until the decision cost meets the preset requirements, and determine the adjusted first boundary threshold and the adjusted second boundary threshold based on the adjusted hyperparameters.
[0029] In some embodiments, the obtaining of multiple groups of initial hyperparameters representing different ranges of the attack detection results, and determining an initial first boundary threshold and an initial second boundary threshold respectively according to the multiple groups of initial hyperparameters, includes:
[0030] Obtaining an initial first hyperparameter representing a normal behavior range, an initial second hyperparameter representing a boundary behavior range, and an initial third hyperparameter representing an attack behavior range;
[0031] An initial first boundary threshold is determined based on the initial first hyperparameter and the initial second hyperparameter, and an initial second boundary threshold is determined based on the initial second hyperparameter and the initial third hyperparameter.
[0032] In some embodiments, the inputting of each of the network data into a preset attack detection model to obtain a corresponding attack evaluation value includes:
[0033] Compress and encode each of the network data to obtain corresponding encoded data;
[0034] Each of the coded data is input into a preset attack detection model to obtain a corresponding attack evaluation value.
[0035] In some embodiments, the network data is compressed and encoded by a trained variational autoencoder, and the variational autoencoder is trained by the following steps:
[0036] Get multiple sample network data;
[0037] Inputting each of the sample network data into the encoder part of the initial variational autoencoder respectively to obtain corresponding sample encoded data;
[0038] Inputting each of the sample encoded data into the decoder part of the initial variational autoencoder respectively to obtain corresponding sample decoded data;
[0039] A target loss value is determined according to the sample decoded data and the corresponding sample network data, and the initial variational autoencoder is trained based on the target loss value to obtain a trained variational autoencoder.
[0040] In some embodiments, there are multiple types of network data, and the step of inputting each type of network data into a preset attack detection model to obtain a corresponding attack evaluation value includes:
[0041] Preprocessing the network data of different types respectively to obtain a plurality of network data of the same length after preprocessing;
[0042] The preprocessed network data are respectively input into a preset attack detection model to obtain a corresponding attack evaluation value.
[0043] In some embodiments, the network data includes description information and attack payload information; and the preprocessing operation is performed on the network data of different types to obtain a plurality of network data of the same length after preprocessing, including:
[0044] The description information and the attack payload information under the different types of the network data are filled and spliced respectively to obtain a plurality of network data of the same length after preprocessing.
[0045] To achieve the above objective, a second aspect of an embodiment of the present disclosure provides an attack detection device, including:
[0046] A first detection unit, used for acquiring a plurality of network data to be detected in a current incremental step, and inputting each of the network data into a preset attack detection model to obtain a corresponding attack evaluation value;
[0047] A data partitioning unit, configured to, when the attack evaluation value is within a preset boundary range, treat the relevant network data as first network data and add it to a boundary set; otherwise, treat the relevant network data as second network data and add it to a remaining set;
[0048] An incremental fine-tuning unit, configured to fine-tune the attack detection model in the current incremental step based on the second network data in the current remaining set to obtain a fine-tuned attack detection model;
[0049] The second detection unit is used to input the first network data in the boundary set into the fine-tuned attack detection model after the next incremental step arrives to obtain a new attack evaluation value, and determine the attack detection result according to the new attack evaluation value.
[0050] To achieve the above-mentioned purpose, the third aspect of the embodiments of the present disclosure proposes an electronic device, which includes a memory and a processor, the memory stores a computer program, and the processor implements the attack detection method described in the embodiment of the first aspect when executing the computer program.
[0051] To achieve the above-mentioned purpose, the fourth aspect of the embodiments of the present disclosure proposes a storage medium, which is a computer-readable storage medium, and the storage medium stores a computer program. When the computer program is executed by a processor, the attack detection method described in the first aspect of the embodiments is implemented.
[0052] The attack detection method, device, equipment and medium proposed in the embodiments of the present disclosure can be applied to the attack detection device. By executing the attack detection method, in the current incremental step, the attack evaluation value of each network data to be detected is first determined by a preset attack detection model. When the size of the attack evaluation value is within the preset boundary range, it means that the relevant network data is difficult to accurately determine the attack behavior or normal behavior. Therefore, the relevant network data is used as the first network data and added to the boundary set. Otherwise, the network data that can accurately determine the attack behavior or normal behavior is used as the second network data and added to the remaining set. Then, based on the second network data in the current remaining set, the attack detection model in the current incremental step is fine-tuned so as to perform incremental learning on the model. In this way, as the amount of data increases, the model can be fine-tuned in each incremental step based on the data that accurately determines the attack behavior or normal behavior, and the fine-tuned attack detection model is obtained, so that the model can adapt to the situation where the amount of network data is increasing. Subsequently, after the next incremental step arrives, since the model has undergone incremental learning, after the first network data in the boundary set is input into the fine-tuned attack detection model, the boundary data can be re-detected, and finally accurate attack detection results can be obtained, thereby improving the efficiency of attack detection and improving network security. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 Schematic diagram of an application environment of the attack detection method provided by the embodiment of the present disclosure
[0054] Figure 2 is a flowchart of an attack detection method provided by an embodiment of the present disclosure;
[0055] Figure 3 yes Figure 2 A schematic diagram of a process flow further included before step S101;
[0056] Figure 4 yes Figure 3 Step S202 further includes a flow chart;
[0057] Figure 5 yes Figure 2 A schematic diagram of a process flow further included after step S102;
[0058] Figure 6 yes Figure 2 Step S102 further includes a flow chart;
[0059] Figure 7 is another flowchart of the attack detection method provided by an embodiment of the present disclosure;
[0060] Figure 8 yes Figure 7 Step S601 further includes a flow chart;
[0061] Fig. 9 yes Figure 2 Step S101 further includes a flow chart;
[0062] Fig.10 is a flow chart of a variational autoencoder training process provided by an embodiment of the present disclosure;
[0063] Fig.11 yes Figure 2 Another flowchart diagram further comprising step S101;
[0064] Fig.12 is a complete flow chart of the attack detection method provided by the embodiment of the present disclosure;
[0065] Fig.13 is a process diagram of an attack detection method provided by an embodiment of the present disclosure;
[0066] Fig.14 is a schematic diagram of functional modules of an attack detection device provided by an embodiment of the present disclosure;
[0067] Fig.15 It is a schematic diagram of the hardware structure of the electronic device provided by the embodiment of the present disclosure. DETAILED DESCRIPTION
[0068] In order to make the purpose, technical solution and advantages of the present disclosure more clear, the present disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present disclosure and are not used to limit the present disclosure.
[0069] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present disclosure belongs. The terms used herein are only for the purpose of describing the embodiments of the present disclosure and are not intended to limit the present disclosure.
[0070] First, some nouns involved in this disclosure are analyzed:
[0071] Artificial intelligence (AI) is a new technical science that studies and develops theories, methods, technologies and application systems for simulating, extending and expanding human intelligence. AI is a branch of computer science that attempts to understand the essence of intelligence and produce a new type of intelligent machine that can respond in a similar way to human intelligence. Research in this field includes robots, language recognition, image recognition, natural language processing and expert systems. AI can simulate the information process of human consciousness and thinking. AI is also a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0072] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0073] Incremental learning is a machine learning method, also known as continuous learning, sequential learning or lifelong learning, which allows the model to continuously learn new information when new data is obtained, while retaining previously learned knowledge. Unlike traditional batch learning methods (such as the standard training process in deep learning), incremental learning does not require retraining the entire model every time new data is introduced, but can gradually update the model in an increasing stream of data.
[0074] In the field of network security, attack payload refers to data or instructions with malicious intent that are delivered by attackers using vulnerabilities, malware, or other attack methods. These data or instructions are executed on the attacked system to achieve the attacker's goals, such as conducting malicious activities. Attack payloads can contain various forms of malicious code.
[0075] Variational Auto Encoders (VAE) are a deep generative model based on a generative network structure inferred by Variational Bayes (VB). They differ from traditional autoencoders in the way they describe the latent space. Variational Auto Encoders use an Encoder-Decoder architecture, where the purpose of the Encoder is to learn the probability distribution of the data and use the latent variable z to represent the learned distribution. Then, vectors are sampled and generated from z as input to the Decoder, which restores these vectors to a high-dimensional representation of the original data, allowing the variational autoencoder to generate new data that is similar to the original data, thus showing great application value in data generation.
[0076] In related technologies, attack detection models are difficult to adapt to the growing amount of network data, which will lead to the attack detection model simply classifying network data into attack or normal behavior without sufficient confidence. As the amount of network data gradually increases, more and more real attack behaviors will be difficult to detect, and the efficiency of attack detection will be low, which will seriously affect network security.
[0077] Based on this, the embodiments of the present disclosure provide an attack detection method, apparatus, device and medium, which can improve the efficiency of attack detection, improve network security, and adapt to the situation where the flow and log data increase during the attack and defense game.
[0078] The attack detection method in the embodiments of the present disclosure can be illustrated by the following embodiments.
[0079] The embodiments of the present disclosure can acquire and process relevant data based on artificial intelligence technology.
[0080] The attack detection method provided in the embodiments of the present disclosure can be applied to a terminal, or to a server, or can be software running in a terminal or a server. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server can be configured as an independent physical server, or a server cluster or a 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 communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the attack detection method, etc., but is not limited to the above forms.
[0081] The present disclosure can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present disclosure can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present disclosure can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0082] Take the application in the terminal as an example, Figure 1 As shown, Figure 1It is a schematic diagram of an application environment of the attack detection method provided by the embodiment of the present disclosure. The terminal is provided with an input device, an output device, a processor, etc., the processor includes an internal memory and a non-volatile memory, and a model program and an operating system are deployed on the non-volatile memory. Among them, the input device can obtain an incremental data stream, and the incremental data stream includes various network data generated by the network. After receiving the network data, the processor can input each network data into a preset attack detection model in the current incremental step to obtain a corresponding attack evaluation value; when the size of the attack evaluation value is within the preset boundary range, the relevant network data is used as the first network data and added to the boundary set, otherwise, the relevant network data is used as the second network data and added to the remaining set; based on the second network data in the current remaining set, the attack detection model in the current incremental step is fine-tuned to obtain a fine-tuned attack detection model; after the next incremental step arrives, the first network data in the boundary set is input into the fine-tuned attack detection model to obtain a new attack evaluation value, and the attack detection result is determined according to the new attack evaluation value. The final output device can output the attack detection result, and the standard data is normal behavior or attack behavior.
[0083] It should be noted that in each specific embodiment of the present disclosure, when network data is obtained for related processing, the user's permission or consent will be obtained first. Moreover, the collection, use and processing of these data will comply with relevant laws, regulations and standards. In addition, when the embodiment of the present disclosure needs to obtain network data, the user's separate permission or consent can be obtained through a pop-up window or by jumping to a confirmation page. After the user's separate permission or consent is clearly obtained, the necessary network data for the normal operation of the embodiment of the present disclosure can be obtained.
[0084] Figure 2 is a flowchart of an attack detection method provided by an embodiment of the present disclosure, Figure 2 The method may include but is not limited to steps S101 to S104.
[0085] Step S101, in the current incremental step, multiple network data to be detected are obtained, and each network data is input into a preset attack detection model to obtain a corresponding attack evaluation value;
[0086] Step S102, when the attack evaluation value is within a preset boundary range, the relevant network data is taken as first network data and added to the boundary set; otherwise, the relevant network data is taken as second network data and added to the remaining set;
[0087] Step S103, fine-tuning the attack detection model in the current incremental step based on the second network data in the current remaining set to obtain a fine-tuned attack detection model;
[0088] Step S104, after the next incremental step arrives, the first network data in the boundary set is input into the fine-tuned attack detection model to obtain a new attack evaluation value, and the attack detection result is determined according to the new attack evaluation value.
[0089] With respect to the above-mentioned step S101, an incremental step refers to an iterative process. In the embodiment of the present disclosure, faced with the situation of an increasing amount of network data, when processing a large amount of data, in order to improve efficiency and avoid the difficulty of processing all data at once, the network data stream is divided into multiple batches for processing, also referred to as "increments". Therefore, in practical applications, the embodiment of the present disclosure processes the network data received in real time in each incremental step. Network data refers to various real-time data of the network, which may include network traffic, behavior logs, system logs, data packets, etc., which are all potential sources of information that may contain attack behaviors.
[0090] The attack detection model (which may be referred to as the model for short) is a trained model based on machine learning and deep learning, which can automatically analyze the input data and output one or more indicators indicating whether the data contains attack behavior. It should be noted that the attack detection model in the embodiment of the present disclosure is a classification model. Furthermore, the attack detection model in the embodiment of the present disclosure processes and analyzes the input network data, and then outputs an attack evaluation value. The attack evaluation value is a score that represents the model's confidence or probability of whether the input data is an attack. For example, the higher the attack evaluation value, the higher the probability that the network data is normal behavior, and conversely, the lower the attack evaluation value, the higher the probability that the network data is an attack behavior. Therefore, the attack detection result of the network data can be determined according to the size of the attack evaluation value.
[0091] For the above step S102, the preset boundary range is a threshold range, which is used to determine whether the network data belongs to the category of "difficult to accurately determine attack behavior or normal behavior". The attack detection model in the embodiment of the present disclosure is not a simple binary classification model. Specifically, in addition to being able to identify network data of normal behavior and attack behavior, if the attack assessment value falls within the preset boundary range, then the model is not sure about the classification of the network data, that is, it is difficult to accurately determine whether it belongs to attack behavior or normal behavior, so further processing is required. Exemplarily, the preset boundary range can be set based on the model's training data, historical data and business needs.
[0092] When the size of the attack assessment value is within the preset boundary range, it means that the model is not sure about the classification of this network data, and the data is a boundary data. Therefore, these network data are classified as the first network data and added to the boundary set. The boundary set is a collection that temporarily stores these difficult-to-classify data for subsequent processing. On the contrary, if the size of the attack assessment value is not within the preset boundary range (that is, the attack assessment value is too high or too low, indicating that the model has a high confidence in the attack or normal behavior), then the model is more certain about the classification of this network data. Therefore, these network data are classified as the second network data and added to the remaining set. The remaining set contains which network data the model can clearly classify as attack or normal.
[0093] For the above step S103, a part or all of the second network data is selected from the remaining set as fine-tuning data, which has a higher confidence and can reflect the characteristics of normal behavior and attack behavior in the current network environment. Model fine-tuning is to further train and optimize the model based on the trained model using new data to improve the performance and adaptability of the model. The fine-tuning in the embodiment of the present disclosure is an incremental learning method, that is, the parameters of the model are updated according to the new data to improve the performance of the model.
[0094] After the above-mentioned fine-tuning process, the attack detection model will be updated and saved as a fine-tuned attack detection model. While maintaining the ability to classify previous data, the fine-tuned attack detection model also has better adaptability to new data and can better identify newly emerging attack patterns. Therefore, in the embodiments of the present disclosure, by fine-tuning the model with data with higher confidence, the model can better adapt to changes in network data, especially to incremental environments, and improve the ability to identify newly emerging attack patterns.
[0095] Furthermore, after fine-tuning is completed, the embodiment of the present disclosure can evaluate the fine-tuned attack detection model to verify its performance on new data. Evaluation indicators may include accuracy, recall, F1 value, etc., which will not be repeated here.
[0096] After obtaining the remaining set, the system will use the second network data in it to fine-tune the attack detection model in the current incremental step. This fine-tuning is a method of incremental learning, that is, the system will update the parameters of the model according to the new data to improve the performance of the model. Since the data in the remaining set can be clearly classified by the model, this data is very valuable for fine-tuning the model. Through this process, the model can learn more attack patterns or normal behavior patterns, thereby improving its classification accuracy.
[0097] In steps S101 to S103, the embodiment of the present disclosure completes the processing of an incremental step. As time goes by, new network data will continue to be generated, so it is necessary to trigger the next incremental step regularly or according to certain conditions. When a new incremental step arrives, step S104 is executed.
[0098] With respect to the above step S104, since the network data whose attack evaluation values are within the preset boundary range are identified and added to the boundary set as the first network data, these data are temporarily marked as "boundary data" in the previous incremental step due to the uncertainty of the model. When a new incremental step begins, since the attack detection model has been fine-tuned based on the second network data in the remaining set, a more accurate and adaptable attack detection model is obtained. Therefore, the first network data in the boundary set can be input into the fine-tuned model, their attack behaviors are re-evaluated, and new attack evaluation values are given. The obtained new evaluation values will be more accurate than before. Finally, according to the new attack evaluation values, it can be determined whether these boundary data are attack behaviors.
[0099] Furthermore, after the next incremental step, if it is still difficult to determine the attack behavior or normal behavior in the first network data, and if it is still impossible to determine after incremental fine-tuning, after the number of fine-tuning iterations is met, the attack detection result of the boundary behavior in the first network data can be output. In addition, expert knowledge can be integrated to evaluate the boundary behavior that is still difficult to judge after multiple iterations. Specifically, expert knowledge can be used for judgment, or the first network data characterized as boundary behavior can be input into the expert model for processing, so as to obtain accurate attack detection results and judge whether it is an attack behavior or a normal behavior, further improving the accuracy of attack detection. Finally, the first network data that obtains accurate results can be added to the remaining set as labeled data feedback so that the attack inspection model can be fine-tuned or trained.
[0100] In summary, the embodiment of the present disclosure, through steps S101 to S104, in the current incremental step, first determines the attack evaluation value of each network data to be detected through the preset attack detection model. When the size of the attack evaluation value is within the preset boundary range, it means that the relevant network data is difficult to accurately determine the attack behavior or normal behavior, so the relevant network data is used as the first network data and added to the boundary set, otherwise, the network data that can accurately determine the attack behavior or normal behavior is used as the second network data and added to the remaining set. Then, based on the second network data in the current remaining set, the attack detection model in the current incremental step is fine-tuned so as to perform incremental learning on the model. In this way, as the amount of data increases, the model can be fine-tuned based on the data that accurately determines the attack behavior or normal behavior in each incremental step to obtain a fine-tuned attack detection model, so that the model adapts to the situation where the amount of network data is increasing. Subsequently, after the next incremental step arrives, since the model has been incrementally learned, after the first network data in the boundary set is input into the fine-tuned attack detection model, the boundary data can be re-detected, and finally an accurate attack detection result is obtained, thereby improving the efficiency of attack detection and improving network security.
[0101] See also Figure 3 , Figure 3 yes Figure 2 In some embodiments, before obtaining the plurality of network data to be detected, the attack detection method may further include steps S201 to S202:
[0102] Step S201, obtaining a plurality of historical network data stored in a preset memory;
[0103] Step S202: training an initial attack detection model based on a plurality of historical network data, and using the trained attack detection model as a preset attack detection model in the current incremental step.
[0104] In the above steps S201 to S202, the embodiment of the present disclosure can obtain multiple historical network data from the preset memory. Among them, the embodiment of the present disclosure can specifically set the corresponding memory space as the preset memory for the needs of attack detection. Since the amount of network data is continuously increasing, the set memory should not be too large for the performance of detection, so as to avoid a large amount of data occupying and causing an impact on the performance of the system. Therefore, the preset memory can be set to a corresponding size according to actual needs. Historical network data is the network traffic, behavior logs, system logs, data packets, etc. that were previously captured, stored and marked as normal behavior or attack behavior on the network.
[0105] After acquiring historical network data, the disclosed embodiment will use this data to train an initial attack detection model. The initial attack detection model is an initialized model. During the training process, data samples marked as normal behavior and attack behavior in the historical network data will be used to guide the learning of the model. By iteratively optimizing the parameters and structure of the model, it can minimize the classification error on the training set, thereby obtaining a relatively accurate attack detection model. After the training is completed, the obtained attack detection model will be saved and used as the preset attack detection model in the current incremental step. Furthermore, in the subsequent incremental learning process, the performance of the preset attack detection model is gradually improved by continuously receiving new network data and fine-tuning it.
[0106] It is understandable that in order to train the model based on more data, it is necessary to obtain all the data at one time in the related technology, and train the model to meet the performance requirements. However, when faced with the problem of large and continuously growing network data volume, the storage and computing overhead of the related technology are relatively large, and it is impossible to process the data arriving in batches in real time. In contrast, in the actual application process, the embodiment of the present disclosure does not need to obtain all the data at one time, which reduces the storage and computing overhead. By first training a preset attack detection model based on the existing data, and then in the scenario of continuous increment, the model is fine-tuned based on the data that accurately determines the attack behavior or normal behavior, and the performance of the model is continuously optimized, so that attack detection can be continuously performed based on the current data, thereby adapting to the situation where the data of the attack detection process is growing and the data distribution is changing. When faced with data that is difficult to accurately determine the attack behavior or normal behavior, through continuous incremental learning, the model can also give a relatively accurate detection result, which greatly improves the efficiency of attack detection and improves network security.
[0107] See also Figure 4 , Figure 4 yes Figure 3 In some embodiments, step 202 may include steps S301 to S303:
[0108] Step S301, dividing the plurality of historical network data into an initial set and a remaining set according to the storage time sequence between the plurality of historical network data;
[0109] Step S302, training an initial attack detection model based on a plurality of historical network data in the initial set to obtain a trained attack detection model;
[0110] Step S303, fine-tuning the trained attack detection model based on the multiple historical network data in the remaining set, and using the fine-tuned attack detection model as the preset attack detection model in the current incremental step.
[0111] In the above steps S301 to S303, each historical network data in the embodiment of the present disclosure has a corresponding timestamp (or similar time mark), and the timestamp can be the date and time when the data is captured, recorded or stored, and the corresponding storage time is determined based on the timestamp. Then, the historical network data is sorted according to the order of the timestamps, so that the earliest stored data will be at the front, and the latest stored data will be at the back.
[0112] In the disclosed embodiment, an initial set and a residual set are established to store data of different functions. The initial set contains the network data stored earlier, and the attack detection model is subsequently trained based on the data in the initial set. The residual set contains the network data stored more recently, and the attack detection model is subsequently fine-tuned based on the data in the residual set. The division of the initial set and the residual set helps the model first learn the relatively stable and characteristic network behavior patterns in history, and then gradually learn newer and more complex patterns.
[0113] Specifically, the disclosed embodiment uses the historical network data in the initial set to train an initial attack detection model. The initial attack detection model is initialized and can be trained by supervised learning. By iteratively optimizing the parameters and structure of the model, the model can identify the data of normal behavior and attack behavior in the initial set as accurately as possible. After the training is completed, a trained attack detection model will be obtained.
[0114] Subsequently, the disclosed embodiment uses the historical network data in the remaining set to fine-tune the trained attack detection model obtained in the previous step. The data in the remaining set contains newer and even more complex network behavior patterns. By fine-tuning the model, it can be adapted to these new patterns and the generalization ability of the model can be improved. Fine-tuning is usually achieved by continuing to train the model, but a smaller learning rate or fewer iterations can be used to avoid overfitting, and since the model structure is fixed during the fine-tuning process, only the model parameters are adjusted. After fine-tuning is completed, a fine-tuned attack detection model will be obtained, and it will be used as the preset attack detection model in the current incremental step for subsequent attack detection tasks.
[0115] Furthermore, if there are many historical network data stored, multiple residual subsets can be obtained. For example, if the capacity of each data set is set to 1000, the first 1000 network data are divided into the initial set in chronological order, and then, multiple residual subsets with 1000 network data are gradually formed in chronological order. In the subsequent fine-tuning process, the attack detection model can be gradually fine-tuned based on each residual subset in order.
[0116] Exemplarily, there can be multiple types of attack detection models, and the model structure is flexible. For example, you can choose a long short-term memory network (LSTM), a recurrent neural network (RNN), a codec, etc. In order to make the model structure simpler in the disclosed embodiment, two stacked sparse auto encoders (SAE) are used as attack detection models, where the output of the first encoder is used as the input of the second encoder, and the output layer of the second SAE model is connected to a softmax layer as the probability output of the classification, so as to obtain the required attack evaluation value. In addition, you can also choose to use.
[0117] For example, after fine-tuning the attack detection model, the fine-tuned model can also be evaluated. In one embodiment, four evaluation indicators are used for evaluation, namely, accuracy, precision, recall, and F1-score. Their calculation formulas are shown in the following formulas (1), (2), (3), and (4):
[0118] (1)
[0119] (2)
[0120] (3)
[0121] (4)
[0122] Among them, TP (True Positive) is a true positive example, TN (True Negative) is a true negative example, FP (False Positive) is a false positive example, and FN (False Negative) is a false negative example. The definitions are shown in Table 1:
[0123]
[0124] Table 1 Relationship between true and false examples
[0125] See also Figure 5 , Figure 5 yes Figure 2 In some embodiments, after the relevant network data is used as the second network data and added to the remaining set, the attack detection method may further include steps S401 to S402:
[0126] Step S401, when the size of the initial set and the remaining set reaches the preset memory, the initial set is deleted;
[0127] Step S402, according to the storage time sequence of the plurality of network data in the residual set, part of the network data in the residual set is transferred to the new initial set to obtain an updated initial set, and the transferred residual set is used as the updated residual set.
[0128] In the above steps S401 to S402, during the incremental learning process, as new network data is continuously added, the memory used to store data may reach its preset upper limit. In order to continue processing new data and avoid memory overflow, some old data needs to be deleted. In the disclosed embodiment, the data in the initial set has been used for the initial training of the attack detection model, and in the subsequent fine-tuning process, the contribution of these data may have been covered or surpassed by the data in the remaining set, so the initial set can be deleted.
[0129] After deleting the initial set, the embodiment of the present disclosure will transfer part of the data in the remaining set to the new initial set. Exemplarily, the transferred data can be the part of the remaining set that is stored earlier, that is, the remaining set is supplemented into the new initial set in chronological order, and the amount of transferred data can be set as needed to ensure that the new initial set is representative enough, and the remaining set also retains enough new data for subsequent model fine-tuning. In addition, new incremental data can also be received at the same time as a supplement to the remaining set. After the transfer is completed, an updated initial set and an updated remaining set are obtained. Therefore, as time goes by, the attack detection model in the embodiment of the present disclosure can still continue to learn from new and old data while maintaining effective use of limited memory resources.
[0130] See also Figure 6 , Figure 6 yes Figure 2 In some embodiments, step 102 may include steps S501 to S503:
[0131] Step S501, when the attack evaluation value is less than a preset first boundary threshold and greater than a preset second boundary threshold, the relevant network data is taken as first network data and added to the boundary set;
[0132] Step S502, when the attack evaluation value is greater than or equal to the first boundary threshold, the relevant network data is used as the second network data and added to the remaining set;
[0133] Step S503: When the attack evaluation value is less than or equal to the second boundary threshold, the relevant network data is taken as the second network data and added to the remaining set.
[0134] In the above steps S501 to S503, the first boundary threshold and the second boundary threshold are thresholds set in the embodiment of the present disclosure for determining whether there is attack behavior, normal behavior, and boundary behavior in the network data. Classifying the network data by the two preset thresholds is helpful for the subsequent fine-tuning and optimization of the attack detection model, as well as the further analysis of the boundary data, thereby improving the accuracy and efficiency of attack detection. It should be noted that the first boundary threshold and the second boundary threshold can be set according to the needs.
[0135] If the attack assessment value is less than the first boundary threshold but greater than the second boundary threshold, it is considered that the nature of this network data is uncertain, and there may be attack behavior or normal behavior. Therefore, it is classified as boundary data, and the network data identified as boundary data is added to the boundary set as the first network data for further analysis or processing.
[0136] If the attack evaluation value is greater than or equal to the first boundary threshold, then it is considered that there is normal behavior in this network data, and the network data identified as normal behavior is added to the remaining set as the second network data for subsequent fine-tuning of the attack detection model. Similarly, if the attack evaluation value is less than or equal to the second boundary threshold, then it is considered that there is an attack behavior in this network data, so the relevant network data is added to the remaining set as the second network data.
[0137] In some embodiments, the attack detection result includes normal behavior, boundary behavior, and attack behavior. Figure 7 , Figure 7 is another flow chart of the attack detection method provided by the embodiment of the present disclosure. The attack detection method may also include steps S601 to S604:
[0138] Step S601, obtaining multiple groups of initial hyperparameters representing different attack detection result ranges, and determining an initial first boundary threshold and an initial second boundary threshold respectively according to the multiple groups of initial hyperparameters;
[0139] Step S602, based on the initial first boundary threshold and the initial second boundary threshold, determining the normal probability of the sample network data being classified as normal behavior and the attack probability of the sample network data being classified as attack behavior;
[0140] Step S603, performing weighted summation based on the normal probability and the attack probability and each group of initial hyperparameters to determine the decision cost representing different attack detection result ranges;
[0141] Step S604, adjusting multiple groups of initial hyperparameters until the decision cost meets the preset requirements, and determining an adjusted first boundary threshold and an adjusted second boundary threshold based on the adjusted hyperparameters.
[0142] In the above steps S601 to S604, the three-branch decision correction model (referred to as the three-branch decision model) is combined in the embodiment of the present disclosure to set a reasonable first boundary threshold and a second boundary threshold. First, it is necessary to obtain multiple sets of initial hyperparameters that characterize the range of different attack detection results. These hyperparameters are parameters related to model performance, data set characteristics or business requirements. Therefore, the initial first boundary threshold and the initial second boundary threshold are determined respectively according to the multiple sets of initial hyperparameters.
[0143] Next, after determining the initial thresholds, use these thresholds to classify the sample network data, and calculate the normal probability of being classified as normal behavior and the attack probability of being classified as attack behavior. Among them, the sample network data is sample data used to train, verify and test attack detection models in the field of network security. Similar to the network data in the above application process, the sample network data can also come from the actual network environment, including various network traffic, data packets, log records, etc. The normal probability and attack probability are calculated based on the performance of the sample data in the model, reflecting the model's ability to classify different categories of data.
[0144] Subsequently, a weighted sum can be performed based on the normal probability and the attack probability, as well as the initial hyperparameters of each group, to determine the decision cost that characterizes the range of different attack detection results. The decision cost is a quantitative indicator used to measure the cost or price of misclassifying network data. For example, misclassifying an attack behavior as normal behavior may lead to serious security consequences, so its decision cost may be high; while misclassifying normal behavior as attack behavior may lead to resource waste or reduced classification performance, but its decision cost may be relatively low. Furthermore, the decision costs of normal behavior, boundary behavior, and attack behavior can be obtained respectively, that is, there are three types of decision costs.
[0145] Therefore, after obtaining the decision cost, it is necessary to adjust multiple sets of initial hyperparameters to find a hyperparameter combination that can minimize the decision cost. This process can be achieved through iterative optimization algorithms (such as gradient descent, genetic algorithm, etc.). In each iteration, the decision cost is calculated based on the current hyperparameter combination, and the hyperparameters are adjusted according to the change of the decision cost. When the decision cost meets the preset requirements (that is, it reaches the preset minimum value or the number of iterations reaches the upper limit), the iteration is stopped, and the adjusted first boundary threshold and the adjusted second boundary threshold are determined based on the adjusted hyperparameters. These adjusted thresholds will be used in the subsequent attack detection process to improve the accuracy and efficiency of detection.
[0146] See also Figure 8 , Figure 8 yes Figure 7In some embodiments, step 601 may include steps S701 to S702:
[0147] Step S701, obtaining an initial first hyperparameter representing a normal behavior range, an initial second hyperparameter representing a boundary behavior range, and an initial third hyperparameter representing an attack behavior range;
[0148] Step S702: determining an initial first boundary threshold based on the initial first hyperparameter and the initial second hyperparameter, and determining an initial second boundary threshold based on the initial second hyperparameter and the initial third hyperparameter.
[0149] In the above steps S701 to S702, there are multiple groups of hyperparameters in the embodiment of the present disclosure, including an initial first hyperparameter characterizing a normal behavior range, an initial second hyperparameter characterizing a boundary behavior range, and an initial third hyperparameter characterizing an attack behavior range. Since the first boundary threshold is used to define normal behavior and boundary behavior, the initial first boundary threshold can be determined based on the initial first hyperparameter and the initial second hyperparameter. Similarly, since the second boundary threshold is used to define attack behavior and boundary behavior, the initial second boundary threshold can be determined based on the initial second hyperparameter and the initial third hyperparameter.
[0150] For example, in one embodiment, the model judges normal behavior as P (Positive), and the model judges attack behavior as N (Negative). Both are immediate decisions and accept the model judgment; the model judges boundary behavior as B (Boundary), which means that a delayed decision is required. Each set of hyperparameters has two, so the initial first hyperparameter is set to and , the initial second hyperparameter is and , the initial third hyperparameter is and . Using parameters, and respectively represent the situation of dividing network data into normal behavior, boundary behavior and attack behavior, the relationship between the parameters can be obtained as shown in Table 2 below:
[0151]
[0152] Table 2 Relationship between parameters
[0153] If the initial first boundary threshold is set as α and the initial second boundary threshold is set as β, the formula (5) of α and β can be obtained as follows:
[0154] (5)
[0155] There are three decision costs, and the sample network data is represented by x, where represents the decision cost of the model classifying data x as normal behavior, Represents the decision cost of the model classifying data x into boundary behavior, Represents the decision cost of the model classifying data x into attack behavior. represents the normal probability that the model classifies data x as normal behavior, It represents the attack probability that the model classifies data x into attack behavior. Therefore, according to the probabilistic rough set, the calculation formulas of the three decision costs in the three-way decision correction model are as shown in the following formulas (6), (7) and (8):
[0156] (6)
[0157] (7)
[0158] (8)
[0159] Finally, after obtaining the three decision costs, we can adjust multiple sets of initial hyperparameters until the decision costs meet the preset requirements, and then determine the adjusted first boundary threshold and the adjusted second boundary threshold based on the adjusted hyperparameters. In this way, the obtained first boundary threshold and second boundary threshold can well integrate multiple situations and ultimately improve the performance of attack detection classification.
[0160] See also Fig. 9 , Fig. 9 yes Figure 2 In some embodiments, step 101 may include steps S801 to S802:
[0161] Step S801, compress and encode each network data to obtain corresponding encoded data;
[0162] Step S802: Input each coded data into a preset attack detection model to obtain a corresponding attack evaluation value.
[0163] In the above steps S801 to S802, since network data often exists in raw form, contains a large amount of information, and occupies a large memory space, directly processing raw data may consume a large amount of computing resources. Therefore, before inputting network data into the attack detection model, the data needs to be preprocessed, and one of the important steps is compression coding. The main purpose of compression coding is to reduce the dimension and complexity of the data while retaining enough information for attack detection, so as to improve computing and storage efficiency, and also to convert text data into feature vectors.
[0164] Exemplarily, there are various ways of compression encoding, for example, data can be compressed using hash functions, feature extraction, neural network encoding, etc. The encoding process converts the original network data into a more compact representation suitable for attack detection model processing, namely, encoded data.
[0165] After obtaining the encoded data, it can be input into the preset attack detection model. When the encoded data is input into the model, the model will process the data according to its internal parameters and structure and output one or more attack evaluation values.
[0166] In some embodiments, network data is compressed and encoded by a trained variational autoencoder, see Fig.10 , Fig. 9 is a flow chart of the variational autoencoder training process provided by the embodiment of the present disclosure. The variational autoencoder is trained by the following steps, which may include steps S901 to S904:
[0167] Step S901, obtaining a plurality of sample network data;
[0168] Step S902, inputting each sample network data into the encoder part of the initial variational autoencoder to obtain corresponding sample encoded data;
[0169] Step S903, inputting each sample encoding data into the decoder part of the initial variational autoencoder to obtain corresponding sample decoded data;
[0170] Step S904, determining a target loss value according to the sample decoded data and the corresponding sample network data, and training an initial variational autoencoder based on the target loss value to obtain a trained variational autoencoder.
[0171] In the above steps S901 to S904, in the process of training the variational autoencoder, a training set can be obtained, and the training set includes multiple sample network data, and the sample network data can be the same as the sample network data in the above embodiment. It should be noted that the variational autoencoder can be trained separately from the attack detection model. Furthermore, in order to improve the joint processing capability of data and improve the generalization between models, the variational autoencoder and the attack detection model are obtained through joint training, that is, the variational autoencoder and the attack detection model can be jointly trained based on the sample network data. This embodiment of the present disclosure does not impose specific limitations on this.
[0172] It should be noted that the variational autoencoder is a deep learning model, including an encoder part and a decoder part, and the encoder part contains a multi-layer neural network. After the sample network data is input into the encoder part of the variational autoencoder, it can be compressed into low-dimensional, easy-to-process sample encoded data. Compared with the traditional autoencoder, the optimization goal of the variational autoencoder is no longer to minimize the reconstruction error, but to maximize the logarithmic probability of the next distribution. Therefore, the variational autoencoder can make the generated data closer to the distribution of the original data, thereby improving the diversity and quality of the generated data.
[0173] The decoder part of the variational autoencoder is also a part of the variational autoencoder, and its structure is the same as that of the encoder part. Its function is to restore the encoded data, that is, to decode it into an approximate representation of the original data. In order to verify the compression coding capability of the encoder part of the variational autoencoder and avoid the encoded data being too different from the original input network data, it is necessary to compare the sample encoded data and the sample network data during the training process to verify the encoding situation. Therefore, the embodiment of the present disclosure inputs each sample encoded data into the decoder part of the initial variational autoencoder to obtain its corresponding sample decoded data, and the obtained sample decoder can be as close to the original sample network data as possible.
[0174] In order to train the variational autoencoder, a loss function needs to be defined to quantify the difference between the sample decoded data and the sample network initial data. Exemplarily, the loss function may include two parts: one part is the reconstruction error, which is used to measure the difference between the decoded data and the original data. For example, the mean square error (MSE) function can be used to calculate the mean square error loss value; the other part may use the KL divergence (Kullback-Leibler divergence) to measure the difference between the distribution of the sample encoded data and the preset distribution. The loss value obtained by calculating the KL divergence is determined as the KL loss value. Finally, the target loss value is obtained by weighting the mean square error loss value and the KL loss value. By minimizing this target loss value, the variational autoencoder can be trained to generate encoded data that can accurately reconstruct the original data and has a suitable distribution.
[0175] During the training process, steps S902 to S904 are continuously and iteratively executed, and each iteration uses new sample network data to update the parameters of the variational autoencoder until the target loss value converges or reaches the preset number of training rounds. Finally, a trained variational autoencoder is obtained, which can compress the input network data into low-dimensional encoded data, and these encoded data can well reconstruct the original data. Therefore, the trained variational autoencoder can be used in subsequent attack detection tasks, and key features can be extracted by compressing the encoded network data, thereby improving the efficiency and accuracy of attack detection.
[0176] Exemplarily, in one embodiment, assuming that the sample network data is x, the variational autoencoder is represented by VAE, where the encoder part is , is the parameter of the encoder part, which is trained after random initialization, and the decoder part is , similarly, are the parameters of the decoder part. During the training process, the encoder part The input data x is compressed into latent variables z, which are sample encoded data and used as the feature matrix of the data. Re-decode the sample encoded data z into , which is the sample decoding data, so that Try to be as similar to the original input data x as possible.
[0177] Next, calculate the mean square error loss value The formula is as follows: Formula (9) calculates the KL loss value The formula is shown in formula (10):
[0178] (9)
[0179] (10)
[0180] Where n is the length of the sample network data; In is the probability distribution of sample network data, Encode data for the reconstructed samples The probability distribution of .
[0181] Furthermore, in order to improve the model's ability to capture effective features, an attention mechanism can be added to the variational autoencoder so that the variational autoencoder can focus on specific important parts of the input data during encoding and decoding. Specifically, when compressing network data into encoded data, the attention mechanism can help the encoder part of the variational autoencoder determine which features or data parts are more important for subsequent detection and assign them higher weights.
[0182] In some embodiments, there are multiple types of network data, see Fig.11 , Fig.11 yes Figure 2 Another flowchart diagram further included in step S101. Step 101 may also include steps S1001 to S1002:
[0183] Step S1001, performing preprocessing operations on different types of network data respectively to obtain a plurality of network data of the same length after preprocessing;
[0184] Step S1002: input each preprocessed network data into a preset attack detection model to obtain a corresponding attack evaluation value.
[0185] In the above steps S1001 to S1002, the sources and types of network data can be varied. For example, they may come from network traffic data, system logs, behavior records, etc. These raw data often have different formats and lengths and cannot be directly input into machine learning or deep learning models for analysis. Therefore, preprocessing operations are required to unify the data format and length for subsequent analysis and model training.
[0186] Specifically, during the preprocessing process, for data of different lengths, a specific value (such as 0, a space, or an average value) is used to fill the data to ensure that all data have the same length. In some embodiments, the network data includes description information and attack payload information; step 1001 may include:
[0187] The description information and attack payload information of different types of network data are filled and concatenated respectively to obtain multiple network data of the same length after preprocessing.
[0188] Furthermore, when the network data includes traffic data and system logs, both the traffic data and the system logs may include description information and attack payload information. The description information describes the basic situation of the network data. By obtaining the attack payload information, it can be used as a feature for obvious attack detection, so as to improve the accuracy of subsequent model classification. Among them, the description information of the traffic data includes information such as timestamp, source IP, source port number, destination IP, destination port number, protocol, connection duration, etc., and the description information of the system log includes information such as timestamp, thread ID, access object, description, etc. During the preprocessing process, the attack payload and description information are padded with space characters to a uniform length, and multiple network data of the same length after preprocessing are obtained, which is convenient for use as the input of the encoder.
[0189] In addition, there may be other processing operations in the preprocessing process, such as removing noise, outliers and duplicates in the data, ensuring the accuracy and reliability of the data, etc. Alternatively, the preprocessing process also needs to convert the text description into a numerical vector, or convert the time series data into a vector or matrix of fixed length, and standardize / normalize the data, scaling the data to the same scale or range, so that the model can better learn the inherent laws of the data.
[0190] In summary, please refer to Fig.12 and Fig.13 , Fig.12 is a complete flow chart of the attack detection method provided by the embodiment of the present disclosure, Fig.13 1 is a process diagram of an attack detection method provided by an embodiment of the present disclosure. During the attack detection process, a network data stream can be obtained through an input device to obtain multiple network data. The attack detection method can be divided into two stages, the first stage is a data representation stage, and the second stage is an attack detection stage.
[0191] In the first stage, after converting the network data from text to vectors, preprocessing operations are performed on different types of network data, and the description information and attack load information under different types of network data are filled and spliced respectively, so as to obtain multiple network data of the same length after preprocessing. Then, it can be input into the trained variational autoencoder for compression encoding, and the obtained feature matrix is used as the encoded data, and the encoded data is input into the attack detection model for processing. In the current incremental step, the current preset attack detection model can be obtained by training and fine-tuning based on the stored historical network data, specifically including dividing the historical network data into an initial set and a residual set, training the initialized attack detection model based on the initial set, adjusting the parameters and structure of the model, and fine-tuning the parameters of the trained attack detection model based on the residual set, so as to obtain the attack detection model that can be applied in the current incremental step.
[0192] In the second stage, the attack detection model determines the attack evaluation value of each network data to be detected, and inputs the attack evaluation value into the three decision models for comparison and judgment. When the size of the attack evaluation value is within the preset boundary range, it means that the relevant network data is difficult to accurately determine the attack behavior or normal behavior, and a delayed decision is required. Therefore, the relevant network data is used as the first network data and added to the boundary set. Otherwise, the network data that can accurately determine the attack behavior or normal behavior is used as the second network data and added to the remaining set, and the decision is accepted. Then, based on the second network data in the current remaining set, the attack detection model in the current incremental step is fine-tuned so as to incrementally learn the model. In this way, as the amount of data increases, the model can be fine-tuned based on the data that accurately determines the attack behavior or normal behavior in each incremental step to obtain a fine-tuned attack detection model, so that the model can adapt to the situation where the amount of network data is increasing. Subsequently, after the next incremental step arrives, since the model has been incrementally learned, the first network data in the boundary set is input into the fine-tuned attack detection model, and the boundary data can be re-detected, and finally an accurate attack detection result is obtained, thereby improving the efficiency of attack detection and improving network security.
[0193] In addition, expert knowledge can be integrated to evaluate boundary behaviors that are still difficult to judge after multiple iterations. Specifically, expert knowledge can be used for judgment, or the first network data characterized as boundary behavior can be input into the expert model for processing, so as to obtain accurate attack detection results and judge whether it is an attack behavior or a normal behavior, further improving the accuracy of attack detection.
[0194] See also Fig.14 The embodiment of the present disclosure further provides an attack detection device, which can implement the above attack detection method. The attack detection device includes:
[0195] The first detection unit 1401 is used to obtain multiple network data to be detected in the current incremental step, and input each network data into a preset attack detection model to obtain a corresponding attack evaluation value;
[0196] The data partitioning unit 1402 is used to, when the attack evaluation value is within a preset boundary range, take the relevant network data as first network data and add it to the boundary set; otherwise, take the relevant network data as second network data and add it to the remaining set;
[0197] An incremental fine-tuning unit 1403 is used to fine-tune the attack detection model in the current incremental step based on the second network data in the current remaining set to obtain a fine-tuned attack detection model;
[0198] The second detection unit 1404 is used to input the first network data in the boundary set into the fine-tuned attack detection model after the next incremental step arrives, obtain a new attack evaluation value, and determine the attack detection result according to the new attack evaluation value.
[0199] In summary, the attack detection device executes the attack detection method. In the current incremental step, the attack evaluation value of each network data to be detected is first determined by the preset attack detection model. When the size of the attack evaluation value is within the preset boundary range, it means that the relevant network data is difficult to accurately determine the attack behavior or normal behavior. Therefore, the relevant network data is used as the first network data and added to the boundary set. Otherwise, the network data that can accurately determine the attack behavior or normal behavior is used as the second network data and added to the remaining set. Then, the attack detection model in the current incremental step is fine-tuned based on the second network data in the current remaining set, so as to perform incremental learning on the model. In this way, as the amount of data increases, the model can be fine-tuned based on the data that accurately determines the attack behavior or normal behavior in each incremental step to obtain a fine-tuned attack detection model, so that the model adapts to the situation where the amount of network data is increasing. Subsequently, after the next incremental step arrives, since the model has been incrementally learned, the first network data in the boundary set is input into the fine-tuned attack detection model, and the boundary data can be re-detected, and finally an accurate attack detection result is obtained, thereby improving the efficiency of attack detection and improving network security.
[0200] The specific implementation of the attack detection device is basically the same as the specific implementation of the above attack detection method, and will not be repeated here. On the premise of meeting the requirements of the embodiment of the present disclosure, the attack detection device can also be provided with other functional modules to implement the attack detection method in the above embodiment.
[0201] The embodiment of the present disclosure also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above attack detection method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0202] See also Fig.15 , Fig.15 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:
[0203] The processor 1501 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present disclosure;
[0204] The memory 1502 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1502 can store operating devices and other applications. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 1502, and the processor 1501 is used to call and execute the attack detection method of the embodiment of the present disclosure;
[0205] Input / output interface 1503, used to implement information input and output;
[0206] Communication interface 1504, used to realize communication interaction between the device and other devices, which can be realized through wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);
[0207] A bus 1505 that transmits information between various components of the device (e.g., the processor 1501, the memory 1502, the input / output interface 1503, and the communication interface 1504);
[0208] The processor 1501 , the memory 1502 , the input / output interface 1503 and the communication interface 1504 are connected to each other in communication within the device via the bus 1505 .
[0209] The embodiment of the present disclosure further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned attack detection method is implemented.
[0210] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0211] The embodiments described in the embodiments of the present disclosure are intended to more clearly illustrate the technical solutions of the embodiments of the present disclosure and do not constitute a limitation on the technical solutions provided by the embodiments of the present disclosure. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of the present disclosure are also applicable to similar technical problems.
[0212] Those skilled in the art will appreciate that the technical solutions shown in the figures do not limit the embodiments of the present disclosure and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0213] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0214] Those skilled in the art will appreciate that all or some of the steps, devices, and functional modules / units in the above disclosed methods may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0215] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, device, product or equipment that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0216] It should be understood that in the present disclosure, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0217] In the several embodiments provided in the present disclosure, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0218] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0219] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0220] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method of each embodiment of the present disclosure. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0221] The preferred embodiments of the present disclosure are described above with reference to the accompanying drawings, but the scope of the rights of the present disclosure is not limited thereto. Any modification, equivalent substitution and improvement made by those skilled in the art without departing from the scope and essence of the present disclosure should be within the scope of the rights of the present disclosure.
Claims
1. An attack detection method, characterized in that: include: In the current incremental step, a plurality of network data to be detected are obtained, and each of the network data is respectively input into a preset attack detection model to obtain a corresponding attack evaluation value; When the attack evaluation value is within a preset boundary range, the relevant network data is taken as first network data and added to the boundary set; otherwise, the relevant network data is taken as second network data and added to the remaining set; Fine-tune the attack detection model in the current incremental step based on the second network data in the current remaining set to obtain a fine-tuned attack detection model; After the next incremental step arrives, inputting the first network data in the boundary set into the fine-tuned attack detection model to obtain a new attack evaluation value, and determining the attack detection result according to the new attack evaluation value; When the attack evaluation value is within a preset boundary range, the relevant network data is used as first network data and added to the boundary set; otherwise, the relevant network data is used as second network data and added to the remaining set, including: When the attack evaluation value is less than a preset first boundary threshold and greater than a preset second boundary threshold, the relevant network data is taken as first network data and added to the boundary set; When the attack evaluation value is greater than or equal to the first boundary threshold, taking the relevant network data as second network data and adding it to the remaining set; When the attack evaluation value is less than or equal to the second boundary threshold, taking the relevant network data as second network data and adding it to the remaining set; The attack detection result includes normal behavior, boundary behavior and attack behavior; the attack detection method also includes: Acquire multiple groups of initial hyperparameters representing different ranges of the attack detection results, and determine an initial first boundary threshold and an initial second boundary threshold respectively according to the multiple groups of initial hyperparameters; Based on the initial first boundary threshold and the initial second boundary threshold, determining a normal probability of the sample network data being classified into the normal behavior and an attack probability of the sample network data being classified into the attack behavior; Determine a decision cost representing different ranges of the attack detection results based on a weighted sum of the normal probability and the attack probability and each group of the initial hyperparameters; Adjust the multiple groups of the initial hyperparameters until the decision cost meets the preset requirements, and determine the adjusted first boundary threshold and the adjusted second boundary threshold based on the adjusted hyperparameters.
2. The attack detection method according to claim 1, characterized in that: Before acquiring the plurality of network data to be detected, the attack detection method further includes: Get multiple historical network data stored in the preset memory; An initial attack detection model is trained based on a plurality of historical network data, and the trained attack detection model is used as a preset attack detection model in the current incremental step.
3. The attack detection method according to claim 2, characterized in that: The initial attack detection model is trained based on the network data of multiple histories, and the trained attack detection model is used as the preset attack detection model in the current incremental step, including: According to the storage time sequence of the plurality of historical network data, the plurality of historical network data are divided into an initial set and a remaining set; Training an initial attack detection model based on the plurality of historical network data in the initial set to obtain a trained attack detection model; The trained attack detection model is fine-tuned based on the multiple historical network data in the remaining set, and the fine-tuned attack detection model is used as the preset attack detection model in the current incremental step.
4. The attack detection method according to claim 3, characterized in that: After taking the relevant network data as the second network data and adding it to the remaining set, the attack detection method further includes: When the sizes of the initial set and the remaining set reach the preset memory, deleting the initial set; According to the storage time sequence of the plurality of network data in the residual set, part of the network data in the residual set is transferred to the new initial set to obtain an updated initial set, and the residual set after the transfer is used as the updated residual set.
5. The attack detection method according to claim 1, characterized in that: The obtaining of a plurality of groups of initial hyperparameters representing different ranges of the attack detection results, and determining an initial first boundary threshold and an initial second boundary threshold respectively according to the plurality of groups of initial hyperparameters, comprises: Obtaining an initial first hyperparameter representing a normal behavior range, an initial second hyperparameter representing a boundary behavior range, and an initial third hyperparameter representing an attack behavior range; An initial first boundary threshold is determined based on the initial first hyperparameter and the initial second hyperparameter, and an initial second boundary threshold is determined based on the initial second hyperparameter and the initial third hyperparameter.
6. The attack detection method according to claim 1, characterized in that: The step of inputting each of the network data into a preset attack detection model to obtain a corresponding attack evaluation value includes: Compress and encode each of the network data to obtain corresponding encoded data; Each of the coded data is input into a preset attack detection model to obtain a corresponding attack evaluation value.
7. The attack detection method according to claim 6, characterized in that: The network data is compressed and encoded by a trained variational autoencoder, and the variational autoencoder is trained by the following steps: Get multiple sample network data; Inputting each of the sample network data into the encoder part of the initial variational autoencoder respectively to obtain corresponding sample encoded data; Inputting each of the sample encoded data into the decoder part of the initial variational autoencoder respectively to obtain corresponding sample decoded data; A target loss value is determined according to the sample decoded data and the corresponding sample network data, and the initial variational autoencoder is trained based on the target loss value to obtain a trained variational autoencoder.
8. The attack detection method according to claim 1, characterized in that: There are multiple types of network data, and each of the network data is input into a preset attack detection model to obtain a corresponding attack evaluation value, including: Preprocessing the network data of different types respectively to obtain a plurality of network data of the same length after preprocessing; The preprocessed network data are respectively input into a preset attack detection model to obtain a corresponding attack evaluation value.
9. The attack detection method according to claim 8, characterized in that: The network data includes description information and attack payload information; The preprocessing operation is performed on the network data of different types to obtain a plurality of network data of the same length after preprocessing, including: The description information and the attack payload information under the different types of the network data are filled and spliced respectively to obtain a plurality of network data of the same length after preprocessing.
10. An attack detection device, characterized in that: include: A first detection unit, used for acquiring a plurality of network data to be detected in a current incremental step, and inputting each of the network data into a preset attack detection model to obtain a corresponding attack evaluation value; A data partitioning unit, configured to, when the attack evaluation value is within a preset boundary range, treat the relevant network data as first network data and add it to a boundary set; otherwise, treat the relevant network data as second network data and add it to a remaining set; An incremental fine-tuning unit, configured to fine-tune the attack detection model in the current incremental step based on the second network data in the current remaining set to obtain a fine-tuned attack detection model; A second detection unit is used to input the first network data in the boundary set into the fine-tuned attack detection model after the next incremental step arrives to obtain a new attack evaluation value, and determine the attack detection result according to the new attack evaluation value; When the attack evaluation value is within a preset boundary range, the relevant network data is used as first network data and added to the boundary set; otherwise, the relevant network data is used as second network data and added to the remaining set, including: When the attack evaluation value is less than a preset first boundary threshold and greater than a preset second boundary threshold, the relevant network data is taken as first network data and added to the boundary set; When the attack evaluation value is greater than or equal to the first boundary threshold, taking the relevant network data as second network data and adding it to the remaining set; When the attack evaluation value is less than or equal to the second boundary threshold, taking the relevant network data as second network data and adding it to the remaining set; The attack detection result includes normal behavior, boundary behavior and attack behavior; the data partitioning unit is also used for: Acquire multiple groups of initial hyperparameters representing different ranges of the attack detection results, and determine an initial first boundary threshold and an initial second boundary threshold respectively according to the multiple groups of initial hyperparameters; Based on the initial first boundary threshold and the initial second boundary threshold, determining a normal probability of the sample network data being classified into the normal behavior and an attack probability of the sample network data being classified into the attack behavior; Determine a decision cost representing different ranges of the attack detection results based on a weighted sum of the normal probability and the attack probability and each group of the initial hyperparameters; Adjust the multiple groups of the initial hyperparameters until the decision cost meets the preset requirements, and determine the adjusted first boundary threshold and the adjusted second boundary threshold based on the adjusted hyperparameters.
11. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the attack detection method according to any one of claims 1 to 9 when executing the computer program.
12. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the attack detection method according to any one of claims 1 to 9 is implemented.
