A method and device for processing data imbalance problem in network attack detection

The generation of uneven attack type data through data preprocessing and conditional diffusion models solves the problem of insufficient detection capabilities of network attacks caused by data imbalance in the prior art, and improves the accuracy and robustness of detection.

CN118590329BActive Publication Date: 2024-12-03CHANGCHUN UNIV OF SCI & TECH
View PDF 14 Cites 0 Cited by

Patent Information

Application Number
CN202411073725.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-07
Publication Date
2024-12-03
Estimated Expiration
2044-08-07

AI Technical Summary

Technical Problem

Due to data imbalance, existing cyberattack detection technologies have high recognition rates for common attacks but insufficient detection capabilities for rare attacks.

Method used

Through data preprocessing and conditional diffusion models, attack type data with uneven properties are generated, which is used to train the network attack detection model to improve the accuracy and robustness of detection.

Benefits of technology

It significantly improves the accuracy and robustness of cyber attack detection, enhances the recognition ability of a few types of attacks, reduces the overfitting problem, and improves the model's adaptability to new attack patterns.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118590329B_ABST
    Figure CN118590329B_ABST
Patent Text Reader

Abstract

The present invention provides a method and device for solving the problem of data imbalance in network attack detection, which relates to the field of data processing and can solve the problem of insufficient detection capability of rare attacks. The method comprises: preprocessing the attack information to obtain different types of training data for feature extraction and model training, wherein the attack information includes information of different types of network intrusion attack behaviors with imbalanced features; inputting different types of training data into the conditional diffusion model training module to dilute statistical attributes and reconstruct distribution information processing to obtain a network conditional diffusion NCDiff model; inputting random noise data combined with attack type category labels into the NCDiff model to obtain attack type data with imbalanced properties; performing network attack detection based on the attack type data and the original training data to determine whether there is a network intrusion attack behavior. The accuracy of network attack detection is significantly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to data processing, and in particular to a method and device for processing data imbalance problem in network attack detection. Background Art

[0002] Computer network security refers to the protection of the hardware, software and data in the computer network system to ensure the continuous, reliable and normal operation of the computer network system.

[0003] In order to prevent computer networks from being damaged, altered, or leaked, intrusion detection is usually performed in multiple branches of a computer network system. The intrusion detection technology of the prior art processes through an attack detection model to determine whether there is a malicious attack.

[0004] However, in actual network traffic, legitimate communication data far outweighs malicious attack data. This imbalance leads to deviations in the training of attack detection models, resulting in existing technologies having a high recognition rate for common attacks but insufficient detection capabilities for rare attacks. Summary of the invention

[0005] In view of the problems existing in the prior art, the present invention provides a method and device for processing the data imbalance problem in network attack detection.

[0006] The present invention is achieved through the following technical solutions:

[0007] The present invention provides a method for processing the data imbalance problem in network attack detection, comprising:

[0008] Preprocessing the acquired attack information to obtain different types of training data for feature extraction and model training, wherein the attack information includes information of different types of network intrusion attack behaviors with unbalanced characteristics, and the preprocessing includes any one of the following or a combination thereof: data cleaning, encoding and conversion, and standardization, and the different types of training data include: normalized attack information data and normalized category label data;

[0009] Inputting the different types of training data into the conditional diffusion model training module to dilute the statistical attributes and reconstruct the distribution information to obtain a network conditional diffusion NCDiff model, wherein the NCDiff model includes a model for sampling different types of attack behavior data by modifying the conditional input;

[0010] Inputting random noise data combined with attack type category labels into the NCDiff model to obtain attack type data with unbalanced properties;

[0011] Network attack detection is performed based on the attack type data with unbalanced properties and the original training data to determine whether there is a network intrusion attack behavior.

[0012] Furthermore, the acquired attack information is preprocessed to obtain different types of training data for feature extraction and model training, including:

[0013] The attack information selected from the database Perform data cleaning to obtain data sets of various dimensions of attack information ,in, , , After cleaning Group data collection, After data cleaning, Group attack data Dimensional data features;

[0014] Through label encoding, the attack type category Label encoding is used for digital mode conversion to obtain the attack type category label set , where , It is the first Dimension category label data;

[0015] By one-hot encoding, the non-numeric features in the attack information data set of each dimension are converted into one-hot vectors to obtain the attack information one-hot encoding set ,in, , is the first Group attack information is collectively referred to as is the one-hot encoded Group attack data Dimensional data features;

[0016] The attack information one-hot encoding set is standardized to obtain the normalized attack information data. , where , After normalization, Group attack data Dimensional data features;

[0017] The attack type category label set is standardized to obtain the normalized category label data. , where , After normalization Dimension category label data.

[0018] Furthermore, the different types of training data are input into the conditional diffusion model training module to dilute the statistical attributes and reconstruct the distribution information to obtain the network conditional diffusion NCDiff model, including:

[0019] The normalized attack information data and the corresponding normalized category label data are connected to obtain a training data set with conditional guidance. ,in, Will be used as model input For the Dimensional input data, It is The first dimension of the input data dimensional data features, It is Dimension category label data;

[0020] The training data set The data is input into the conditional diffusion model module for processing to obtain the network conditional diffusion NCDiff model.

[0021] Furthermore, the random noise data combined with the attack type category label is input into the NCDiff model to obtain the attack type data with unbalanced properties, including:

[0022] Create the number to be generated A random noise data set with attack type category labels ,in, , It is a general term for random noise data combined with attack type category labels. Combined with the attack type category label dimensional random noise data, Combined with the attack type category label dimensional random noise data dimensional data features, Category label data for target attack types;

[0023] The random noise data set combined with the attack type category label Input the NCDiff model for reverse diffusion and obtain the generated quantity as There is an imbalance in the nature of the attack type data .

[0024] Furthermore, the random noise data set combined with the attack type category label Input the NCDiff model for reverse diffusion and obtain the generated quantity as There is an imbalance in the nature of the attack type data ,include:

[0025] Combine each dimension of the normalized attack information data with the corresponding normalized category label data along the preset dimension to obtain a training data set with conditional guidance after adjusting the dimension and shape. ;

[0026] The training data set Input into the conditional diffusion model module to obtain the network conditional diffusion NCDiff model, including:

[0027] The conditional diffusion model module is used to dilute the training data set by continuously adding noise in the forward phase The statistical characteristics of the conditional diffusion model are transformed into noise, and then the noise is restored by a neural network in the reverse stage. The conditional diffusion model module includes at least an encoding path, a bottleneck layer, a decoding path and a final output layer;

[0028] For the training data set The encoding path for extracting the features of each maintenance layer includes multiple groups of downsampling layers, and the downsampling layers include multiple groups of convolutional layers, batch normalization layers, activation functions, and maximum pooling layers;

[0029] The bottleneck layer for feature compression and feature dimension conversion includes multiple groups of convolutional layers and activation functions;

[0030] The decoding path for restoring the image includes multiple groups of upsampling layers, and the upsampling layers include multiple groups of fractional-strided convolutions, batch normalization layers, and activation functions;

[0031] The final output layer for converting the image feature dimension and outputting the data format in accordance with the requirements includes multiple groups of convolutional layers.

[0032] The embodiment of the present invention further provides a device for processing data imbalance problem in network attack detection, comprising:

[0033] A preprocessing module, used to preprocess the acquired attack information to obtain different types of training data for feature extraction and model training, wherein the attack information includes information of different types of network intrusion attack behaviors with unbalanced characteristics, and the preprocessing includes any one of the following or a combination thereof: data cleaning, encoding and conversion, and standardization, and the different types of training data include: normalized attack information data and normalized category label data;

[0034] A conditional diffusion model training module is used to input the different types of training data into the conditional diffusion model training module to dilute the statistical attributes and reconstruct the distribution information to obtain a network conditional diffusion NCDiff model, wherein the NCDiff model includes a model for sampling different types of attack behavior data by modifying the conditional input;

[0035] A sample generation module, used to input random noise data combined with attack type category labels into the NCDiff model to obtain attack type data with unbalanced properties;

[0036] The determination module is used to perform network attack detection based on the attack type data with unbalanced properties and the original training data to determine whether there is a network intrusion attack behavior.

