Network intrusion detection method, system and medium based on graph anomaly detection algorithm

By constructing a network flow graph and using a graph autoencoder for encoding and decoding based on the graph anomaly detection algorithm, the problems of low network intrusion detection efficiency and imperfect behavioral modeling in the existing technology are solved, and the network flow graph is constructed in a complex network environment. Efficient detection of malicious traffic.

CN118118274BActive Publication Date: 2024-10-18HARBIN INSTITUTE OF TECHNOLOGY (SHENZHEN) (INSTITUTE OF SCIENCE AND TECHNOLOGY INNOVATION HARBIN INSTITUTE OF TECHNOLOGY SHENZHEN)

Patent Information

Application Number
CN202410445603.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-15
Publication Date
2024-10-18
Estimated Expiration
2044-04-15

AI Technical Summary

Technical Problem

Existing network intrusion detection methods are inefficient when processing encrypted traffic, and due to imperfect behavior modeling and lack of annotated data, the detection effect is limited, especially in complex network environments, it is difficult to effectively distinguish between benign and malicious behaviors.

Method used

Using a method based on graph anomaly detection algorithm, network traffic data packets are aggregated into network flows according to quintuple, constructing the same origin and same destination network flow graph, and using graph autoencoder for encoding and decoding, through similarity calculation and decoding error Determine abnormal traffic and implement unsupervised learning to distinguish benign and malicious behaviors.

Benefits of technology

It improves the accuracy and detection efficiency of network traffic behavior modeling, reduces the dependence on high-quality annotated data, adapts to the characteristics of single-step attacks in complex network environments, and enhances the detection capabilities of malicious traffic.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118118274B_ABST
    Figure CN118118274B_ABST
Patent Text Reader

Abstract

The present invention provides a network intrusion detection method, system and medium based on a graph anomaly detection algorithm, the method comprising: aggregating network traffic data packets into network flows according to five-tuples for different protocols, the five-tuples comprising source IP address, source port number, destination IP address, destination port number and transport layer protocol; using the aggregated network flows to construct a homologous network flow graph and a homologous network flow graph, and using similarity calculation to reduce the scale of the homologous network flow graph and the homologous network flow graph; using a graph autoencoder to encode and decode the homologous network flow graph and the homologous network flow graph, and finally obtaining an abnormal score for each network flow, and then judging whether it is abnormal malicious traffic according to the abnormal score of each network flow. The present invention can fully model the relationship between network flows.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technologies such as network intrusion detection, and in particular to a network intrusion detection method, system and medium based on a graph anomaly detection algorithm. Background Art

[0002] The Network Intrusion Detection System (NIDS) detects various malicious behavior patterns in the network system and is a feasible solution for protecting the target network. In the research on network traffic-side attacks, the traditional method often uses deep packet inspection technology (DPI) to check all data packets in the network traffic. However, in the current network environment, encrypted traffic accounts for a large proportion. This method cannot handle encrypted traffic. In actual network communications, data is streamed. This method has a high overhead for detecting each data packet and cannot adapt well to the actual network environment where the current network topology is becoming more complex and the amount of data exchange is becoming larger.

[0003] In response to the problems existing in deep packet inspection technology, the existing solutions are mainly to aggregate network traffic into network flows and use network flow-level statistical features for intrusion detection. When aggregating network flows, a five-tuple (source IP address, source port number, destination IP address, destination port number, transport layer protocol) is often used to aggregate data packets. The network flow-level features adopted include statistical features such as the number of data packets and flow duration. Since the specific information in the data packet is not used, it has the ability to detect both encrypted and non-encrypted traffic, which is more suitable for the current network environment, and the cost of calculating statistical features is much smaller than that of detecting each data packet. However, due to the coarse granularity of network flow-level statistical features, attackers can forge statistical features similar to benign traffic by doping benign traffic, so as to evade detection. In order to avoid this situation, current research has also used network flow-level data to construct a communication behavior graph in the network to better model the behavior of communication entities in the network. The current method mainly uses the communication entities in the network, namely the IP address and port number, as nodes, and the network flow between two nodes as edges to construct a graph, and uses graph deep learning and other methods on the graph to classify different behaviors in the network. However, existing research mainly uses the structure of the graph to calculate the attributes, and does not analyze the behavior in the graph from the perspective of the graph structure. Therefore, its ability to model the behavior of communication entities in the network is limited, and it cannot well represent its communication behavior. In addition, different researchers use different composition methods for different scenarios, so it is necessary to find a more general way to represent the communication behavior in the network to achieve better detection results. In addition, in existing behavioral analysis research, supervised learning is often used to train the model, which requires relying on sample labels. However, in the field of network security, the labeled data of various attack categories is not abundant, and high-quality attack labeled data is even scarcer, which will result in insufficient learning samples and poor model generalization.

[0004] Existing network intrusion detection methods have problems such as imperfect behavior modeling and a small amount of data cannot support supervised model learning. Therefore, it is an urgent issue to design an intrusion detection model that can learn massive benign data in an unsupervised learning manner and effectively distinguish between benign and malicious behaviors in network traffic. Summary of the invention

[0005] The main purpose of the present invention is to provide a network intrusion detection method, system and medium based on a graph anomaly detection algorithm, aiming to fully model the relationship between network flows.

