Attack detection method, device, equipment and storage medium
By performing compliance detection and reassembly of fragmented IPv6 data messages and verifying the message content, the problem of malicious fragmentation attack detection in IPv6 is solved and the accuracy of attack detection and network security are improved.
Patent Information
- Application Number
- CN202111244945.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-26
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2041-10-26
AI Technical Summary
Malicious fragmentation attacks in IPv6 cause abnormal computer processing, and it is difficult for existing technologies to effectively detect and defend against such attacks.
By receiving multiple fragmented messages of the target data message, compliance detection and reassembly are performed, and the first header and number of bytes of the reassembled message are verified. If the message does not pass, it is determined to be an attack message and discarded.
Improves the detection accuracy of malicious fragmentation attacks, prevents computer blue screens of death, and enhances network security.
Smart Images

Figure CN114039749B
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of network technology, and in particular to an attack detection method, device, equipment and storage medium. Background Art
[0002] With the development of network technology, the limited address space defined by IPv4 is gradually exhausted. In order to expand the address space, IPv6 is redefined to replace IPv4. Compared with IPv4, IPv6 has greatly improved in security. However, the original attack methods in IPv4 still continue to IPv6, such as the fragmentation attack in IPv4 is still effective in IPv6.
[0003] Currently, IPv6 includes malicious fragmentation attacks. Malicious fragmentation attacks are caused by triggering recursive reassembly of data packets. Malicious fragmentation attacks can cause computer processing exceptions, causing the computer to crash with a blue screen. Summary of the invention
[0004] The embodiments of the present application provide an attack detection method, apparatus, device and storage medium for improving the accuracy of detecting fragmentation attacks.
[0005] On the one hand, an embodiment of the present application provides an attack detection method, the method comprising:
[0006] receiving a plurality of fragment messages in the target data message in sequence, and performing compliance detection on the plurality of fragment messages in sequence;
[0007] If the multiple fragmented messages all pass the detection, the multiple fragmented messages are reassembled to obtain a reassembled message;
[0008] The first header contained in the reassembled message and the number of bytes corresponding to the reassembled message are verified. If the verification fails, the reassembled message is determined to be an attack message, and the reassembled message is discarded.
[0009] On the one hand, an embodiment of the present application provides an attack detection device, the device comprising:
[0010] A detection module, used to sequentially receive multiple fragment messages in the target data message, and sequentially perform compliance detection on the multiple fragment messages;
[0011] A reassembly module, configured to reassemble the multiple fragmented messages to obtain a reassembled message if the multiple fragmented messages all pass the detection;
[0012] The verification module is used to verify the first header contained in the reassembled message and the number of bytes corresponding to the reassembled message. If the verification fails, the reassembled message is determined to be an attack message and the reassembled message is discarded.
[0013] Optionally, the detection module is specifically used to:
[0014] For each fragment message, perform the following steps respectively:
[0015] In the second header of a fragmented message, if the fragmentable header is located before the non-fragmentable header, it is determined that the compliance check of the fragmented message fails, and the fragmented message is discarded.
[0016] Optionally, the detection module is further used for:
[0017] In a second header of a fragmented message, if the fragmentable header is located after the non-fragmentable header, determining whether the values of the fragment end flag and the fragment offset field in the second header are both 0;
[0018] If yes, determine that the compliance check of the fragment message fails, and discard the fragment message;
[0019] Otherwise, it is determined that the compliance test of the one fragment message passes.
[0020] Optionally, a verification module is further included, and the verification module is specifically used to:
[0021] Before performing compliance checks on the multiple fragmented messages in sequence, if the fragment end flag in the second header is 1, and the number of bytes corresponding to the one fragmented message is less than the first link maximum transmission unit, then the one fragmented message is discarded, and the first link maximum transmission unit is the lower limit value of the link maximum transmission unit.
[0022] Optionally, the verification module is further used to:
[0023] If the number of bytes corresponding to the fragment message is not an integer multiple of 8, or the difference between the number of bytes corresponding to the fragment message and the second link maximum transmission unit is greater than 4 bytes, the fragment message is discarded, where the second link maximum transmission unit is the upper limit value of the link maximum transmission unit.
[0024] Optionally, the verification module is further used to:
[0025] Recombining the multiple fragment messages, and before obtaining the recombined message, if the multiple fragment messages all pass the detection, determining the reception time interval between the first fragment message and the last fragment message in the multiple fragment messages;
[0026] If the receiving time interval exceeds the optimal time interval, discarding the multiple fragment messages; or,
[0027] If the number of the multiple fragment messages exceeds the preset message number, the multiple fragment messages are discarded.
[0028] Optionally, the verification module is specifically used to:
[0029] If the next header field in the first header points to the fragment header, or the number of bytes corresponding to the reassembled message is greater than a preset value, the verification fails, and the reassembled message is determined to be an attack message, and the reassembled message is discarded.
[0030] Optionally, the verification module is further used to:
[0031] If the next header field in the first header does not point to the fragment header, and the number of bytes corresponding to the reassembled message is less than or equal to the preset value, it is determined whether the fragmentable header of the first header is located before the non-fragmentable header. If so, the verification fails.
[0032] On the one hand, an embodiment of the present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned attack detection method when executing the program.
[0033] On the one hand, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program executable by a computer device. When the program is run on the computer device, the computer device executes the steps of the above-mentioned attack detection method.
[0034] In an embodiment of the present application, multiple fragment messages in a target data message are received in sequence, and compliance checks are performed on the multiple fragment messages in sequence. If multiple fragment messages all pass the test, the multiple fragment messages are reassembled to obtain a reassembled message. The first header contained in the reassembled message and the number of bytes corresponding to the reassembled message are verified. If the verification fails, the reassembled message is determined to be an attack message and the reassembled message is discarded. Since malicious fragment attacks are caused by triggering recursive reassembly of fragment messages, the first header and the corresponding number of bytes contained in the reassembled message after reassembly are different from those of normal data messages. By verifying the first header and the corresponding number of bytes of the reassembled message, malicious attacks can be effectively detected. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0036] Figure 1 A schematic diagram of a system architecture provided for an embodiment of the present application;
[0037] Figure 2 A schematic diagram of the structure of an IPv6 data message provided in an embodiment of the present application;
[0038] Figure 3 A schematic diagram of the structure of an IPv6 data message provided in an embodiment of the present application;
[0039] Figure 4 A schematic diagram of the structure of a fragment header provided in an embodiment of the present application;
[0040] Figure 5 A schematic diagram of the structure of an IPv6 data message fragment provided in an embodiment of the present application;
[0041] Figure 6 A flowchart of an attack detection method provided in an embodiment of the present application;
[0042] Figure 7 A schematic diagram of the structure of a fragment message provided in an embodiment of the present application;
[0043] Figure 8 A schematic diagram of the structure of a fragment message provided in an embodiment of the present application;
[0044] Fig. 9 A schematic diagram of the structure of a reassembled message provided in an embodiment of the present application;
[0045] Fig.10 A schematic diagram of the structure of a fragment message provided in an embodiment of the present application;
[0046] Fig.11 A schematic diagram of the structure of a reassembled message provided in an embodiment of the present application;
[0047] Fig.12 A schematic diagram of the structure of a reassembled message provided in an embodiment of the present application;
[0048] Fig.13 A schematic diagram of the structure of a reassembled message provided in an embodiment of the present application;
[0049] Fig.14A flowchart of an attack detection method provided in an embodiment of the present application;
[0050] Fig.15 A schematic diagram of the structure of an attack detection device provided in an embodiment of the present application;
[0051] Fig.16 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solution and beneficial effects of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0053] IPv4: Internet Protocol Version 4, Internet Communication Protocol Version 4, is the fourth revised version in the development process of the Internet Protocol and the first widely deployed version of this protocol.
[0054] IPv6: Internet Protocol Version 6, Internet Communication Protocol Version 6, is the next-generation IP protocol designed by the Internet Engineering Task Force to replace IPv4.
[0055] Maximum Transmission Unit: Maximum Transmission Unit, MTU, is used to inform the other party of the maximum size of the data service unit that can be accepted, indicating the effective load size that the sender can accept.
[0056] IP datagram fragmentation: When an IP datagram is larger than the maximum transmission unit of a link, the IP datagram can be broken down into many small fragments so that it can be transmitted on the link.
[0057] Fragmented message: After the IP data message is fragmented, many small fragments are formed, which are fragmented messages.
[0058] Extension header: When the IPv6 extension header provides optional functions, you only need to load the required information into the extension header.
[0059] refer to Figure 1 , which is a system architecture diagram applicable to the embodiment of the present application, the system architecture at least includes a client 101, an attack detection system 102 and a server 103. Among them, the attack detection system 102 can be independent of the server 103, or it can be built into the server 103.
[0060] Client 101 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), as well as big data and artificial intelligence platforms.
[0061] The attack detection system 102 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), as well as big data and artificial intelligence platforms.
[0062] The server 103 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), as well as big data and artificial intelligence platforms.
[0063] The client 101 and the attack detection system 102 can be directly or indirectly connected via wired or wireless communication, which is not limited in this application. The attack detection system 102 and the server 103 can be directly or indirectly connected via wired or wireless communication, which is not limited in this application.
[0064] Before receiving each sub-message, the server 103 receives multiple fragment messages in the target data message in sequence, and performs compliance detection on the multiple fragment messages in sequence, wherein the target data message is an IPv6 data message. If multiple fragment messages are detected and passed, the multiple fragment messages are reassembled to obtain a reassembled message. The first header contained in the reassembled message and the number of bytes corresponding to the reassembled message are verified. If the verification fails, the reassembled message is determined to be an attack message, and the reassembled message is discarded. If the verification fails, it is determined that the reassembled message is not an attack message, and the reassembled message is sent to the server 103.
[0065] Specifically, an IPv6 datagram includes an IPv6 header, an extended header, and payload data, and its structure is as follows: Figure 2 The detailed structure of IPv6 datagram is as shown in Figure 3shown.
[0066] The payload data is the upper layer protocol data. The payload data can be fragmented.
[0067] The IPv6 header includes version, traffic level, flow label, payload length, next header, hop limit, source IP address, and destination IP address.
[0068] The version is used to indicate the version number of the current IP protocol, and the value corresponding to the version is 6. The traffic level is used to indicate the communication category or priority of the IPv6 data flow. The flow label is unique to IPv6 and is used to mark the data flow for special processing. The payload length is used to describe the number of bytes corresponding to the extension header part and the payload. The next header is used to mark the first header after the IPv6 header. The hop limit is used to limit the number of times the IPv6 data message is forwarded between routers. The source IP address is the IP address of the initiator, and the destination IP address is the IP address of the destination.
[0069] The extended header part may include multiple extended headers, such as extended header 1, extended header 2, ..., extended header N, where N>0, and N is less than or equal to 6. The order of various extended headers in the extended header part is: hop-by-hop option header, destination option header, routing header, fragmentation header, authentication header, and ESP protocol header.
[0070] Among them, the hop-by-hop options header is mainly used to specify the transmission parameters for each hop forwarding on the transmission path. Each router on the transmission path must read and process this field. The destination options header carries information that only the destination will process. The routing header can be used by the initiator to force IPv6 data packets to pass through a specific router. The fragmentation header provides fragmentation and reassembly information. The authentication header provides authentication, data integrity, and replay protection. The ESP protocol header provides encryption services.
[0071] The specific structure of the fragment header is as follows Figure 4 As shown, the fragment header includes a next header field, a reserved field, a fragment offset field, a Res field, a fragment end flag, and an identifier field.
[0072] The Next Header field is used to mark the first header after the Fragment header. The Fragment Offset field is used to identify the offset of the payload data after the IPv6 header during message reassembly. The Fragment End Flag is used to identify whether the fragment message is the last fragment message of the original IPv6 data message. When the Fragment End Flag is 0, it indicates that the fragment message is the last fragment message of the original IPv6 data message; when the Fragment End Flag is 1, it indicates that the fragment message is not the last fragment message of the original IPv6 data message.
[0073] In an IPv6 datagram, the non-fragmentable headers include: IPv6 header, hop-by-hop options header, destination options header, and routing header.
[0074] The fragmentable headers include: authentication header and ESP protocol header.
[0075] When IPv6 data messages are fragmented, the non-fragmentable part and a part of the fragmentable part in the IPv6 data message are combined to obtain multiple fragment messages.
[0076] For example, if Figure 5 As shown, an IPv6 datagram includes an IPv6 header, a routing header, and payload data. The IPv6 header corresponds to 40 bytes, the routing header corresponds to 8 bytes, and the payload data corresponds to 3960 bytes.
[0077] The IPv6 data packet is fragmented according to the link maximum transmission unit of 1500 bytes to obtain three fragment packets, namely fragment packet 1, fragment packet 2 and fragment packet 3.
[0078] Each fragment message includes the non-fragmentable part of the IPv6 data message and a part of the fragmentable part, namely the IPv6 header, routing header, and part of the payload data in the non-fragmentable part. At the same time, a fragment header is added to each fragment message.
[0079] Each fragment message cannot exceed the link maximum transmission unit of 1500 bytes. Therefore, the number of bytes corresponding to fragment message 1 is 1496 bytes, of which the IPv6 header corresponds to 40 bytes, the routing header corresponds to 8 bytes, the fragment header corresponds to 8 bytes, and the payload data corresponds to 1440 bytes.
[0080] The number of bytes corresponding to fragment message 2 is 1496 bytes, of which the IPv6 header corresponds to 40 bytes, the routing header corresponds to 8 bytes, the fragment header corresponds to 8 bytes, and the payload data corresponds to 1440 bytes.
[0081] The number of bytes corresponding to fragment message 3 is 1136 bytes, of which the IPv6 header corresponds to 40 bytes, the routing header corresponds to 8 bytes, the fragment header corresponds to 8 bytes, and the payload data corresponds to 1080 bytes.
[0082] based on Figure 1 The system architecture diagram, the embodiment of the present application provides a process of an attack detection method, such as Figure 6 As shown, the process of this method is Figure 1 The attack detection system 102 shown executes the following steps:
[0083] Step S601, receiving multiple fragment messages in the target data message in sequence, and performing compliance detection on the multiple fragment messages in sequence.
[0084] Specifically, the attack detection system 102 receives multiple fragment messages in different target data messages, groups multiple fragment messages with the same destination IP address into one group according to the destination IP addresses in the fragment messages, and performs compliance detection on multiple fragment messages in each group.
[0085] The compliance detection of the fragment message includes the following two detection methods: detecting the second header of the fragment message and detecting the fragment end flag and the fragment offset field in the second header. The second header of the fragment message includes an IPv6 header and an extended header part.
[0086] Step S602: If the multiple fragmented messages all pass the detection, the multiple fragmented messages are reassembled to obtain a reassembled message.
[0087] Specifically, if one of the fragmented messages fails the detection, the fragmented message is discarded.
[0088] Step S603: verify the first header contained in the reassembled message and the number of bytes corresponding to the reassembled message. If the verification fails, determine that the reassembled message is an attack message, and discard the reassembled message.
[0089] Specifically, the first header includes an IPv6 header and an extended header portion. If the verification is successful, the reassembled message is a non-attack message, and the reassembled message is sent to the server 103 .
[0090] In an embodiment of the present application, multiple fragment messages in a target data message are received in sequence, and compliance checks are performed on the multiple fragment messages in sequence. If multiple fragment messages all pass the test, the multiple fragment messages are reassembled to obtain a reassembled message. The first header contained in the reassembled message and the number of bytes corresponding to the reassembled message are verified. If the verification fails, the reassembled message is determined to be an attack message and the reassembled message is discarded. Since malicious fragment attacks are caused by triggering recursive reassembly of fragment messages, the first header and the corresponding number of bytes contained in the reassembled message after reassembly are different from those of normal data messages. By verifying the first header and the corresponding number of bytes of the reassembled message, malicious attacks can be effectively detected.
[0091] Optionally, before sequentially performing compliance checks on multiple fragment messages, the embodiment of the present application uses at least the following implementation methods to perform preliminary checks on each fragment message:
[0092] Implementation method 1: if the fragment end flag in the second header of a fragment message is 1, and the number of bytes corresponding to the fragment message is less than the maximum transmission unit of the first link, the fragment message is discarded.
[0093] Specifically, the first link maximum transmission unit is the lower limit value of the link maximum transmission unit. Different links correspond to different link maximum transmission units. Each link maximum transmission unit corresponds to an upper limit value and a lower limit value.
[0094] For example, in Ethernet, the upper limit of the maximum transmission unit of the link is 1500 bytes, and the lower limit of the maximum transmission unit of the link is 1280 bytes.
[0095] In each fragment message, except the last fragment message, the number of bytes corresponding to each fragment message is greater than or equal to the lower limit of the link maximum transmission unit, and less than or equal to the upper limit of the link maximum transmission unit.
[0096] The second header of any fragment message includes a fragment header. If the fragment message is the last fragment message, the fragment end flag in the fragment header is 0. If the fragment message is not the last fragment message, the fragment end flag in the fragment header is 1.
[0097] When a fragment message is not the last fragment message, the number of bytes corresponding to the fragment message is close to the upper limit of the link maximum transmission unit, that is, the number of bytes corresponding to the fragment message must be greater than or equal to the lower limit of the link maximum transmission unit. Therefore, if the fragment end flag of the fragment header in the second extended header of the fragment message is 1, and the number of bytes corresponding to the fragment message is less than the first link maximum transmission unit, it means that the fragment message is abnormal, and the fragment message is discarded.
[0098] Implementation method 2: If the fragment end flag in the second header of a fragment message is 1, and the number of bytes corresponding to a fragment message is not an integer multiple of 8, or the difference between the number of bytes corresponding to a fragment message and the maximum transmission unit of the second link is greater than 4 bytes, then the fragment message is discarded.
[0099] Specifically, the second link maximum transmission unit is the upper limit of the link maximum transmission unit. When a fragment message is not the last fragment message, the number of bytes corresponding to the fragment message is an integer multiple of 8, and the number of bytes corresponding to the fragment message is close to the upper limit of the link maximum transmission unit.
[0100] For example, in Ethernet, the upper limit of the maximum transmission unit of the link is 1500 bytes. For a normal fragment message, if the fragment message is not the last fragment message, the number of bytes corresponding to the fragment message is 1496 bytes. The number of bytes corresponding to the fragment message is an integer multiple of 8 and differs from the upper limit of the maximum transmission unit of 1500 bytes by 4 bytes.
[0101] If a fragment message is not the last fragment message, and the corresponding number of bytes is 1495 bytes, since the number of bytes corresponding to the fragment message is not an integer multiple of 8, the fragment message is abnormal and is discarded.
[0102] If a fragment message is not the last fragment message, and the corresponding number of bytes is 1488 bytes, since the number of bytes corresponding to the fragment message is an integer multiple of 8, but 1488 bytes differs from the upper limit of the maximum transmission unit 1500 bytes by 12 bytes, the fragment message is abnormal and is discarded.
[0103] It should be noted that when performing preliminary verification on each fragment message, the above two methods can be used for preliminary verification at the same time, or one of the methods can be used. This application does not make specific limitations on this.
[0104] In an embodiment of the present application, if the fragment message is not the last fragment message, the number of bytes corresponding to the fragment message is checked, which can effectively filter out data messages with abnormal number of bytes.
[0105] Optionally, in the above step S601, the embodiment of the present application uses at least the following method to perform compliance detection on each fragment message:
[0106] For each fragment message, the following steps are respectively performed: in the second header of a fragment message, if the fragmentable header is located before the non-fragmentable header, it is determined that a fragment message compliance check fails, and a fragment message is discarded.
[0107] Specifically, the fragmentable headers in the second header include: a hop-by-hop option header, a destination option header, a routing header, and a fragmentation header. The non-fragmentable headers in the second header include: an authentication header and an ESP protocol header.
[0108] If any fragmentable header of the second header of the fragmented message is located before any non-fragmentable header, the compliance check of the fragmented message fails and the fragmented message is discarded.
[0109] For example, the fragment message structure is as follows Figure 7 As shown in FIG, it includes an IPv6 header, a routing header, an authentication header, a fragmentation header, and payload data, wherein the routing header and the fragmentation header are non-fragmentable headers, and the authentication header is a fragmentable header. Figure 7 In the example, the authentication header is located before the fragment header, that is, the fragmentable message is located before the non-fragmentable header. Therefore, the compliance check of the fragmented message fails and the fragmented message is discarded.
[0110] In a possible implementation manner, in a second header of a fragmented message, if the fragmentable header is located after the non-fragmentable header, it is directly determined that the compliance check of the fragmented message has passed.
[0111] In a possible implementation, in the second header of a fragmented message, if the fragmentable header is located after the non-fragmentable header, it is determined whether the values of the fragment end flag and the fragment offset field in the second header are both 0; if so, it is determined that a fragmented message compliance test fails, and a fragmented message is discarded. Otherwise, it is determined that a fragmented message compliance test passes.
[0112] Specifically, if the fragment message is the last fragment message, the fragment end flag in the fragment header is 0, and the corresponding value of the fragment offset field is a non-zero value.
[0113] If the fragment message is the first fragment message, the fragment end flag in the fragment header is 1, and the corresponding value of the fragment offset field is 0. If the fragment message is another fragment message, the fragment end flag in the fragment header is 1, and the corresponding value of the fragment offset field is a non-zero value. In other words, a normal fragment message will not have the situation where the values of the fragment end flag and the fragment offset field are both 0.
[0114] Based on this, when a fragment message is subjected to compliance check, if the values of the fragment end flag and the fragment offset field are both 0, the fragment message fails the compliance check and is discarded.
[0115] In an embodiment of the present application, the positions of the fragmentable header and the non-fragmentable header in the second header of the fragmented message are detected, and the fragment end flag and the fragment offset field in the second header are detected, so as to effectively filter out data messages with abnormal second headers.
[0116] Optionally, before reassembling the multiple fragmented messages and obtaining the reassembled message, the embodiment of the present application adopts at least the following implementation modes to verify the multiple fragmented messages:
[0117] Implementation method 1: if multiple fragment messages are detected to be passed, determine the receiving time interval between the first fragment message and the last fragment message in the multiple fragment messages. If the receiving time interval exceeds the optimal time interval, discard the multiple fragment messages.
[0118] Specifically, for a target data message, the first fragment message may be the first fragment message received, or may be the first fragment message in the target data message.
[0119] The last fragment message may be the last fragment message received, or the last fragment message in the target data message. The receiving time interval is the difference between the time when the first fragment message is received and the time when the last fragment message is received.
[0120] The optimal time interval can be obtained through training of any model among time series models, linear regression models, and deep learning models, or can be preset.
[0121] In a possible implementation, different links correspond to different optimal time intervals, that is, each link corresponds to a training model.
[0122] In another possible implementation, links with similar link states correspond to the same optimal time interval, that is, multiple links correspond to one training model.
[0123] The following describes a method for training a deep learning model for a link. The deep learning model is used to determine the optimal time interval. The training method includes the following steps:
[0124] Step S701, collecting the time intervals between each fragment message in different data messages under a link as a characteristic part.
[0125] For example, in Ethernet, a data message is fragmented into three fragment messages, namely, fragment message 1, fragment message 2, and fragment message 3. The time interval between fragment message 1 and fragment message 2 is 1ms, and the time interval between fragment message 2 and fragment message 3 is 2ms. The time intervals of 1ms and 2ms obtained above are used as the characteristic parts of a piece of data.
[0126] Step S702: for different data messages, select the optimal preset time interval from different preset time intervals under the link as the label part.
[0127] Step S703, matching the feature part with the label part to obtain training data.
[0128] Step S704: Iteratively train the deep learning model using the training data until the corresponding loss function meets the convergence condition, thereby obtaining a trained deep learning model.
[0129] After the training is completed, the time interval between each fragment message in the target data message is input into the above-mentioned trained deep learning model to determine the optimal time interval corresponding to the target data message.
[0130] In the embodiment of the present application, the receiving time interval between the first fragment message and the last fragment message is determined, and by comparing the relationship between the receiving time interval and the optimal time interval, the time for waiting to receive the fragment message can be effectively reduced. At the same time, each link corresponds to a different optimal time interval, and the optimal time interval is adjusted according to different link states. Therefore, the detection strategy of the fragment attack can be dynamically adjusted.
[0131] Implementation method 2: if the number of multiple fragment messages exceeds a preset number of messages, the multiple fragment messages are discarded.
[0132] Specifically, the preset number of messages can be obtained through training of any model among a time series model, a linear regression model, and a deep learning model, or can be preset.
[0133] In one possible implementation, different destination IP addresses correspond to different preset numbers of messages, that is, each destination IP address corresponds to a training model.
[0134] Another possible implementation is that destination IP addresses with similar destination IP addresses correspond to the same preset number of messages, that is, multiple destination IP addresses correspond to one training model.
[0135] The following introduces a method for training a deep learning model for a destination IP address. The deep learning model is used to determine the preset number of messages. The training method includes the following steps:
[0136] Step S801, collecting the number of each fragment message in different data messages under a destination IP address as a characteristic part.
[0137] For example, the destination IP address is 27.115.105.155, and one data message corresponds to three fragment messages after fragmentation, namely, fragment message 1, fragment message 2, and fragment message 3. The number of messages 3 obtained above is used as the characteristic part of a data.
[0138] Step S802: for different data packets, select the optimal preset packet quantity from different preset packet quantities under the link as the label part.
[0139] Step S803, matching the feature part with the label part to obtain training data.
[0140] Step S804: Iteratively train the deep learning model using the training data until the corresponding loss function meets the convergence condition, thereby obtaining a trained deep learning model.
[0141] After the training is completed, the number of messages in each fragment message in the target data message is input into the above-mentioned trained deep learning model to determine the preset number of messages corresponding to the target data message.
[0142] In the embodiment of the present application, by detecting the number of multiple fragmented messages, a large number of fragmented messages in a fragmented attack can be effectively filtered out. At the same time, since each destination IP address corresponds to a preset number of messages, the preset number of messages is adjusted according to different destination IP addresses, and therefore, the detection strategy of the fragmented attack can be dynamically adjusted.
[0143] Optionally, in the above step S603, at least the following implementation modes of the embodiment of the present application verify the number of bytes corresponding to the first header and the reassembled message included in the reassembled message:
[0144] In a possible implementation, if the next header field in the first header points to the fragment header, or the number of bytes corresponding to the reassembled message is greater than a preset value, the verification fails, and the reassembled message is determined to be an attack message, and the reassembled message is discarded.
[0145] Specifically, in a logic error attack, generally, multiple logic error fragment messages are reassembled to obtain an abnormal reassembled message. In the first header in the abnormal reassembled message, the next header field in the IPv6 header points to the fragment header. Therefore, in the present application, when the next header field in the first header points to the fragment header, the verification fails, and the logic error attack can be effectively detected.
[0146] In a malicious attack, multiple malicious attack messages are generally reassembled to obtain an abnormal reassembled message. The number of bytes corresponding to the abnormal reassembled message is greater than 65536 bytes. Therefore, in this application, when the number of bytes corresponding to the reassembled message is greater than the preset value, the verification fails, which can effectively detect malicious attacks.
[0147] For example, if Figure 8 As shown, it is assumed that the reassembled message includes three fragment messages, which are fragment message 1, fragment message 2, and fragment message 3. Each fragment message includes an IPv6 header, a fragment header, and payload data.
[0148] Among them, fragment message 1 includes an IPv6 header, a fragment header 1 and payload data 1, and the next header field in the IPv6 header points to the fragment header 1.
[0149] Fragment message 2 includes an IPv6 header, a fragment header 2, and payload data 2. The next header field in the IPv6 header points to fragment header 2.
[0150] The fragment header in fragment message 3 is fragment header 3, the payload data includes routing header 1 and payload data 3, and the next header field in the IPv6 header points to fragment header 3.
[0151] After reassembling the three fragmented messages, we get the reassembled message, such as Fig. 9As shown. The reassembled message includes an IPv6 header, a routing header, a fragment header, and payload data. Among them, the fragment header is an internal fragment header 1, and the payload data includes payload data 1, payload data 2, and payload data 3. The next header field in the IPv6 header points to fragment header 1. Therefore, the reassembled message verification fails, and the reassembled message is determined to be an attack message, and the reassembled message is discarded.
[0152] For example, if Fig.10 As shown, it is assumed that the reassembled message includes n (n is an integer greater than 2) fragment messages, which are fragment message 1, fragment message 2, ..., fragment message n in sequence. Each fragment message includes an IPv6 header, a fragment header, and payload data.
[0153] The fragment message 1 includes an external fragment header 1 and payload data 1.
[0154] Fragment message 2 includes external fragment header 2 and payload data 2. The structures of fragment messages 3 to n-1 are the same as that of fragment message 1.
[0155] The fragment header in the fragment message n is the outer fragment header n, and the payload data includes the inner fragment header 1 and the payload data n, and the inner fragment header 1 is the fragment header.
[0156] After reassembling n fragmented messages, the first reassembled message is obtained, such as Fig.11 The first reassembled message includes an IPv6 header, a fragment header, and payload data, wherein the fragment header is an internal fragment header 1, and the payload data includes payload data 1, payload data 2, ..., payload data n.
[0157] Since the first reassembled message still contains the fragment header, the first reassembled message is reassembled again, and the internal fragment header 1 is discarded to obtain the second reassembled message, such as Fig.12 The second reassembled message includes an IPv6 header and payload data, wherein the payload data includes payload data 1, payload data 2, ..., payload data n.
[0158] At this time, if the number of bytes corresponding to the second reassembled message is greater than 65535 bytes, the verification fails, and the second reassembled message is determined to be an attack message, and the second reassembled message is discarded.
[0159] In an embodiment of the present application, by judging whether the next header field in the first header in the reassembled message points to the fragment header and the number of bytes corresponding to the reassembled message, malicious fragmentation attacks and logical error attacks can be effectively resolved.
[0160] In a possible implementation manner, if the next header field in the first header does not point to the fragment header, and the number of bytes corresponding to the reassembled message is less than or equal to a preset value, it is directly determined that the reassembled message has passed the verification.
[0161] A possible implementation method is that if the next header field in the first header does not point to the fragment header, and the number of bytes corresponding to the reassembled message is less than or equal to a preset value, it is determined whether the fragmentable header of the first header is located before the non-fragmentable header. If so, the verification fails.
[0162] Specifically, the fragmentable headers in the first header include: a hop-by-hop option header, a destination option header, and a routing header. The non-fragmentable headers in the first header include: an authentication header and an ESP protocol header.
[0163] If any fragmentable header of the first header of the reassembled message is located before any non-fragmentable header, the reassembled message fails the verification and is discarded.
[0164] For example, the reassembled message structure is as follows Fig.13 As shown, it includes an IPv6 header, an authentication header, a routing header, and payload data, wherein the routing header is a non-fragmentable header and the authentication header is a fragmentable header. Fig.13 In the example, the authentication header is located before the routing header. Therefore, the reassembled message fails the verification and is discarded.
[0165] In the embodiment of the present application, by judging the positions of the fragmentable header and the non-fragmentable header in the first header of the reassembled message, the compliance of the reassembled message is further verified, thereby enhancing the accuracy of attack detection.
[0166] In order to better explain the embodiment of the present application, an attack detection method provided by the embodiment of the present application is described below in combination with a specific implementation scenario. Fig.14 As shown, it includes the following steps:
[0167] Step S1401, receiving N fragment messages in the target data message in sequence.
[0168] Step S1402, set variable i=1.
[0169] Step S1403, obtaining the i-th fragment message.
[0170] Step S1404, determine whether i is less than or equal to N, if so, jump to step S1405; if not, jump to step S1407.
[0171] Step S1405, determine whether the i-th fragment message passes the compliance test, if so, jump to step S1406; if not, end.
[0172] Step S1406, i=i+1.
[0173] Step S1407, determining the reception time interval between the first fragment message and the Nth fragment message.
[0174] Step S1408, determine whether the receiving time interval exceeds the optimal time interval, if so, execute step S1416; otherwise, execute step S1409.
[0175] Step S1409, determine whether N exceeds the preset number of messages, if so, execute step S1416; otherwise, execute step S1410.
[0176] Step S1410, reassemble the N fragmented messages to obtain a reassembled message.
[0177] Step S1411, determine whether the next header field in the first header of the reassembled message points to the fragment header, if so, execute step S1415; otherwise, execute step S1412.
[0178] Step S1412, determine whether the number of bytes corresponding to the reassembled message is greater than a preset value, if so, execute step S1415; otherwise, execute step S1413.
[0179] Step S1413, determine whether the fragmentable header in the first header is located before the non-fragmentable header, if so, execute step S1415; otherwise, execute step S1414.
[0180] Step S1414, determine that the reassembled message is a normal message, and end.
[0181] Step S1415: determine that the reassembled message is an attack message, discard the reassembled message, and end.
[0182] Step S1416, discard N fragmented messages and end.
[0183] In an embodiment of the present application, by performing compliance detection on the fragmented message, data messages with abnormal headers in the fragmented message can be filtered out. The receiving time interval between the first fragmented message and the last fragmented message is determined, and by comparing the relationship between the receiving time interval and the optimal time interval, the time waiting for receiving the fragmented message can be effectively reduced. At the same time, each link corresponds to a different optimal time interval, and the optimal time interval is adjusted according to different link states. Therefore, the detection strategy of the fragmentation attack can be dynamically adjusted. By detecting the number of multiple fragmented messages, the situation of a large number of fragmented messages in the fragmentation attack can be effectively filtered out. At the same time, since each destination IP address corresponds to a preset number of messages, the preset number of messages is adjusted according to different destination IP addresses, therefore, the detection strategy of the fragmentation attack can be dynamically adjusted. By judging whether the next header field in the first header in the reassembled message points to the fragment header and the number of bytes corresponding to the reassembled message, malicious fragmentation attacks and logical error attacks can be effectively resolved. By judging the positions of the fragmentable header and the non-fragmentable header in the first header of the reassembled message, the compliance of the reassembled message is further verified, thereby enhancing the accuracy of attack detection.
[0184] Based on the same technical concept, the embodiment of the present application provides an attack detection device, such as Fig.15 As shown, the device 1500 includes:
[0185] The detection module 1501 is used to sequentially receive multiple fragment messages in the target data message, and sequentially perform compliance detection on the multiple fragment messages;
[0186] A reassembly module 1502 is configured to reassemble the multiple fragmented messages to obtain a reassembled message if the multiple fragmented messages all pass the detection;
[0187] The verification module 1503 is used to verify the first header contained in the reassembled message and the number of bytes corresponding to the reassembled message. If the verification fails, the reassembled message is determined to be an attack message and the reassembled message is discarded.
[0188] Optionally, the detection module 1501 is specifically used for:
[0189] For each fragment message, perform the following steps respectively:
[0190] In the second header of a fragmented message, if the fragmentable header is located before the non-fragmentable header, it is determined that the compliance check of the fragmented message fails, and the fragmented message is discarded.
[0191] Optionally, the detection module 1501 is further used for:
[0192] In a second header of a fragmented message, if the fragmentable header is located after the non-fragmentable header, determining whether the values of the fragment end flag and the fragment offset field in the second header are both 0;
[0193] If yes, determine that the compliance check of the fragment message fails, and discard the fragment message;
[0194] Otherwise, it is determined that the compliance test of the one fragment message passes.
[0195] Optionally, a verification module 1504 is further included, and the verification module 1504 is specifically used to:
[0196] Before performing compliance checks on the multiple fragmented messages in sequence, if the fragment end flag in the second header is 1, and the number of bytes corresponding to the one fragmented message is less than the first link maximum transmission unit, then the one fragmented message is discarded, and the first link maximum transmission unit is the lower limit value of the link maximum transmission unit.
[0197] Optionally, the verification module 1504 is further used to:
[0198] If the number of bytes corresponding to the fragment message is not an integer multiple of 8, or the difference between the number of bytes corresponding to the fragment message and the second link maximum transmission unit is greater than 4 bytes, the fragment message is discarded, where the second link maximum transmission unit is the upper limit value of the link maximum transmission unit.
[0199] Optionally, the verification module 1504 is further used to:
[0200] Recombining the multiple fragment messages, and before obtaining the recombined message, if the multiple fragment messages all pass the detection, determining the reception time interval between the first fragment message and the last fragment message in the multiple fragment messages;
[0201] If the receiving time interval exceeds the optimal time interval, discarding the multiple fragment messages; or,
[0202] If the number of the multiple fragment messages exceeds the preset message number, the multiple fragment messages are discarded.
[0203] Optionally, the verification module 1503 is specifically used for:
[0204] If the next header field in the first header points to the fragment header, or the number of bytes corresponding to the reassembled message is greater than a preset value, the verification fails, and the reassembled message is determined to be an attack message, and the reassembled message is discarded.
[0205] Optionally, the verification module 1503 is further used to:
[0206] If the next header field in the first header does not point to the fragment header, and the number of bytes corresponding to the reassembled message is less than or equal to the preset value, it is determined whether the fragmentable header of the first header is located before the non-fragmentable header. If so, the verification fails.
[0207] Based on the same technical concept, the embodiment of the present application provides a computer device, which may be a terminal or a server, such as Fig.16 As shown, it includes at least one processor 1601 and a memory 1602 connected to the at least one processor. The specific connection medium between the processor 1601 and the memory 1602 is not limited in the embodiment of the present application. Fig.16 For example, the processor 1601 and the memory 1602 are connected via a bus. The bus can be divided into an address bus, a data bus, a control bus, etc.
[0208] In the embodiment of the present application, the memory 1602 stores instructions that can be executed by at least one processor 1601. The at least one processor 1601 can execute the steps included in the above-mentioned attack detection method by executing the instructions stored in the memory 1602.
[0209] Among them, the processor 1601 is the control center of the computer device, and can use various interfaces and lines to connect various parts of the computer device, and perform attack detection by running or executing instructions stored in the memory 1602 and calling data stored in the memory 1602. Optionally, the processor 1601 may include one or more processing units, and the processor 1601 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 1601. In some embodiments, the processor 1601 and the memory 1602 may be implemented on the same chip, and in some embodiments, they may also be implemented separately on independent chips.
[0210] Processor 1601 can be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor, an application-specific integrated circuit (ASIC), a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, and can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware processor for execution, or can be executed by a combination of hardware and software modules in the processor.
[0211] Memory 1602 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. Memory 1602 may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (Random Access Memory, RAM), static random access memory (Static Random Access Memory, SRAM), programmable read-only memory (Programmable Read Only Memory, PROM), read-only memory (Read Only Memory, ROM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), magnetic memory, disk, optical disk, etc. Memory 1602 is any other medium that can be used to carry or store a desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory 1602 in the embodiment of the present application can also be a circuit or any other device that can realize a storage function, for storing program instructions and / or data.
[0212] Based on the same inventive concept, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program executable by a computer device. When the program runs on the computer device, the computer device executes the steps of the above-mentioned attack detection method.
[0213] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0214] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0215] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0216] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0217] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. An attack detection method, characterized in that: include: Receive multiple fragment messages in the target data message in sequence through the link, and perform the following steps for each fragment message: if the fragment end flag in the second header of a fragment message is 1, and the number of bytes corresponding to the fragment message is less than the first link maximum transmission unit, then discard the fragment message, and the first link maximum transmission unit is the lower limit value of the link maximum transmission unit; If the number of bytes corresponding to the fragment message is not an integer multiple of 8, or the difference between the number of bytes corresponding to the fragment message and the second link maximum transmission unit is greater than 4 bytes, the fragment message is discarded, wherein the second link maximum transmission unit is the upper limit of the link maximum transmission unit; the fragment end flag is 1 to indicate that the fragment message is not the last fragment message; and performing compliance checks on the multiple fragment messages in sequence; Determine the receiving time interval between the first fragment message and the last fragment message in the multiple fragment messages, and if the receiving time interval exceeds the optimal time interval, discard the multiple fragment messages; the optimal time interval is determined according to the link; the optimal time intervals corresponding to different links are different; each link corresponds to a training model, and the training model corresponding to each link is used to obtain the optimal time interval corresponding to each link; If the number of the multiple fragmented messages exceeds the preset number of messages, the multiple fragmented messages are discarded; the preset number of messages is determined according to the destination IP addresses corresponding to the multiple fragmented messages; the preset number of messages corresponding to different destination IP addresses is different; a training model corresponding to each destination IP address, and the training model corresponding to each destination IP address is used to obtain the preset number of messages corresponding to each destination IP address; If the multiple fragmented messages all pass the detection, the multiple fragmented messages are reassembled to obtain a reassembled message; If the next header field in the first header of the reassembled message points to the fragment header, or the number of bytes corresponding to the reassembled message is greater than a preset value, the verification fails, and the reassembled message is determined to be an attack message, and the reassembled message is discarded; If the next header field in the first header does not point to the fragment header, and the number of bytes corresponding to the reassembled message is less than or equal to the preset value, it is determined whether the fragmentable header of the first header is located before the non-fragmentable header. If so, the verification fails.
2. The method according to claim 1, characterized in that The sequentially performing compliance checks on the multiple fragment messages includes: For each fragment message, perform the following steps respectively: In the second header of a fragmented message, if the fragmentable header is located before the non-fragmentable header, it is determined that the compliance check of the fragmented message fails, and the fragmented message is discarded.
3. The method according to claim 2, characterized in that Also includes: In a second header of a fragmented message, if the fragmentable header is located after the non-fragmentable header, determining whether the values of the fragment end flag and the fragment offset field in the second header are both 0; If yes, determine that the compliance check of the fragment message fails, and discard the fragment message; Otherwise, it is determined that the compliance test of the one fragment message passes.
4. The method according to claim 1, characterized in that Before reassembling the plurality of fragmented messages to obtain the reassembled message, the method further comprises: If the multiple fragment messages all pass the detection, determine the reception time interval between the first fragment message and the last fragment message in the multiple fragment messages; If the receiving time interval exceeds the optimal time interval, discarding the multiple fragment messages; or, If the number of the multiple fragment messages exceeds the preset message number, the multiple fragment messages are discarded.
5. An attack detection device, characterized in that: include: A detection module, used to sequentially receive multiple fragment messages in a target data message through a link, and for each fragment message, respectively perform the following steps: if the fragment end flag in the second header of a fragment message is 1, and the number of bytes corresponding to the fragment message is less than the first link maximum transmission unit, then discard the fragment message, and the first link maximum transmission unit is the lower limit value of the link maximum transmission unit; If the number of bytes corresponding to the fragment message is not an integer multiple of 8, or the difference between the number of bytes corresponding to the fragment message and the second link maximum transmission unit is greater than 4 bytes, then the fragment message is discarded, wherein the second link maximum transmission unit is the upper limit of the link maximum transmission unit; the fragment end flag is 1 to indicate that the fragment message is not the last fragment message; and the compliance of the multiple fragment messages is checked in turn; the receiving time interval between the first fragment message and the last fragment message in the multiple fragment messages is determined, and if the receiving time interval exceeds the optimal time interval, the multiple fragment messages are discarded. ; The optimal time interval is determined according to the link; the optimal time intervals corresponding to different links are different; each link corresponds to a training model, and the training model corresponding to each link is used to obtain the optimal time interval corresponding to each link; if the number of the multiple fragmented messages exceeds the preset number of messages, the multiple fragmented messages are discarded; the preset number of messages is determined according to the destination IP addresses corresponding to the multiple fragmented messages; the preset number of messages corresponding to different destination IP addresses is different; each destination IP address corresponds to a training model, and the training model corresponding to each destination IP address is used to obtain the preset number of messages corresponding to each destination IP address; A reassembly module, configured to reassemble the multiple fragmented messages to obtain a reassembled message if the multiple fragmented messages all pass the detection; If the next header field in the first header of the reassembled message points to the fragment header, or the number of bytes corresponding to the reassembled message is greater than a preset value, the verification module is used to determine that the verification fails, determine that the reassembled message is an attack message, and discard the reassembled message; If the next header field in the first header does not point to the fragment header, and the number of bytes corresponding to the reassembled message is less than or equal to a preset value, the verification module is used to determine whether the fragmentable header of the first header is located before the non-fragmentable header. If so, the verification fails.
6. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the method according to any one of claims 1 to 4 are implemented.
7. A computer-readable storage medium, characterized in that: It stores a computer program executable by a computer device. When the program is run on the computer device, the computer device executes the steps of any method described in claims 1 to 4.