[0037] Furthermore, the preprocessing module includes:

[0038] A data cleaning module is used to select the attack information from the database. Perform data cleaning to obtain data sets of various dimensions of attack information ,in, , , After cleaning Group data collection, After data cleaning, Group attack data Dimensional data features;

[0039] The encoding and conversion module is used to classify attack types through label encoding. Label encoding is used for digital mode conversion to obtain the attack type category label set , where , After digital mode conversion dimensional category label data; and converting the non-numeric features in the attack information data set of each dimension into a one-hot vector by one-hot encoding to obtain a one-hot encoding set of attack information ,in, , is the first Group attack information is collectively referred to as is the one-hot encoded Group attack data Dimensional data features;

[0040] The normalization and standardization module is used to perform normalization processing on the attack information one-hot encoding set to obtain the normalized attack information data. , where , After normalization, Group attack data dimensional data features; and normalizing the attack type category label set to obtain the normalized category label data , where , After normalization Dimension category label data.

[0041] Furthermore, the conditional diffusion model training module includes:

[0042] The feature label connection module is used to connect the normalized attack information data and the corresponding normalized category label data to obtain a training data set with conditional guidance. ,in, Will be used as model input For the Dimensional input data, It is The first dimension of the input data dimensional data features, It is Dimension category label data;

[0043] Conditional diffusion model module, used to set the training data Processing is performed to obtain the network conditional diffusion NCDiff model.

[0044] Furthermore, the sample generation module includes:

[0045] The random noise condition generation module is used to create the number of A random noise data set with attack type category labels ,in, , It is a general term for random noise data combined with attack type category labels. Combined with the attack type category label dimensional random noise data, Combined with the attack type category label dimensional random noise data dimensional data features, Category label data for target attack types;

[0046] NCDiff model, used for reverse diffusion of random noise data sets combined with attack type category labels , and the generated quantity is There is an imbalance in the nature of the attack type data .

[0047] Furthermore, the NCDiff model is specifically used to combine each dimension of the normalized attack information data with the corresponding normalized category label data along a preset dimension to obtain a training data set with conditional guidance after adjusting the dimension and shape. ;

[0048] The conditional diffusion model module is used to dilute the training data set by continuously adding noise in the forward phase The statistical characteristics are directly converted into noise, and then the noise is restored by the neural network in the reverse stage. The conditional diffusion model module at least includes an encoding path, a bottleneck layer, a decoding path and a final output layer.

[0049] For the training data set The encoding path for extracting the features of each maintenance layer includes: multiple groups of downsampling layers, the downsampling layers include multiple groups of convolutional layers, batch normalization layers, activation functions, and maximum pooling layers;

[0050] The bottleneck layer used for feature compression and feature dimension conversion includes: multiple groups of convolutional layers and activation functions;

[0051] The decoding path for restoring an image comprises: a plurality of groups of upsampling layers, wherein the upsampling layers comprise a plurality of groups of fractional-stride convolutions, batch normalization layers, and activation functions;

[0052] The final output layer used for converting the image feature dimension and outputting the data format that meets the requirements includes: multiple groups of convolutional layers.

[0053] Compared with the prior art, the present invention has the following beneficial technical effects:

[0054] The present invention provides a method and device for solving the problem of data imbalance in network attack detection. The method comprises: preprocessing the acquired attack information to obtain different types of training data for feature extraction and model training, wherein the attack information includes information of different types of network intrusion attack behaviors with imbalanced features; inputting different types of training data into the conditional diffusion model training module to dilute statistical attributes and reconstruct distribution information to obtain a network conditional diffusion NCDiff model; inputting random noise data combined with attack type category labels into the NCDiff model to obtain attack type data with imbalanced properties; performing network attack detection based on the attack type data with imbalanced properties and the original training data to determine whether there is network intrusion attack behavior. The accuracy and robustness of network attack detection are significantly improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 It is a flow chart of a method for processing data imbalance problem in network attack detection according to an embodiment of the present invention;

[0056] Figure 2 This is the structural intention of a device for solving data imbalance problem in network attack detection in one embodiment of the present invention;

[0057] Figure 3 This is the structural intention of a device for solving data imbalance problem in network attack detection in another embodiment of the present invention;

[0058] Figure 4 It is a schematic diagram of the structure of a conditional diffusion model module of a device for solving data imbalance problem in network attack detection according to an embodiment of the present invention. DETAILED DESCRIPTION

[0059] The present invention is further described in detail below in conjunction with specific embodiments, which are intended to explain the present invention rather than to limit it.

[0060] The device for processing data imbalance in network attack detection provided by the embodiment of the present invention is applicable to the case where, in actual network traffic, legitimate communication data far outweighs malicious attack data. This imbalance leads to deviations in attack detection model training, causing the existing model to tend to ignore those few but critical malicious attack scenarios. Furthermore, the device for processing data imbalance in network attack detection provided by the embodiment of the present invention can be set inside the network attack detector or outside the network attack detector. When set outside the network attack detector, it can be an independently set device or a device set together with the network attack detector, which is not limited here.

[0061] Figure 1 FIG. 1 is a flow chart of a method for processing data imbalance problem in network attack detection according to an embodiment of the present invention; Figure 1 As shown, the method for processing the data imbalance problem in the network attack detection includes the following steps:

[0062] Step 101: pre-process the acquired attack information to obtain different types of training data for feature extraction and model training.

[0063] The attack information in this embodiment includes information of different types of network intrusion attack behaviors with unbalanced characteristics, and the preprocessing includes any one of the following or a combination thereof: data cleaning, encoding and conversion, and standardization. The different types of training data include: normalized attack information data and normalized category label data;

[0064] Specifically, step 101 includes:

[0065] S1001, the attack information selected from the database Perform data cleaning, which mainly checks and removes possible duplicate or erroneous data to obtain data sets of various dimensions of attack information ,in, , , After cleaning Group data collection, After data cleaning, Group attack data Dimensional data features;

[0066] For example, in this example, pd.read_csv() is used to read the file and the category label column is excluded by setting it, df.drop_duplicates() is used to delete duplicate data rows, pd.to_numeric() is used to check whether there are abnormal values ​​in the data (such as non-numeric values ​​in numeric columns), and the coerce setting of to_numeric() is used to set the values ​​that cannot be converted to numbers to NaN, and then df.dropna() is used to remove these rows, and finally df.to_csv() is used to save the cleaned data.

[0067] S1002, through label encoding, attack type classification Label encoding is used for digital mode conversion to obtain the attack type category label set , where It is a collective name for the converted category labels, which is also a data set , After digital mode conversion Dimension category label data;

[0068] S1003: Convert the non-digital features in the attack information data set of each dimension into a one-hot vector by one-hot encoding to obtain a one-hot encoding set of the attack information. ,in, , is the first Group attack information is collectively referred to as is the one-hot encoded Group attack data Dimensional data features;

[0069] In this embodiment, the present invention uses label_encoder.fit_transform(df['attack_type']) to label encode the attack type category, uses ct=ColumnTransformer([('one_hot_encoder',OneHotEncoder(),['protocol_type'])],remainder='passthrough') (here protocol_type is a non-numeric feature column as an example), df_encoded=ct.fit_transform(df) to one-hot encode the non-numeric feature column, and finally converts the one-hot encoded result back to DataFrame: df_encoded=pd.DataFrame(df_encoded,columns=ct.get_feature_names_out()), where it is assumed that only the protocol_type column needs to be one-hot encoded, and the other columns remain as they are. If there are other columns that need to be processed, the same applies. The above df refers to a DataFrame object, which is a core data structure of the pandas library in the Python programming language.

[0070] S1004: Standardize the attack information one-hot encoding set to obtain the normalized attack information data. , where After normalization A collective name for group attack information data, which is also a data set. , After normalization, Group attack data Dimensional data features;

[0071] S1005: Standardize the attack type category label set to obtain the normalized category label data. , where It is a general term for the normalized attack type category labels, which is also a data set. , After normalization Dimension category label data.