[0006] In order to achieve the above object, the present invention proposes a network intrusion detection method based on a graph anomaly detection algorithm, the method comprising the following steps:

[0007] Step S10, aggregating network traffic data packets into network flows according to five-tuples for different protocols, wherein the five-tuples include a source IP address, a source port number, a destination IP address, a destination port number, and a transport layer protocol;

[0008] Step S20, using the aggregated network flows to construct a homologous network flow graph and a homologous network flow graph, and using similarity calculation to reduce the scale of the homologous network flow graph and the homologous network flow graph;

[0009] Step S30, use the graph autoencoder to encode and decode the same-source network flow graph and the same-destination network flow graph, and finally obtain the anomaly score of each network flow, and then determine whether it is abnormal malicious traffic based on the anomaly score of each network flow.

[0010] A further technical solution of the present invention is that step S10 comprises:

[0011] Step S101, sequentially read data packets from a pcap file storing network traffic data packets and initially construct a network flow according to five-tuples, while recording the data packet size and data packet arrival time information;

[0012] Step S102, determining whether to construct a bidirectional flow or a unidirectional flow according to the characteristics of different transport layer protocols;

[0013] Step S103, record the statistical features of each network flow, extract n network flows from the network traffic, and record their features as .

[0014] A further technical solution of the present invention is that in step S102:

[0015] When the transport layer protocol is TCP, a bidirectional flow is constructed, that is, the data packets sent to each other by both ends of the TCP protocol connection are counted into one flow, and the IP address and port number of the initial connection application are used as the source IP address and source port number of the entire flow. At the same time, the flag bit is monitored. Both parties use SYN to establish a connection to initialize the flow, and use FIN to disconnect or RST to reset to end the flow. At the same time, a time threshold is set. When the duration of the entire flow exceeds the threshold, the flow is terminated, and it is considered that the capture device has failed to capture the disconnected data packets;

[0016] When the transport layer protocol is the UDP protocol, a unidirectional flow is constructed, and only the time threshold is used for cutoff.

[0017] A further technical solution of the present invention is that step S20 comprises:

[0018] Step S201, using the aggregated network flow, obtaining its source IP address and source port number from its quintuple as its source, obtaining its destination IP address and destination port number as its destination, and obtaining a same-source list and a same-destination list of each network flow;

[0019] Step S202, taking each network flow as a node, for each network flow , calculate the top k network flows with the same source list If the length of the same source list is less than k, all of them are used. The same operation is performed on the same destination list. When calculating the similarity, the Euclidean distance is used to measure the similarity between two network flows. For two network flows with m dimensions, and , and its Euclidean distance is ,in and Respectively and The p-th dimension feature, the smaller the distance, the higher the similarity;

[0020] Step S203, network flow Each network flow in the top k lists with similarity Establish edges and obtain the same-source network flow graph. Perform the same operation on the same-destination list to obtain the same-destination network flow graph.

[0021] A further technical solution of the present invention is that step S30 comprises:

[0022] Step S301, encode the homologous network flow graph and the homologous network flow graph respectively, and the encoder uses a multi-layer GNN to obtain the homologous graph encoding vector and the homologous graph encoding vector of each network flow, and record the encoding matrix of the entire homologous network flow graph as ,in They represent the encoding vectors of n network flows in the same source graph, and the encoding matrix of the entire graph of the same destination network flow graph is recorded as ,in, They represent the encoding vectors of n network flows in the same destination graph respectively;

[0023] Step S302, structural decoding is performed on the encoding vector, and the calculation method of structural decoding is as follows:

[0024] ,

[0025] Where E is the encoding vector of the graph, and the decoding of the homology graph is done by , when decoding the same target graph structure, use , sigmoid is the activation function, and the structural decoding result is obtained ,

[0026] Then the adjacency matrix of the corresponding graph is subtracted from the structural decoding result to obtain the structural reconstruction error : ,

[0027] Where A is the adjacency matrix of the original image, Decode the result of the structure just obtained;

[0028] Step S303: Attribute decoding is performed on the encoded vector. The attribute decoder uses a multi-layer GNN and takes the difference between the decoding results of the two graphs and the initial feature F of the flow as the attribute reconstruction error. ;

[0029] Step S304: weight the structure reconstruction error and the attribute reconstruction error Sum the total error R of the graph:

[0030] ,

[0031] in, is the structural reconstruction error obtained in step 302, is the attribute reconstruction error obtained in step 303, is a hyperparameter of the setting;

[0032] The same calculation is performed on the homology graph and the homology graph. The total error of the homology graph is recorded as , the total error of the same target graph is recorded as , and then take the weighted sum of the errors of the two images to get the final error:

[0033] ,

[0034] in is a hyperparameter set artificially, and the final error is recorded as ;

[0035] Step S305, using benign data to train the model so that the model can learn the behavior pattern of benign traffic, using the final error as the loss training model, and using the maximum error of benign traffic in the training phase as the anomaly threshold;

[0036] In testing and formal use, the final error is used as the anomaly score. Since benign traffic has been trained, its original features are similar to the decoded results and the error is small. However, for malicious traffic, due to its different statistical features and behavior patterns from benign traffic, a decoding result with a large error will be obtained, that is, the anomaly score is greater than the threshold, thereby effectively detecting abnormal malicious traffic.

