WO2024207804A1 - 网络入侵检测方法、装置、电子设备和可读存储介质 - Google Patents

网络入侵检测方法、装置、电子设备和可读存储介质 Download PDF

Info

Publication number
WO2024207804A1
WO2024207804A1 PCT/CN2023/139627 CN2023139627W WO2024207804A1 WO 2024207804 A1 WO2024207804 A1 WO 2024207804A1 CN 2023139627 W CN2023139627 W CN 2023139627W WO 2024207804 A1 WO2024207804 A1 WO 2024207804A1
Authority
WO
WIPO (PCT)
Prior art keywords
sample
feature
sample set
samples
feature information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2023/139627
Other languages
English (en)
French (fr)
Inventor
方文
李旭
张卫平
郑尧展
张刚
林志銮
刘阳
景广豫
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Telecom Cloud Technology Co Ltd
Original Assignee
China Telecom Cloud Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Telecom Cloud Technology Co Ltd filed Critical China Telecom Cloud Technology Co Ltd
Publication of WO2024207804A1 publication Critical patent/WO2024207804A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/14Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic
    • H04L63/1408Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic by monitoring network traffic
    • H04L63/1416Event detection, e.g. attack signature detection
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/14Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic
    • H04L63/1441Countermeasures against malicious traffic
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/50Reducing energy consumption in communication networks in wire-line communication networks, e.g. low power modes or reduced link rate