[0072] In this embodiment, the present invention uses MinMaxScaler as a normalizer to normalize the data to the range of [0, 1] and adjust each feature value to the same scale. This is generally helpful to improve the performance and stability of machine learning algorithms, especially for algorithms that rely on distance calculations.

[0073] In this embodiment, as an optimization algorithm for network intrusion detection, it is necessary to be able to target all unbalanced data, so the categories whose data quantity corresponding to all attack categories in the data set accounts for less than 0.1% are selected, namely guess_passwd, buffer_overflow, warezmaster, land, imap, rootkit, loadmodule, ftp_write, multihop, phf, perl and spy. The proportion of each type of data varies greatly, and the number of unbalanced categories accounts for 52.17% of the total number of categories, more than half, and the data volume only accounts for 1.39% of the total data volume, which is very easy to mislead the classifier, resulting in missed detection and inability to accurately identify. At the same time, due to the small proportion, even if abnormal behavior is identified, the recognition rate will be too low and it is difficult to attract attention.

[0074] The preprocessing stage of the present invention can ensure the maximum utility of the data set in model training and improve the accuracy and generalization ability of the model through thorough preprocessing. The systematic data preprocessing process is helpful for long-term maintenance and updating of the model, especially when the data format or data source changes, the preprocessing process can ensure the consistency and compatibility of the data. Data cleaning improves the accuracy and availability of data by removing duplicate data and correcting erroneous or missing values, ensuring that the data is accurate and complete when training the model. Removing unnecessary data can reduce storage and computing requirements and increase processing speed, especially in a big data environment. Encoding and conversion convert these non-numeric data such as text or category labels that cannot be directly processed into a format that can be directly processed by machine learning algorithms. The non-order relationship of the category data is maintained through unique hot encoding, ensuring that the model will not interpret the data incorrectly, and it can be clearly seen which features have an impact on the prediction results of the model, which is helpful for debugging and improving the model. The normalized data has a unified scale, avoiding the disproportionate impact of high-scale features on the model results. When using optimization algorithms such as gradient descent, the unified data scale helps to converge to the optimal solution faster, especially for those algorithms that are sensitive to data scale.

[0075] Step 102: Input the different types of training data into the conditional diffusion model training module to dilute the statistical attributes and reconstruct the distribution information to obtain the network conditional diffusion NCDiff model.

[0076] The NCDiff model in this embodiment includes a model for sampling different types of attack behavior data by modifying conditional input;

[0077] This step specifically includes:

[0078] S2001: Connect the normalized attack information data and the corresponding normalized category label data to obtain a training data set with conditional guidance. ,in, Will be used as model input For the Dimensional input data, It is The first dimension of the input data dimensional data features, It is Dimension category label data;

[0079] Specifically, the attack data is divided into various dimensions. And the corresponding category label data The input is combined into the feature label connection module 201 to obtain a training data set with conditional guidance function. ;

[0080] In this embodiment, the present invention uses a combination of a neural network Reshape layer and a Concatenate layer to connect all dimensional features of the attack behavior information and the category label information along the desired dimension, effectively integrating information from different parts and increasing the guidance and flexibility of the input data;

[0081] It can be understood that individual features may not be sufficient to fully express all relevant information of the data. By directly splicing the category label with the feature through the feature label connection module 201, the model can learn a more direct association between the feature and the specific category during the training process. This method is particularly suitable for conditional generation models, in which the output depends not only on the input features, but also on specific conditions or categories. In the field of network security, especially intrusion detection, the model needs to generate or reconstruct attack samples, which must be not only true in terms of features, but also accurate in terms of attack categories. By combining category information with feature data, the accuracy of the generated data in terms of category can be ensured, and the model's ability to predict and identify new and unseen attack samples can be enhanced. The model can better learn the data behavior under specific attack types, so that it has better response and processing capabilities for different types of attacks in practical applications. First, the comprehensive use of feature and label information can improve the generalization ability and accuracy of the model, making the model more aware of the differences between different categories when learning; second, by training the model to understand and generate data with specific labels, the output of the model can be more flexibly adjusted during actual deployment to adapt to different security requirements and application scenarios, thereby enhancing the practicality and adaptability of the model; finally, the systematic integration of features and labels not only improves the training efficiency of the model, but also simplifies the subsequent model maintenance and upgrades, because the input and output of the model have been clearly specified in a certain format and under certain conditions, thereby improving the efficiency of the data science workflow.

[0082] In the network intrusion detection project, the significance of using the conditional diffusion model module 202 lies in its powerful data generation capability and adaptability. By generating missing attack type samples, this model helps solve the learning bias problem caused by traditional data imbalance, so that the model can more comprehensively and accurately identify and respond to various potential security threats in practical applications. In addition, the conditional diffusion model module 202 maintains a high degree of flexibility and controllability while generating data, providing an effective data enhancement and model training method for the security field.

[0083] S2002: The training data set The data is input into the conditional diffusion model module for processing to obtain the network conditional diffusion NCDiff model.

[0084] In this embodiment, the conditional diffusion model module 202 of the present invention is built based on the UNet structure. Its symmetrical structure helps the model to maintain context information during the encoding and decoding stages, and includes four parts: encoding path, bottleneck layer, decoding path and final output layer. The encoding path includes multiple groups of downsampling layers to gradually extract data features; the bottleneck layer includes multiple groups of convolutional layers and activation functions for feature compression and information aggregation, while performing feature dimension conversion and improving model efficiency; the decoding path includes multiple groups of upsampling layers for gradually restoring images; the final output layer includes multiple groups of convolutional layers for image feature dimension conversion and outputting data formats that meet the requirements. The downsampling layer includes multiple groups of convolutional layers, batch normalization layers, activation functions, and maximum pooling layers; the upsampling layer includes multiple groups of fractional-step convolutions, batch normalization, and activation functions.

[0085] It can be understood that the conditional diffusion model module 202 can be used to artificially generate samples of rare attacks by its ability to generate data under a given attack type label. This method can effectively balance the data set and increase the number of samples in the minority class, thereby helping the model to better learn and identify these less common attack patterns; in the field of network security, attack methods continue to evolve and new attack methods continue to emerge. The conditional diffusion model module 202 can generate new and changing attack samples based on existing attack categories, which helps to train the model to identify unknown or mutated attack types, enhance the system's defense capabilities, and improve the robustness of the model; by generating high-quality attack data, the conditional diffusion model module 202 not only increases the sample size, but also maintains the diversity and complexity of the samples. This helps the model learn more complex data patterns and more detailed category differences, thereby improving the accuracy of detecting various attacks.

[0086] Step 103: inputting the random noise data combined with the attack type category label into the NCDiff model to obtain attack type data with unbalanced properties;

[0087] Specifically, this embodiment includes the following implementation steps:

[0088] S3001, create the quantity to be generated A random noise data set with attack type category labels ,in, , It is a general term for random noise data combined with attack type category labels. Combined with the attack type category label dimensional random noise data, Combined with the attack type category label dimensional random noise data dimensional data features, Category label data for target attack types;

[0089] In this example, the random noise condition generation module 301 of the present invention includes three parts: random noise generation, label requirements and data combination. The random noise generation includes the random() instruction, which ensures the shape of the input data by setting parameters of the same size as the input data, and ensures that the shape error will not cause unusability; the label requirement includes the tensor() instruction, which inputs the fixed attack behavior category label data to be generated through data input, and ensures that all the generated data belongs to the attack behavior type; the data combination includes the embedding() instruction, the view() instruction and the expand() instruction, the embedding() instruction converts the input condition information into a condition vector, the view() instruction resets the shape connected to the condition, and ensures that the shape does not affect the combination of the condition vector and the data vector, and the expand() instruction expands the size of the tensor without copying the data, thereby splicing the data vector and the condition vector.

[0090] It can be understood that the random noise condition generation module 301 is mainly responsible for generating initial random noise data and processing these data in combination with the specified conditions (i.e., the labels of the attack types) to provide a starting point for the reverse diffusion stage of the model. The random noise condition generation module 301 generates random noise of the same size as the input data through the random() instruction to ensure that these noise data have the basic shape and structure for subsequent processing. This generation randomness is the basis for creating diversified and uncertain outputs in the conditional diffusion model. The attack type label is converted into a tensor form using the tensor() instruction and combined with the noise data. This ensures that the generated data conforms to the specific type of attack behavior, so that the data output by the model not only increases in quantity, but also meets specific requirements in terms of quality and relevance. Through the embedding(), view() and expand() instructions, the random noise condition generation module 301 ensures the correct integration of conditional information and noise data. The embedding layer converts the label into a conditional vector, and the view and expand operations ensure that these vectors are compatible with the noise data in shape and correctly merged, providing the correct input format for the reverse diffusion process.

[0091] The NCDiff model back diffusion module 302 is responsible for gradually generating specific, high-quality target data from the initial random noise state. In a network intrusion detection system, this means generating specific attack behavior samples from the noise data combined with the conditional labels.

[0092] S3002: The random noise data set combined with the attack type category label Input the NCDiff model for reverse diffusion and obtain the generated quantity as There is an imbalance in the nature of the attack type data .

[0093] In this example, the use of the NCDiff model reverse diffusion module 302 of the present invention is concentrated in the conditional diffusion model module 202, the difference is that the NCDiff model reverse diffusion module 302 is a network parameter set based on the statistical characteristics of the input data after training.

[0094] It can be understood that the NCDiff model reverse diffusion module 302 allows the model to accurately control the data generation process at each step, by gradually reducing noise and introducing more structural information, so as to generate data with rich details and meeting the predetermined conditions. Since the process can generate samples close to real-world data, it can well enhance the authenticity of the data; it can generate new and unseen attack samples given a small number of instances, increase sample diversity, which is crucial to improve the robustness of the model in the face of unknown attacks; this method can effectively generate samples of these rare attack types, thereby balancing the training data set; by generating detailed and diverse attack samples, the NCDiff model reverse diffusion module 302 helps the network intrusion detection system better understand the characteristics of various attacks, improves the accuracy and generalization ability of the detection algorithm; more importantly, in the case where it may be difficult, costly or related to obtain real attack data, the NCDiff model provides a feasible alternative, allowing researchers and engineers to train and test their systems without actual attack data; and as the attack method continues to evolve, the reverse diffusion module can continuously generate data that conforms to the latest attack mode, support the continuous learning and adaptation of the intrusion detection system, and ensure that the system can effectively respond to emerging threats.

[0095] Step 104: Perform network attack detection based on the attack type data with unbalanced properties and the original training data to determine whether there is a network intrusion attack behavior.

[0096] The original training data in this embodiment refers to data information of attacks on the network collected within a period of time, wherein the original training data includes the attack information used for pre-processing in step 101 .

[0097] In this embodiment, first, the acquired attack information is preprocessed to obtain different types of training data for feature extraction and model training, the attack information includes information of different types of network intrusion attack behaviors with unbalanced features, the preprocessing includes any one of the following or a combination thereof: data cleaning, encoding and conversion, standardization, the different types of training data include: normalized attack information data and normalized category label data; then, the different types of training data are input into the conditional diffusion model training module for dilution statistical attributes and reconstruction distribution information processing, and a network conditional diffusion NCDiff model is obtained, the NCDiff model includes a model for sampling different types of attack behavior data by modifying conditional input; then, random noise data combined with attack type category labels is input into the NCDiff model to obtain attack type data with unbalanced properties; then, network attack detection is performed based on the attack type data with unbalanced properties and the original training data to determine whether there is a network intrusion attack behavior. The accuracy and robustness of network attack detection are significantly improved, and rare attack type samples in the actual environment are generated by the conditional diffusion model, thereby balancing the data set and enhancing the model's recognition ability for minority attacks. This method not only increases the number of samples of rare attacks, but also maintains the diversity and authenticity of the samples, avoiding the overfitting problem that may be introduced by simply repeating minority class samples; further, by using the NCDiff model, the training and generation of the model no longer rely on strict data distribution assumptions, which improves the adaptability and robustness of the model to actual data changes. At the same time, through an effective sample generation strategy, the complex data resampling technology and high computing resources required during the training process are reduced. The conditional diffusion model requires only a few adjustments when generating data, and can be effectively performed using existing hardware. The NCDiff model improves the model's adaptability and generalization to emerging attack patterns by learning and generating data containing various types of attack behaviors. This is because the model not only sees more diverse attack data, but also understands the core characteristics of attack behaviors by simulating variants of attacks.

[0098] Based on the above embodiment, the random noise data set combined with the attack type category label Input the NCDiff model for reverse diffusion and obtain the generated quantity as There is an imbalance in the nature of the attack type data ,include:

[0099] Combine each dimension of the normalized attack information data with the corresponding normalized category label data along the preset dimension to obtain a training data set with conditional guidance after adjusting the dimension and shape. ;

[0100] Input into the conditional diffusion model module to obtain the network conditional diffusion NCDiff model, including:

[0101] The conditional diffusion model module is used to dilute the training data set by continuously adding noise in the forward phase The statistical characteristics of the conditional diffusion model are transformed into noise, and then the noise is restored by a neural network in the reverse stage. The conditional diffusion model module includes at least an encoding path, a bottleneck layer, a decoding path and a final output layer;

[0102] For the training data set The encoding path for extracting the features of each maintenance layer includes multiple groups of downsampling layers, and the downsampling layers include multiple groups of convolutional layers, batch normalization layers, activation functions, and maximum pooling layers;

[0103] The bottleneck layer for feature compression and feature dimension conversion includes multiple groups of convolutional layers and activation functions;

[0104] The decoding path for restoring the image includes multiple groups of upsampling layers, and the upsampling layers include multiple groups of fractional-strided convolutions, batch normalization layers, and activation functions;

[0105] The final output layer for converting the image feature dimension and outputting the data format in accordance with the requirements includes multiple groups of convolutional layers.

[0106] Figure 2 This is the structural intention of a device for solving data imbalance problem in network attack detection in one embodiment of the present invention; Figure 3 This is the structural intention of a device for solving data imbalance problem in network attack detection in another embodiment of the present invention. Figure 4 It is a schematic diagram of the structure of a conditional diffusion model module of a device for solving data imbalance problem in network attack detection according to an embodiment of the present invention;

[0107] like Figure 2 As shown, a device for processing data imbalance problem in network attack detection includes: a preprocessing module 1, a conditional diffusion model training module 2, a sample generation module 3 and a determination module 4, wherein:

[0108] A preprocessing module 1 is used to preprocess the acquired attack information to obtain different types of training data for feature extraction and model training, wherein the attack information includes information of different types of network intrusion attack behaviors with unbalanced characteristics, and the preprocessing includes any one of the following or a combination thereof: data cleaning, encoding and conversion, and standardization, and the different types of training data include: normalized attack information data and normalized category label data;

[0109] Conditional diffusion model training module 2, inputs the different types of training data into the conditional diffusion model training module to dilute statistical attributes and reconstruct distribution information to obtain a network conditional diffusion NCDiff model, wherein the NCDiff model includes a model for sampling different types of attack behavior data by modifying conditional input;

[0110] The sample generation module 3 inputs the random noise data combined with the attack type category label into the NCDiff model to obtain the attack type data with unbalanced properties;

[0111] The determination module 4 performs network attack detection based on the attack type data with unbalanced properties and the original training data to determine whether there is a network intrusion attack behavior.

[0112] It should be noted that it is understandable Figure 3 The sample generation module 3 can be connected with the determination module 4. Figure 3 The determination module 4 is not shown.

[0113] The original training data in this embodiment refers to data information of attacks on the network collected within a period of time, wherein the original training data includes attack information used for preprocessing.

[0114] In this embodiment, first, the acquired attack information is preprocessed to obtain different types of training data for feature extraction and model training, the attack information includes information of different types of network intrusion attack behaviors with unbalanced features, the preprocessing includes any one of the following or a combination thereof: data cleaning, encoding and conversion, standardization, the different types of training data include: normalized attack information data and normalized category label data; then, the different types of training data are input into the conditional diffusion model training module for dilution statistical attributes and reconstruction distribution information processing, and a network conditional diffusion NCDiff model is obtained, the NCDiff model includes a model for sampling different types of attack behavior data by modifying conditional input; then, random noise data combined with attack type category labels is input into the NCDiff model to obtain attack type data with unbalanced properties; then, network attack detection is performed based on the attack type data with unbalanced properties and the original training data to determine whether there is a network intrusion attack behavior. The accuracy and robustness of network attack detection are significantly improved, and rare attack type samples in the actual environment are generated by the conditional diffusion model, thereby balancing the data set and enhancing the model's recognition ability for minority attacks. This method not only increases the number of samples of rare attacks, but also maintains the diversity and authenticity of the samples, avoiding the overfitting problem that may be introduced by simply repeating minority class samples; further, by using the NCDiff model, the training and generation of the model no longer rely on strict data distribution assumptions, which improves the adaptability and robustness of the model to actual data changes. At the same time, through an effective sample generation strategy, the complex data resampling technology and high computing resources required during the training process are reduced. The conditional diffusion model requires only a few adjustments when generating data, and can be effectively performed using existing hardware. The NCDiff model improves the model's adaptability and generalization to emerging attack patterns by learning and generating data containing various types of attack behaviors. This is because the model not only sees more diverse attack data, but also understands the core characteristics of attack behaviors by simulating variants of attacks.

[0115] Based on the above embodiment, the preprocessing module 1 includes:

[0116] Data cleaning module 101, used to select the attack information from the database Perform data cleaning to obtain data sets of various dimensions of attack information ,in, , , After cleaning Group data collection, After data cleaning, Group attack data Dimensional data features;

[0117] The encoding and conversion module 102 is used to classify the attack type by label encoding. Label encoding is used for digital mode conversion to obtain the attack type category label set , where , After digital mode conversion dimensional category label data; and converting the non-numeric features in the attack information data set of each dimension into a one-hot vector by one-hot encoding to obtain a one-hot encoding set of attack information ,in, , is the first Group attack information is collectively referred to as is the one-hot encoded Group attack data Dimensional data features;

[0118] The normalization and standardization module 103 is used to perform normalization processing on the attack information one-hot encoding set to obtain the normalized attack information data. , where , After normalization, Group attack data dimensional data features; and normalizing the attack type category label set to obtain the normalized category label data , where , After normalization Dimension category label data.

[0119] The original label conditions of different types of network intrusion attack behaviors are collectively referred to as , each dimension of original information of different types of network intrusion attack behaviors is collectively referred to as ,After preprocessing, different types of network intrusion attack behavior label conditions are collectively referred to as After preprocessing, each dimension of original information features of different types of network intrusion attack behaviors is collectively referred to as , the training data is and jointly constitute;

[0120] As a preferred embodiment, the different types of network intrusion attack behavior information with unbalanced characteristics selected in the database mainly include but are not limited to Guess_Passwd, Buffer_Overflow, Warezmaster, Land, Imap, Rootkit, Loadmodule, Ftp_Write, Multihop, Phf, Perl, Spy, DoS, Analysis, Backdoor and Worms.

[0121] This embodiment can use Figure 1 The method shown is implemented, and its technical effect is Figure 1 The embodiments shown are similar and will not be described again here.

[0122] Based on the above embodiment, the conditional diffusion model training module 2 includes:

[0123] The feature label connection module 201 is used to connect the normalized attack information data and the corresponding normalized category label data to obtain a training data set with conditional guidance function. ,in, Will be used as model input For the Dimensional input data, It is The first dimension of the input data dimensional data features, It is Dimension category label data;

[0124] Conditional diffusion model module 202, used to set the training data set Processing is performed to obtain the network conditional diffusion NCDiff model.

[0125] In this embodiment, the feature label connection module 201 and the conditional diffusion model module 202 adopt a serial structure. The conditional diffusion model module 202 is trained by using the output data of the feature label connection module 201 to obtain a conditional diffusion model NCDiff that uses conditional input to sample different types of attack behavior data.

[0126] Further, based on the above embodiment, the sample generation module 3 includes:

[0127] The random noise condition generating module 301 is used to create a random noise condition generating module 301, which is used to generate a random noise condition generating module 301. A random noise data set with attack type category labels ,in, , It is a general term for random noise data combined with attack type category labels. Combined with the attack type category label dimensional random noise data, Combined with the attack type category label dimensional random noise data dimensional data features, Category label data for target attack types;

[0128] The NCDiff model may be a NCDiff model reverse diffusion module 302, which is used to reversely diffuse the random noise data set combined with the attack type category label , and the generated quantity is There is an imbalance in the nature of the attack type data .

[0129] The operation of the random noise condition generation module 301 in this embodiment ensures that the conditional diffusion model can generate data under specific conditions, which is particularly important for simulating specific types of network attack behaviors. This control enables the model to generate corresponding training data for specific needs of network security, improving the pertinence and effectiveness of model training. When facing specific security threats, the random noise condition generation module 301 can be quickly adjusted to generate data that matches the current threat, supporting the security system to quickly adapt to new or changing attack patterns.

[0130] Optionally, based on the above embodiment, the NCDiff model is specifically used to combine each dimensional data feature of the normalized attack information data with the corresponding normalized category label data along a preset dimension to obtain a training data set with conditional guidance after adjusting the dimension and shape. ;

[0131] The conditional diffusion model module 202 is used to dilute the training data set by continuously adding noise in the forward phase. The statistical characteristics of the , until it turns into noise, and then the noise is restored through the neural network in the reverse stage. Figure 4 As shown, the conditional diffusion model module at least includes an encoding path, a bottleneck layer, a decoding path and a final output layer.

[0132] For the training data set The encoding path for extracting the features of each maintenance layer includes: multiple groups of downsampling layers, the downsampling layers include multiple groups of convolutional layers, batch normalization layers, activation functions, and maximum pooling layers;

[0133] The bottleneck layer used for feature compression and feature dimension conversion includes: multiple groups of convolutional layers and activation functions;

[0134] The decoding path for restoring an image comprises: a plurality of groups of upsampling layers, wherein the upsampling layers comprise a plurality of groups of fractional-stride convolutions, batch normalization layers, and activation functions;

[0135] The final output layer used for converting the image feature dimension and outputting the data format that meets the requirements includes: multiple groups of convolutional layers.

[0136] In the embodiment of the present invention, the conditional diffusion model module 202 includes four parts: an encoding path, a bottleneck layer, a decoding path, and a final output layer. The encoding path includes multiple groups of downsampling layers to gradually extract data features; the bottleneck layer includes multiple groups of convolutional layers and activation functions for feature compression and information aggregation, while performing feature dimension conversion and improving model efficiency; the decoding path includes multiple groups of upsampling layers for gradually restoring images; the final output layer includes multiple groups of convolutional layers for image feature dimension conversion and outputting data formats that meet the requirements. The downsampling layer includes multiple groups of convolutional layers, batch normalization layers, activation functions, and maximum pooling layers; the upsampling layer includes multiple groups of fractional-step convolutions, batch normalization, and activation functions.

[0137] The encoding path realizes the step-by-step feature extraction and compression of input data through multi-level convolution, batch normalization, activation and pooling operations. These operations not only improve the model's feature extraction ability and computational efficiency, but also enhance the model's robustness and generalization ability. In network intrusion detection tasks, this layer-by-layer feature extraction and dimensionality reduction processing can effectively capture complex attack patterns and improve the model's ability to detect abnormal behaviors. The convolution layer can extract local features of the input data and capture important spatial patterns; batch normalization reduces the changes in the input distribution of each layer, accelerates the model training process, helps stabilize and accelerate the network training process, and reduces sensitivity to initialization; the activation function can introduce nonlinearity, improve the model's expressiveness, enable it to handle complex tasks, help alleviate the gradient vanishing problem, maintain the propagation of gradients, and improve the training effect of deep networks; the maximum pooling layer extracts the maximum value of the local area through a sliding window, realizes spatial downsampling, reduces the size of the feature map, retains the most significant features through dimensionality reduction, reduces the amount of calculation, improves the model's computational efficiency, and improves the model's robustness to position changes, so that the model can better handle small changes in input data. The bottleneck layer further extracts features, performs feature compression and information aggregation, compresses high-dimensional features into low-dimensional representations, retains important information, improves the compactness of features, and enhances the association between features through convolution operations while reducing the dimension, thereby improving the quality of feature representation. The decoding path gradually restores the spatial size of the feature map through the upsampling layer, so that the generated data has higher resolution and details. Batch normalization and activation functions ensure the consistency of the generated data in the numerical range and feature representation, thereby improving the quality of the generated data. The final output layer performs the final conversion and adjustment on the features output by the decoding path, generates data in the expected format, and further optimizes the details and quality of the output data through convolution operations, ensuring the high quality and practicality of the generated data.