[0037] To achieve the above object, the present invention further proposes a network intrusion detection system based on a graph anomaly detection algorithm, the system comprising a memory, a processor, and a network intrusion detection program based on a graph anomaly detection algorithm stored on the processor, the network intrusion detection program based on a graph anomaly detection algorithm performing the following steps when called by the processor:

[0038] Aggregate network traffic data packets into network flows according to five-tuples for different protocols. The five-tuples include source IP address, source port number, destination IP address, destination port number and transport layer protocol.

[0039] Use the aggregated network flows to construct the same-source network flow graph and the same-destination network flow graph, and use similarity calculation to reduce the scale of the same-source network flow graph and the same-destination network flow graph;

[0040] Use graph autoencoders to encode and decode the same-source network flow graphs and the same-destination network flow graphs, and finally obtain the anomaly score of each network flow. Then, based on the anomaly score of each network flow, determine whether it is abnormal malicious traffic.

[0041] A further technical solution of the present invention is that when the network intrusion detection program based on the graph anomaly detection algorithm is called by the processor, the following steps are further performed:

[0042] Sequentially read the data packets from the pcap file storing the network traffic data packets and initially construct the network flow according to the five-tuple, while recording the data packet size and data packet arrival time information;

[0043] Determine whether to construct a bidirectional flow or a unidirectional flow based on the characteristics of different transport layer protocols;

[0044] Record the statistical characteristics of each network flow, extract n network flows from the network traffic, and record their characteristics as .

[0045] A further technical solution of the present invention is that, when the transport layer protocol is the TCP protocol, a bidirectional flow is constructed, that is, the data packets sent to each other by both ends of the TCP protocol connection are counted into one flow, and the IP address and port number of the initial connection application are used as the source IP address and source port number of the entire flow, and the flag bit is monitored at the same time. Both parties use SYN to establish a connection to initialize the flow, and use FIN to disconnect or RST to reset to end the flow. At the same time, a time threshold is set. When the duration of the entire flow exceeds the threshold, the flow is terminated, and it is regarded as that the capture device fails to capture the disconnected data packet;

[0046] When the transport layer protocol is the UDP protocol, a unidirectional flow is constructed, and only the time threshold is used for cutoff.

[0047] A further technical solution of the present invention is that when the network intrusion detection program based on the graph anomaly detection algorithm is called by the processor, the following steps are further performed:

[0048] Using the aggregated network flow, obtain its source IP address and source port number from its five-tuple as its source, obtain its destination IP address and destination port number as its destination, and obtain the same-source list and same-destination list of each network flow;

[0049] Take each network flow as a node, for each network flow , calculate the top k network flows with the same source list If the length of the same source list is less than k, all of them are used. The same operation is performed on the same destination list. When calculating the similarity, the Euclidean distance is used to measure the similarity between two network flows. For two network flows with m dimensions, and , and its Euclidean distance is ,in and Respectively and The p-th dimension feature, the smaller the distance, the higher the similarity;

[0050] For network flow Each network flow in the top k lists with similarity Establish edges and obtain the same-source network flow graph. Perform the same operation on the same-destination list to obtain the same-destination network flow graph.

[0051] To achieve the above objectives, the present invention also proposes a computer-readable storage medium, which stores a network intrusion detection program based on a graph anomaly detection algorithm. When the network intrusion detection program based on a graph anomaly detection algorithm is called by a processor, it executes the steps of the method described above.

[0052] The beneficial effects of the network intrusion detection method, system and medium based on the graph anomaly detection algorithm of the present invention are:

[0053] 1. In the process of constructing the network flow into a graph, the present invention uses the network flow as a node, and uses the relationship between the network flows with the same source or the same purpose to establish an edge between two nodes. This is different from the existing method that uses IP addresses and port numbers as nodes and establishes edges with the network flows of two nodes. This method is equivalent to logically converting the edge points of the traditional graph to obtain a line graph. In addition, this method constructs a homologous network flow graph and a homologous network flow graph on this basis. Compared with the existing technology, the method of the present invention pays more attention to the relationship between network flows, and pays more attention to the characteristics of single-step attacks in network traffic side attacks;

[0054] 2. The present invention uses graph autoencoders for anomaly detection to detect abnormal malicious traffic. Compared with existing supervised learning methods, the present invention does not require attack annotation data and is more suitable for scenarios lacking high-quality annotation data. The use of attribute decoders and structure decoders in the decoder also enhances the ability of the model to learn network traffic behavior patterns. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 It is a flow chart of a preferred embodiment of a network intrusion detection method based on a graph anomaly detection algorithm of the present invention;

[0056] Figure 2 It is a schematic diagram of a model designed by a preferred embodiment of a network intrusion detection method based on a graph anomaly detection algorithm of the present invention;

[0057] Figure 3 is a detailed flow chart of step S10;

[0058] Figure 4 It is a schematic diagram of the system structure involved in the embodiment of the present invention.

[0059] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. DETAILED DESCRIPTION

[0060] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0061] The present invention proposes a network intrusion detection method based on a graph anomaly detection algorithm, which adopts a new method of constructing a network communication behavior graph to fully model the relationship between network flows. The present invention designs a graph construction method for homologous network flows and homologous network flows for single-step attacks, and finally obtains a graph construction method with less redundancy.

[0062] In the process of anomaly detection on graphs, the present invention designs graph autoencoders for both homologous graphs and homologous destination graphs, and adopts attribute decoders and structure decoders in the decoder part to enhance the model's learning ability for benign traffic, thereby achieving better detection effect for abnormal malicious network traffic.

[0063] The technical solution adopted by the network intrusion detection method based on the graph anomaly detection algorithm proposed in the present invention is mainly: first, the network traffic is aggregated into network flows according to five-tuples, and then the aggregated network flows are used to construct the same-source network flow graph and the same-destination network flow graph respectively, and then the graph autoencoder is used to calculate the anomaly score.

[0064] Please refer to Figure 1The preferred embodiment of the network intrusion detection method based on the graph anomaly detection algorithm of the present invention comprises the following steps:

[0065] Step S10, aggregating network traffic data packets into network flows according to five-tuples for different protocols, wherein the five-tuple includes a source IP address, a source port number, a destination IP address, a destination port number and a transport layer protocol.

[0066] In this embodiment, a five-tuple is used to aggregate network traffic data packets into network flows for different protocols, and the processing process is as follows:

[0067] (1) Read packets sequentially from the pcap file that stores network traffic packets and use the five-tuple (source IP address, source port number, destination IP address, destination port number, transport layer protocol) to initially construct the network flow.

[0068] (2) Determine whether to build a bidirectional flow or a unidirectional flow based on the characteristics of different transport layer protocols.

[0069] (3) While constructing the network flow, the information such as the packet size and packet arrival time is recorded for subsequent construction of flow statistical features and calculation.

[0070] Step S20, using the aggregated network flow to construct a homologous network flow graph and a homologous network flow graph, and using similarity calculation to reduce the scale of the homologous network flow graph and the homologous network flow graph. The specific process of step S20 includes:

[0071] (1) Using the aggregated network flow, obtain its source IP address and source port number from its five-tuple as its source, obtain its destination IP address and destination port number as its destination, and obtain a list of the same source and the same destination of each network flow.

[0072] (2) Each network flow is similar to other network flows in the two lists with the same source and destination, and the top k similar network flows are selected.

[0073] (3) With network flows as nodes, edges are constructed between each network flow and the first k network flows in the same source list to form a homologous network flow graph, and then the same destination list is used to construct a same-destination network flow graph in the same way. Different from the graphing method in traditional research, this embodiment uses network flows as nodes in the graphing process, and establishes an edge between two nodes based on the same source or same destination relationship between network flows. On this basis, in view of the fact that attacks on the network traffic side are often single-step attacks, homologous source graphs and same-destination graphs are established respectively, reducing the interference of redundant connections on detection in complex network topologies. Similarity calculation is used to reduce the scale of the graph, which is more efficient.

[0074] Step S30, use the graph autoencoder to encode and decode the same-source network flow graph and the same-destination network flow graph, and finally obtain the anomaly score of each network flow, and then determine whether it is abnormal malicious traffic based on the anomaly score of each network flow.

[0075] The specific process of step S30 includes:

[0076] (1) A multi-layer GNN encoder is used to encode the same source network flow graph and the same destination network flow graph respectively. Each node in the graph, i.e., each network flow, obtains two encoding vectors.

[0077] (2) Perform attribute decoding and structural decoding on the encoded vector, calculate the mean square error between the result of attribute decoding and the original attribute of the node as the attribute error, calculate the mean square error between the result of structure decoding and the adjacency matrix of the original graph as the structural error, and set the weights of the two to add up as the total error of the node in the graph.

[0078] (3) Perform the same operation on the network flow graph with the same source and the network flow graph with the same destination. Finally, add the weights of the total errors of the nodes in the two graphs to obtain the final anomaly score.

[0079] This embodiment uses a graph autoencoder for anomaly detection, which belongs to unsupervised learning and does not require attack labeled data. It can be trained based on massive benign data in the network.

[0080] The above steps are the process of using the graph autoencoder to calculate the network traffic anomaly score and make the final judgment. The model structure is as follows: Figure 2 shown.

[0081] Please refer to Figure 3 In this embodiment, step S10 includes:

[0082] Step S101, sequentially read data packets from a pcap file storing network traffic data packets and initially construct a network flow according to five-tuples, while recording the data packet size and data packet arrival time information.

[0083] Step S102, determining whether to construct a bidirectional flow or a unidirectional flow according to the characteristics of different transport layer protocols.

[0084] Specifically, when the transport layer protocol is TCP, a bidirectional flow is constructed, that is, the data packets sent to each other by both ends of the TCP protocol connection are counted into one flow, and the IP address and port number of the initial connection application are used as the source IP address and source port number of the entire flow, with the same purpose. At the same time, the flag bit is monitored, and both parties use SYN to establish a connection to initialize the flow, and use FIN to disconnect or RST to reset to end the flow. At the same time, a time threshold is set. When the duration of the entire flow exceeds the threshold, the flow is terminated, and it is considered that the capture device has failed to capture the disconnected data packet.

[0085] When the transport layer protocol is the UDP protocol, a unidirectional flow is constructed, and only the time threshold is used for cutoff.

[0086] The present invention combines the characteristics of different transport layer protocols and adopts different methods to aggregate network flows, thereby reducing the generation of invalid network flows.