Definitions

  • the present application relates to the field of system security, and in particular to a network intrusion detection method, device, electronic device and readable storage medium.
  • cloud computing has many advantages, it has always faced major challenges brought by network security issues, especially abnormal traffic data, which greatly increases the risk of network intrusion.
  • the features of traffic data are relatively sparse.
  • the traffic data features based on CNN are insufficient in learning the dependencies between traffic sequences. Therefore, the network detection method based on CNN has low accuracy when classifying and detecting traffic data in the detection network, resulting in a high risk of network intrusion caused by abnormal traffic data.
  • the embodiments of the present application provide a network intrusion detection method, device, electronic device and readable storage medium, which can improve the accuracy of abnormal traffic data classification and reduce the risks brought by network intrusion.
  • the present invention provides a method for detecting network intrusion, which includes:
  • the second feature information is processed cyclically using the feature extraction model until the third feature information is obtained when the loop exit condition is met; in each round of the loop, the input data of the feature extraction model is the output data of the previous round;
  • the third characteristic information is classified and detected to obtain the detection result of the flow data to be detected.
  • the first characteristic information includes at least one first characteristic matrix
  • Extracting second feature information from the first feature information using a pre-trained feature extraction model includes:
  • M represents the sparsity of the i-th first feature matrix q i in the first feature information
  • L K represents the number of first feature matrices in the first feature information
  • k j represents the j-th first feature matrix in the first feature information
  • T represents the matrix transpose.
  • the second feature information is processed in a loop using the feature extraction model until a loop exit condition is met to obtain the third feature information, including:
  • the fourth feature information is processed in a loop using the feature extraction model until a loop exit condition is met to obtain the third feature information;
  • F represents the fourth feature information
  • S represents the second feature information
  • Convld represents one-dimensional convolution processing
  • ELU represents activation function
  • MaxPool represents maximum pooling processing.
  • the method before extracting the second feature information from the first feature information using a pre-trained feature extraction model, the method further includes:
  • a final sample set is generated based on the balanced sample set and the majority class samples
  • the multi-head self-attention network model is iteratively trained to obtain the feature extraction model of the data to be detected.
  • the method further comprises:
  • the first sample is re-extracted from the minority class samples, and the balanced sample set is readjusted based on the re-extracted first sample, wherein each minority class sample can only be extracted once.
  • adjusting the balanced sample set according to the number of majority class samples contained in the hypersphere formed by the first sample and the second sample includes:
  • the first sample set is an empty set
  • a third sample is generated in the space formed by the first hypersphere, and the third sample is added to the balanced sample set.
  • the method further comprises:
  • first sample set is not an empty set, determine the set with the closest Euclidean distance to the first sample from the first sample set.
  • the first sample set is re-determined according to the majority class samples located in the space formed by the second hypersphere.
  • x syn represents the coordinate of the third sample in the Euclidean space
  • xi represents the coordinate of the first sample in the Euclidean space
  • xk represents the coordinate of the second sample in the Euclidean space
  • r represents the radius of the first hypersphere
  • v ⁇ v 1 , ..., vi , ...v d ⁇ ,v 1 ⁇ (-1,1), vi ⁇ (-1,1),v d ⁇ (-1,1), 1 ⁇ i ⁇ d, and
  • generating a final sample set based on the balanced sample set and the majority class samples includes:
  • a safe sample is selected from the majority class samples, wherein there is no minority class sample in the B samples corresponding to the safe sample;
  • the final sample set is generated based on the safety sample and the balanced sample set.
  • the present application provides a network intrusion detection device, the device comprising:
  • a flow data acquisition module used to acquire flow data to be detected
  • a first characteristic information extraction module used to extract first characteristic information of the flow data to be detected
  • a second feature information extraction module used to extract second feature information from the first feature information using a pre-trained feature extraction model, where the feature extraction model is a multi-head self-attention network model;
  • a third feature information extraction module is used to use the feature extraction model to cyclically process the second feature information until the loop exit condition is met to obtain the third feature information; in each round of loop, the input data of the feature extraction model is the output data of the previous round;
  • the classification module is used to classify and detect the third characteristic information to obtain the detection result of the flow data to be detected.
  • An embodiment of the present application provides an electronic device, including: a processor and a memory, wherein the processor executes a computer program stored in the memory to implement the network intrusion detection method as in the first aspect.
  • An embodiment of the present application provides a readable storage medium, in which computer instructions are stored. When the computer instructions are executed by a processor, the network intrusion detection method of the first aspect is implemented.
  • the embodiment of the present application provides a network intrusion detection method. After obtaining the traffic data to be detected, extract the first feature information of the traffic data to be detected, use the pre-trained feature extraction model based on the multi-head self-attention network to extract the second feature information in the first feature information, and use the feature extraction model to extract the second feature information of the first feature information.
  • the second feature information is processed in a loop until the third feature information is obtained when the loop exit condition is met; in each cycle, the input data of the feature extraction model is the output data of the previous cycle; the third feature information is classified and detected to obtain the detection result of the traffic data to be detected.
  • the feature extraction model based on multi-head self-attention networks can effectively learn the dependency characteristics of traffic data, and further cyclic processing of the second feature information based on the feature extraction model can improve the accuracy of dependency feature extraction, thereby effectively improving the accuracy of traffic data classification detection, and then accurately identifying abnormal traffic in network traffic data, reducing the risk of network intrusion.
  • FIG1 shows a flow chart of a network intrusion detection method provided by an embodiment of the present application
  • FIG2 shows an architecture diagram of a local feature extraction model provided in an embodiment of the present application
  • FIG3 shows an architecture diagram of a feature extraction model provided in an embodiment of the present application
  • FIG4 shows a loop processing architecture diagram provided by an embodiment of the present application
  • FIG5 shows a flow chart of a sample processing method provided in an embodiment of the present application
  • FIG6 shows a training flow chart of a feature extraction model provided in an embodiment of the present application
  • FIG. 7 shows a flow chart of another data processing method provided in an embodiment of the present application.
  • FIG8 shows a structural block diagram of a network intrusion detection device provided in an embodiment of the present application.
  • FIG. 9 shows a schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
  • the method may specifically include the following steps:
  • Step 101 Obtain traffic data to be detected.
  • Traffic data refers to the transmission data used for interaction in the network.
  • abnormal data often leads to a greatly increased risk of network intrusion. Therefore, during the data interaction process, the transmitted data needs to be detected first to prevent the acquisition of abnormal data from causing damage to the local network.
  • This application does not limit the specific method of obtaining traffic data.
  • Step 102 extract the first characteristic information of the flow data to be detected.
  • the first feature information refers to the local feature information of the traffic data to be detected.
  • Convolutional neural networks, detect-then-describe and other methods can be used to extract local features, and this application does not limit this.
  • the first feature information is extracted using a local feature extraction model based on a convolutional neural network.
  • i represents the number of bytes contained in the traffic data to be detected
  • n represents the dimension of the embedded vector
  • e i represents the vector formed after the i-th byte data is encoded.
  • the local feature extraction model includes two convolutional layers, two pooling layers, and a fully connected layer.
  • the input of the convolutional layer is the matrix encoded by the traffic data to be detected, which can be processed by the convolutional layer to obtain the following results:
  • hj is the feature map of the jth layer
  • j 1, 2, 3...n.
  • bj is the bias coefficient of the jth layer
  • f(x) is the activation function
  • this model uses the linear rectifier unit (ReLU).
  • ReLU linear rectifier unit
  • the local feature extraction model based on CNN can accurately extract the local features of the traffic data to be detected, and can provide a good data foundation for the subsequent learning of the dependency relationship of the traffic sequence.
  • Step 103 Use a pre-trained feature extraction model to extract second feature information from the first feature information, where the feature extraction model is a multi-head self-attention network model.
  • a feature extraction model based on a multi-head self-attention mechanism is used to learn the dependency characteristics of the traffic data to be detected, i.e., the second feature information.
  • attention can be calculated by a dot product attention mechanism, wherein the multi-head, i.e., heads, is used to represent multiple attention heads for self-attention calculation, Q (Query), K (Key), and V (Value) represent query, key, and value, respectively, and the normalized exponential function refers to the softmax function.
  • the inputs Q, K, and V of the feature extraction model can all be the first feature information of the data to be detected obtained in step 102, or the first feature information can be subjected to feature enhancement, convolution, and other processing and then used as Q, K, and V, respectively, and the present application does not limit this.
  • Step 104 Utilize the feature extraction model to process the second feature information in a loop until a loop exit condition is met to obtain third feature information; in each loop, the input data of the feature extraction model is the output data of the previous loop.
  • the third feature information of the stray data to be detected is further extracted based on the second feature information by stacking self-attention blocks.
  • a loop processing architecture diagram is provided in an embodiment of the present application, wherein the self-attention model is used to represent the feature extraction model based on multi-head self-attention in step 103, and the residual addition normalization represents the processing process of add&norm, which is used to prevent the model degradation problem caused by depth and ensure that the efficiency of the loop processing is not affected.
  • the feature extraction model of step 103 is used to perform loop processing on the second feature information, that is, the second feature information is continuously input into the feature extraction model for loop processing.
  • the input data of the feature extraction model is the output data of the previous round until the loop exit condition is met and the input of the feature extraction model is stopped.
  • the feature information output by the Z self-attention blocks is processed by a feedforward neural network to output the third feature information.
  • the loop exit condition may be a pre-set Z feature extraction model loops, i.e., Z self-attention blocks, or it may refer to the third feature information reaching a certain condition, which is not limited in the present application.
  • Step 105 Classify and detect the third characteristic information to obtain the detection result of the flow data to be detected.
  • F represents the third feature information
  • is the softmax function, which can convert the third feature information into a probability value between 0 and 1
  • P is the output probability matrix, which is used to represent the probability that the traffic data to be detected is identified as the corresponding type of traffic.
  • P [0.6, 0.2, 0.1, 0.05, 0.05]
  • the corresponding traffic type list is [Nromal, Dos, R2L, Probe, U2R]
  • the probability of the input traffic being identified as Normal 0.6
  • the probability of Dos is 0.2
  • the probability of R2L is 0.1
  • the probability of Probe is 0.05
  • U2R is 0.05.
  • the element data in P is larger, the possibility of being identified as the type of traffic is greater.
  • the largest value in the above P is 0.6, and the corresponding traffic type is Normal, then it can be considered that the traffic data to be detected is normal traffic; if the probability of Dos is 0.7, it means that the traffic data to be detected is denial of service attack traffic data, which is abnormal traffic data.
  • the feature extraction model based on multi-head self-attention networks can effectively learn the dependency characteristics of traffic data, and the cyclic processing of the second feature information based on the feature extraction model can further improve the accuracy of dependency feature extraction, thereby effectively improving the accuracy of traffic data classification, and then accurately identifying abnormal traffic in network traffic data, reducing the risks brought by network intrusion.
  • the first characteristic information includes at least one first characteristic matrix
  • the step 103 of extracting the second feature information from the first feature information by using a pre-trained feature extraction model includes:
  • Step S11 calculating the sparsity of the first feature matrix
  • Step S12 based on the sparsity of the first feature matrix, select N consecutive first feature matrices from at least one first feature matrix according to a preset sparsity threshold;
  • Step S13 extracting second feature information from N consecutive first feature matrices using a pre-trained feature extraction model
  • M represents the sparsity of the i-th first feature matrix q i in the first feature information
  • L K represents the number of first feature matrices in the first feature information
  • k j represents the j-th first feature matrix in the first feature information
  • T represents the matrix transpose.
  • the sparsity of the feature matrix in the first feature information can be measured based on the KL divergence, and then N consecutive first feature matrices are selected as the input of step 103 based on a preset sparsity threshold. That is, the improved calculation formula of self-attention can be:
  • the improved Self-attention mechanism reduces the time complexity and memory overhead and improves the efficiency of feature extraction.
  • step 104 uses the feature extraction model to loop process the second feature information until a loop exit condition is met to obtain third feature information, including:
  • Step S21 extracting features from the second feature information to obtain fourth feature information of the flow data to be detected
  • Step S22 looping the fourth feature information using the feature extraction model until the third feature information is obtained when the loop exit condition is met;
  • F represents the fourth feature information
  • S represents the second feature information
  • Convld represents one-dimensional convolution processing
  • ELU represents activation function
  • MaxPool represents maximum pooling processing.
  • the second feature information is subjected to a "distillation" operation, that is, one-dimensional convolution, activation processing and maximum pooling operations are performed on the second feature information, which helps to extract deeper sequence features of the traffic data and reduce memory usage.
  • the method before extracting the second feature information from the first feature information using a pre-trained feature extraction model in step 103, the method further includes:
  • Step S31 obtaining an initial sample set, wherein the initial sample set includes majority class samples and minority class samples, and the minority class samples constitute a balanced sample set;
  • Step S32 extracting a first sample from the minority class samples
  • Step S33 determining a second sample whose Euclidean distance to the first sample is closest from the minority class samples
  • Step S34 adjusting the balanced sample set according to the number of majority class samples contained in the hypersphere formed by the first sample and the second sample;
  • Step S35 if the number of samples in the balanced sample set and the number of samples in the majority class meet a preset ratio, a final sample set is generated based on the balanced sample set and the majority class samples;
  • Step S36 iteratively train the multi-head self-attention network model based on the final sample set to obtain a feature extraction model for the data to be detected.
  • Network traffic data usually consists of a majority of normal traffic and a minority of abnormal traffic. Therefore, when training a feature extraction model with labeled traffic data, the prediction accuracy of the majority class traffic data can be improved, but the prediction accuracy of the minority class will be very low.
  • the majority class refers to the class with a larger sample size than other classes
  • the minority class refers to the class with a smaller number of samples than the majority class.
  • the majority class samples and minority class samples are used to describe the problem of sample size imbalance between different classes.
  • the samples in the initial sample set are first mapped to the Euclidean space, and the first sample is extracted from the minority class sample.
  • the second sample with the closest Euclidean distance to the first sample is determined from the minority class sample, and then the first sample and the second sample are used to construct a first hypersphere.
  • the Euclidean distance between the first sample and the second sample can be used as the diameter, and the center of the line connecting the first sample and the second sample can be used as the center of the circle to construct the first hypersphere. Interpolation is then performed in the space formed by the first hypersphere to generate a new sample belonging to the minority class, namely the third sample.
  • the present application adds the third sample to the balanced sample set including the initial minority class sample, generates a final sample set based on the balanced sample set and the majority class sample when the number of samples in the balanced sample set and the number of samples in the majority class meet the preset ratio, and finally iteratively trains the multi-head self-attention network model based on the final sample set to obtain a feature extraction model for the data to be detected.
  • the preset ratio can be determined according to actual conditions and is not limited by the present application.
  • the final sample set is encoded and normalized to obtain a final sample set in matrix form, and the sample set can be divided into a training set and a test set according to a certain ratio.
  • a local feature extraction model based on a convolutional neural network can be used to extract the first feature information
  • the training samples in the training set can be used to uniformly train the local feature extraction model of step 102 and the feature extraction model based on the self-attention network in step 103, and then the trained model can be tested using the test samples in the test set.
  • the method further comprises:
  • Step S37 If the number of samples in the balanced sample set does not satisfy the number of samples in the majority class, The preset ratio is achieved by re-extracting the first sample from the minority class samples, and re-adjusting the balanced sample set based on the re-extracted first sample, wherein each minority class sample can only be extracted once.
  • different first hyperspheres are constructed by repeatedly extracting different first samples from the minority class samples, and third samples are generated by interpolation in different first hyperspheres until the number of samples in the balanced sample set and the number of samples in the majority class meet a preset ratio.
  • the step S34 of adjusting the balanced sample set according to the number of majority class samples contained in the hypersphere formed by the first sample and the second sample includes:
  • Step S41 constructing a first hypersphere based on the first sample and the second sample
  • Step S42 adding the majority class samples located in the space formed by the first hypersphere to the first sample set;
  • Step S43 If the first sample set is an empty set, a third sample is generated in the space formed by the first hypersphere, and the third sample is added to the balanced sample set.
  • D represents the initial sample set
  • D- represents the minority class sample
  • D+ represents the majority class sample
  • x i represents the first sample
  • x k represents the second sample
  • CS represents the first sample set
  • C represents the first hypersphere.
  • the majority class samples cannot fall into the space formed by the first hypersphere. Therefore, only when there are no majority class samples in the space formed by the first hypersphere, that is, the first sample set is an empty set, a third sample can be generated in the space formed by the first hypersphere and added to the balanced sample set.
  • the method further comprises:
  • Step S51 if the first sample set is not an empty set, determine a fourth sample from the first sample set that has the shortest Euclidean distance to the first sample;
  • Step S52 constructing a second hypersphere based on the first sample and the fourth sample
  • Step S53 re-determine the first sample set according to the majority class samples located in the space formed by the second hypersphere.
  • y p represents the fourth sample
  • C n represents the nth second hypersphere
  • n is an integer.
  • the first sample set is not an empty set
  • x syn represents the coordinate of the third sample in the Euclidean space
  • xi represents the coordinate of the first sample in the Euclidean space
  • xk represents the coordinate of the second sample in the Euclidean space
  • r represents the radius of the first hypersphere
  • v ⁇ v 1 , ..., v i , ... v d ⁇ , v 1 ⁇ (-1, 1), v i ⁇ (-1, 1), v d ⁇ (-1, 1), 1 ⁇ i ⁇ d, and
  • xk in formula (10) can be replaced by the fourth sample point yp corresponding to the second hypersphere without majority class samples in the internal space.
  • v 1 , vi , and v d can all be random numbers between -1 and 1.
  • generating a final sample set based on the balanced sample set and the majority class samples includes:
  • Step S61 if the number of samples in the balanced sample set and the number of samples in the majority class meet a preset ratio, determine a second sample set corresponding to each majority class sample, the second sample set includes B samples closest to the single majority class sample in the initial sample set, where B is a preset integer;
  • Step S62 Filter safe samples from majority class samples according to the second sample set, wherein there are no minority class samples in the B samples corresponding to the safe samples;
  • Step S63 Generate a final sample set based on the safety sample and the balanced sample set.
  • clustering can be used to calculate the Euclidean distance between each majority class sample and other samples in the initial sample set, and the second sample set corresponding to each majority class sample is determined therefrom, that is, the B samples with the closest Euclidean distance corresponding to a single majority class sample.
  • the attributes of the majority class samples corresponding to the B samples can be determined based on the category composition of the B samples. Specifically, taking the majority class sample A as an example, if the B samples corresponding to A all belong to the majority class, then A can be determined to be a safe sample and can be used for model training; if the B samples corresponding to A all belong to the minority class, then A can be determined to be a noise sample; if the B samples corresponding to A include both majority class samples and minority class samples, then A can be determined to be a boundary sample.
  • the method for generating the balanced sample set is not limited to the method shown in FIG. 7 .
  • the embodiment of the present application provides a network intrusion detection method. After acquiring the traffic data to be detected, the first feature information of the traffic data to be detected is extracted, and the second feature information in the first feature information is extracted using a pre-trained feature extraction model based on a multi-head self-attention network, and the second feature information is cyclically processed using the feature extraction model until the third feature information is obtained when the loop exit condition is met; in each round of the loop, the input data of the feature extraction model is the output data of the previous round; the third feature information is classified and detected to obtain the detection result of the traffic data to be detected.
  • the feature extraction model based on a multi-head self-attention network can be used to effectively learn the dependency characteristics of traffic data, and further based on the feature extraction model
  • the cyclic processing of the second feature information can further improve the accuracy of dependency feature extraction, thereby effectively improving the accuracy of traffic data classification, and then accurately identifying abnormal traffic in network traffic data, reducing the risk of network intrusion.
  • the device 200 may include:
  • the flow data acquisition module 201 is used to acquire the flow data to be detected
  • a first characteristic information extraction module 202 used to extract first characteristic information of the flow data to be detected
  • a second feature information extraction module 203 is used to extract second feature information from the first feature information using a pre-trained feature extraction model, where the feature extraction model is a multi-head self-attention network model;
  • the third feature information extraction module 204 is used to perform a loop processing on the second feature information using the feature extraction model until the loop exit condition is met to obtain the third feature information; in each round of loop, the input data of the feature extraction model is the output data of the previous round;
  • the classification module 205 is used to perform classification detection on the third characteristic information to obtain the detection result of the flow data to be detected.
  • the first characteristic information includes at least one first characteristic matrix
  • the second feature information extraction module includes:
  • a sparsity calculation submodule used to calculate the sparsity of the first feature matrix
  • a screening submodule configured to screen out N consecutive first feature matrices from at least one first feature matrix according to a preset sparsity threshold based on the sparsity of the first feature matrix;
  • a second feature information extraction submodule used to extract second feature information from N consecutive first feature matrices using a pre-trained feature extraction model
  • M represents the sparsity of the i-th first feature matrix q i in the first feature information
  • L K represents the number of first feature matrices in the first feature information
  • k j represents the j-th first feature matrix in the first feature information
  • T represents the matrix transpose.
  • the third feature information extraction module includes:
  • a fourth characteristic information extraction submodule is used to extract characteristics of the second characteristic information to obtain fourth characteristic information of the flow data to be detected;
  • a third feature information extraction submodule used for looping the fourth feature information using the feature extraction model until the third feature information is obtained when a loop exit condition is met;
  • F represents the fourth feature information
  • S represents the second feature information
  • Convld represents one-dimensional convolution processing
  • ELU represents activation function
  • MaxPool represents maximum pooling processing.
  • the device may further include:
  • An initial sample set acquisition module used to acquire an initial sample set before extracting the second feature information in the first feature information using a pre-trained feature extraction model, the initial sample set including majority class samples and minority class samples, and the minority class samples constitute a balanced sample set;
  • a sample extraction module used for extracting a first sample from the minority class samples
  • a second sample determination module used to determine a second sample whose Euclidean distance to the first sample is closest from the minority class samples
  • a balanced sample set adjustment module used to adjust the balanced sample set according to the number of majority class samples contained in the hypersphere formed by the first sample and the second sample;
  • a final sample set generation module used for generating a final sample set based on the balanced sample set and the majority class samples if the number of samples in the balanced sample set and the number of samples in the majority class meet a preset ratio
  • the training module is used to iteratively train the multi-head self-attention network model based on the final sample set to obtain a feature extraction model for the data to be detected.
  • the device may further include:
  • the first loop module is used to re-extract the first sample from the minority class samples if the number of samples in the balanced sample set and the number of samples in the majority class do not meet the preset ratio, and readjust the balanced sample set based on the re-extracted first sample, wherein each minority class sample can only be extracted once.
  • the balanced sample set adjustment module may include:
  • a first hypersphere construction submodule configured to construct a first hypersphere based on the first sample and the second sample
  • a first sample set updating submodule used to add the majority class samples located in the space formed by the first hypersphere to the first sample set
  • the third sample generating submodule is used for generating a third sample in the space formed by the first hypersphere if the first sample set is an empty set, and adding the third sample to the balanced sample set.
  • the balanced sample set adjustment module may also include
  • a fourth sample determination submodule configured to determine, if the first sample set is not an empty set, a fourth sample from the first sample set whose Euclidean distance to the first sample is closest;
  • a second hypersphere construction submodule used to construct a second hypersphere based on the first sample and the fourth sample
  • the second circulation submodule is used to redefine the first sample set according to the majority class samples located in the space formed by the second hypersphere.
  • x syn represents the coordinate of the third sample in the Euclidean space
  • xi represents the coordinate of the first sample in the Euclidean space
  • xk represents the coordinate of the second sample in the Euclidean space
  • r represents the radius of the first hypersphere
  • v ⁇ v 1 , ..., vi , ...v d ⁇ ,v 1 ⁇ (-1,1), vi ⁇ (-1,1),v d ⁇ (-1,1), 1 ⁇ i ⁇ d, and
  • the final sample set generation module may include:
  • a second sample set determination submodule configured to determine a second sample set corresponding to each majority class sample if the number of samples in the balanced sample set and the number of samples in the majority class meet a preset ratio, wherein the second sample set includes B samples closest to the single majority class sample in the initial sample set, where B is a preset integer;
  • a safety sample screening submodule used to screen safety samples from majority class samples according to the second sample set, wherein there are no minority class samples in the B samples corresponding to the safety samples;
  • the final sample set generation submodule is used to generate the final sample set based on the safety sample and the balanced sample set.
  • the electronic device 700 may include one or more of the following components: a processing component 702, a memory 704, a power supply component 706, a multimedia component 708, an audio component 710, an input/output (I/O, Input/Output) interface 712, sensor component 714, and communication component 716.
  • the processing component 702 generally controls the overall operation of the electronic device 700, such as operations associated with display, phone calls, data communications, camera operations, and recording operations.
  • the processing component 702 may include one or more processors 720 to execute instructions to complete all or part of the steps of the above-mentioned network intrusion detection method.
  • the processing component 702 may include one or more modules to facilitate the interaction between the processing component 702 and other components.
  • the processing component 702 may include a multimedia module to facilitate the interaction between the multimedia component 708 and the processing component 702.
  • the memory 704 is configured to store various types of data to support operations on the electronic device 700. Examples of such data include instructions for any application or method operating on the electronic device 700, contact data, phone book data, messages, pictures, videos, etc.
  • the memory 704 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static RAM, referred to as SRAM), electrically erasable programmable read only memory (EEPROM), erasable programmable read only memory (EPROM), programmable read only memory (PROM), read only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
  • SRAM static random access memory
  • EEPROM electrically erasable programmable read only memory
  • EPROM erasable programmable read only memory
  • PROM programmable read only memory
  • ROM read only memory
  • magnetic memory flash memory
  • flash memory magnetic disk or optical disk.
  • the power supply component 706 provides power to the various components of the electronic device 700.
  • the power supply component 706 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 700.
  • the multimedia component 708 includes a screen that provides an output interface between the electronic device 700 and the user.
  • the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user.
  • the touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation.
  • the multimedia component 708 includes a front camera and/or a rear camera. When the electronic device 700 is in an operating mode, such as a shooting mode or a video mode, the front camera and/or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
  • the audio component 710 is configured to output and/or input audio signals.
  • the audio component 710 includes a microphone (MIC), which is configured to receive external audio signals when the electronic device 700 is in an operating mode, such as a call mode, a recording mode, and a voice information processing mode.
  • the received audio signal can be further stored in the memory 704 or sent via the communication component 716.
  • the audio component 710 also includes a speaker for outputting audio signals.
  • I/O interface 712 provides an interface between processing component 702 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
  • the sensor assembly 714 includes one or more sensors for providing various aspects of status assessment for the electronic device 700.
  • the sensor assembly 714 can detect the open/closed state of the electronic device 700, the relative positioning of components, such as the display and keypad of the device 700, and the sensor assembly 714 can also detect the position change of the electronic device 700 or a component of the electronic device 700, the presence or absence of user contact with the electronic device 700, the orientation or acceleration/deceleration of the electronic device 700, and the temperature change of the electronic device 700.
  • the sensor assembly 714 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact.
  • the sensor assembly 714 may also include a light sensor, such as a CMOS (Complementary Metal Oxide Semiconductor) or CCD (Charge-coupled Device) image sensor for use in imaging applications.
  • CMOS Complementary Metal Oxide Semiconductor
  • CCD Charge-coupled Device
  • the sensor assembly 714 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
  • the communication component 716 is configured to facilitate wired or wireless communication between the electronic device 700 and other devices.
  • the electronic device 700 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof.
  • the communication component 716 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel.
  • the communication component 716 also includes a near field communication (NFC) module to facilitate short-range communication.
  • the NFC module can be implemented based on Radio Frequency Identification (RFID) technology, Infrared Data Association (IrDA) technology, Ultra Wide Band (UWB) technology, Bluetooth (BT) technology and other technologies.
  • RFID Radio Frequency Identification
  • IrDA Infrared Data Association
  • UWB Ultra Wide Band
  • Bluetooth Bluetooth
  • the electronic device 700 can be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned network intrusion detection method.
  • ASICs application specific integrated circuits
  • DSPs digital signal processors
  • DSPDs digital signal processing devices
  • PLDs programmable logic devices
  • FPGAs field programmable gate arrays
  • controllers microcontrollers, microprocessors or other electronic components to execute the above-mentioned network intrusion detection method.
  • a non-temporary computer-readable storage medium including instructions is also provided, such as a memory 704 including instructions, and the instructions can be executed by a processor 720 of an electronic device 700 to complete the above-mentioned network intrusion detection method.
  • the non-temporary computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
  • a non-temporary computer-readable storage medium when the instructions in the storage medium are executed by a processor of an electronic device (server or terminal), enables the processor to execute the network intrusion detection method described above.
  • each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments.
  • the same or similar parts between the embodiments can be referred to each other.
  • the description is relatively simple, and the relevant parts can be referred to the method part.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Biophysics (AREA)
  • General Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Artificial Intelligence (AREA)
  • Molecular Biology (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Image Analysis (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

本申请实施例提供了一种网络入侵检测方法、装置、电子设备和可读存储介质,涉及系统安全领域,所述方法包括:获取待检测流量数据;提取所述待检测流量数据的第一特征信息;利用预先训练的特征提取模型提取所述第一特征信息中的第二特征信息,所述特征提取模型为多头自注意力网络模型;利用所述特征提取模型对所述第二特征信息进行循环处理,直至满足循环退出条件时得到第三特征信息;在每一轮循环中,所述特征提取模型的输入数据为上一轮的输出数据;对所述第三特征信息进行分类检测,得到所述待检测流量数据的检测结果。通过上述方法,可以有效提高流量数据分类的准确性,降低网络入侵带来的风险。

Description

网络入侵检测方法、装置、电子设备和可读存储介质
相关申请的交叉引用
本申请要求于2023年04月27日提交中国专利局,申请号为202310365470.7,申请名称为“网络入侵检测方法、装置、电子设备和可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及系统安全领域,尤其涉及一种网络入侵检测方法、装置、电子设备和可读存储介质。
背景技术
随着信息化、数字化的迅猛发展,以云计算为代表的新兴技术产业正备受关注,尽管云计算有着诸多优势,但其一直面临着网络安全问题带来的重大挑战,尤其是异常的流量数据更会导致网络入侵的风险大大提高。
在相关技术中,通常利用卷积神经网络(Convolutional Neural Network,CNN)对网络上的流量数据进行特征提取,进而通过分类识别流量数据是否存在异常。
但是,与其他数据如图像、语音数据不同,由于流量数据的特征比较稀疏,在流量数据序列较长的情况下,基于CNN的流量数据特征在学习流量序列间的依赖关系方面有所欠缺,因此基于CNN的网络检测方法在对检测网络中的流量数据进行分类检测时准确率较低,导致异常流量数据所带来的网络入侵风险较高。
发明内容
本申请实施例提供一种网络入侵检测方法、装置、电子设备和可读存储介质,可以提高对异常流量数据分类的准确性,降低网络入侵带来的风险。
本申请实施例提供了一种网络入侵检测方法,方法包括:
获取待检测流量数据;
提取待检测流量数据的第一特征信息;
利用预先训练的特征提取模型提取第一特征信息中的第二特征信息,特征提取模型为多头自注意力网络模型;
利用特征提取模型对第二特征信息进行循环处理,直至满足循环退出条件时得到第三特征信息;在每一轮循环中,特征提取模型的输入数据为上一轮的输出数据;
对第三特征信息进行分类检测,得到待检测流量数据的检测结果。
可选地,第一特征信息中包括至少一个第一特征矩阵;
利用预先训练的特征提取模型提取第一特征信息中的第二特征信息,包括:
计算第一特征矩阵的稀疏度;
基于第一特征矩阵的稀疏度,按照预设的稀疏度阈值从至少一个第一特征矩阵中筛选出N个连续的第一特征矩阵;
利用预先训练的特征提取模型提取N个连续的第一特征矩阵中的第二特征信息;
其中,稀疏度表示为:
其中,M表示第一特征信息中第i个第一特征矩阵qi的稀疏度,LK表示第一特征信息中第一特征矩阵的个数,kj表示第一特征信息中第j个第一特征矩阵,表示比例因子系数,T表示矩阵转置。
可选地,利用特征提取模型对第二特征信息进行循环处理,直至满足循环退出条件时得到第三特征信息,包括:
对第二特征信息进行特征提取,得到待检测流量数据的第四特征信息;
利用特征提取模型对第四特征信息进行循环处理,直至满足循环退出条件时得到第三特征信息;
其中,第四特征信息表示为:
F=MaxPool(ELU(Convld(S))),
F表示第四特征信息,S表示第二特征信息;Convld表示一维卷积处理,ELU表示激活函数,MaxPool表示最大池化处理。
可选地,利用预先训练的特征提取模型提取第一特征信息中的第二特征信息之前,方法还包括:
获取初始样本集,初始样本集包括多数类样本和少数类样本,少数类样本构成平衡样本集;
从少数类样本中抽取一个第一样本;
从少数类样本中确定与第一样本的欧氏距离最近的第二样本;;
根据第一样本和第二样本构成的超球面中包含的多数类样本的样本数量调整平衡样本集;
若平衡样本集中的样本数与多数类样本的样本数满足预设比例,则基于平衡样本集和多数类样本生成最终样本集;
基于最终样本集对多头自注意力网络模型进行迭代训练,得到待检测数据的特征提取模型。
可选地,方法还包括:
若平衡样本集中的样本数与多数类样本的样本数不满足预设比例,则从少数类样本中重新抽取第一样本,并基于重新抽取的第一样本重新调整平衡样本集,其中,每个少数类样本只能被抽取一次。
可选地,根据第一样本和第二样本构成的超球面中包含的多数类样本的样本数量调整平衡样本集,包括:
基于第一样本和第二样本构建第一超球面;
将位于第一超球面所构成的空间中的多数类样本添加到第一样本集中;
若第一样本集为空集,则在第一超球面所构成的空间中生成一个第三样本,并将第三样本添加到平衡样本集中。
可选地,方法还包括:
若第一样本集不为空集,则从第一样本集中确定与第一样本的欧氏距离最近 的第四样本;
基于第一样本和第四样本构建第二超球面;
根据位于第二超球面所构成的空间中的多数类样本重新确定第一样本集中。
可选地,第三样本满足以下条件:

xsyn=xm+r·v,
其中,xsyn表示第三样本在欧式空间中的坐标,xi表示第一样本在欧式空间中的坐标,xk表示第二样本在欧式空间中的坐标;r表示第一超球面的半径;v={v1,…,vi,…vd},v1∈(-1,1),vi∈(-1,1),vd∈(-1,1),1<i<d,且||v||2<1。
可选地,若平衡样本集中的样本数与多数类样本的样本数满足预设比例,则基于平衡样本集和多数类样本生成最终样本集,包括:
若平衡样本集中的样本数与多数类样本的样本数满足预设比例,确定每个多数类样本所分别对应的第二样本集,第二样本集中包括在初始样本集中距离单个多数类样本最近的B个样本,其中,B为预设的整数;
根据第二样本集,从多数类样本中筛选安全样本,其中,安全样本所对应的B个样本中没有少数类样本;
基于安全样本和平衡样本集生成最终样本集。
本申请实施例提供了一种网络入侵检测装置,装置包括:
流量数据获取模块,用于获取待检测流量数据;
第一特征信息提取模块,用于提取待检测流量数据的第一特征信息;
第二特征信息提取模块,用于利用预先训练的特征提取模型提取第一特征信息中的第二特征信息,特征提取模型为多头自注意力网络模型;
第三特征信息提取模块,用于利用特征提取模型对第二特征信息进行循环处理,直至满足循环退出条件时得到第三特征信息;在每一轮循环中,特征提取模型的输入数据为上一轮的输出数据;
分类模块,用于对第三特征信息进行分类检测,得到待检测流量数据的检测结果。
本申请实施例提供一种电子设备,包括:处理器和存储器,处理器执行存储在存储器中的计算机程序,实现如第一方面的网络入侵检测方法。
本申请实施例提供一种可读存储介质,可读存储介质中存储有计算机指令,计算机指令被处理器执行时实现如第一方面的网络入侵检测方法。
本申请实施例包括以下优点:
综上,本申请实施例提供了一种网络入侵检测方法。在获取待检测流量数据之后,提取待检测流量数据的第一特征信息,利用预先训练的基于多头自注意力网络的特征提取模型提取第一特征信息中的第二特征信息,利用特征提取模型对 第二特征信息进行循环处理,直至满足循环退出条件时得到第三特征信息;在每一轮循环中,特征提取模型的输入数据为上一轮的输出数据;对第三特征信息进行分类检测,得到待检测流量数据的检测结果。在利用卷积神经网络提取流量数据局部特征的基础上,利用基于多头自注意力网络的特征提取模型可以有效学习到流量数据的依赖关系特征,而进一步基于该特征提取模型对第二特征信息的循环处理更可以提高依赖关系特征提取的准确性,从而可以有效提高流量数据分类检测的准确性,进而精确识别出网络流量数据中的异常流量,降低网络入侵带来的风险。
附图说明
为了更清楚地说明本申请实施例的技术方案,下面将对本申请实施例的描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1示出了本申请实施例提供的一种网络入侵检测方法的流程图;
图2示出了本申请实施例提供的一种局部特征提取模型的架构图;
图3示出了本申请实施例提供的一种特征提取模型的架构图;
图4示出了本申请实施例提供的一种循环处理架构图;
图5示出了本申请实施例提供的一种样本处理方法的流程图;
图6示出了本申请实施例提供的一种特征提取模型的训练流程图;
图7示出了本申请实施例提供的另一种数据处理方法的流程图
图8示出了本申请实施例提供的一种网络入侵检测装置的结构框图;
图9示出了本申请实施例提供的电子设备的结构示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。并且,需要说明的是,本申请实施例中获取各种数据相关过程,都是在遵照所在地国家相应的数据保护法规政策的前提下,并获得由相应装置所有者给予授权的情况下进行的。
参照图1所示的本申请实施例提供的一种网络入侵检测方法的流程图,具体可以包括如下步骤:
步骤101、获取待检测流量数据。
流量数据是指网络中用于交互的传输数据。数据在交互过程中,异常的数据往往会导致网络入侵的风险大大提高,因此在进行数据交互过程中,首先需要对传输的数据进行检测,防止获取到异常的数据对本地网络的造成损害,对于获取流量数据的具体方式本申请不作限定。
步骤102、提取所述待检测流量数据的第一特征信息。
其中,第一特征信息是指待检测流量数据的局部特征信息。卷积神经网络、先检测后描述(detect-then-describe)等方法均可以用于提取局部特征,本申请对此不做限定。在本申请实施例中,利用基于卷积神经网络的局部特征提取模型提取第一特征信息。
考虑到流量数据的特征比较稀疏,为了便于后续模型的检测,可以对其进行 编码。在本申请实施例中使用嵌入(embedding)技术来对流量数据进行编码,可以对流量数据进行向量化表示。通过嵌入,待检测流量数据可以被表示为:
E=[e1,e2,…,ei]∈Ri×n,  (1)
其中,i表示待检测流量数据所包含的字节数,n表示嵌入向量的维度,ei表示第i个字节数据被编码后形成的向量。
参照图2所示的本申请实施例提供的一种局部特征提取模型的架构图,在本申请实施例中,局部特征提取模型包含两个卷积层和两个池化层,以及一个全连接层。卷积层的输入是待检测流量数据编码后的矩阵,其经过卷积层处理后可以得到以下结果:
其中,hj是第j层的特征图,j=1,2,3…n。bj是第j层的偏置系数,是卷积运算操作,f(x)是激活函数,本模型采用线性整流单元(ReLU)。为了缩小特征图的大小以及避免过拟合问题,因此在卷积层输出后,紧接着将其输入到池化层,表示为:
hj=pool(hj-1),  (3)
基于CNN的局部特征提取模型可以准确地提取待检测流量数据的局部特征,可以为后续学习流量序列的依赖关系提供良好的数据基础。
步骤103、利用预先训练的特征提取模型提取所述第一特征信息中的第二特征信息,所述特征提取模型为多头自注意力网络模型。
参照图3所示的本申请实施例提供的一种特征提取模型的架构图,在本申请实施例中,采用基于多头自注意力机制的特征提取模型学习待检测流量数据的依赖关系特征即第二特征信息,具体可以通过点积注意力机制计算注意力,其中,多头即heads用于表示自注意力计算的多个注意力头,Q(Query),K(Key),V(Value)分别代表查询,键,值,归一化指数函数是指softmax函数。在本申请实施例中,特征提取模型的输入Q、K、V可以均为步骤102得到的待检测数据的第一特征信息,也可以对第一特征信息进行特征增强、卷积等处理后再分别作为Q、K、V,本申请对此不作限定。
在将第一特征信息输入多头自注意力网络后,可以按照如下公式计算多头自注意力网络的Multi-head Attention:


Multihead(Q,K,V)=Concat(H1,...,Hi)WO,  (6)
其中,表示通过点积自注意力(Scaled Dot-Product Attentiion)方式计算 注意力分数时的比例因子系数;Hi代表多头注意力中第i个头的注意力计算结果,则分别为对应于Q、K、V的转换矩阵,可以进行预先设置或通过预先训练得到;Concat()表示多个注意力头之间的连接函数,WO表示计算Multihead(Q,K,V)的参数矩阵;Multihead(Q,K,V)表示多头自注意力网络的注意力计算结果,即第二特征信息。
利用在自注意力网络基础上利用多头自注意力网络构建特征提取模型,不仅可以充分学习流量序列的依赖关系特征,还可以改善常规的单头注意力单一计算的局限性,多头注意力的计算结果相互佐证,可以有效提高提取流量数据序列的依赖关系特征的准确率,从而提高对于异常流量数据识别的准确性,增强网络安全。
步骤104、利用所述特征提取模型对所述第二特征信息进行循环处理,直至满足循环退出条件时得到第三特征信息;在每一轮循环中,所述特征提取模型的输入数据为上一轮的输出数据。
考虑到流量数据间的复杂关系以及流量数据特征的稀疏性,为了提取流量数据更深层的序列特征,在本申请实施例中,通过堆叠自注意力块(self-attention blocks)基于第二特征信息进行进一步提取待检测流浪数据的第三特征信息。
参照图4所示的本申请实施例提供的一种循环处理架构图,其中,自注意力模型用于表示步骤103基于多头自注意力的特征提取模型,残差相加归一化表示add&norm的处理过程,用于防止由于深度所导致的模型退化问题,保证循环处理的效率不受影响。
在本申请实施例中,利用步骤103的特征提取模型对第二特征信息进行循环处理,即将第二特征信息继续输入特征提取模型进行循环处理,在每一轮循环中,特征提取模型的输入数据为上一轮的输出数据,直到满足循环退出条件时停止输入特征提取模型,最后将Z个自注意力块输出的特征信息经过前馈神经网络处理后,输出第三特征信息。
其中,Z为整数;循环退出条件可以为预先设定的Z次特征提取模型循环,即Z个自注意力块,也可以指第三特征信息达到了某种条件,本申请对此不作限定。
步骤105、对所述第三特征信息进行分类检测,得到所述待检测流量数据的检测结果。
在本申请中,可以利用softmax函数来输出流量类别的概率:
P=σ(F),  (7)
其中,F表示第三特征信息,σ为softmax函数,它可以将前面第三特征信息转换为0-1之间的概率值;P是输出的概率矩阵,用于表示待检测流量数据被识别为对应类型流量的概率,例如当P=[0.6,0.2,0.1,0.05,0.05],对应的流量类型列表为[Nromal,Dos,R2L,Probe,U2R]时,则表示输入的流量被识别为Normal的概率为0.6,Dos的概率为0.2,R2L的概率为0.1,Probe的概率为0.05,U2R的概率为0.05。当P中元素数据越大时,被识别为该类型流量的可能性就越大,例如上述P中最大的是0.6,对应的流量类型是Normal,那么可以认为待检测流量数据是正常的流量;若Dos的概率为0.7,则说明待检测流量数据为拒绝服务攻击流量数据,为异常流量数据。
通过上述方法,在利用卷积神经网络提取流量数据局部特征的基础上,利用基于多头自注意力网络的特征提取模型可以有效学习到流量数据的依赖关系特征,而基于该特征提取模型对第二特征信息的循环处理更可以提高依赖关系特征提取的准确性,从而可以有效提高流量数据分类的准确性,进而精确识别出网络流量数据中的异常流量,降低网络入侵带来的风险。
可选地,第一特征信息中包括至少一个第一特征矩阵;
步骤103所述利用预先训练的特征提取模型提取所述第一特征信息中的第二特征信息,包括:
步骤S11、计算第一特征矩阵的稀疏度;
步骤S12、基于第一特征矩阵的稀疏度,按照预设的稀疏度阈值从至少一个第一特征矩阵中筛选出N个连续的第一特征矩阵;
步骤S13、利用预先训练的特征提取模型提取N个连续的第一特征矩阵中的第二特征信息;
其中,稀疏度表示为:
其中,M表示第一特征信息中第i个第一特征矩阵qi的稀疏度,LK表示第一特征信息中第一特征矩阵的个数,kj表示第一特征信息中第j个第一特征矩阵,表示比例因子系数,T表示矩阵转置。
考虑到Self-attention的概率分布具有潜在的稀疏性,可以基于KL散度度量第一特征信息中特征矩阵的稀疏性,再基于预设的稀疏度阈值筛选N个连续的第一特征矩阵作为步骤103的输入,即改进后的Self-attention的计算公式可以为:
其中,为经过评估函数M(qi,K)计算出来的N个连续的第一特征矩阵。
在保证了能够充分学习到待检测流量数据的依赖关系特征的基础上,改进后的Self-attention机制降低了时间复杂度和内存开销,提高了特征提取效率。
可选地,步骤104利用特征提取模型对第二特征信息进行循环处理,直至满足循环退出条件时得到第三特征信息,包括:
步骤S21、对第二特征信息进行特征提取,得到待检测流量数据的第四特征信息;
步骤S22、利用特征提取模型对第四特征信息进行循环处理,直至满足循环退出条件时得到第三特征信息;
其中,第四特征信息表示为:
F=MaxPool(ELU(Convld(S))),  (10)
F表示第四特征信息,S表示第二特征信息;Convld表示一维卷积处理,ELU表示激活函数,MaxPool表示最大池化处理。
在本申请实施例中,将第二特征信息进行了“蒸馏”操作,即对第二特征信息一维卷积、激活处理和最大池化操作,有助于提取流量数据更深层的序列特征,并减少内存的使用。
可选地,步骤103所述利用预先训练的特征提取模型提取所述第一特征信息中的第二特征信息之前,所述方法还包括:
步骤S31、获取初始样本集,所述初始样本集包括多数类样本和少数类样本,所述少数类样本构成平衡样本集;
步骤S32、从所述少数类样本中抽取一个第一样本;
步骤S33、从所述少数类样本中确定与所述第一样本的欧氏距离最近的第二样本;
步骤S34、根据所述第一样本和所述第二样本构成的超球面中包含的多数类样本的样本数量调整所述平衡样本集;
步骤S35、若所述平衡样本集中的样本数与所述多数类样本的样本数满足预设比例,则基于所述平衡样本集和所述多数类样本生成最终样本集;
步骤S36、基于所述最终样本集对多头自注意力网络模型进行迭代训练,得到待检测数据的特征提取模型。
网络流量数据通常是由多数的正常流量和少数的异常流量组成,因此在通过标签过的流量数据训练特征提取模型时,多数类流量数据的预测精度可以得到提高,但少数类的预测精度会很低。
其中,多数类是指样本量大于其他类别的类别,少数类是相较于多数类样本数较少的类别,多数类样本和少数类样本用于描述不同类别之间样本量不平衡的问题。
参照如图5所示的本申请实施例提供的一种样本处理方法的流程图,为了平衡多数类和少数类流量数据通过插值生成新的样本,首先将初始样本集中的样本映射到欧氏空间中,并从少数类样本抽取第一样本,考虑到噪声样本的影响,在本申请实施例中,从少数类样本中确定与第一样本的欧氏距离最近的第二样本,然后以第一样本和第二样本构建第一超球面,具体地,可以以第一样本与第二样本之间的欧氏距离为直径,以第一样本和第二样本连线的中心为圆心构建第一超球面。再在第一超球面构成的空间内进行插值,从而生成新的属于少数类的样本即第三样本。
本申请通过将第三样本添加到包括初始的少数类样本的平衡样本集中,在平衡样本集中的样本数与多数类样本的样本数满足预设比例的情况下,基于平衡样本集和多数类样本生成最终样本集,最后基于最终样本集对多头自注意力网络模型进行迭代训练,得到待检测数据的特征提取模型。其中,预设比例可以根据实际情况确定,本申请不作限定。
参照如图6所示的本申请实施例提供的一种特征提取模型的训练流程图,在对初始样本集进行如图5所示的样本平衡处理后,将最终样本集进行编码、归一化进而得到矩阵形式的最终样本集,可以按照一定比例将样本集划分为训练集和测试集,考虑到在步骤102中,可以利用基于卷积神经网络的局部特征提取模型提取第一特征信息,因此可以利用训练集中的训练样本对步骤102的局部特征提取模型和步骤103基于自注意力网络的特征提取模型进行统一训练,然后利用测试集中的测试样本对训练好的模型进行测试。
可选地,所述方法还包括:
步骤S37、若所述平衡样本集中的样本数与所述多数类样本的样本数不满足 所述预设比例,则从所述少数类样本中重新抽取第一样本,并基于重新抽取的第一样本重新调整所述平衡样本集,其中,每个少数类样本只能被抽取一次。
为了保证新生成的样本分布均匀,在一个超球面内不适合生成过多的新样本即第三样本,因此在本申请实施例中,通过从少数类样本中反复抽取不同的第一样本来构建不同的第一超球面,并在不同的第一超球面内插值生成第三样本,直到平衡样本集中的样本数与多数类样本的样本数满足预设比例。
可选地,步骤S34所述根据所述第一样本和所述第二样本构成的超球面中包含的多数类样本的样本数量调整所述平衡样本集,包括:
步骤S41、基于第一样本和第二样本构建第一超球面;
步骤S42、将位于第一超球面所构成的空间中的多数类样本添加到第一样本集中;
步骤S43、若第一样本集为空集,则在第一超球面所构成的空间中生成一个第三样本,并将第三样本添加到平衡样本集中。
参照如图7所示的本申请实施例提供的另一种数据处理方法的流程图,其中,D表示初始样本集,D—表示少数类样本,D+表示多数类样本,xi表示第一样本,xk表示第二样本,CS表示第一样本集,C表示第一超球面。
为了保证训练样本的平衡性,确保新生成的第三样本的类别为少数类,那么第一超球面构成的空间中不能落入多数类样本,因此只有在第一超球面所构成的空间中无多数类样本即第一样本集为空集的情况下,可以第一超球面所构成的空间中生成一个第三样本,并将第三样本添加到平衡样本集中。
可选地,方法还包括:
步骤S51、若第一样本集不为空集,则从第一样本集中确定与第一样本的欧氏距离最近的第四样本;
步骤S52、基于第一样本和第四样本构建第二超球面;
步骤S53、根据位于第二超球面所构成的空间中的多数类样本重新确定第一样本集中。
参照如图7所示的本申请实施例提供的另一种数据处理方法的流程图,其中,yp表示第四样本,Cn表示第n个第二超球面,n为整数。
若是第一超球面所构成的空间中存在多数类样本,即第一样本集不为空集,则需要从第一样本集中确定与第一样本的欧氏距离最近的多数类样本即第四样本,再根据第一样本和第四样本构建第二超球面,然后根据第二超球面所构成的空间中的多数类样本重新确定第一样本集,若第一样本集仍然不为空集则继续执行步骤S51-S53,直到第一样本集为空集,从而确保多数类样本不会对新生成的第三样本产生干扰。
可选地,第三样本满足以下条件:

xsyn=xm+r·v,  (11)
其中,xsyn表示第三样本在欧式空间中的坐标,xi表示第一样本在欧式空间中的坐标,xk表示第二样本在欧式空间中的坐标;r表示第一超球面的半径; v={v1,…,vi,…vd},v1∈(-1,1),vi∈(-1,1),vd∈(-1,1),1<i<d,且||v||2<1。
当然,在如步骤S51-S53所示的情况下,公式(10)中的xk可以替换为内部空间中无多数类样本的第二超球面所对应的第四样本点yp
为了新生成的第三样本的随机性,在确定了超球面后,可以在超球面内的任意位置生成第三样本,因此,v1,vi,vd均可以为-1到1之间的随机数。
可选地,若平衡样本集中的样本数与多数类样本的样本数满足预设比例,则基于平衡样本集和多数类样本生成最终样本集,包括:
步骤S61、若平衡样本集中的样本数与多数类样本的样本数满足预设比例,确定每个多数类样本所分别对应的第二样本集,第二样本集中包括在初始样本集中距离单个多数类样本最近的B个样本,其中,B为预设的整数;;
步骤S62、根据第二样本集,从多数类样本中筛选安全样本,其中,安全样本所对应的B个样本中没有少数类样本;
步骤S63、基于安全样本和平衡样本集生成最终样本集。
参照如图7所示的本申请实施例提供的另一种数据处理方法的流程图,考虑到多数类样本可能存在噪声样本会对模型训练产生影响,因此,可以利用聚类计算每个多数类样本与初始样本集中其他样本的欧氏距离,并从中确定每个多数类样本所对应的第二样本集,即单个多数类样本所对应的欧氏距离最近的B个样本。
可以根据B个样本的类别构成确定B个样本所对应的多数类样本的属性。具体地,以多数类样本A为例,若A对应的B个样本均属于多数类,则可以确定A为安全样本,可以用于模型训练;若A对应的B个样本均属于少数类,则可以确定A为噪声样本;若A对应的B个样本中既有多数类样本也有少数类样本,那么可以确定A为边界样本。
考虑到边界样本和噪声样本均可能对模型训练造成干扰,所以仅保留安全样本与平衡样本集构成最终样本集,以保证训练样本的可靠性。在本实施例中,平衡样本集的生成方法不限于如图7所示的方法。
综上,本申请实施例提供了一种网络入侵检测方法。在获取待检测流量数据之后,提取待检测流量数据的第一特征信息,利用预先训练的基于多头自注意力网络的特征提取模型提取第一特征信息中的第二特征信息,利用特征提取模型对第二特征信息进行循环处理,直至满足循环退出条件时得到第三特征信息;在每一轮循环中,特征提取模型的输入数据为上一轮的输出数据;对第三特征信息进行分类检测,得到待检测流量数据的检测结果。在利用卷积神经网络提取流量数据局部特征的基础上,利用基于多头自注意力网络的特征提取模型可以有效学习到流量数据的依赖关系特征,而进一步基于该特征提取模型对第二特征信息的循环处理更可以提高依赖关系特征提取的准确性,从而可以有效提高流量数据分类的准确性,进而精确识别出网络流量数据中的异常流量,降低网络入侵带来的风险。
参照图8,所示的本申请实施例提供的一种网络入侵检测装置的结构框图,装置200可以包括:
流量数据获取模块201,用于获取待检测流量数据;
第一特征信息提取模块202,用于提取待检测流量数据的第一特征信息;
第二特征信息提取模块203,用于利用预先训练的特征提取模型提取第一特征信息中的第二特征信息,特征提取模型为多头自注意力网络模型;
第三特征信息提取模块204,用于利用特征提取模型对第二特征信息进行循环处理,直至满足循环退出条件时得到第三特征信息;在每一轮循环中,特征提取模型的输入数据为上一轮的输出数据;
分类模块205,用于对第三特征信息进行分类检测,得到待检测流量数据的检测结果。
可选地,第一特征信息中包括至少一个第一特征矩阵;
第二特征信息提取模块包括:
稀疏度计算子模块,用于计算第一特征矩阵的稀疏度;
筛选子模块,用于基于第一特征矩阵的稀疏度,按照预设的稀疏度阈值从至少一个第一特征矩阵中筛选出N个连续的第一特征矩阵;
第二特征信息提取子模块,用于利用预先训练的特征提取模型提取N个连续的第一特征矩阵中的第二特征信息;
其中,稀疏度表示为:
其中,M表示第一特征信息中第i个第一特征矩阵qi的稀疏度,LK表示第一特征信息中第一特征矩阵的个数,kj表示第一特征信息中第j个第一特征矩阵,表示比例因子系数,T表示矩阵转置。
可选地,第三特征信息提取模块,包括:
第四特征信息提取子模块,用于对第二特征信息进行特征提取,得到待检测流量数据的第四特征信息;
第三特征信息提取子模块,用于利用特征提取模型对第四特征信息进行循环处理,直至满足循环退出条件时得到第三特征信息;
其中,第四特征信息表示为:
F=MaxPool(ELU(Convld(S))),
F表示第四特征信息,S表示第二特征信息;Convld表示一维卷积处理,ELU表示激活函数,MaxPool表示最大池化处理。
可选地,装置还可以包括:
初始样本集获取模块,用于在利用预先训练的特征提取模型提取第一特征信息中的第二特征信息之前,获取初始样本集,初始样本集包括多数类样本和少数类样本,少数类样本构成平衡样本集;
样本抽取模块,用于从少数类样本中抽取一个第一样本;
第二样本确定模块,用于从少数类样本中确定与第一样本的欧氏距离最近的第二样本;
平衡样本集调整模块,用于根据第一样本和第二样本构成的超球面中包含的多数类样本的样本数量调整平衡样本集;
最终样本集生成模块,用于若平衡样本集中的样本数与多数类样本的样本数满足预设比例,则基于平衡样本集和多数类样本生成最终样本集;
训练模块,用于基于最终样本集对多头自注意力网络模型进行迭代训练,得到待检测数据的特征提取模型。
可选地,装置还可以包括:
第一循环模块,用于若平衡样本集中的样本数与多数类样本的样本数不满足预设比例,则从少数类样本中重新抽取第一样本,并基于重新抽取的第一样本重新调整平衡样本集,其中,每个少数类样本只能被抽取一次。
可选地,平衡样本集调整模块,可以包括:
第一超球面构建子模块,用于基于第一样本和第二样本构建第一超球面;
第一样本集更新子模块,用于将位于第一超球面所构成的空间中的多数类样本添加到第一样本集中;
第三样本生成子模块,用于若第一样本集为空集,则在第一超球面所构成的空间中生成一个第三样本,并将第三样本添加到平衡样本集中。
可选地,平衡样本集调整模块,还可以包括
第四样本确定子模块,用于若第一样本集不为空集,则从第一样本集中确定与第一样本的欧氏距离最近的第四样本;
第二超球面构建子模块,用于基于第一样本和第四样本构建第二超球面;
第二循环子模块,用于根据位于第二超球面所构成的空间中的多数类样本重新确定第一样本集中。
可选地,第三样本满足以下条件:

xsyn=xm+r·v,
其中,xsyn表示第三样本在欧式空间中的坐标,xi表示第一样本在欧式空间中的坐标,xk表示第二样本在欧式空间中的坐标;r表示第一超球面的半径;v={v1,…,vi,…vd},v1∈(-1,1),vi∈(-1,1),vd∈(-1,1),1<i<d,且||v||2<1。
可选地,最终样本集生成模块,可以包括:
第二样本集确定子模块,用于若平衡样本集中的样本数与多数类样本的样本数满足预设比例,确定每个多数类样本所分别对应的第二样本集,第二样本集中包括在初始样本集中距离单个多数类样本最近的B个样本,其中,B为预设的整数;
安全样本筛选子模块,用于根据第二样本集,从多数类样本中筛选安全样本,其中,安全样本所对应的B个样本中没有少数类样本;
最终样本集生成子模块,用于基于安全样本和平衡样本集生成最终样本集。
参照图9,电子设备700可以包括以下一个或多个组件:处理组件702,存储器704,电源组件706,多媒体组件708,音频组件710,输入/输出(I/O, Input/Output,输入/输出)的接口712,传感器组件714,以及通信组件716。
处理组件702通常控制电子设备700的整体操作,诸如与显示,电话呼叫,数据通信,相机操作和记录操作相关联的操作。处理元件702可以包括一个或多个处理器720来执行指令,以完成上述的网络入侵检测方法的全部或部分步骤。此外,处理组件702可以包括一个或多个模块,便于处理组件702和其他组件之间的交互。例如,处理组件702可以包括多媒体模块,以方便多媒体组件708和处理组件702之间的交互。
存储器704被配置为存储各种类型的数据以支持在电子设备700的操作。这些数据的示例包括用于在电子设备700上操作的任何应用程序或方法的指令,联系人数据,电话簿数据,消息,图片,视频等。存储器704可以由任何类型的易失性或非易失性存储设备或者它们的组合实现,如静态随机存取存储器(Static RAM,简称SRAM),电可擦除可编程只读存储器(Electrically Erasable Programmable read only memory,简称EEPROM),可擦除可编程只读存储器(Erasable Programmable Read Only Memory,简称EPROM),可编程只读存储器(Programmable Read Only Memory,简称PROM),只读存储器(Read Only Memory,简称ROM),磁存储器,快闪存储器,磁盘或光盘。
电源组件706为电子设备700的各种组件提供电力。电源组件706可以包括电源管理系统,一个或多个电源,及其他与为电子设备700生成、管理和分配电力相关联的组件。
多媒体组件708包括在电子设备700和用户之间的提供一个输出接口的屏幕。在一些实施例中,屏幕可以包括液晶显示器(Liquid Crystal Display,简称LCD)和触摸面板(Touch Panel,简称TP)。如果屏幕包括触摸面板,屏幕可以被实现为触摸屏,以接收来自用户的输入信号。触摸面板包括一个或多个触摸传感器以感测触摸、滑动和触摸面板上的手势。触摸传感器可以不仅感测触摸或滑动动作的边界,而且还检测与触摸或滑动操作相关的持续时间和压力。在一些实施例中,多媒体组件708包括一个前置摄像头和/或后置摄像头。当电子设备700处于操作模式,如拍摄模式或视频模式时,前置摄像头和/或后置摄像头可以接收外部的多媒体数据。每个前置摄像头和后置摄像头可以是一个固定的光学透镜系统或具有焦距和光学变焦能力。
音频组件710被配置为输出和/或输入音频信号。例如,音频组件710包括一个麦克风(Microphone,简称MIC),当电子设备700处于操作模式,如呼叫模式、记录模式和语音信息处理模式时,麦克风被配置为接收外部音频信号。所接收的音频信号可以被进一步存储在存储器704或经由通信组件716发送。在一些实施例中,音频组件710还包括一个扬声器,用于输出音频信号。
I/O接口712为处理组件702和外围接口模块之间提供接口,上述外围接口模块可以是键盘,点击轮,按钮等。这些按钮可包括但不限于:主页按钮、音量按钮、启动按钮和锁定按钮。
传感器组件714包括一个或多个传感器,用于为电子设备700提供各个方面的状态评估。例如,传感器组件714可以检测到电子设备700的打开/关闭状态,组件的相对定位,例如组件为装置700的显示器和小键盘,传感器组件714还可以检测电子设备700或电子设备700一个组件的位置改变,用户与电子设备700接触的存在或不存在,电子设备700方位或加速/减速和电子设备700的温度变化。传感器组件714可以包括接近传感器,被配置用来在没有任何的物理接触时检测附近物体的存在。传感器组件714还可以包括光传感器,如CMOS (Complementary Metal Oxide Semiconductor,互补金属氧化物半导体)或CCD(Charge-coupled Device,电荷耦合元件)图像传感器,用于在成像应用中使用。在一些实施例中,该传感器组件714还可以包括加速度传感器,陀螺仪传感器,磁传感器,压力传感器或温度传感器。
通信组件716被配置为便于电子设备700和其他设备之间有线或无线方式的通信。电子设备700可以接入基于通信标准的无线网络,如WiFi,2G或3G,或它们的组合。在一个示例性实施例中,通信组件716经由广播信道接收来自外部广播管理系统的广播信号或广播相关信息。在一个示例性实施例中,通信组件716还包括近场通信(Near Field Communication,简称NFC)模块,以促进短程通信。例如,在NFC模块可基于射频信息处理(Radio Frequency Identification,简称RFID)技术,红外数据协会(Infrared Data Association,简称IrDA)技术,超宽带(Ultra Wide Band,简称UWB)技术,蓝牙(BlueTooth,简称BT)技术和其他技术来实现。
在示例性实施例中,电子设备700可以被一个或多个应用专用集成电路(Application Specific Integrated Circuit,简称ASIC)、数字信号处理器(Digital Signal Processing,简称DSP)、数字信号处理设备(Digital Signal Processing Device,简称DSPD)、可编程逻辑器件(Programmable Logic Device,简称PLD)、现场可编程门阵列(Field Programmable Gate Array,简称FPGA)、控制器、微控制器、微处理器或其他电子元件实现,用于执行上述网络入侵检测方法。
在示例性实施例中,还提供了一种包括指令的非临时性计算机可读存储介质,例如包括指令的存储器704,上述指令可由电子设备700的处理器720执行以完成上述网络入侵检测方法。例如,非临时性计算机可读存储介质可以是ROM、随机存取存储器(Random Access Memory,简称RAM)、CD-ROM、磁带、软盘和光数据存储设备等。
一种非临时性计算机可读存储介质,当存储介质中的指令由电子设备(服务器或者终端)的处理器执行时,使得处理器能够执行前文的网络入侵检测方法。
本说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其它实施例的不同之处,各个实施例之间相同或相似部分互相参见即可。对于实施例公开的装置而言,由于其与实施例公开的方法相对应,所以描述的比较简单,相关之处参见方法部分说明即可。
最后,还需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性地包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括要素的过程、方法、物品或者设备中还存在另外的相同要素。
以上对本申请所提供的一种网络入侵检测方法、装置、电子设备和可读存储介质进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的一般技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上,本说明书内容不应理解为对本申请的限制。

Claims (15)

  1. 一种网络入侵检测方法,其特征在于,所述方法包括:
    获取待检测流量数据;
    提取所述待检测流量数据的第一特征信息;
    利用预先训练的特征提取模型提取所述第一特征信息中的第二特征信息,所述特征提取模型为多头自注意力网络模型;
    利用所述特征提取模型对所述第二特征信息进行循环处理,直至满足循环退出条件时得到第三特征信息;在每一轮循环中,所述特征提取模型的输入数据为上一轮的输出数据;
    对所述第三特征信息进行分类检测,得到所述待检测流量数据的检测结果。
  2. 根据权利要求1所述的方法,其特征在于,所述第一特征信息中包括至少一个第一特征矩阵;
    所述利用预先训练的特征提取模型提取所述第一特征信息中的第二特征信息,包括:
    计算所述第一特征矩阵的稀疏度;
    基于所述第一特征矩阵的稀疏度,按照预设的稀疏度阈值从所述至少一个第一特征矩阵中筛选出N个连续的第一特征矩阵;
    利用预先训练的特征提取模型提取所述N个连续的第一特征矩阵中的第二特征信息;
    其中,所述稀疏度表示为:
    其中,M表示所述第一特征信息中第i个第一特征矩阵qi的稀疏度,LK表示所述第一特征信息中第一特征矩阵的个数,kj表示所述第一特征信息中第j个第一特征矩阵,表示比例因子系数,T表示矩阵转置。
  3. 根据权利要求1所述的方法,其特征在于,所述利用所述特征提取模型对所述第二特征信息进行循环处理,直至满足循环退出条件时得到第三特征信息,包括:
    对所述第二特征信息进行特征提取,得到所述待检测流量数据的第四特征信息;
    利用所述特征提取模型对所述第四特征信息进行循环处理,直至满足循环退出条件时得到第三特征信息;
    其中,所述第四特征信息表示为:
    F=MaxPool(ELU(Convld(S))),
    F表示所述第四特征信息,S表示所述第二特征信息;Convld表示一维卷积处理,ELU表示激活函数,MaxPool表示最大池化处理。
  4. 根据权利要求1所述的方法,其特征在于,所述利用预先训练的特征提取模型提取所述第一特征信息中的第二特征信息之前,所述方法还包括:
    获取初始样本集,所述初始样本集包括多数类样本和少数类样本,所述少数 类样本构成平衡样本集;
    从所述少数类样本中抽取一个第一样本;
    从所述少数类样本中确定与所述第一样本的欧氏距离最近的第二样本;
    根据所述第一样本和所述第二样本构成的超球面中包含的多数类样本的样本数量调整所述平衡样本集;
    若所述平衡样本集中的样本数与所述多数类样本的样本数满足预设比例,则基于所述平衡样本集和所述多数类样本生成最终样本集;
    基于所述最终样本集对多头自注意力网络模型进行迭代训练,得到待检测数据的特征提取模型。
  5. 根据权利要求4所述方法,其特征在于,所述方法还包括:
    若所述平衡样本集中的样本数与所述多数类样本的样本数不满足所述预设比例,则从所述少数类样本中重新抽取第一样本,并基于重新抽取的第一样本重新调整所述平衡样本集,其中,每个少数类样本只能被抽取一次。
  6. 根据权利要求4所述的方法,其特征在于,所述根据所述第一样本和所述第二样本构成的超球面中包含的多数类样本的样本数量调整所述平衡样本集,包括:
    基于所述第一样本和所述第二样本构建第一超球面;
    将位于所述第一超球面所构成的空间中的多数类样本添加到第一样本集中;
    若所述第一样本集为空集,则在所述第一超球面所构成的空间中生成一个第三样本,并将所述第三样本添加到所述平衡样本集中。
  7. 根据权利要求6所述的方法,其特征在于,所述方法还包括:
    若所述第一样本集不为空集,则从所述第一样本集中确定与所述第一样本的欧氏距离最近的第四样本;
    基于所述第一样本和所述第四样本构建第二超球面;
    根据位于所述第二超球面所构成的空间中的多数类样本重新确定第一样本集中。
  8. 根据权利要求6所述的方法,其特征在于,所述第三样本满足以下条件:

    xsyn=xm+r·v,
    其中,xsyn表示第三样本在欧式空间中的坐标,xi表示第一样本在欧式空间中的坐标,xk表示第二样本在欧式空间中的坐标;r表示所述第一超球面的半径;v={v1,…,vi,…vd},v1∈(-1,1),vi∈(-1,1),vd∈(-1,1),1<i<d,且||v||2<1。
  9. 根据权利要求4所述的方法,其特征在于,所述若所述平衡样本集中的样本数与所述多数类样本的样本数满足预设比例,则基于所述平衡样本集和所述多数类样本生成最终样本集,包括:
    若所述平衡样本集中的样本数与所述多数类样本的样本数满足预设比例,确 定每个多数类样本所分别对应的第二样本集,所述第二样本集中包括在所述初始样本集中距离单个多数类样本最近的B个样本,其中,B为预设的整数;
    根据所述第二样本集,从所述多数类样本中筛选安全样本,其中,所述安全样本所对应的B个样本中没有少数类样本;
    基于所述安全样本和所述平衡样本集生成最终样本集。
  10. 一种网络入侵检测装置,其特征在于,所述装置包括:
    流量数据获取模块,用于获取待检测流量数据;
    第一特征信息提取模块,用于提取所述待检测流量数据的第一特征信息;
    第二特征信息提取模块,用于利用预先训练的特征提取模型提取所述第一特征信息中的第二特征信息,所述特征提取模型为多头自注意力网络模型;
    第三特征信息提取模块,用于利用所述特征提取模型对所述第二特征信息进行循环处理,直至满足循环退出条件时得到第三特征信息;在每一轮循环中,所述特征提取模型的输入数据为上一轮的输出数据;
    分类模块,用于对所述第三特征信息进行分类检测,得到所述待检测流量数据的检测结果。
  11. 根据权利要求10所述的装置,其特征在于,所述第一特征信息中包括至少一个第一特征矩阵;
    所述第二特征信息提取模块包括:
    稀疏度计算子模块,用于计算所述第一特征矩阵的稀疏度;
    筛选子模块,用于基于所述第一特征矩阵的稀疏度,按照预设的稀疏度阈值从所述至少一个第一特征矩阵中筛选出N个连续的第一特征矩阵;
    第二特征信息提取子模块,用于利用预先训练的特征提取模型提取所述N个连续的第一特征矩阵中的第二特征信息;
    其中,所述稀疏度表示为:
    其中,M表示所述第一特征信息中第i个第一特征矩阵qi的稀疏度,LK表示所述第一特征信息中第一特征矩阵的个数,kj表示所述第一特征信息中第j个第一特征矩阵,表示比例因子系数,T表示矩阵转置。
  12. 根据权利要求10所述的装置,其特征在于,所述装置还包括:
    初始样本集获取模块,用于在利用预先训练的特征提取模型提取所述第一特征信息中的第二特征信息之前,获取初始样本集,所述初始样本集包括多数类样本和少数类样本,所述少数类样本构成平衡样本集;
    样本抽取模块,用于从所述少数类样本中抽取一个第一样本;
    第二样本确定模块,用于从所述少数类样本中确定与所述第一样本的欧式距离最近的第二样本;
    平衡样本集调整模块,用于根据所述第一样本和所述第二样本构成的超球面中包含的多数类样本的样本数量调整所述平衡样本集;
    最终样本集生成模块,用于若所述平衡样本集中的样本数与所述多数类样本的样本数满足预设比例,则基于所述平衡样本集和所述多数类样本生成最终样本 集;
    训练模块,用于基于所述最终样本集对多头自注意力网络模型进行迭代训练,得到待检测数据的特征提取模型。
  13. 根据权利要求12所述的装置,其特征在于,所述最终样本集生成模块,包括:
    第二样本集确定子模块,用于若所述平衡样本集中的样本数与所述多数类样本的样本数满足预设比例,确定每个多数类样本所分别对应的第二样本集,所述第二样本集中包括在所述初始样本集中距离单个多数类样本最近的B个样本,其中,B为预设的整数;
    安全样本筛选子模块,用于根据所述第二样本集,从所述多数类样本中筛选安全样本,其中,所述安全样本所对应的B个样本中没有少数类样本;
    最终样本集生成子模块,用于基于所述安全样本和所述平衡样本集生成最终样本集。
  14. 一种电子设备,其特征在于,包括:处理器和存储器,所述处理器执行存储在所述存储器中的计算机程序,实现权利要求1至9中任一项所述的网络入侵检测方法。
  15. 一种可读存储介质,其特征在于,当所述存储介质中的指令由装置的处理器执行时,使得装置能够执行如方法权利要求1至9中任一所述的网络入侵检测方法。
PCT/CN2023/139627 2023-04-07 2023-12-18 网络入侵检测方法、装置、电子设备和可读存储介质 Ceased WO2024207804A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202310365470.7A CN116112288B (zh) 2023-04-07 2023-04-07 网络入侵检测方法、装置、电子设备和可读存储介质
CN202310365470.7 2023-04-07

Publications (1)

Publication Number Publication Date
WO2024207804A1 true WO2024207804A1 (zh) 2024-10-10

Family

ID=86261851

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/139627 Ceased WO2024207804A1 (zh) 2023-04-07 2023-12-18 网络入侵检测方法、装置、电子设备和可读存储介质

Country Status (2)

Country Link
CN (1) CN116112288B (zh)
WO (1) WO2024207804A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119835693A (zh) * 2025-03-17 2025-04-15 深圳市启明智显科技有限公司 一种流量分配方法、装置、终端设备及存储介质

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116112288B (zh) * 2023-04-07 2023-08-04 天翼云科技有限公司 网络入侵检测方法、装置、电子设备和可读存储介质
CN117749653A (zh) * 2024-01-02 2024-03-22 人工智能与数字经济广东省实验室(深圳) 一种QoS预测方法、装置、电子设备及可读存储介质

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109871901A (zh) * 2019-03-07 2019-06-11 中南大学 一种基于混合采样和机器学习的不平衡数据分类方法
CN111160343A (zh) * 2019-12-31 2020-05-15 华南理工大学 一种基于Self-Attention的离线数学公式符号识别方法
US20200322362A1 (en) * 2019-04-05 2020-10-08 Hoseo University Academic Cooperation Foundation Deep-learning-based intrusion detection method, system and computer program for web applications
CN113723440A (zh) * 2021-06-17 2021-11-30 北京工业大学 一种云平台上加密tls应用流量分类方法及系统
CN113823264A (zh) * 2021-06-30 2021-12-21 腾讯科技(深圳)有限公司 语音识别方法、装置、计算机可读存储介质及计算机设备
CN114048468A (zh) * 2021-11-19 2022-02-15 北京天融信网络安全技术有限公司 入侵检测的方法、入侵检测模型训练的方法、装置及介质
CN116112288A (zh) * 2023-04-07 2023-05-12 天翼云科技有限公司 网络入侵检测方法、装置、电子设备和可读存储介质

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110875912A (zh) * 2018-09-03 2020-03-10 中移(杭州)信息技术有限公司 一种基于深度学习的网络入侵检测方法、装置和存储介质
CN111651558B (zh) * 2020-05-09 2023-04-07 清华大学深圳国际研究生院 基于预训练语义模型的超球面协同度量推荐装置和方法
CN113542241B (zh) * 2021-06-30 2023-05-09 杭州电子科技大学 一种基于CNN-BiGRU混合模型的入侵检测方法及装置
CN114462520B (zh) * 2022-01-25 2024-12-31 北京工业大学 一种基于流量分类的网络入侵检测方法

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109871901A (zh) * 2019-03-07 2019-06-11 中南大学 一种基于混合采样和机器学习的不平衡数据分类方法
US20200322362A1 (en) * 2019-04-05 2020-10-08 Hoseo University Academic Cooperation Foundation Deep-learning-based intrusion detection method, system and computer program for web applications
CN111160343A (zh) * 2019-12-31 2020-05-15 华南理工大学 一种基于Self-Attention的离线数学公式符号识别方法
CN113723440A (zh) * 2021-06-17 2021-11-30 北京工业大学 一种云平台上加密tls应用流量分类方法及系统
CN113823264A (zh) * 2021-06-30 2021-12-21 腾讯科技(深圳)有限公司 语音识别方法、装置、计算机可读存储介质及计算机设备
CN114048468A (zh) * 2021-11-19 2022-02-15 北京天融信网络安全技术有限公司 入侵检测的方法、入侵检测模型训练的方法、装置及介质
CN116112288A (zh) * 2023-04-07 2023-05-12 天翼云科技有限公司 网络入侵检测方法、装置、电子设备和可读存储介质

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119835693A (zh) * 2025-03-17 2025-04-15 深圳市启明智显科技有限公司 一种流量分配方法、装置、终端设备及存储介质

Also Published As

Publication number Publication date
CN116112288A (zh) 2023-05-12
CN116112288B (zh) 2023-08-04

Similar Documents

Publication Publication Date Title
TWI759722B (zh) 神經網路訓練方法及裝置、圖像處理方法及裝置、電子設備和計算機可讀存儲介質
CN109829433B (zh) 人脸图像识别方法、装置、电子设备及存储介质
CN116112288B (zh) 网络入侵检测方法、装置、电子设备和可读存储介质
EP3855360A1 (en) Method and device for training image recognition model, and storage medium
CN113868497A (zh) 一种数据分类方法、装置和存储介质
CN109389162B (zh) 样本图像筛选方法和装置、电子设备及存储介质
CN111259967B (zh) 图像分类及神经网络训练方法、装置、设备及存储介质
CN111583907A (zh) 信息处理方法、装置及存储介质
CN112926339A (zh) 文本相似度确定方法、系统、存储介质以及电子设备
TWI735112B (zh) 圖像生成方法、電子設備和儲存介質
WO2017071083A1 (zh) 指纹识别方法及装置
CN120342715B (zh) 基于多模态行为融合的通讯风险识别方法及系统
CN111583919A (zh) 信息处理方法、装置及存储介质
CN115222991B (zh) 分类模型的训练方法、图像分类方法、装置及电子设备
CN109271552A (zh) 通过图片检索视频的方法、装置、电子设备及存储介质
CN114446318B (zh) 音频数据分离方法、装置、电子设备及存储介质
CN115146633A (zh) 一种关键词识别方法、装置、电子设备及存储介质
CN111209429A (zh) 用于度量语音数据库覆盖性的无监督模型训练方法及装置
CN110162939A (zh) 人机识别方法、设备和介质
CN112884040A (zh) 训练样本数据的优化方法、系统、存储介质及电子设备
CN112036507A (zh) 图像识别模型的训练方法、装置、存储介质和电子设备
CN116260907B (zh) 一种异常号码识别方法、装置、电子设备及存储介质
CN110070046A (zh) 人脸图像识别方法及装置、电子设备和存储介质
CN108256542A (zh) 一种通信标识的特征确定方法、装置及设备
CN113742199A (zh) 功能测试方法、装置、电子设备和存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23931849

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE