A message detection method, electronic device and storage medium
By caching and replacing retransmitted data packets, the problem of low accuracy of retransmitted packet detection in firewalls is solved, and attack identification and server security are improved.
Patent Information
- Application Number
- CN202110117289.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-28
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2041-01-28
AI Technical Summary
In existing firewall technology, the attack identification accuracy of retransmitted packet detection is low, and the retransmitted data packets carrying attacks cannot be effectively identified and intercepted, resulting in possible attacks on the server.
By caching received TCP packets that do not contain attacks, and replacing retransmitted packets with cached packets within a set period of time, the server is prevented from receiving retransmitted packets carrying attacks, thereby improving the accuracy of attack detection.
It effectively improves the accuracy of retransmitted packet detection and identification of attacks, prevents the server from being attacked by retransmitted data packets, and enhances the security and operating efficiency of the firewall.
Smart Images

Figure CN114826634B
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of firewall detection, and in particular to a message detection method, electronic equipment and storage medium. Background Art
[0002] Firewalls can separate internal networks from public networks, and can identify and discard messages in the public network that may attack the internal network, thereby ensuring the security of the internal network. Firewalls can identify attack messages by retransmission packet detection. In related technologies, retransmission packet detection has the problem of low accuracy in identifying attacks. Summary of the invention
[0003] In view of this, the main purpose of the embodiments of the present application is to provide a message detection method, an electronic device and a storage medium to solve the technical problem that the accuracy of identifying attacks in retransmission packet detection is low.
[0004] To achieve the above purpose, the technical solution of the embodiment of the present application is implemented as follows:
[0005] The present application provides a message detection method, the method comprising:
[0006] caching a first Transmission Control Protocol (TCP) message; the first TCP message is a received TCP message indicating that the message does not contain an attack;
[0007] When a retransmission data packet of the first TCP message is received within a first set time period, the retransmission data packet is replaced with the cached first TCP message.
[0008] The present application also provides another message detection method, the method comprising:
[0009] Predicting whether the server will perform a discard operation if the received segmented message is sent to the server; wherein, if it is predicted that the server will not perform the discard operation, determining that the corresponding segmented message is not a confusing message;
[0010] The segmented messages that are determined not to be obfuscated messages are reassembled, and attack feature detection is performed based on the reassembled messages.
[0011] By pre-determining whether the server will discard the received segmented messages, and reassembling the segmented messages that are determined not to be obfuscated messages, and performing attack feature detection on the reassembled messages, it is possible to first filter out messages with abnormal fields, and then detect the reassembled messages with normal fields, so as to further determine whether the messages contain attacks, thereby improving the accuracy of message attack detection.
[0012] The embodiment of the present application further provides an electronic device, characterized in that it includes: a processor and a memory for storing a computer program that can be run on the processor,
[0013] Wherein, the processor is used to execute the steps of any of the above methods when running the computer program.
[0014] An embodiment of the present application further provides a storage medium having a computer program stored thereon, wherein the computer program implements the steps of any of the above methods when executed by a processor.
[0015] In an embodiment of the present application, by caching the first TCP message; the first TCP message is a received TCP message that does not contain an attack; when a retransmitted data packet of the first TCP message is received within a first set time period, the retransmitted data packet is replaced with the cached first TCP message, thereby ensuring that the data packet forwarded to the server is not a retransmitted data packet carrying an attack, thereby preventing the server from being attacked by the retransmitted data packet and improving the accuracy of retransmitted packet detection and identification of attacks. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 A schematic diagram of the implementation flow of the message detection method provided in the embodiment of the present application;
[0017] Figure 2a It shows the commonly used detection deployment scenarios in practical applications;
[0018] Figure 2b Another commonly used detection deployment scenario in practical applications is shown;
[0019] Figure 3 A schematic diagram of the implementation flow of another message detection method provided in an embodiment of the present application;
[0020] Figure 4 A schematic diagram of the header structure of an IP message provided in an embodiment of the present application;
[0021] Figure 5 A schematic diagram of the header structure of a TCP message provided in an embodiment of the present application;
[0022] Figure 6 A schematic diagram of the implementation flow of another message detection method provided in an embodiment of the present application;
[0023] Figure 7 A schematic diagram of the implementation flow of another message detection method provided in an embodiment of the present application;
[0024] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0025] The present application is further described in detail below in conjunction with the accompanying drawings and embodiments.
[0026] Timeout retransmission is an important mechanism of the TCP protocol to ensure data reliability. A timer is started after sending a data. If no confirmation message about the data is received within a certain period of time, the data will be resent until a confirmation message about the data is received.
[0027] TCP retransmission packets refer to TCP packets with the same sequence number and length that are sent repeatedly. The reliability of the TCP protocol is guaranteed by the timeout retransmission mechanism, but attackers will use the timeout retransmission mechanism to repeatedly send packets with the same sequence number but inconsistent content, causing confusion. In related technologies, firewalls directly forward packets to servers without checking whether the content of the packets is consistent. When retransmission packets with the same sequence number but inconsistent content are attack packets, the server may be attacked after receiving such packets. In other words, in related technologies, retransmission packet detection cannot effectively identify attack packets and intercept them.
[0028] Based on this, an embodiment of the present application provides a message detection method, an electronic device and a storage medium. By caching a first TCP message, when a retransmitted data packet of the first TCP message is received within a first set time, the retransmitted data packet is replaced with the cached first TCP message, thereby ensuring that the data packet forwarded to the server is not a retransmitted data packet carrying an attack, thereby preventing the server from being attacked by the retransmitted data packet and improving the accuracy of retransmitted packet detection and identification of attacks.
[0029] Figure 1 Schematic diagram of the implementation process of the message detection method of the embodiment of the present application. Figure 1 As shown, the method includes:
[0030] Step 101: caching a first TCP message; the first TCP message is a received TCP message indicating that it does not contain an attack.
[0031] Here, when it is detected that the received TCP message does not contain an attack, the TCP message is cached as the first TCP message for subsequent retransmission.
[0032] Step 102: When a retransmitted data packet of the first TCP message is received within a first set time period, the retransmitted data packet is replaced with the cached first TCP message.
[0033] Here, when receiving the retransmission data packet of the first TCP message, the retransmission data packet is not directly forwarded to the server, but the received retransmission data packet is discarded, and the cached first TCP message is used to replace the retransmission data packet and sent to the server. In this way, even if there is an attack in the retransmission data packet, it will not affect the server, thereby preventing the server from being attacked by the retransmission data packet.
[0034] In order to implement the method of the embodiment of the present application, Figure 2a and Figure 2b The commonly used detection deployment scenarios in practical applications are shown. Figure 2a It shows that a firewall is built at the entrance of the Internet network. When external traffic passes through the firewall, the firewall detects it and intercepts the attack traffic when it is detected to prevent hacker intrusion. Figure 2b It shows the deployment of a firewall in bypass mode. The interface connecting the firewall to the switch is set to mirror mode. A copy of all traffic flowing through the switch is placed in the firewall for detection. Alternatively, policy routing is configured in the switch to divert traffic to the firewall for detection. After the traffic sent to the firewall is detected by the firewall, if there is an abnormality, it will be marked as an abnormality in the firewall.
[0035] In an embodiment of the present application, by caching a first TCP message; the first TCP message is a received TCP message that does not contain an attack; when a retransmitted data packet of the first TCP message is received within a first set time period, the retransmitted data packet is replaced with the cached first TCP message, thereby ensuring that the data packet forwarded to the server is not a retransmitted data packet carrying an attack, so that the server is protected from attacks by retransmitted data packets, and the accuracy of retransmitted packet detection and identification of attacks is improved.
[0036] In addition, in the embodiment of the present application, it can be assumed that the first received TCP message is a TCP message that does not contain an attack, and the first received TCP message is cached to replace the subsequent TCP message. This solution is also within the scope of protection of the present application. This method avoids executing attack feature detection, can improve the operating efficiency of devices such as firewalls, and save memory resources.
[0037] In one embodiment, the method further comprises:
[0038] When receiving the second TCP message, releasing the cached first TCP message; the second TCP message represents a confirmation message about the first TCP message returned by the server after sending the first TCP message to the server;
[0039] and / or,
[0040] When a third TCP message is received after the second TCP message is received, the third TCP message is discarded; and the sequence number of the third TCP message is smaller than the sequence number of the second TCP message.
[0041] After replacing the retransmission data packet of the first TCP message with the cached first TCP message, the replaced first TCP message is sent to the server. After receiving the first TCP message, the server returns a confirmation message about the first TCP message, and the confirmation message indicates that the sent first TCP message has been confirmed to be received correctly. Therefore, when receiving the confirmation message sent by the server based on the first TCP message, it means that the first TCP message has been successfully received and the retransmission process has been successful, so the cached first TCP message is released to avoid buffer overflow, thereby ensuring that the first TCP message sent subsequently can continue to be received.
[0042] In addition, before receiving the confirmation message from the server, the retransmission process continues, the first TCP message will continue to be sent to the server, and in chronological order, the first TCP message sent to the server first will receive the confirmation message from the server first, and the first TCP message sent to the server last will receive the confirmation message last. After receiving the confirmation message returned by the server for the first time about the first TCP message, it means that the retransmission has been successful and the retransmission process is over. After the retransmission process is over, if a message with a sequence number smaller than the sequence number of the confirmation message sent by the server is received again, the message is directly discarded to avoid repeated confirmation.
[0043] Figure 3 Another packet detection method is shown in FIG. Figure 3 , the method comprising:
[0044] In one embodiment, before caching the first TCP message, the method further includes:
[0045] The header field of the received IP fragment is detected, and if the detection result meets at least one of the following conditions, the received IP fragment is determined to be an obfuscated message:
[0046] The TTL of the IP fragment is less than the set threshold;
[0047] The routing path of IP fragmentation is not the set routing path;
[0048] The routing address of the last hop of the IP fragment is the set routing address; the set routing address represents the address of the firewall;
[0049] The checksum of the IP fragment is wrong;
[0050] There is an error in the timestamp option of IP fragmentation;
[0051] The determined IP fragments that are not obfuscated messages are reassembled to obtain TCP messages, and the TCP messages are used for subsequent attack detection.
[0052] Figure 4 A diagram showing the structure of an IP packet header is shown in Figure 4 , Version indicates the version number of the IP protocol, IHL indicates the header length, Type of Service indicates the service type, Total Length indicates the total length, Identification indicates the identification, Flags indicates the flag, Fragment Offset indicates the fragment offset, Time to Live indicates the lifetime, Protocol indicates the protocol, Header Checksum indicates the header checksum, Source Address indicates the source IP address, Destination Address indicates the destination IP address, Options indicates the options, and Padding indicates the padding.
[0053] Here, TTL is the maximum number of hops that an IP fragment can be forwarded in a computer network. Each time an IP fragment is forwarded, the TTL value decreases by one. When a firewall receives a confused message with a very small TTL and then receives an attack message with the same fields but a normal TTL, if the firewall does not detect whether there is an abnormality in the TTL of the message, and directly puts the message with a very small TTL and the message with a normal TTL into the IP fragment for reassembly, it may not detect the attack.
[0054] Usually, in a session, the network devices that the message passes through are basically stable, and the TTL will not fluctuate greatly. If a very small TTL value suddenly appears, such as the TTL value suddenly changes to 1 or even 0, then this message is likely to be an obfuscated message and there is a behavior of bypassing firewall detection. Therefore, the message with a TTL value less than the set threshold is determined as an obfuscated message. After being determined as an obfuscated message, it can be directly discarded.
[0055] Using illegal strict routing in obfuscated messages, such as the next hop address of the route is the test-specific local machine address 127.0.0.1 or 0.0.0.0, which represents all host IP addresses, or when the firewall receives the message, the routing address of the message is not in the routing address set by the firewall, which will also cause the message to bypass firewall detection. Therefore, according to the definition of strict routing in RFC971, if the routing path is defined as A->B->C->D, then each hop must be a strictly corresponding address, such as the next hop routing address of A must be B, and the next hop routing address of B must be C. Therefore, when the firewall detects that the routing path of the routing option in the IP fragment is not the set routing path, specifically including the next hop routing address is not the routing address in the set routing path; or when the last hop routing address of the message is detected as the firewall address, the messages with abnormal routing addresses are determined to be obfuscated messages and are directly discarded.
[0056] The purpose of the checksum is to verify whether the message has been tampered with during transmission. If an error is detected in the checksum of the IP fragment, it means that the IP fragment is likely to have been tampered with. Therefore, the IP fragment with an error in the checksum is determined as an obfuscated message and is directly discarded.
[0057] If an error is detected in the timestamp option of the IP fragment, the IP fragment is determined to be a confused message and the IP fragment is discarded. By detecting the TTL, routing address, checksum and timestamp options of the IP fragment header field, the message is directly discarded when an abnormality is detected during the IP fragment header field detection process, which can prevent abnormal messages from entering the subsequent detection process to cause attacks and improve the accuracy of IP fragment header field detection.
[0058] In one embodiment, before step 101, the method further includes:
[0059] In the case where the offsets of at least two IP fragments overlap, the overlapping portion of the offset of the first IP fragment is overlaid onto the overlapping portion of the offset of the second IP fragment; wherein,
[0060] The receiving time of the first IP fragment is before the receiving time of the second IP fragment.
[0061] An IP data packet may need to pass through multiple different physical networks to be transmitted from the source host to the destination host. Since the data frames of each network have a maximum transmission unit (MTU), when the size of the data packet exceeds the maximum transmission unit of the egress link, the IP data packet will be broken down into many small enough fragments so that they can be transmitted on the target link. These IP fragments are re-encapsulated into an IP data packet for independent transmission and will be reassembled when they reach the destination host.
[0062] IP fragment reassembly means that when a message is received, if the Flags in the IP header indicate fragmentation, the fragments are reassembled into a complete message according to the fragment offset.
[0063] When the offsets of various IP fragments overlap or contain each other, such as the second half of IP fragment ① and the first half of IP fragment ② overlap, different server operating systems have different processing methods for the overlapping content. Some operating systems overwrite the overlapping part of IP fragment ② with the overlapping part of IP fragment ①, and some operating systems overwrite the overlapping part of IP fragment ① with the overlapping part of IP fragment ②. Attackers take advantage of this difference in processing to make the firewall receive obfuscated messages, thereby bypassing the firewall's detection. In the embodiment of the present application, the content of the first IP fragment received first is taken as the default. When IP fragments with overlapping content are received, the overlapping part of the offset of the first IP fragment received first is overwritten with the overlapping part of the offset of the second IP fragment received later. For example, if the second half of IP fragment ① and the first half of IP fragment ② overlap in content, the overlapping part of IP fragment ① is overwritten with the overlapping part of IP fragment ②. The receiving time of IP fragment ① is before the receiving time of IP fragment ②. By uniformly processing the overlapping parts of the IP fragment offsets, it is ensured that the message received by the server is consistent with the message detected in the firewall, thereby avoiding attackers from using the IP fragment reassembly process to carry out attacks.
[0064] In one embodiment, the method further comprises:
[0065] Perform a TCP header field detection on the received TCP message, and determine that the TCP message is an obfuscated message if the detection result meets at least one of the following conditions:
[0066] There is an error in the checksum of the TCP message;
[0067] All flag bits of the TCP message are null values;
[0068] All flag bits of the TCP message are not null values;
[0069] The urgent flag of the TCP message is not a null value, and there is a valid load;
[0070] The TCP message repeatedly sends a synchronization sequence number SYN flag on the established connection session;
[0071] There is an error in the setting option field of the TCP message;
[0072] The TCP messages that are determined not to be obfuscated messages are reassembled to obtain application layer messages, and the application layer messages are used for subsequent attack detection.
[0073] Figure 5 A schematic diagram showing the header structure of a TCP message is shown in Figure 5 , Source Port is the source port, Destination Port is the destination port, Sequence Number is the sequence number of the first byte in the sent data packet, Acknowledgment Number is the confirmation sequence number, and Data Offset is the data offset. URG is the urgent flag, ACK is the confirmation flag, PSH is the push bit, RST is the reset flag, SYN is the synchronization sequence number, and FIN is the end flag. Window indicates the free space in the receive buffer, Checksum is the checksum, and Urgent Pointers are urgent pointers. This field is meaningful only when the URG flag is set, indicating the offset of the urgent data relative to the value of the sequence number (Sequence Number) field.
[0074] The purpose of the checksum is to verify whether the message has been tampered with during transmission. If an error is detected in the checksum of a TCP message, it means that the TCP message is likely to have been tampered with. Therefore, the TCP message with an error in the checksum is determined as an obfuscated message and is directly discarded.
[0075] Here, when it is detected that all flag bits of a TCP message are null values, the TCP message is discarded. All flag bits are null values, which means that there is no SYN / ACK / PSH / FIN / RST / URG flag. According to the RFC793 specification, except for the SYN message initially sent, other messages must have an ACK flag. When all flag bits of a message are null values, the message is likely to be a confused message. Therefore, a TCP message with all flag bits null values is determined as a confused message and is directly discarded.
[0076] When it is detected that all flag bits of the TCP message are not empty, if each flag bit of SYN / ACK / PSH / FIN / RST / URG has a value, the server cannot know the meaning of the message. Therefore, the TCP message with all flag bits not empty is also determined as a confusing message and is directly discarded.
[0077] When it is detected that the urgent flag of a TCP message is not a null value, for the urgent message, the operating system usually only takes one byte for processing and does not process the other bytes. Therefore, it is necessary to detect whether the other bytes have a valid load. When the detection result shows that the other messages have a valid load, the TCP message whose urgent flag is not a null value and has a valid load is determined as an obfuscated message and is directly discarded.
[0078] When it is detected that a TCP message repeatedly sends the SYN flag on an established session, sending the SYN flag indicates that a new TCP connection session is to be established. Repeatedly sending a TCP message with the SYN flag on an established session will cause confusion to the firewall and reinitialize the connection. Therefore, the TCP message is determined to be a confusing message and is discarded.
[0079] The options of TCP messages include the maximum message length (MSS, Max Segment Size) option, the window expansion factor option, the selective acknowledgment (SACK, Selective Acknowledgement) option, the timestamp option, and the custom option. Different network protocols handle TCP option anomalies in different ways. Some ignore the options, while others discard the messages. In order to ensure that all servers receive the same messages, the firewall directly corrects the correctable option errors in the TCP messages when it detects correctable option errors, such as the window expansion factor option and the MSS option.
[0080] When it is detected that there is an uncorrectable error in the option field of the TCP message header field, for the uncorrectable option errors, such as timestamp, SACK, and custom options, the message is determined to be a confused message, and the TCP message with the uncorrectable option error is directly discarded.
[0081] By performing TCP header field detection on TCP packets, the packets that may cause confusion attacks in the TCP header field can be effectively identified and discarded, avoiding attack behaviors in TCP header field detection and improving the accuracy of identifying attacks.
[0082] In one embodiment, before step 101, the method further includes:
[0083] When the contents of at least two received TCP messages overlap, the overlapping part of the contents of the TCP messages received at the first moment is overwritten with the overlapping part of the contents of the TCP messages received at the second moment; wherein,
[0084] The first time is before the second time.
[0085] In the case where the contents of at least two TCP messages overlap, the content of the first received TCP message is used as the default. When another TCP message with overlapping content is received, the overlapping part of the content of the TCP message received at the first moment is overwritten with the overlapping part of the content of the TCP message received at the second moment, where the first moment is before the second moment. If the second half of message ① and the first half of message ② overlap, the overlapping part of message ① is overwritten with the overlapping part of message ②, and the receiving time of message ① is before the receiving time of message ②, thereby ensuring that the message received by the server is consistent with the message detected in the firewall, avoiding attacks in the TCP stream reassembly process.
[0086] In one embodiment, after step 102, the method further includes:
[0087] Detect the message transmitted to the application layer, use the vulnerability, attack fingerprint and other feature libraries or syntax and semantic engines to match the content of the message. If the message matches the vulnerability or attack fingerprint, it is considered that the message contains an attack and intercepts the message. By detecting the message at the application layer, the attack behavior at the application layer is avoided.
[0088] Figure 6 FIG. 1 is a flowchart of another message detection method according to an embodiment of the present application. Please refer to FIG. Figure 6 In one embodiment, the method further comprises:
[0089] Step 601: Predict whether the server will discard the received segmented message if it is sent to the server; if it is predicted that the server will not discard the message, determine that the corresponding segmented message is not a confusing message.
[0090] Here, it is judged in advance whether the server will discard the received segmented message if it is sent to the server. Usually, the server will discard the segmented message when it receives the abnormal field.
[0091] If the discard operation is not performed, it means that the segmented message is not a message with abnormal fields, and it is determined that the segmented message is not a confused message.
[0092] If it is determined that the server will perform a discard operation, it means that the segmented message is a message with abnormal fields, and the segmented message is determined to be a confused message.
[0093] Step 602: reassemble the segmented messages that are determined not to be obfuscated messages, and perform attack feature detection based on the reassembled messages.
[0094] Here, after determining that the message is not an obfuscated message, the determined message is reassembled and the reassembled message is subjected to attack feature detection, that is, the reassembled message needs to be further detected to determine whether the reassembled message is an attack message.
[0095] By pre-determining whether the server will discard the received segmented messages, and reassembling the segmented messages that are determined not to be obfuscated messages, and performing attack feature detection on the reassembled messages, it is possible to first filter out messages with abnormal fields, and then detect the reassembled messages with normal fields, so as to further determine whether the messages contain attacks, thereby improving the accuracy of message attack detection.
[0096] The prediction operation here does not mean that it is necessary to communicate with the server to determine whether it will perform the discard operation. You can use RFC documents to determine whether the server is likely to perform the discard operation. This is just a prediction, and the prediction result may be inconsistent with the actual operation of the server.
[0097] In one embodiment, the step 601 further includes:
[0098] Detecting whether the header field of the segmented message meets the set condition;
[0099] If it is detected that the header field of the segmented message meets the set condition, it is determined that the server will perform a discard operation.
[0100] Here, whether the server will perform a discard operation is determined by detecting whether the header field of the segmented message meets a set condition. The set condition may be that there is an abnormality in the header field of the segmented message. If it is detected that there is an abnormality in the header field of the segmented message, it is determined that the server will perform a discard operation.
[0101] By detecting whether the segmented message meets the set conditions, it is determined whether the server will perform a discard operation, thereby improving the judgment efficiency.
[0102] In one embodiment, the segmented message includes an IP fragment; and the set condition includes at least one of the following:
[0103] The TTL of the IP fragment is less than the set threshold;
[0104] The routing path of IP fragmentation is not the set routing path;
[0105] The routing address of the last hop of the IP fragment is the set routing address; the set routing address represents the address of the firewall;
[0106] The checksum of the IP fragment is wrong;
[0107] There was an error in the timestamp option for IP fragmentation.
[0108] By detecting the TTL, routing address, checksum, and timestamp options of the segmented message header field, the message is directly discarded when an abnormality is detected during the detection of the IP fragment header field, which can prevent abnormal messages from entering the subsequent detection process and causing attacks, and also improve the accuracy of IP fragment header field detection. In one embodiment, the segmented message includes a TCP message; the set condition includes at least one of the following:
[0109] The checksum of the TCP message is incorrect;
[0110] All flag bits of the TCP message are empty;
[0111] All flag bits of the TCP message are not empty;
[0112] The urgent flag of the TCP message is not empty and there is a payload;
[0113] TCP packets repeatedly send the synchronization sequence number SYN flag on the established session;
[0114] There is an error in the TCP message's set options field.
[0115] By performing TCP header field detection on TCP packets, the packets that may cause confusion attacks in the TCP header field can be effectively identified and discarded, avoiding attack behaviors in TCP header field detection and improving the accuracy of identifying attacks.
[0116] In one embodiment, the setting option field is an option field that cannot correct errors;
[0117] The method further comprises:
[0118] If the TCP message includes an option field capable of correcting errors, the option field capable of correcting errors is corrected to a correct field.
[0119] Here, different network protocols handle TCP option field anomalies differently, some ignore options, and some discard messages. In order to ensure that all servers receive the same messages, the firewall detects correctable option errors in TCP messages, such as the window expansion factor option and the MSS option. It directly corrects these correctable option errors to correct option values.
[0120] When it is detected that there is an uncorrectable error in the option field of the TCP message header field, for the uncorrectable option errors, such as timestamp, SACK, and custom options, the message is determined to be a confused message, and the TCP message with the uncorrectable option error is directly discarded.
[0121] By performing option field detection on TCP packets, the packets that may cause confusion attacks in the TCP option field are effectively identified and discarded, avoiding attack behaviors in TCP option field detection and improving the accuracy of identifying attacks.
[0122] In one embodiment, the method further comprises:
[0123] When performing segment reassembly, when the contents of the at least two received segment messages overlap, overwriting the overlapping part of the contents of the segment messages received at the first moment to the overlapping part of the contents of the segment messages received at the second moment; wherein the first moment is before the second moment;
[0124] When no attack feature is detected based on the reassembled message, the covered segmented messages are sent to the server.
[0125] Here, if no attack features are detected in the reassembled message, it means that the reassembled message is a normal message. Therefore, the segmented message after the overwrite operation is sent to the server, thereby ensuring that the segmented message received by the server is consistent with the segmented message detected in the firewall, avoiding attack behaviors in the reassembly process.
[0126] In one embodiment, the message includes a TCP message; the method further includes:
[0127] Cache the TCP packets that are determined not to be attack packets;
[0128] When receiving a retransmitted data packet of the TCP message, replacing the retransmitted data packet with a corresponding cached TCP message;
[0129] The replaced retransmission data packet is sent to the server.
[0130] Here, if no attack feature is detected in the reassembled message, it means that the reassembled message is a normal message, so the retransmitted data packet after the replacement operation is performed is sent to the server, thereby ensuring that the server receives the retransmitted data packet that does not contain the attack content, avoiding the attack behavior in the retransmission process. In one embodiment, the method further includes:
[0131] When receiving the second TCP message, releasing the cached first TCP message; the second TCP message represents a confirmation message about the first TCP message returned by the server after sending the first TCP message to the server;
[0132] and / or,
[0133] When a third TCP message is received after the second TCP message is received, the third TCP message is discarded; and the sequence number of the third TCP message is smaller than the sequence number of the second TCP message.
[0134] By releasing the cached first TCP message, buffer overflow can be avoided, thereby ensuring that the first TCP message sent subsequently can continue to be received.
[0135] After the retransmission process is completed, when a message with a sequence number smaller than the sequence number of the confirmation message sent by the server is received, the message is directly discarded to avoid duplicate confirmation.
[0136] Figure 7 For a schematic diagram of the implementation flow of another message detection method provided in the embodiment of the present application, please refer to Figure 7 , the reorganized message is an application layer message, and the method further includes:
[0137] When no attack feature is detected based on the application layer message, determining the abnormality level of the application layer message based on application layer protocol analysis;
[0138] Whether to perform interception is determined based on the abnormal level of the application layer message and whether the corresponding messages of the TCP layer and the IP layer are obfuscated.
[0139] Specifically, when the abnormal level of the application layer message parsed based on the application layer protocol is a first set level, intercepting the application layer message;
[0140] When the abnormality level of the application layer message based on the application layer protocol analysis is not the first set level, determining the abnormality level of the corresponding message based on the TCP / IP layer protocol analysis;
[0141] When the abnormality level of the corresponding message parsed based on the TCP / IP layer protocol is a first set level, intercepting the corresponding message;
[0142] When the abnormality level of the corresponding message parsed based on the TCP / IP layer protocol is the second set level and the corresponding message is an attack message, intercepting the corresponding message;
[0143] When the abnormal level of the corresponding message parsed based on the TCP / IP layer protocol is the third set level, the corresponding message is released; wherein,
[0144] The first setting level is higher than the second setting level, and the second setting level is higher than the third setting level.
[0145] Here, the abnormality level of the application layer message is determined based on the application layer protocol analysis, and the abnormality level can be divided according to the impact degree of the application layer message abnormality.
[0146] By classifying the messages parsed by the application layer and TCP / IP layer protocols into abnormal levels, abnormal messages can be intercepted more conveniently and intuitively, thereby improving the efficiency of identifying abnormal messages.
[0147] In order to implement the method of the embodiment of the present application, the embodiment of the present application also provides an electronic device. Figure 8 Schematic diagram of the hardware structure of the electronic device of the present application embodiment. Figure 8 As shown, the electronic equipment includes:
[0148] Communication interface 801, capable of exchanging information with other devices such as network devices;
[0149] The processor 802 is connected to the communication interface 801 to implement information exchange with other devices and is used to execute the method provided by one or more technical solutions of the electronic device side when running the computer program. The computer program is stored in the memory 803.
[0150] Specifically, the processor 802 is used to cache a first TCP message; the first TCP message is a received TCP message that does not contain an attack; when a retransmitted data packet of the first TCP message is received within a first set time period, the retransmitted data packet is replaced with the cached first TCP message.
[0151] In one embodiment, the processor 802 is further configured to release the cached first TCP message when a second TCP message is received; the second TCP message represents a confirmation message about the first TCP message returned by the server after the first TCP message is sent to the server;
[0152] and / or,
[0153] When a third TCP message is received after the second TCP message is received, the third TCP message is discarded; and the sequence number of the third TCP message is smaller than the sequence number of the second TCP message.
[0154] In one embodiment, before receiving the first TCP message, the processor 802 is further configured to detect a header field of the received IP fragment, and determine that the received IP fragment is an obfuscated message when the detection result meets at least one of the following conditions:
[0155] The TTL of the IP fragment is less than the set threshold;
[0156] The routing path of IP fragmentation is not the set routing path;
[0157] The routing address of the last hop of the IP fragment is the set routing address; the set routing address represents the address of the firewall;
[0158] The checksum of the IP fragment is wrong;
[0159] There is an error in the timestamp option of IP fragmentation;
[0160] The determined IP fragments that are not obfuscated messages are reassembled to obtain TCP messages, and the TCP messages are used for subsequent attack detection.
[0161] In one embodiment, the processor 802 is further configured to, before caching the first TCP message, overwrite the overlapping portion of the first IP fragment offset to the overlapping portion of the second IP fragment offset when the offsets of at least two IP fragments overlap; wherein,
[0162] The receiving time of the first IP fragment is before the receiving time of the second IP fragment.
[0163] In one embodiment, the processor 802 is further configured to perform a TCP header field detection on the received TCP message, and determine that the TCP message is an obfuscated message when the detection result meets at least one of the following conditions:
[0164] There is an error in the checksum of the TCP message;
[0165] All flag bits of the TCP message are null values;
[0166] All flag bits of the TCP message are not null values;
[0167] The urgent flag of the TCP message is not a null value, and there is a valid load;
[0168] The TCP message repeatedly sends a synchronization sequence number SYN flag on the established connection session;
[0169] There is an error in the setting option field of the TCP message;
[0170] The TCP messages that are determined not to be obfuscated messages are reassembled to obtain application layer messages, and the application layer messages are used for subsequent attack detection.
[0171] In one embodiment, the processor 802 is further configured to, before caching the first TCP message, overwrite the overlapping portion of the content of the TCP message received at the first moment with the overlapping portion of the content of the TCP message received at the second moment when the contents of at least two received TCP messages overlap;
[0172] in,
[0173] The first time is before the second time.
[0174] In one embodiment, the processor 802 is further configured to predict whether the server will perform a discard operation if the received segmented message is sent to the server; wherein, if it is predicted that the server will not perform the discard operation, it is determined that the corresponding segmented message is not a confused message;
[0175] The segmented messages that are determined not to be obfuscated messages are reassembled, and attack feature detection is performed based on the reassembled messages.
[0176] In one embodiment, the processor 802 is further configured to detect whether a header field of the segmented message satisfies a set condition;
[0177] If it is detected that the header field of the segmented message meets the set condition, it is determined that the server will perform a discard operation.
[0178] In one embodiment, the message includes an IP fragment message; the setting condition includes at least the following:
[0179] 1: The TTL of the IP packet is less than the set threshold;
[0180] The routing path of IP fragment packets is not the set routing path;
[0181] The routing address of the last hop of the IP fragment message is the set routing address; the set routing address represents the address of the firewall;
[0182] The checksum of the IP fragment message is incorrect;
[0183] The timestamp option of the IP fragment packet contains an error.
[0184] In one embodiment, the message includes a TCP message; and the setting condition includes at least one of the following:
[0185] The checksum of the TCP message is incorrect;
[0186] All flag bits of the TCP message are empty;
[0187] All flag bits of the TCP message are not empty;
[0188] The urgent flag of the TCP message is not empty and there is a payload;
[0189] TCP packets repeatedly send the synchronization sequence number SYN flag on the established session;
[0190] There is an error in the TCP message's set options field.
[0191] In one embodiment, the set option field is an option field whose error cannot be corrected; the processor 802 is further configured to correct the option field whose error can be corrected to a correct field if the TCP message includes an option field whose error can be corrected.
[0192] In one embodiment, the processor 802 is further configured to, when performing segment reassembly, overwrite the overlapping portion of the content of the segment message received at the first time with the overlapping portion of the content of the segment message received at the second time when the contents of the at least two received segment messages overlap; wherein the first time is before the second time;
[0193] When no attack feature is detected based on the reassembled message, the covered segmented messages are sent to the server.
[0194] In one embodiment, the message includes a TCP message; the processor 802 is further configured to cache the TCP message that is determined not to be an attack message;
[0195] When receiving a retransmitted data packet of the TCP message, replacing the retransmitted data packet with a corresponding cached TCP message;
[0196] The replaced retransmission data packet is sent to the server.
[0197] In one embodiment, the reassembled message is an application layer message, and the processor 802 is further configured to determine the abnormality level of the application layer message based on application layer protocol analysis when no attack feature is detected based on the application layer message;
[0198] Whether to perform interception is determined based on the abnormal level of the application layer message and whether the corresponding messages of the TCP layer and the IP layer are obfuscated.
[0199] Of course, in actual application, the various components in the electronic device are coupled together through the bus system 804. It can be understood that the bus system 804 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 804 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Figure 8 Various buses are labeled as bus system 804 .
[0200] The memory 803 in the embodiment of the present application is used to store various types of data to support the operation of the electronic device. Examples of such data include: any computer program used to operate on the electronic device.
[0201] It can be understood that the memory 803 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), and direct RAM bus random access memory (DRRAM, Direct Rambus Random Access Memory).The memory 803 described in the embodiments of the present application is intended to include but is not limited to these and any other suitable types of memories.
[0202] The method disclosed in the above embodiment of the present application can be applied to the processor 802, or implemented by the processor 802. The processor 802 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of the hardware in the processor 802 or an instruction in the form of software. The above processor 802 may be a general-purpose processor, a DSP, or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 802 can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present application, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in the memory 803, and the processor 802 reads the program in the memory 803 and completes the steps of the above method in combination with its hardware.
[0203] When the processor 802 executes the program, the corresponding processes in the various methods of the embodiments of the present application are implemented.
[0204] In an exemplary embodiment, the present application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, for example, a memory 803 storing a computer program, and the computer program can be executed by a processor 802 to complete the steps of the aforementioned method. The computer-readable storage medium can be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface storage, optical disk, or CD-ROM.
[0205] In the several embodiments provided in the present application, it should be understood that the disclosed devices, terminals and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0206] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0207] In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0208] A person of ordinary skill in the art can understand that: all or part of the steps of implementing the above-mentioned method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium, which, when executed, executes the steps of the above-mentioned method embodiment; and the aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, disks or optical disks.
[0209] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable an electronic device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.
[0210] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A message detection method, applied to a firewall, characterized in that: The method comprises: caching a first transmission control protocol TCP message; the first TCP message is a received TCP message indicating that the message does not contain an attack; When a retransmission data packet of the first TCP message is received within a first set time period, the retransmission data packet is replaced with the cached first TCP message; The replaced retransmission data packet is sent to the server.
2. The message detection method according to claim 1, characterized in that: The method further comprises: When receiving the second TCP message, releasing the cached first TCP message; the second TCP message represents a confirmation message about the first TCP message returned by the server after sending the first TCP message to the server; and / or, When a third TCP message is received after the second TCP message is received, the third TCP message is discarded; and the sequence number of the third TCP message is smaller than the sequence number of the second TCP message.
3. The message detection method according to claim 1, characterized in that: Before caching the first TCP message, the method further includes: The header field of the received IP fragment is detected, and if the detection result meets at least one of the following conditions, the received IP fragment is determined to be an obfuscated message: The TTL of the IP fragment is less than the set threshold; The routing path of IP fragmentation is not the set routing path; The routing address of the last hop of the IP fragment is the set routing address; the set routing address represents the address of the firewall; The checksum of the IP fragment is wrong; There is an error in the timestamp option of IP fragmentation; The determined IP fragments that are not obfuscated messages are reassembled to obtain TCP messages, and the TCP messages are used for subsequent attack detection.
4. The message detection method according to any one of claims 1 to 3, characterized in that: Before caching the first TCP message, the method further includes: In the case where the offsets of at least two IP fragments overlap, the overlapping portion of the offset of the first IP fragment is overlaid onto the overlapping portion of the offset of the second IP fragment; wherein, The receiving time of the first IP fragment is before the receiving time of the second IP fragment.
5. The message detection method according to any one of claims 1 to 3, characterized in that: The method further comprises: Perform a TCP header field detection on the received TCP message, and determine that the TCP message is an obfuscated message if the detection result meets at least one of the following conditions: There is an error in the checksum of the TCP message; All flag bits of the TCP message are null values; All flag bits of the TCP message are not null values; The urgent flag of the TCP message is not a null value, and there is a valid load; The TCP message repeatedly sends a synchronization sequence number SYN flag on the established connection session; There is an error in the setting option field of the TCP message; The TCP messages that are determined not to be obfuscated messages are reassembled to obtain application layer messages, and the application layer messages are used for subsequent attack detection.
6. The message detection method according to any one of claims 1 to 3, characterized in that: Before caching the first TCP message, the method further includes: When the contents of at least two received TCP messages overlap, the overlapping part of the contents of the TCP messages received at the first moment is overwritten with the overlapping part of the contents of the TCP messages received at the second moment; wherein, The first time is before the second time.
7. A message detection method, applied to a firewall, characterized in that: The method comprises: Predicting whether the server will perform a discard operation if the received segmented message is sent to the server; wherein, if it is predicted that the server will not perform the discard operation, determining that the corresponding segmented message is not a confusing message; Reassemble the segmented messages that are determined not to be obfuscated messages, and perform attack feature detection based on the reassembled messages; The segmented message includes a TCP message; the method also includes: Cache the TCP packets that are determined not to be attack packets; When receiving a retransmitted data packet of the TCP message, replacing the retransmitted data packet with a corresponding cached TCP message; The replaced retransmission data packet is sent to the server.
8. The message detection method according to claim 7, characterized in that: The pre-judgment of whether the server will perform a discard operation if the received segmented message is sent to the server includes: Detecting whether the header field of the segmented message meets the set condition; If it is detected that the header field of the segmented message meets the set condition, it is determined that the server will perform a discard operation.
9. The message detection method according to claim 8, characterized in that: The segmented message includes an IP fragment message; the setting condition includes at least one of the following: The TTL of the IP fragment message is less than the set threshold; The routing path of IP fragment packets is not the set routing path; The routing address of the last hop of the IP fragment message is the set routing address; The set routing address represents the address of the firewall; The checksum of the IP fragment message is incorrect; The timestamp option of the IP fragment packet contains an error.
10. The message detection method according to claim 8 or 9, characterized in that: The segmented message includes a TCP message; the setting condition includes at least one of the following: The checksum of the TCP message is incorrect; All flag bits of the TCP message are empty; All flag bits of the TCP message are not empty; The urgent flag of the TCP message is not empty and there is a payload; TCP packets repeatedly send the synchronization sequence number SYN flag on the established session; There is an error in the TCP message's set options field.
11. The message detection method according to claim 10, characterized in that: The setting option field is an option field that cannot correct errors; The method further comprises: If the TCP message includes an option field capable of correcting errors, the option field capable of correcting errors is corrected to a correct field.
12. The message detection method according to claim 7, characterized in that: The method further comprises: When performing segment reassembly, when the contents of at least two received segment messages overlap, overwriting the overlapping part of the contents of the segment messages received at the first moment to the overlapping part of the contents of the segment messages received at the second moment; wherein the first moment is before the second moment; When no attack feature is detected based on the reassembled message, the covered segmented messages are sent to the server.
13. The message detection method according to any one of claims 7 to 9, characterized in that: The reorganized message is an application layer message; the method further includes: When no attack feature is detected based on the application layer message, determining the abnormality level of the application layer message based on application layer protocol analysis; Whether to perform interception is determined based on the abnormal level of the application layer message and whether the corresponding messages of the TCP layer and the IP layer are obfuscated.
14. An electronic device, characterized in that: include: a processor and a memory for storing a computer program capable of being executed on the processor, Wherein, when the processor is used to run the computer program, it executes the steps of the method described in any one of claims 1-13.
15. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 13 are implemented.