[0087] Step S103, record the statistical features of each network flow, extract n network flows from the network traffic, and record their features as .

[0088] In this embodiment, step S20 includes:

[0089] Step S201, using the aggregated network flow, obtains its source IP address and source port number from its quintuple as its source, obtains its destination IP address and destination port number as its destination, and obtains the same-source list and the same-destination list of each network flow.

[0090] Step S202, taking each network flow as a node, for each network flow , calculate the top k network flows with the same source list If the length of the same source list is less than k, all of them are used. The same operation is performed on the same destination list. When calculating the similarity, the Euclidean distance is used to measure the similarity between two network flows. For two network flows with m dimensions, and , and its Euclidean distance is ,in and Respectively and The p-th dimension feature, the smaller the distance, the higher the similarity.

[0091] Step S203, network flow Each network flow in the top k lists with similarity Establish edges and obtain the same-source network flow graph. Perform the same operation on the same-destination list to obtain the same-destination network flow graph.

[0092] In this embodiment, step S30 includes:

[0093] Step S301, encode the homologous network flow graph and the homologous network flow graph respectively, and the encoder uses a multi-layer GNN to obtain the homologous graph encoding vector and the homologous graph encoding vector of each network flow, and record the encoding matrix of the entire homologous network flow graph as ,in They represent the encoding vectors of n network flows in the same source graph, and the encoding matrix of the entire graph of the same destination network flow graph is recorded as ,in, They represent the encoding vectors of n network flows in the same destination graph respectively;

[0094] Step S302, structural decoding is performed on the encoding vector, and the calculation method of structural decoding is as follows:

[0095] ,

[0096] Where E is the encoding vector of the graph, and the decoding of the homology graph is done by , when decoding the same target graph structure, use , sigmoid is the activation function, and the structural decoding result is obtained .

[0097] Then the adjacency matrix of the corresponding graph is subtracted from the structural decoding result to obtain the structural reconstruction error : ,

[0098] Where A is the adjacency matrix of the original image, Decode the result of the structure just obtained.

[0099] Step S303: Attribute decoding is performed on the encoded vector. The attribute decoder uses a multi-layer GNN and takes the difference between the decoding results of the two graphs and the initial feature F of the flow as the attribute reconstruction error. .

[0100] Step S304: weight the structure reconstruction error and the attribute reconstruction error Sum the total error R of the graph:

[0101] .

[0102] in, is the structural reconstruction error obtained in step 302, is the attribute reconstruction error obtained in step 303, is a hyperparameter of the setting.

[0103] The same calculation is performed on the homology graph and the homology graph. The total error of the homology graph is recorded as , the total error of the same target graph is recorded as , and then take the weighted sum of the errors of the two images to get the final error:

[0104] .

[0105] in is a hyperparameter set artificially, and the final error is recorded as .

[0106] Step S305, using benign data to train the model so that the model can learn the behavior pattern of benign traffic, using the final error as the loss training model, and using the maximum error of benign traffic in the training phase as the anomaly score threshold.

[0107] In testing and formal use, the final error is used as the anomaly score. Since benign traffic has been trained, its original features are similar to the decoded results and the error is small. However, for malicious traffic, due to its different statistical features and behavior patterns from benign traffic, a decoding result with a large error will be obtained, that is, the anomaly score is greater than the threshold, thereby effectively detecting abnormal malicious traffic.

[0108] Different from the graphing method in traditional research, the present invention uses network flows as nodes in the graphing process, and establishes an edge between two nodes based on the relationship between the same source or the same purpose between network flows. On this basis, in view of the fact that attacks on the network flow side are often single-step attacks, a homologous graph and a homologous graph are established respectively, reducing the interference of redundant connections on detection in complex network topologies. Similarity calculation is used to reduce the scale of the graph, which is more efficient.

[0109] The beneficial effects of the network intrusion detection method based on the graph anomaly detection algorithm of the present invention are:

[0110] 1. In the process of constructing the network flow into a graph, the present invention uses the network flow as a node, and establishes an edge between two nodes based on the relationship between the same source or the same purpose between the network flows. This is different from the existing method that uses IP addresses and port numbers as nodes and establishes edges based on the network flows of two nodes. This method is equivalent to logically converting the edge points of the traditional graph to obtain a line graph. In addition, the present method constructs a homologous network flow graph and a homologous network flow graph on this basis. Compared with the existing technology, the method of the present invention pays more attention to the relationship between network flows, and pays more attention to the characteristics of single-step attacks in network traffic side attacks.

[0111] 2. The present invention uses graph autoencoders for anomaly detection to detect abnormal malicious traffic. Compared with existing supervised learning methods, the present invention does not require attack annotation data and is more suitable for scenarios lacking high-quality annotation data. The use of attribute decoders and structure decoders in the decoder also enhances the ability of the model to learn network traffic behavior patterns.

[0112] To achieve the above objectives, the present invention also proposes a network intrusion detection system based on a graph anomaly detection algorithm, such as Figure 4As shown, the system includes a processor 1001, a CPU, a network interface 1004, a user interface 1003, a memory 1005, a communication bus 1002, and a network intrusion detection program based on a graph anomaly detection algorithm stored on the processor, wherein the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0113] Those skilled in the art will understand that Figure 4 The system structure shown in the figure does not constitute a limitation of the system, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0114] like Figure 4 As shown, the memory 1005 as a computer storage medium may include an operating device, a network communication module, a user interface module, and a network intrusion detection program based on a graph anomaly detection algorithm.