[0138] It can be understood that the conditional diffusion model module 202 can effectively alleviate the problem of data imbalance by generating more minority attack samples, enhance the diversity and balance of the data set, and improve the model's detection ability for different types of attacks. At the same time, the generated high-quality synthetic data can help the model learn more attack features, so that it has better generalization ability when facing new or unseen attacks, and improve the generalization ability of the model. In addition, in a practical environment, it may be very difficult and costly to obtain a large amount of high-quality attack data. The conditional diffusion model module 202 reduces the dependence on real data by generating realistic attack data, and reduces the difficulty and cost of collecting real data. At the same time, the conditional diffusion model module 202 can generate corresponding data according to emerging threats, helping the intrusion detection system to maintain the latest defense capabilities. Specifically, the encoding path is responsible for extracting and compressing useful features from the input data, and through steps such as convolution operations, batch normalization and pooling, gradually reducing the dimension and redundant information of the data, providing efficient feature representation for subsequent feature aggregation and reconstruction, and providing high-quality feature input for the bottleneck layer; the bottleneck layer is the core part of the model, further compressing and summarizing the feature information extracted from the encoding path. This layer significantly reduces the feature dimension and retains key information through deep convolution and activation function operations, thereby improving the efficiency and expressiveness of the model; the decoding path is responsible for gradually recovering the spatial resolution and details of the data from the compressed features of the bottleneck layer, and generating high-quality output similar to the input data format through upsampling operations, batch normalization and activation functions; the final output layer performs final processing and conversion on the features generated by the decoding path to ensure that the output data meets specific application requirements and formats. This step is crucial to ensuring the quality and practical usability of the generated data.

[0139] Set the loss function of the present invention:

[0140] By setting the reconstruction loss function to measure the similarity between the generated data and the real data, it is ensured that the conditional diffusion model NCDiff can accurately reconstruct the input data.

[0141] By setting a conditional loss function, it is used to ensure that the generated data meets specific conditions or attributes. Conditional loss helps the model learn how to generate data according to given conditions, enhances its adaptability and flexibility, and makes the generated data more targeted and practical.

[0142] By setting the total loss function to balance the various loss components, the performance of the model on multiple objectives is optimized to ensure that the model can reconstruct and generate data with high quality while meeting the conditions.

[0143] In this example, the reconstruction loss function of the present invention uses the MSE loss function to enable the model to more accurately capture small errors in the data:

[0144] ,

[0145] in The number of samples refers to the number of samples used for training in a batch. In the present invention, it specifically refers to the number of attack behavior data participating in feature dilution and restoration during each batch of training; It is The actual value of the sample is a certain dimension of feature information data of each group of attack vectors. , refers to the specific features that we want the model to accurately reconstruct; It is the feature information data of a certain dimension corresponding to each group of attack vectors predicted by the model. When using the conditional diffusion model module 202, these predictions are usually recovered from partially diluted or completely diluted inputs, which means that the model needs to reconstruct clear and undisturbed outputs from noisy data; Represents the square of the prediction error. The squaring operation ensures that the error is always positive and amplifies the impact of larger errors, which helps the model focus more on reducing large prediction errors during training. This means that the squared errors of all samples in a batch are accumulated to obtain the total error of the entire batch of data, which lays the foundation for the subsequent calculation of the average value. Divide the accumulated sum of squared errors by the number of samples , we get the mean squared error, which is a measure of the average performance of the model over the entire batch.

[0146] It can be understood that the MSE loss function is very suitable for tasks that require accurate numerical predictions. It is mainly used to measure the error between the predicted value and the actual value. In the context of network intrusion detection, MSE can effectively evaluate the prediction accuracy of the model, helping the model to focus on reducing the error between the predicted value and the actual value of each sample, especially the large error, thereby improving the model's fit in details.

[0147] In this example, the conditional loss function of the present invention uses a weighted cross entropy loss function. When the data categories are extremely unbalanced, the weighted cross entropy loss can adjust the importance of different categories and assign higher weights to categories with fewer samples:

[0148] in, is the total number of label categories, i.e. , including normal traffic and various types of attack labels; It is The class weights are usually set inversely based on the class frequency, with minority classes receiving higher weights in order to increase their influence in the loss function, thereby making the model pay more attention to these minority classes during training; is a binary indicator if the sample Belongs to category , then it is 1, otherwise it is 0. For each sample, this is the actual category label. This value indicates whether it belongs to the category currently considered. ; The model predicts samples based on input features Belongs to category probability. The weighted losses of all categories are accumulated to ensure that the model's performance on all categories is taken into account; Is the penalty term for calculating the probability. If the predicted probability Deviation from the true label , the logarithmic function returns a larger loss value, thus motivating the model to improve its prediction accuracy.

[0149] It can be understood that the weighted cross entropy loss function is very suitable for dealing with the problem of class imbalance in classification tasks, and can effectively guide the model to better identify attack types with small sample sizes. By adjusting the weight of each category, the model can significantly improve the recognition performance of the minority class while maintaining good recognition capabilities for the majority class.

[0150] In this example, the total loss function of the present invention uses a combination function of the MSE loss function and the weighted cross entropy loss function.

[0151] ,

[0152] in and is the weight coefficient, which is used to adjust the proportion of reconstruction loss and conditional loss in the total loss. In terms of numerical relationship, . is a hyperparameter used to control the reconstruction loss In the total loss function In network intrusion detection tasks, adjusting this parameter can help the model find a balance between reconstructing network connection features and accurate classification. It is also a hyperparameter used to control the conditional loss In the total loss function Increasing the value of this parameter can make the model focus more on correctly classifying various types of network traffic, especially the minority class. The total loss function By combining the two losses, the model optimizes the classification task (correctly labeling various types of network flows) while learning the reconstruction task (predicting accurate feature values). This combination ensures that the model will neither ignore the importance of any category nor sacrifice the ability to accurately reconstruct network flow features when dealing with imbalanced data sets.

[0153] It is understandable that in the actual training process, adjustment and The value of has a significant impact on the performance of the model. Through experiments and verification, the optimal weight setting can be found to achieve the best detection effect. This flexible loss function design allows the model to better adapt to different training objectives, such as focusing more on accurate classification or focusing more on the accuracy of feature reconstruction, thereby effectively solving the problem of data imbalance. Through such a loss function setting, the model can pay more attention to all categories during learning, especially improving the recognition ability of minority classes, which is particularly critical for intrusion detection in the field of network security. By setting these parameters reasonably, the model will neither ignore the recognition of minority categories nor sacrifice the accurate reconstruction of network traffic features during training, thereby effectively improving the detection rate of uncommon attack types while ensuring overall performance. This method is crucial for optimizing the performance of network intrusion detection systems in practical applications, especially when dealing with complex and unbalanced data sets.

[0154] To further illustrate the effects of the embodiments of the present invention, the following experiments are conducted: The present invention selects the NSL-KDD training and test sets of the commonly used benchmark data set for network intrusion detection systems. The NSL-KDD data set summarizes the attack behaviors of Guess_Passwd, Buffer_Overflow, Warezmaster, Land, Imap, Rootkit, Loadmodule, Ftp_Write, Multihop, Phf, Perl, and Spy into four major categories: Probe, DoS, U2R, and R2L. In order to fully verify the effectiveness of the method and the actual effect on the intrusion detection system, a decision tree is used for classification, and accuracy, precision, recall, and F value are used as evaluation indicators. The hyperparameter setting , the learning rate of the Adam optimizer is set to . The accuracy index comparison results are shown in Table 1. Compared with the second highest, the accuracy of the present invention is improved by 0.025, and the accuracy is the highest, showing extremely high effectiveness in processing unbalanced data for network intrusion detection, indicating its great potential in practical applications. The accuracy index comparison results are shown in Table 2. The performance of the method of the present invention on Normal, Probe and DoS is very good, and U2R and R2L also perform well, indicating that the method has extremely high effectiveness and applicability in processing network intrusion detection tasks. The accuracy index comparison results are shown in Table 3. The recall rate of the method of the present invention in all categories is the best, especially the Normal, Probe and DoS categories, showing extremely high detection capabilities. The F value index comparison results are shown in Table 4. The F value of the method of the present invention is the best in all categories, especially the Normal, Probe and DoS categories, showing good comprehensive performance.