[0115] exist Figure 4 In the system shown, the network interface 1004 is mainly used to connect to the network server and communicate data with the network server; the user interface 1003 is mainly used to interact with the user terminal and receive instructions input by the user; and the processor 1001 can be used to call the network intrusion detection program based on the graph anomaly detection algorithm stored in the memory 1005.

[0116] The network intrusion detection program based on the graph anomaly detection algorithm performs the following steps when the processor is running:

[0117] For different protocols, network traffic data packets are aggregated into network flows according to five-tuples, and the five-tuple includes source IP address, source port number, destination IP address, destination port number and transport layer protocol.

[0118] The aggregated network flows are used to construct homologous network flow graphs and homologous network flow graphs, and similarity calculation is used to reduce the scale of homologous network flow graphs and homologous network flow graphs.

[0119] Use graph autoencoders to encode and decode the same-source network flow graphs and the same-destination network flow graphs, and finally obtain the anomaly score of each network flow. Then, based on the anomaly score of each network flow, determine whether it is abnormal malicious traffic.

[0120] When the network intrusion detection program based on the graph anomaly detection algorithm is called by the processor, the following steps are further performed:

[0121] Read the data packets sequentially from the pcap file storing the network traffic data packets and initially construct the network flow according to the five-tuple, while recording the data packet size and data packet arrival time information.

[0122] Determine whether to build a bidirectional flow or a unidirectional flow based on the characteristics of different transport layer protocols. When the transport layer protocol is the TCP protocol, a bidirectional flow is built, that is, the data packets sent to each other by both ends of the TCP protocol connection are counted into one flow, and the IP address and port number that initially apply for the connection are used as the source IP address and source port number of the entire flow. At the same time, the flag bit is monitored. Both parties use SYN to establish a connection to initialize the flow, and use FIN to disconnect or RST to reset to end the flow. At the same time, a time threshold is set. When the duration of the entire flow exceeds the threshold, the flow is terminated, and it is considered that the capture device has failed to capture the disconnected data packets.

[0123] When the transport layer protocol is the UDP protocol, a unidirectional flow is constructed, and only the time threshold is used for cutoff.

[0124] Record the statistical characteristics of each network flow, extract n network flows from the network traffic, and record their characteristics as .

[0125] When the network intrusion detection program based on the graph anomaly detection algorithm is called by the processor, the following steps are further performed:

[0126] Using the aggregated network flow, its source IP address and source port number are obtained from its quintuple as its source, and its destination IP address and destination port number are obtained as its destination, to obtain the same-source list and same-destination list of each network flow.

[0127] Take each network flow as a node, for each network flow , calculate the top k network flows with the same source list If the length of the same source list is less than k, all of them are used. The same operation is performed on the same destination list. When calculating the similarity, the Euclidean distance is used to measure the similarity between two network flows. For two network flows with m dimensions, and , and its Euclidean distance is ,in and Respectively and The p-th dimension feature, the smaller the distance, the higher the similarity.

[0128] For network flow Each network flow in the top k lists with similarity Establish edges and obtain the same-source network flow graph. Perform the same operation on the same-destination list to obtain the same-destination network flow graph.

[0129] The beneficial effects of the network intrusion detection system based on the graph anomaly detection algorithm of the present invention are:

[0130] 1. In the process of constructing the network flow into a graph, the present invention uses the network flow as a node, and establishes an edge between two nodes based on the relationship between the same source or the same purpose between the network flows. This is different from the existing method that uses IP addresses and port numbers as nodes and establishes edges based on the network flows of two nodes. This method is equivalent to logically converting the edge points of the traditional graph to obtain a line graph. In addition, the present method constructs a homologous network flow graph and a homologous network flow graph on this basis. Compared with the existing technology, the method of the present invention pays more attention to the relationship between network flows, and pays more attention to the characteristics of single-step attacks in network traffic side attacks.

[0131] 2. The present invention uses graph autoencoders for anomaly detection to detect abnormal malicious traffic. Compared with existing supervised learning methods, the present invention does not require attack annotation data and is more suitable for scenarios lacking high-quality annotation data. The use of attribute decoders and structure decoders in the decoder also enhances the ability of the model to learn network traffic behavior patterns.

[0132] To achieve the above objectives, the present invention also proposes a computer-readable storage medium, which stores a network intrusion detection program based on a graph anomaly detection algorithm. When the network intrusion detection program based on a graph anomaly detection algorithm is called by a processor, the steps of the method described above are executed, which will not be repeated here.

[0133] The above description is only a preferred embodiment of the present invention, and does not limit the patent scope of the present invention. Any equivalent structure or process transformation made by using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A network intrusion detection method based on a graph anomaly detection algorithm, characterized in that: The method comprises the following steps: Step S10, aggregating network traffic data packets into network flows according to five-tuples for different protocols, wherein the five-tuples include a source IP address, a source port number, a destination IP address, a destination port number, and a transport layer protocol; Step S20, using the aggregated network flows to construct a homologous network flow graph and a homologous network flow graph, and using similarity calculation to reduce the scale of the homologous network flow graph and the homologous network flow graph; Step S30, using a graph autoencoder to encode and decode the same-source network flow graph and the same-destination network flow graph, and finally obtain the abnormal score of each network flow, and then determine whether it is abnormal malicious traffic according to the abnormal score of each network flow; The step S30 comprises: Step S301, encode the homologous network flow graph and the homologous network flow graph respectively, and the encoder uses a multi-layer GNN to obtain the homologous graph encoding vector and the homologous graph encoding vector of each network flow, and record the encoding matrix of the entire homologous network flow graph as ,in They represent the encoding vectors of n network flows in the same source graph, and the encoding matrix of the entire graph of the same destination network flow graph is recorded as ,in, They represent the encoding vectors of n network flows in the same destination graph respectively; Step S302, structural decoding is performed on the encoding vector, and the calculation method of structural decoding is as follows: , Where E is the encoding vector of the graph, and the decoding of the homology graph is done by , when decoding the same target graph structure, use , sigmoid is the activation function, and the structural decoding result is obtained , Then the adjacency matrix of the corresponding graph is subtracted from the structural decoding result to obtain the structural reconstruction error : , Where A is the adjacency matrix of the original image, Decode the result of the structure just obtained; Step S303: Attribute decoding is performed on the encoded vector. The attribute decoder uses a multi-layer GNN and takes the difference between the decoding results of the two graphs and the initial feature F of the flow as the attribute reconstruction error. ; Step S304: weight the structure reconstruction error and the attribute reconstruction error Sum the total error R of the graph: , in, is the structural reconstruction error obtained in step 302, is the attribute reconstruction error obtained in step 303, is a hyperparameter of the setting; The same calculation is performed on the homology graph and the homology graph. The total error of the homology graph is recorded as , the total error of the same target graph is recorded as , and then take the weighted sum of the errors of the two images to get the final error: , in is a hyperparameter set artificially, and the final error is recorded as ; Step S305, using benign data to train the model so that the model can learn the behavior pattern of benign traffic, using the final error as the loss training model, and using the maximum error of benign traffic in the training phase as the anomaly threshold; In testing and formal use, the final error is used as the anomaly score. Since benign traffic has been trained, its original features are similar to the decoded results and the error is small. However, for malicious traffic, due to its different statistical features and behavior patterns from benign traffic, a decoding result with a large error will be obtained, that is, the anomaly score is greater than the threshold, thereby effectively detecting abnormal malicious traffic.

2. The network intrusion detection method based on graph anomaly detection algorithm according to claim 1 is characterized in that: The step S10 comprises: Step S101, sequentially read data packets from a pcap file storing network traffic data packets and initially construct a network flow according to five-tuples, while recording the data packet size and data packet arrival time information; Step S102, determining whether to construct a bidirectional flow or a unidirectional flow according to the characteristics of different transport layer protocols; Step S103, record the statistical features of each network flow, extract n network flows from the network traffic, and record their features as .

3. The network intrusion detection method based on graph anomaly detection algorithm according to claim 2 is characterized in that: In step S102: When the transport layer protocol is TCP, a bidirectional flow is constructed, that is, the data packets sent to each other by both ends of the TCP protocol connection are counted into one flow, and the IP address and port number of the initial connection application are used as the source IP address and source port number of the entire flow. At the same time, the flag bit is monitored. Both parties use SYN to establish a connection to initialize the flow, and use FIN to disconnect or RST to reset to end the flow. At the same time, a time threshold is set. When the duration of the entire flow exceeds the threshold, the flow is terminated, and it is considered that the capture device has failed to capture the disconnected data packets; When the transport layer protocol is the UDP protocol, a unidirectional flow is constructed, and only the time threshold is used for cutoff.

4. The network intrusion detection method based on graph anomaly detection algorithm according to claim 3 is characterized in that: The step S20 comprises: Step S201, using the aggregated network flow, obtaining its source IP address and source port number from its quintuple as its source, obtaining its destination IP address and destination port number as its destination, and obtaining a same-source list and a same-destination list of each network flow; Step S202: Take each network flow as a node, and , calculate the top k network flows with the same source list If the length of the same source list is less than k, all of them are used. The same operation is performed on the same destination list. When calculating the similarity, the Euclidean distance is used to measure the similarity between two network flows. For two network flows with m dimensions, and , and its Euclidean distance is ,in and Respectively and The p-th dimension feature, the smaller the distance, the higher the similarity; Step S203, network flow Each network flow in the top k lists with similarity Establish edges and obtain the same-source network flow graph. Perform the same operation on the same-destination list to obtain the same-destination network flow graph.