[0155] Based on these four tables, the performance of the method of the present invention in processing network intrusion detection tasks can be summarized as follows:

[0156] The method performs well in accuracy, precision, recall and F-value, indicating that it is highly efficient in detecting various types of attacks. It performs very stably in all categories, especially in Normal, Probe and DoS categories, showing good generalization ability. By generating high-quality unbalanced samples, the method has high practical value in actual network security applications and can effectively deal with complex and changing network threats.

[0157] Table 1 Comparison results of accuracy indicators of different algorithms:

[0158]

[0159] Table 2 Comparison results of accuracy indicators of different algorithms

[0160]

[0161] Table 3 Comparison results of recall rate indicators of different algorithms

[0162]

[0163] Table 4 Comparison results of F-value indicators of different algorithms

[0164]

[0165] The innovation of the present invention is to use the conditional diffusion model to solve the data imbalance problem in network intrusion detection. The specific improvement proposes solutions to multiple defects of the prior art, which significantly improves the accuracy and robustness of network attack detection.

[0166] An analysis of the various improvements and how they overcome the deficiencies of existing technologies includes the following:

[0167] 1. Generate minority class samples using the conditional diffusion model:

[0168] Existing technology defects: Traditional machine learning methods often ignore rare attacks when dealing with imbalanced data, resulting in insufficient detection capabilities for these attacks.

[0169] Improvement: Generate rare attack type samples in the actual environment through the conditional diffusion model, so as to balance the data set and enhance the model's ability to identify minority attacks. This method not only increases the number of rare attack samples, but also maintains the diversity and authenticity of the samples, avoiding the overfitting problem that may be introduced by simply repeating minority samples.

[0170] 2. Reduce sensitivity to data quality and distribution:

[0171] Existing technology defects: Traditional network intrusion detection is too sensitive to data quality and specific distribution, which affects their application effectiveness in changing environments.

[0172] Improvement: By using the NCDiff model, model training and generation no longer rely on strict data distribution assumptions, which improves the adaptability and robustness of the model to actual data changes.

[0173] 3. Reduce false alarm and misreporting rates:

[0174] Deficiencies of existing technologies: Traditional network intrusion detection often has high false alarm and misreporting rates when faced with data imbalance.

[0175] Improvements: The conditional diffusion model trains the model by generating highly representative attack samples, which enables the model to learn the characteristics of various types of attacks more accurately, thereby reducing the possibility of misjudgment and wrong judgment.

[0176] 4. Reduce model complexity and computing resource requirements:

[0177] Deficiencies of existing technologies: Processing unbalanced data often requires complex algorithms and high computational costs.

[0178] Improvements: Through an effective sample generation strategy, the complex data resampling techniques and high computing resources required during training are reduced. The conditional diffusion model requires only a few adjustments when generating data and can be effectively performed using existing hardware.

[0179] 5. Enhance the generalization ability of the detection model for different attack behavior data:

[0180] Deficiencies of existing technologies: Existing network intrusion detection models are often difficult to adapt to new or changing attack patterns.

[0181] Improvements: The NCDiff model improves the model's adaptability and generalization to emerging attack patterns by learning and generating data containing various types of attack behaviors. This is because the model not only sees more diverse attack data, but also understands the core characteristics of attack behaviors by simulating variants of attacks.

[0182] These improvements not only solve the main challenges faced by existing technologies in the field of network security, but also provide a scalable and efficient solution, enabling network security defense systems to respond more intelligently and effectively to increasingly complex security threats. In addition, the application of this technical solution may also promote the further development and application of deep learning technology in the security field, especially in application scenarios with highly unbalanced data.

[0183] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any modifications, equivalent substitutions and improvements made by any technician familiar with the technical field within the technical scope disclosed by the present invention and within the spirit and principles of the present invention should be covered within the protection scope of the present invention.

Claims

1. A method for dealing with data imbalance in network attack detection. It is characterized in that include: Preprocessing the acquired attack information to obtain different types of training data for feature extraction and model training, wherein the attack information includes information of different types of network intrusion attack behaviors with unbalanced characteristics, and the preprocessing includes any one of the following or a combination thereof: data cleaning, encoding and conversion, and standardization, and the different types of training data include: normalized attack information data and normalized category label data; Inputting the different types of training data into the conditional diffusion model training module to dilute the statistical attributes and reconstruct the distribution information to obtain a network conditional diffusion NCDiff model, wherein the NCDiff model includes a model for sampling different types of attack behavior data by modifying the conditional input; Inputting random noise data combined with attack type category labels into the NCDiff model to obtain attack type data with unbalanced properties; Perform network attack detection based on the attack type data with unbalanced properties and the original training data to determine whether there is a network intrusion attack behavior; The inputting of the different types of training data into the conditional diffusion model training module to dilute the statistical attributes and reconstruct the distribution information to obtain the network conditional diffusion NCDiff model includes: The normalized attack information data and the corresponding normalized category label data are connected to obtain a training data set x with conditional guidance function. c ={ 0 c ,x 1 c ,...,χ k c ,...,χ K c }, where χ c As the model input, χ k c ={x k 0 ,x k 1 ,...,x k i ,...x k N ,c j } is the k-th dimension input data, x k i is the i-th dimension data feature of the k-th dimension input data, c j is the j-th dimension category label data; The training data set x c Input into the conditional diffusion model module for processing to obtain the network conditional diffusion NCDiff model; The step of inputting the random noise data combined with the attack type category label into the NCDiff model to obtain the attack type data with unbalanced properties includes: Create a random noise data set with attack type category labels to be generated, the number of which is R where r∈[0,R], It is a general term for random noise data combined with attack type category labels. is the r-th dimension random noise data combined with the attack type category label, is the i-th dimension data feature of the r-th dimension random noise data combined with the attack type category label, c j Classification label data for target attack types; Each dimension data feature of the normalized attack information data is combined with the corresponding normalized category label data along the preset dimension to obtain a training data set x with conditional guiding effect after the dimension and shape are adjusted. c ={ 0 c ,x 1 c ,...,χ k c ,...,χ K c }; The conditional diffusion model module is used to dilute the training data set x by continuously adding noise in the forward phase. c The statistical characteristics of the conditional diffusion model are transformed into noise, and then the noise is restored by a neural network in the reverse stage. The conditional diffusion model module includes at least an encoding path, a bottleneck layer, a decoding path and a final output layer; For the training data set x c The encoding path for extracting features of each dimension in the image includes multiple groups of downsampling layers, and the downsampling layers include multiple groups of convolutional layers, batch normalization layers, activation functions, and maximum pooling layers; The bottleneck layer for feature compression and feature dimension conversion includes multiple groups of convolutional layers and activation functions; The decoding path for restoring the image includes multiple groups of upsampling layers, and the upsampling layers include multiple groups of fractional-strided convolutions, batch normalization layers, and activation functions; The final output layer for converting the image feature dimension and outputting the data format in accordance with the requirements includes multiple groups of convolutional layers; The inputting of the different types of training data into the conditional diffusion model training module to dilute the statistical attributes and reconstruct the distribution information to obtain the network conditional diffusion NCDiff model also includes: Set the total loss function L Total =α×L reconstruction +β×L condition , where the weight coefficients α and β are used to adjust the proportion of reconstruction loss and conditional loss in the total loss; reconstruction loss function n is the number of samples, y i is the actual value of the ith sample, is the data predicted by the NCDiff model; conditional loss function M is the total number of class labels j-1, w c is the weight of the cth class, y o,c is a binary indicator that is 1 if sample o belongs to class c and 0 otherwise. o,c is the probability that the predicted sample o belongs to category c based on the input features, The weighted losses of all categories are accumulated, and log(·) is the penalty term for calculating the probability.