5. A network intrusion detection system based on a graph anomaly detection algorithm, characterized in that: The system includes a memory, a processor, and a network intrusion detection program based on a graph anomaly detection algorithm stored on the processor. When the network intrusion detection program based on a graph anomaly detection algorithm is called by the processor, the following steps are performed: Aggregate network traffic data packets into network flows according to five-tuples for different protocols. The five-tuples include source IP address, source port number, destination IP address, destination port number and transport layer protocol. Use the aggregated network flows to construct the same-source network flow graph and the same-destination network flow graph, and use similarity calculation to reduce the scale of the same-source network flow graph and the same-destination network flow graph; Use graph autoencoders to encode and decode the same-source network flow graph and the same-destination network flow graph, and finally obtain the anomaly score of each network flow. Then, determine whether it is abnormal malicious traffic based on the anomaly score of each network flow. The step of using a graph autoencoder to encode and decode a homologous network flow graph and a homologous network flow graph, and finally obtaining an abnormal score of each network flow, and then judging whether it is abnormal malicious traffic according to the abnormal score of each network flow includes: The homologous network flow graph and the homologous network flow graph are encoded separately. The encoder uses a multi-layer GNN to obtain the homologous graph encoding vector and the homologous graph encoding vector of each network flow. The encoding matrix of the entire homologous network flow graph is recorded as ,in They represent the encoding vectors of n network flows in the same source graph, and the encoding matrix of the entire graph of the same destination network flow graph is recorded as ,in, They represent the encoding vectors of n network flows in the same destination graph respectively; The encoding vector is structurally decoded. The calculation method of structural decoding is as follows: , Where E is the encoding vector of the graph, and the decoding of the homology graph is done by , when decoding the same target graph structure, use , sigmoid is the activation function, and the structural decoding result is obtained , Then the adjacency matrix of the corresponding graph is subtracted from the structural decoding result to obtain the structural reconstruction error : , Where A is the adjacency matrix of the original image, Decode the result of the structure just obtained; The attribute decoder uses a multi-layer GNN to decode the encoded vector and take the difference between the decoding results of the two graphs and the initial feature F of the flow as the attribute reconstruction error. ; The structural reconstruction error and the attribute reconstruction error are weighted Sum the total error R of the graph: , in, is the structural reconstruction error obtained in step 302, is the attribute reconstruction error obtained in step 303, is a hyperparameter of the setting; The same calculation is performed on the homology graph and the homology graph. The total error of the homology graph is recorded as , the total error of the same target graph is recorded as , and then take the weighted sum of the errors of the two images to get the final error: , in is a hyperparameter set artificially, and the final error is recorded as ; Use benign data to train the model so that the model can learn the behavior pattern of benign traffic. Use the final error as the loss to train the model, and use the maximum error of benign traffic in the training phase as the anomaly threshold. In testing and formal use, the final error is used as the anomaly score. Since benign traffic has been trained, its original features are similar to the decoded results and the error is small. However, for malicious traffic, due to its different statistical features and behavior patterns from benign traffic, a decoding result with a large error will be obtained, that is, the anomaly score is greater than the threshold, thereby effectively detecting abnormal malicious traffic.

6. The network intrusion detection system based on graph anomaly detection algorithm according to claim 5 is characterized in that: When the network intrusion detection program based on the graph anomaly detection algorithm is called by the processor, the following steps are further performed: Sequentially read the data packets from the pcap file storing the network traffic data packets and initially construct the network flow according to the five-tuple, while recording the data packet size and data packet arrival time information; Determine whether to construct a bidirectional flow or a unidirectional flow based on the characteristics of different transport layer protocols; Record the statistical characteristics of each network flow, extract n network flows from the network traffic, and record their characteristics as .

7. The network intrusion detection system based on graph anomaly detection algorithm according to claim 6 is characterized in that: When the transport layer protocol is TCP, a bidirectional flow is constructed, that is, the data packets sent to each other by both ends of the TCP protocol connection are counted into one flow, and the IP address and port number of the initial connection application are used as the source IP address and source port number of the entire flow. At the same time, the flag bit is monitored. Both parties use SYN to establish a connection to initialize the flow, and use FIN to disconnect or RST to reset to end the flow. At the same time, a time threshold is set. When the duration of the entire flow exceeds the threshold, the flow is terminated, and it is considered that the capture device has failed to capture the disconnected data packets; When the transport layer protocol is the UDP protocol, a unidirectional flow is constructed, and only the time threshold is used for cutoff.

8. The network intrusion detection system based on graph anomaly detection algorithm according to claim 7 is characterized in that: When the network intrusion detection program based on the graph anomaly detection algorithm is called by the processor, the following steps are further performed: Using the aggregated network flow, obtain its source IP address and source port number from its five-tuple as its source, obtain its destination IP address and destination port number as its destination, and obtain the same-source list and same-destination list of each network flow; Take each network flow as a node, for each network flow , calculate the top k network flows with the same source list If the length of the same source list is less than k, all of them are used. The same operation is performed on the same destination list. When calculating the similarity, the Euclidean distance is used to measure the similarity between two network flows. For two network flows with m dimensions, and , and its Euclidean distance is ,in and Respectively and The p-th dimension feature, the smaller the distance, the higher the similarity; For network flow Each network flow in the top k lists with similarity Establish edges and obtain the same-source network flow graph. Perform the same operation on the same-destination list to obtain the same-destination network flow graph.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a network intrusion detection program based on a graph anomaly detection algorithm, and the network intrusion detection program based on a graph anomaly detection algorithm executes the steps of the method according to any one of claims 1 to 5 when called by a processor.

Citation Information

Patent Citations

  • Distributed network anomaly detection method and system based on depth feature rough coding

    CN114666075A

  • Identification of anomalous data records

    US20060161592A1

Cited By

  • Identifying Flows in AI Algorithms

    US20260094049A1