2. The method for processing data imbalance in network attack detection according to claim 1, It is characterized in that The acquired attack information is preprocessed to obtain different types of training data for feature extraction and model training, including: The attack information x selected from the database is cleaned to obtain a data set x of each dimension of the attack information. k clear ={ k 0-clear ,x k 1-clear ,...,χ k i-clear ,...,χ k N-clear }, where i∈[0,N], k∈[0,K], χ k clear is the kth group of data after cleaning, χ k i-clear is the i-th dimension data feature of the k-th group of attack data after data cleaning; Through label encoding, the attack type category ε label encoding is converted into a digital mode to obtain the attack type category label set c l ={c 0-l ,c 1-l ,...,c j-l ,...,c M-l }, where j∈[0,M], c j-l is the j-th dimension category label data after digital mode conversion; By one-hot encoding, the non-numeric features in the attack information data set of each dimension are converted into one-hot vectors to obtain the attack information one-hot encoding set χ k onehot ={ k 0-onehot ,x k 1-onehot ,...,χ k i-onehot ,...,χ k N-onehot }, where i∈[0,N], χ k onehot is the collective name of the kth group of attack information after one-hot encoding, χ k i-onehot is the i-th dimension data feature of the k-th group of attack data after one-hot encoding; The attack information one-hot encoding set is standardized to obtain the normalized attack information data x k BN ={ k 0-BN ,x k 1-BN ,...,χ k i-BN ,...,χ k N-BN }, where i∈[0,N], χ k i-BN is the i-th dimension data feature of the k-th group of attack data after normalization; The attack type category label set is standardized to obtain the standardized category label data c BN ={c 0-BN ,c 1-BN ,...,c j-BN ,...,c M-BN }, where j∈[0,M], c j-BN is the normalized j-th dimension category label data.

3. A device for processing data imbalance in network attack detection, It is characterized in that include: A preprocessing module, used to preprocess the acquired attack information to obtain different types of training data for feature extraction and model training, wherein the attack information includes information of different types of network intrusion attack behaviors with unbalanced characteristics, and the preprocessing includes any one of the following or a combination thereof: data cleaning, encoding and conversion, and standardization, and the different types of training data include: normalized attack information data and normalized category label data; A conditional diffusion model training module is used to input the different types of training data into the conditional diffusion model training module to dilute the statistical attributes and reconstruct the distribution information to obtain a network conditional diffusion NCDiff model, wherein the NCDiff model includes a model for sampling different types of attack behavior data by modifying the conditional input; A sample generation module, used to input random noise data combined with attack type category labels into the NCDiff model to obtain attack type data with unbalanced properties; A determination module, used to perform network attack detection based on the attack type data with unbalanced properties and the original training data to determine whether there is a network intrusion attack behavior; The conditional diffusion model training module includes: The feature label connection module is used to connect the normalized attack information data and the corresponding normalized category label data to obtain a training data set x with conditional guidance function. c ={ 0 c ,x 1 c ,...,χ k c ,...,χ K c }, where χ c The model input χ k c ={x k 0 ,x k 1 ,...,x k i ,...x k N ,c j } is the k-th dimension input data, x k i is the i-th dimension data feature of the k-th dimension input data, c j is the j-th dimension category label data; Conditional diffusion model module, used to transform the training data set x c Processing is performed to obtain the network conditional diffusion NCDiff model; The sample generation module comprises: The random noise condition generation module is used to create a random noise data set with a number of attack type category labels to be generated. where r∈[0,R], It is a general term for random noise data combined with attack type category labels. is the r-th dimension random noise data combined with the attack type category label, is the i-th dimension data feature of the r-th dimension random noise data combined with the attack type category label, c j Classification label data for target attack types; NCDiff model is used to combine the random noise data set with the attack type category label Get the attack type data x with the generated number R and the unbalanced nature c ={ 0 c ,x 1 c ,...,χ r c ,...,χ R c }; The NCDiff model is specifically used to combine each dimensional data feature of the normalized attack information data with the corresponding normalized category label data along a preset dimension to obtain a training data set x having a conditional guiding effect after adjusting the dimension and shape. c ={ 0 c ,x 1 c ,...,χ k c ,...,χ K c }; The conditional diffusion model module is used to dilute the training data set x by continuously adding noise in the forward phase. c The statistical characteristics of the conditional diffusion model are transformed into noise, and then the noise is restored by a neural network in the reverse stage. The conditional diffusion model module includes at least an encoding path, a bottleneck layer, a decoding path and a final output layer; For the training data set x c The encoding path for extracting the features of each maintenance layer includes: multiple groups of downsampling layers, the downsampling layers include multiple groups of convolutional layers, batch normalization layers, activation functions, and maximum pooling layers; The bottleneck layer used for feature compression and feature dimension conversion includes: multiple groups of convolutional layers and activation functions; The decoding path for restoring an image comprises: a plurality of groups of upsampling layers, wherein the upsampling layers comprise a plurality of groups of fractional-stride convolutions, batch normalization layers, and activation functions; The final output layer used for image feature dimension conversion and outputting data in a required format includes: multiple groups of convolutional layers; The conditional diffusion model training module is also used to set the total loss function L Total =α×L reconstruction +β×L condition , where the weight coefficients α and β are used to adjust the proportion of reconstruction loss and conditional loss in the total loss; reconstruction loss function n is the number of samples, y i is the actual value of the ith sample, is the data predicted by the NCDiff model; conditional loss function M is the total number of class labels j-1, w c is the weight of the cth class, y o,c is a binary indicator that is 1 if sample o belongs to class c and 0 otherwise. o,c is the probability that the predicted sample o belongs to category c based on the input features, The weighted losses of all categories are accumulated, and log(·) is the penalty term for calculating the probability.

4. The device for processing data imbalance problem in network attack detection according to claim 3, It is characterized in that The preprocessing module comprises: A data cleaning module is used to perform data cleaning on the attack information x selected from the database to obtain a data set x of each dimension of the attack information k clear ={ k 0-clear ,x k 1-clear ,...,χ k i-clear ,...,χ k N-clear }, where i∈[0,N], k∈[0,K], χ k clear is the kth group of data after cleaning, χ k i-clear is the i-th dimension data feature of the k-th group of attack data after data cleaning; The encoding and conversion module is used to convert the attack type category ε label code into a digital mode through label coding to obtain the attack type category label set c l ={c 0-l ,c 1-l ,...,c j-l ,...,c M-l }, where j∈[0,M], c j-l is the j-th dimension category label data after digital mode conversion; and through one-hot encoding, the non-digital features in the attack information data set of each dimension are converted into a one-hot vector to obtain the attack information one-hot encoding set χ k onehot ={ k 0-onehot ,x k 1-onehot ,...,χ k i-onehot ,...,χ k N-onehot }, where i∈[0,N], χ k onehot is the collective name of the kth group of attack information after one-hot encoding, χ k i-onehot is the i-th dimension data feature of the k-th group of attack data after one-hot encoding; The normalization and standardization module is used to perform normalization processing on the attack information one-hot encoding set to obtain the normalized attack information data x k BN ={ k 0-BN ,x k 1-BN ,...,χ k i-BN ,...,χ k N-BN }, where i∈[0,N], χ k i-BN is the i-th dimension data feature of the k-th group of attack data after normalization; and the attack type category label set is normalized to obtain the normalized category label data c BN ={c 0-BN ,c 1-BN ,...,c j-BN ,...,c M-BN }, where j∈[0,M], c j-BN is the normalized j-th dimension category label data.

Citation Information

Patent Citations

  • Abnormal image detection method based on a supervised generative adversarial network

    CN109584221A

  • DVGAE-GAN-based traffic road network data restoration method

    CN113033619A

  • Abnormality detection method based on conditional diffusion probability generation model

    CN114500004A

  • Image enhancement method and device, electronic equipment and storage medium

    CN115689964A

  • Flow data set generation method and device based on conditional diffusion model

    CN116304705A