Multiprotocol traffic processing methods, devices, equipment and media

By acquiring the unified instruction intermediate representation output by the protocol plugin, and performing policy matching and structured modification based on risk scoring rules, the problem of insufficient compatibility of multi-protocol traffic forwarding in traditional DPI technology is solved, and efficient forwarding and parsing of multi-protocol traffic is achieved.

CN123075111APending Publication Date: 2026-11-10SHENZHEN LEAGSOFT TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611568881.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-12
Publication Date
2026-11-10

AI Technical Summary

Technical Problem

Traditional DPI technology lacks high compatibility in multi-protocol traffic identification and control, and cannot achieve unified and precise command control, resulting in traffic forwarding compatibility issues.

Method used

By obtaining the unified instruction intermediate representation output by the preset protocol plugin, single instruction policy matching is performed based on risk scoring rules, structured modifications are executed and legality verification is performed, and the data is reserialized into a legal byte stream for forwarding.

Benefits of technology

It solves the compatibility problem of multi-protocol traffic forwarding, reduces false alarms and missed alarms caused by TCP segmentation, out-of-order delivery and retransmission, maintains the semantic legality of the protocol, and ensures that the modified traffic can be parsed normally by the other end.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123075111A_ABST
    Figure CN123075111A_ABST
Patent Text Reader

Abstract

This application relates to a method, apparatus, device, and storage medium for processing multi-protocol traffic. The method includes: acquiring a unified instruction intermediate representation output by a preset protocol plugin; determining a risk score corresponding to the unified instruction intermediate representation using preset risk scoring rules; performing single-instruction policy matching on the unified instruction intermediate representation based on a preset policy and the risk score to generate an action set; performing structured modifications on modifiable fields in the unified instruction intermediate representation according to the action set to obtain a modified instruction intermediate representation; performing legality verification on the modified instruction intermediate representation; reserializing the modified instruction intermediate representation that has passed the legality verification into a valid byte stream according to the syntax rules of the corresponding protocol, and outputting the valid byte stream for forwarding. This method avoids protocol corruption caused by directly modifying the byte stream and solves the compatibility problem of multi-protocol traffic forwarding.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of network security technology, and in particular to a method, apparatus, device and medium for processing multi-protocol traffic. Background Technology

[0002] Enterprise network management and data leakage prevention require fine-grained identification and control of application layer protocols during traffic forwarding. This includes controlling HTTP uploads, restricting access to specific domains, blocking FTP file transfers, auditing email content, and recognizing WebSocket interaction commands. Traditional DPI (Data Interference Processing) often uses keyword matching or simple regular expression matching to judge single protocols and one-way messages. However, these methods suffer from inconsistent parsing results for different protocols during identification and control, failing to achieve unified and precise command control and lacking high compatibility in traffic forwarding.

[0003] Therefore, it is necessary to provide a method, apparatus, device, and medium for processing multi-protocol traffic in order to solve the compatibility problem of multi-protocol traffic forwarding. Summary of the Invention

[0004] In view of the above, this application provides a multi-protocol traffic processing method, apparatus, device and storage medium, the purpose of which is to solve the above-mentioned technical problems.

[0005] In a first aspect, this application provides a method for processing multi-protocol traffic, the method comprising: Obtain the unified instruction intermediate representation output by the preset protocol plugin; wherein, the unified instruction intermediate representation is obtained by the protocol plugin parsing the continuous byte stream after session reassembly, and the unified instruction intermediate representation includes protocol type, direction, session stage, opcode, semantic tag, parameter field, length information and modifiable fields; The risk score corresponding to the intermediate representation of the unified instruction is determined by a preset risk scoring rule; Based on the preset strategy and the risk score, single-instruction strategy matching is performed on the unified instruction intermediate representation to generate an action set. Based on the set of actions, the modifiable fields in the unified instruction intermediate representation are structurally modified to obtain the modified instruction intermediate representation; The legality of the modified instruction intermediate representation is verified; The modified instruction intermediate representation that has passed the legality verification is reserialized into a legal byte stream according to the syntax rules of the corresponding protocol, and the legal byte stream is output for forwarding.

[0006] In some embodiments, determining the risk score corresponding to the unified instruction intermediate representation through a preset risk scoring rule includes: Based on the semantic tags and the operation codes, a preset risk weight mapping relationship is queried to determine the behavior type risk weight corresponding to the unified instruction intermediate representation; Based on the parameter fields, determine the parameter risk weight corresponding to the intermediate representation of the unified instruction; Based on the behavior type risk weight and the parameter risk weight, the basic risk score of the unified instruction intermediate representation is determined; Based on the behavioral history of the session, a first risk correction factor is determined for the session, wherein the behavioral history includes at least one of the following: number of historical violations, size of historical data sent out, and number of historical login failures. Based on the current system resource load, a second risk correction factor is determined under the current resource constraints, wherein the resource load includes at least one of session cache usage, processor load, and queue latency; The risk score is determined based on the basic risk score, the first risk correction factor, and the second risk correction factor.

[0007] In some embodiments, the step of performing single-instruction policy matching on the unified instruction intermediate representation based on a preset strategy and the risk score to generate an action set includes: Based on the risk threshold range corresponding to the risk score, a target matching mode is determined from a preset multi-level strategy matching mode, wherein the multi-level strategy matching mode includes a fast matching mode and a deep matching mode, and the matching field corresponding to the fast matching mode is less than the matching field corresponding to the deep matching mode. In the target matching mode, the unified instruction intermediate representation is matched with the preset strategy; The action set is generated based on the target strategy that matches the intermediate representation of the unified instruction and the risk threshold range.

[0008] In some embodiments, generating the action set based on the target policy matched with the unified instruction intermediate representation and the risk threshold range includes: Based on the target strategy, corresponding candidate actions are determined, wherein the candidate actions include at least one of allow, block, field replacement, field injection, instruction injection, and redirection; Based on the risk threshold range, determine the risk level corresponding to the risk score; Based on the risk level, the candidate actions are enhanced or weakened to obtain the adjusted actions; Based on the adjusted actions, the action set is generated.

[0009] In some embodiments, the step of performing structured modifications on the modifiable fields in the unified instruction intermediate representation based on the action set to obtain the modified instruction intermediate representation includes: Based on the set of actions, determine the field path and modification type to be modified in the unified instruction intermediate representation, wherein the modification type includes at least one of field replacement, field injection, instruction injection, and redirection; Based on the field path and the modification type, perform structured modification on the modifiable field; During the structured modification process, the associated fields in the unified instruction intermediate representation that are affected by the modification type are marked; Based on the modification result of the modifiable field, recalculate the value of the associated field; The recalculated associated fields are combined with the modified modifiable fields to generate the modified intermediate representation of the instruction.

[0010] In some embodiments, the validity verification of the modified instruction intermediate representation includes: Based on the protocol type corresponding to the modified instruction, determine the set of legality constraints; Based on the set of legality constraints, the modified intermediate representation of the instruction is verified; Specifically, when the protocol type is HTTP, the modified instruction intermediate representation is verified for consistency of the length field and the chunked transmission boundary; when the protocol type is WebSocket, the modified instruction intermediate representation is verified for consistency of the frame header and the mask field; when the protocol type is FTP, the modified instruction intermediate representation is verified for consistency of the command and data connection states; and when the protocol type is SMTP, the modified instruction intermediate representation is verified for consistency of the command phase and the data phase boundary.

[0011] In some embodiments, the step of reserializing the modified intermediate representation of the instruction that has passed the validity verification into a valid byte stream according to the syntax rules of the corresponding protocol includes: Before modification, obtain the original byte reference of the unified instruction intermediate representation, the original byte reference indicating the unmodified byte range in the unified instruction intermediate representation; Based on the original byte reference, the unmodified byte range is preserved; The modified fields in the modified instruction intermediate representation are serialized according to the syntax rules of the corresponding protocol to obtain the modified byte segment; The modified byte segment and the unmodified byte range are concatenated in their original order to obtain the valid byte stream.

[0012] Secondly, this application provides a multi-protocol traffic processing apparatus, which includes: The acquisition module is used to acquire the unified instruction intermediate representation output by the preset protocol plugin; wherein, the unified instruction intermediate representation is obtained by the protocol plugin parsing the continuous byte stream after session reassembly, and the unified instruction intermediate representation includes protocol type, direction, session stage, opcode, semantic tag, parameter field, length information and modifiable fields; The first determining module is used to determine the risk score corresponding to the intermediate representation of the unified instruction according to a preset risk scoring rule; The generation module is used to perform single-instruction strategy matching on the unified instruction intermediate representation based on the preset strategy and the risk score to generate an action set; The second determining module is used to perform structured modifications on the modifiable fields in the unified instruction intermediate representation based on the action set, so as to obtain the modified instruction intermediate representation; The verification module is used to verify the legality of the modified intermediate representation of the instruction; The forwarding module is used to reserialize the modified instruction intermediate representation that has passed the legality verification into a legal byte stream according to the syntax rules of the corresponding protocol, and output the legal byte stream for forwarding.

[0013] Thirdly, this application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; When a processor executes a program stored in memory, it implements the steps of the multi-protocol traffic processing method described in any embodiment of the first aspect.

[0014] Fourthly, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the multiprotocol traffic processing method as described in any embodiment of the first aspect.

[0015] The technical solutions provided in this application have the following advantages compared with the prior art: By acquiring the unified intermediate representation of instructions parsed from the protocol plugin and performing single-instruction policy matching based on risk scores, multi-protocol control can be advanced from keyword matching to the instruction level, reducing false positives and false negatives caused by TCP segmentation, out-of-order delivery, and retransmission. By performing structured modifications and validity verification on modifiable fields, the semantic validity of the protocol can be maintained after field replacement or injection, avoiding protocol corruption caused by direct modification of the byte stream. By re-serializing and forwarding according to the protocol syntax rules, the modified traffic can be parsed normally by the peer, thereby solving the compatibility problem of multi-protocol traffic forwarding. Attached Figure Description

[0016] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0017] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 This is a flowchart illustrating a preferred embodiment of the multi-protocol traffic processing method of this application; Figure 2 This is an exemplary flowchart illustrating the determination of risk scores according to some embodiments of this application; Figure 3 This is an exemplary flowchart illustrating the generation of a set of actions according to some embodiments of this application; Figure 4 This is an exemplary flowchart illustrating the determination of the intermediate representation of the modified instructions according to some embodiments of this application; Figure 5 This is a schematic diagram of a preferred embodiment of the multi-protocol traffic processing device of this application; Figure 6 This is a schematic diagram of a preferred embodiment of the electronic device of this application; The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0019] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application. All other embodiments obtained by those skilled in the art based on the embodiments in this application without inventive effort are within the scope of protection of this application.

[0020] It should be noted that the use of terms such as "first" and "second" in this application is for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of those features. Furthermore, the technical solutions of the various embodiments can be combined with each other, but this must be based on the ability of those skilled in the art to implement them. If the combination of technical solutions is contradictory or impossible to implement, such a combination of technical solutions should be considered non-existent and not within the scope of protection claimed in this application.

[0021] Reference Figure 1 The diagram shown is a flowchart illustrating an embodiment of the multi-protocol traffic processing method of this application. The method is executed by an electronic device, which can be implemented by a software system and / or a hardware system. The multi-protocol traffic processing method includes: Step 101: Obtain the unified instruction intermediate representation output by the preset protocol plugin.

[0022] Preset protocol plugins are pluggable modules used to parse and serialize one or more application layer protocols. For example, a preset protocol plugin can be an HTTP protocol plugin, an FTP protocol plugin, an SMTP protocol plugin, a POP3 protocol plugin, or a WebSocket protocol plugin.

[0023] A unified instruction intermediate representation refers to an instruction-level or frame-level intermediate representation that carries the parsing results of a protocol plugin using a unified data structure. For example, a unified instruction intermediate representation can be a structured object containing protocol type, direction, session stage, opcode, semantic tags, parameter fields, length information, and modifiable fields. The unified instruction intermediate representation is obtained by the protocol plugin parsing the continuous byte stream after session reassembly.

[0024] A reassembled continuous byte stream refers to a continuous application-layer byte stream that has undergone TCP reordering, retransmission deduplication, and segmentation. For example, a reassembled continuous byte stream can be a continuous sequence of bytes corresponding to a complete HTTP request message.

[0025] Protocol type refers to information used to identify the application layer protocol category to which the unified instruction intermediate belongs. For example, the protocol type can be HTTP, FTP, SMTP, POP3, or WebSocket.

[0026] Direction refers to the direction in which instructions are transmitted within a session. For example, the direction can be uplink or downlink.

[0027] A session phase refers to the stage a session is in within the protocol state machine. For example, a session phase can be a request phase, response phase, command phase, data phase, or escalation phase.

[0028] An opcode is an identifier used in the unified instruction intermediate representation to indicate a specific operation or command category.

[0029] Semantic tags are labels that normalize and categorize opcodes or instruction behaviors. For example, semantic tags can be upload, download, login, file transfer, domain access, or message sending.

[0030] Parameter fields are data items that carry instruction operands or parameter content. For example, parameter fields can be URLs, filenames, usernames, email addresses, or WebSocket payloads.

[0031] Length information refers to data used to characterize the length of message bodies, fields, frames, or chunk boundaries. For example, length information can be HTTP Content-Length or the payload length of a WebSocket frame.

[0032] Modifiable fields refer to fields in the unified instruction intermediate representation that can be rewritten, replaced, or injected by policy actions. For example, modifiable fields can be HTTP header fields, FTP command parameters, SMTP email subjects, or WebSocket frame payloads.

[0033] In some embodiments, the processor obtains the unified instruction intermediate representation output by the preset protocol plugin, which includes: receiving the unified instruction intermediate representation output by the protocol plugin after parsing the continuous byte stream after session reassembly, and reading the protocol type, direction, session stage, opcode, semantic label, parameter field, length information and modifiable fields in the unified instruction intermediate representation.

[0034] Step 102: Determine the risk score corresponding to the unified instruction intermediate representation using preset risk scoring rules.

[0035] Preset risk scoring rules refer to a set of rules that are pre-defined to determine risk scores based on instruction semantics and parameters. For example, preset risk scoring rules can be a combination of a risk weight mapping table and risk correction factor calculation rules.

[0036] A risk score is a numerical value or level that characterizes the degree of risk associated with a given action under a unified instruction. For example, a risk score can be a value between 0 and 100, with a higher value indicating a higher risk.

[0037] In some embodiments, the processor determines the risk score corresponding to the unified instruction intermediate representation by means of a preset risk scoring rule, including: querying a preset risk weight mapping relationship based on semantic tags and opcodes to determine the behavior type risk weight, determining the parameter risk weight based on parameter fields, determining the basic risk score based on the behavior type risk weight and the parameter risk weight, determining the first risk correction factor based on the session behavior history, determining the second risk correction factor based on the current system resource load, and determining the risk score based on the basic risk score, the first risk correction factor and the second risk correction factor.

[0038] Step 103: Based on the preset strategy and the risk score, perform single-instruction strategy matching on the unified instruction intermediate representation to generate an action set.

[0039] Preset policies refer to a set of rules that are pre-configured to control the intermediate representation of unified instructions. For example, preset policies can be domain blacklists, upload blocking rules, sensitive word auditing rules, or file type restriction rules.

[0040] Single-instruction policy matching refers to a process that uses a single, unified intermediate representation of an instruction as the matching object, comparing the semantic tags, opcodes, and parameter fields in that intermediate representation with a preset policy. For example, single-instruction policy matching can independently match a URL policy for a single HTTP request instruction, without merging matches across instructions.

[0041] An action set refers to a collection of actions generated after policy matching, which indicate what processing should be performed on a unified instruction intermediate representation. For example, an action set can be one or more of the following: allow, block, field replacement, field injection, instruction injection, redirection, and auditing.

[0042] In some embodiments, the processor performs single-instruction policy matching and generates an action set based on a preset policy and risk score, including: determining a target matching mode from a preset multi-level policy matching mode according to the risk threshold range corresponding to the risk score; selecting a fast matching mode if the risk score is in a low risk threshold range, and selecting a deep matching mode if the risk score is in a high risk threshold range; matching the unified instruction intermediate representation with the preset policy in the target matching mode; and generating an action set based on the matched target policy and risk threshold range.

[0043] In other embodiments, the processor performs single-instruction policy matching and generates an action set based on a preset policy and risk score, including: determining candidate actions according to the target policy, determining the risk level corresponding to the risk score according to the risk threshold range, enhancing or weakening the candidate actions according to the risk level to obtain the adjusted actions, and generating an action set based on the adjusted actions.

[0044] Step 104: Based on the action set, perform structured modification on the modifiable fields in the unified instruction intermediate representation to obtain the modified instruction intermediate representation.

[0045] Structured modification refers to a modification method that uses fields represented by a unified instruction as the operation objects, and replaces, injects, or redirects field values ​​according to the field path and modification type, while synchronously maintaining related fields. For example, structured modification can replace HTTP header fields and update the length field.

[0046] The modified instruction intermediate representation refers to an intermediate representation that retains the structured field relationships after performing structured modifications on the unified instruction intermediate representation. For example, the modified instruction intermediate representation could be an HTTP instruction structure with URL fields replaced and audit fields injected.

[0047] In some embodiments, the processor performs structured modification on a modifiable field based on an action set, including: determining the path and modification type of the field to be modified in the unified instruction intermediate representation based on the action set; performing field replacement, field injection, instruction injection, or redirection on the modifiable field based on the field path and modification type; marking associated fields affected by the modification type during the structured modification process; recalculating the value of the associated field based on the modification result of the modifiable field; and combining the recalculated associated field with the modified modifiable field to generate a modified instruction intermediate representation.

[0048] Step 105: Verify the legality of the modified instruction intermediate representation.

[0049] Legality verification refers to validating the modified instruction's intermediate representation against the legality constraint set of the corresponding protocol type. The legality constraint set refers to a pre-defined set of conditions for the protocol type, used to constrain the legality of fields such as length, boundaries, frame headers, and state transitions. For example, the HTTP legality constraint set includes length field consistency and chunked transmission boundary consistency.

[0050] In some embodiments, the processor performs legality verification on the modified instruction intermediate representation, which includes: determining a set of legality constraints based on the protocol type corresponding to the modified instruction intermediate representation; verifying the modified instruction intermediate representation based on the set of legality constraints; verifying the consistency of the length field and the consistency of the chunked transmission boundary when the protocol type is HTTP; verifying the consistency of the frame header and the consistency of the mask field when the protocol type is WebSocket; verifying the consistency of the command and data connection states when the protocol type is FTP; and verifying the consistency of the command phase and data phase boundaries when the protocol type is SMTP.

[0051] In some embodiments, the legality verification of the modified instruction intermediate representation includes: determining a set of legality constraints based on the protocol type corresponding to the modified instruction intermediate representation; and verifying the modified instruction intermediate representation based on the set of legality constraints.

[0052] Specifically, when the protocol type is HTTP, the modified instruction intermediate representation is verified for consistency of the length field and the chunked transmission boundary; when the protocol type is WebSocket, the modified instruction intermediate representation is verified for consistency of the frame header and the mask field; when the protocol type is FTP, the modified instruction intermediate representation is verified for consistency of the command and data connection states; and when the protocol type is SMTP, the modified instruction intermediate representation is verified for consistency of the command phase and the data phase boundary.

[0053] In some embodiments, the processor determines the set of legality constraints based on the protocol type corresponding to the modified instruction intermediate representation, including: reading the protocol type field from the modified instruction intermediate representation; querying a preset legality constraint table using the protocol type as an index; if the protocol type is HTTP, extracting the length field consistency constraint and the chunked transmission boundary consistency constraint from the legality constraint table as the set of legality constraints; if the protocol type is WebSocket, extracting the frame header consistency constraint and the mask field consistency constraint as the set of legality constraints; if the protocol type is FTP, extracting the command and data connection state consistency constraint as the set of legality constraints; if the protocol type is SMTP, extracting the command stage and data stage boundary consistency constraint as the set of legality constraints; and loading the set of legality constraints into the verification context.

[0054] Length field consistency means that the value of the length field declared in the modified instruction intermediate representation is consistent with the actual byte length of the data it carries.

[0055] Chunked transfer boundary consistency refers to the consistency between the block boundaries and the block length declaration in the modified instruction intermediate representation of the chunked transfer encoding.

[0056] Frame header consistency means that the header fields of a modified WebSocket frame are consistent with the actual attributes of the frame payload.

[0057] Mask field consistency means that the mask field of the modified WebSocket frame is consistent with the mask processing state of the payload.

[0058] Command and data connection state consistency means that the command connection state indicated by the modified FTP command is consistent with the data connection state.

[0059] Consistency between the command phase and the data phase boundary means that the boundary marker between the command phase and the data phase remains consistent in the modified SMTP command.

[0060] In some embodiments, if any constraint validation fails, the validity validation is determined to have failed. The failed constraint identifier and the failed field path are recorded in the audit event, and the blocking, session-level permission, or pass-through is performed according to the preset degradation strategy, and the degradation reason is recorded.

[0061] Some embodiments of this application, by determining the set of legality constraints according to the protocol type and verifying the modified intermediate representation of the instruction, can respectively verify the length, block boundary, frame header, mask, connection status and stage boundary for HTTP, WebSocket, FTP and SMTP, thereby solving the problem of forwarding failure or parsing abnormality at the peer end caused by inconsistency of modified protocol fields.

[0062] Step 106: The modified instruction intermediate representation that has passed the legality verification is reserialized into a legal byte stream according to the syntax rules of the corresponding protocol, and the legal byte stream is output for forwarding.

[0063] A valid byte stream refers to a sequence of bytes that, after being serialized according to the corresponding protocol syntax rules, can be correctly parsed and forwarded by the peer's protocol stack. For example, a valid byte stream can be a reassembled HTTP request message.

[0064] Forwarding refers to outputting a valid byte stream to a network forwarding link and sending it to the destination. For example, forwarding can be sending via the data plane interface.

[0065] The syntax rules of a protocol refer to the rules governing the order of fields, separators, lengths, encoding, and frame structure specified by the protocol. For example, HTTP syntax rules include rules for the content length field.

[0066] In some embodiments, the processor reserializes the data into a valid byte stream and outputs it for forwarding, which includes: obtaining the original byte reference corresponding to the modified instruction intermediate representation, wherein the original byte reference indicates the unmodified byte range in the unified instruction intermediate representation; retaining the unmodified byte range according to the original byte reference; serializing the modified fields in the modified instruction intermediate representation according to the syntax rules of the corresponding protocol to obtain the modified byte segment; and concatenating the modified byte segment and the unmodified byte range in the original order to obtain a valid byte stream.

[0067] In some embodiments, the step of reserializing the modified intermediate representation of the instruction that has passed the validity verification into a valid byte stream according to the syntax rules of the corresponding protocol may include the following operations: S11, before modification, obtain the original byte reference of the unified instruction intermediate representation, the original byte reference indicating the unmodified byte range in the unified instruction intermediate representation.

[0068] A raw byte reference is a reference used to indicate an unmodified byte range within the raw byte stream corresponding to the intermediate representation of a unified instruction. For example, a raw byte reference can be the starting offset and length information in the raw byte stream, or it can be a pointer to an unmodified range in the raw byte buffer and the range length.

[0069] An unmodified byte range refers to the original byte range corresponding to fields that have not undergone structured modification in the Uniform Instruction intermediate representation. For example, an unmodified byte range could be the original byte segment occupied by the request line and method fields in an HTTP request that have not been replaced.

[0070] In some embodiments, the processor obtains the original byte reference of the unified instruction intermediate representation before modification by: reading the starting offset and length information of the original byte stream from the parsing result of the unified instruction intermediate representation, storing the starting offset and length information as the original byte reference in the modification context, the original byte reference pointing to the unmodified byte range, and keeping the original byte reference unchanged during subsequent structured modification.

[0071] S12, based on the original byte reference, the unmodified byte range is reserved.

[0072] In some embodiments, the processor retains an unmodified byte range based on the original byte reference by: reading the starting offset and length information from the original byte reference, copying the unmodified byte range from the original byte stream to the output buffer according to the starting offset and length information, and marking the copied unmodified byte range as reserved.

[0073] S13, the modified fields in the modified instruction intermediate representation are serialized according to the syntax rules of the corresponding protocol to obtain the modified byte segment.

[0074] A modified field refers to a field in the modified instruction intermediate representation that has undergone content changes relative to the original uniform instruction intermediate representation. For example, a modified field could be a replaced HTTP header field, an injected audit identifier field, or a redirected target address field.

[0075] A modified byte segment refers to the byte sequence obtained after serializing the modified fields according to the protocol syntax rules. For example, a modified byte segment can be a byte segment consisting of the replaced HTTP header fields and their CRLF delimiters.

[0076] In some embodiments, the processor serializes the modified fields in the modified instruction intermediate representation according to the syntax rules of the corresponding protocol, including: reading the field path and field value of the modified field from the modified instruction intermediate representation, querying the corresponding syntax rules according to the protocol type, encoding the field value into a byte sequence according to the syntax rules, and appending the delimiter and length identifier specified by the protocol to the byte sequence to obtain the modified byte segment.

[0077] S14, the modified byte segment and the unmodified byte range are concatenated in their original order to obtain the legal byte stream.

[0078] In some embodiments, the processor concatenates the modified byte segment and the unmodified byte range in the original order, including: determining the insertion position of the modified byte segment according to the offset order in the original byte reference, inserting the modified byte segment into the corresponding insertion position in the output buffer, and concatenating the unmodified byte range and the modified byte segment in the original order to obtain a valid byte stream.

[0079] In other embodiments, if there are multiple modified byte segments, they are sorted in ascending order according to the offset of the corresponding field in the original byte stream, and the unmodified byte range and the modified byte segments are written into the send buffer in sequence to generate a valid byte stream.

[0080] This embodiment retains the unmodified byte range by referencing the original byte, and only serializes the modified fields according to the protocol syntax rules to obtain the modified byte segment, and then concatenates them in the original order. This can reduce the amount of data to be reserialized and avoid field misalignment caused by re-encoding the entire instruction, thereby solving the problem of inconsistency between the modified forwarded message and the original protocol structure.

[0081] In some embodiments of this application, by obtaining the unified instruction intermediate representation parsed from the protocol plugin and performing single instruction policy matching based on risk scores, multi-protocol control can be advanced from keyword matching to the instruction level, reducing false positives and false negatives caused by TCP segmentation, out-of-order delivery, and retransmission. By performing structured modifications and legality verification on modifiable fields, the semantic legality of the protocol can be maintained after field replacement or injection, avoiding protocol corruption caused by direct modification of the byte stream. By re-serializing and forwarding according to the protocol syntax rules, the modified traffic can be parsed normally by the peer, thereby solving the compatibility problem of multi-protocol traffic forwarding.

[0082] Figure 2 This is an exemplary flowchart illustrating the determination of risk scores according to some embodiments of this application. Figure 2 As shown, the process may include the following operations.

[0083] Step 201: Based on the semantic tag and the operation code, query the preset risk weight mapping relationship to determine the behavior type risk weight corresponding to the unified instruction intermediate representation.

[0084] A preset risk weight mapping relationship refers to a pre-defined correspondence used to map semantic tags and opcodes to behavioral type risk weights. For example, a preset risk weight mapping relationship can be a risk weight table, a set of key-value pairs, or a mapping function.

[0085] Behavior type risk weight refers to the weight value that characterizes the risk level of a certain instruction behavior type. For example, the behavior type risk weight can be 0.8 for uploading behavior, 0.3 for downloading behavior, and 0.5 for logging in behavior.

[0086] In some embodiments, the processor determines the behavior type risk weight corresponding to the unified instruction intermediate representation by querying a preset risk weight mapping relationship based on semantic tags and opcodes. This includes: extracting semantic tags and opcodes from the unified instruction intermediate representation, combining the semantic tags and opcodes into a query key, searching for the behavior type risk weight corresponding to the query key in the preset risk weight mapping relationship, and if found, assigning the behavior type risk weight to the unified instruction intermediate representation; if not found, using a preset default weight as the behavior type risk weight.

[0087] Step 202: Based on the parameter fields, determine the parameter risk weight corresponding to the unified instruction intermediate representation.

[0088] Parameter risk weight refers to the weight value that characterizes the risk level of the content of the instruction parameter field. For example, the parameter risk weight can be 0.9 when the URL hits the blacklist, 0.8 when the file name is an executable file, and 0.2 when it is plain text.

[0089] In some embodiments, the processor determines the parameter risk weight corresponding to the unified instruction intermediate representation based on the parameter field by: matching the parameter field with a preset sensitive word library, domain name blacklist or file type list, determining the parameter risk weight according to the matching result, and assigning a high parameter risk weight if the parameter field matches the blacklist, and assigning a low parameter risk weight if the parameter field does not match the blacklist.

[0090] Step 203: Based on the behavior type risk weight and the parameter risk weight, determine the basic risk score of the unified instruction intermediate representation.

[0091] The basic risk score is the risk score obtained by combining the risk weights of behavioral types and the risk weights of parameters. For example, the basic risk score can be the weighted sum of the risk weights of behavioral types and the risk weights of parameters, or it can be the product of the two and then normalized to 0 to 100.

[0092] In some embodiments, the processor performs a weighted summation of the two according to preset weighting coefficients to obtain a basic risk score.

[0093] In other embodiments, the processor multiplies the behavior type risk weight with the parameter risk weight to obtain a product, and maps the product to a preset score range to obtain a basic risk score.

[0094] Step 204: Based on the behavioral history of the session, determine the first risk correction factor corresponding to the session.

[0095] The behavioral history includes at least one of the following: historical violation count, historical data outbound size, and historical login failure count.

[0096] Behavioral history refers to a record of security- or behavioral events that occurred during a session over a past period. For example, behavioral history could include the number of historical violations, the amount of data sent out historically, and the number of historical login failures.

[0097] The first risk correction factor is a coefficient used to adjust the base risk score based on the history of conversational behavior. For example, the first risk correction factor can be a value between 1.0 and 2.0.

[0098] Historical violation count refers to the cumulative number of times a user or terminal corresponding to a session has been penalized by a policy in the past. For example, the historical violation count could be 3 times.

[0099] Historical data outgoing size refers to the total amount of data that a session has sent out in the past. For example, historical data outgoing size can be 100MB.

[0100] The historical login failure count refers to the cumulative number of times a session has failed to authenticate in the past. For example, the historical login failure count could be 5 times.

[0101] In some embodiments, the processor determines the first risk correction factor based on the session's behavior history by: reading the number of historical violations, the size of historical data sent out, and the number of historical login failures in the behavior history according to the session identifier, and calculating the first risk correction factor according to preset rules. The more historical violations, the larger the first risk correction factor; the larger the size of historical data sent out, the larger the first risk correction factor; and the more historical login failures, the larger the first risk correction factor.

[0102] Step 205: Based on the current system resource load, determine the second risk correction factor under the current resource constraints.

[0103] Resource load refers to the current state of resource usage in the system. For example, resource load can be at least one of session cache usage, processor load, and queue latency.

[0104] The second risk correction factor is a coefficient used to adjust the base risk score based on the current system resource load. For example, the second risk correction factor can be a value between 1.0 and 1.5.

[0105] Session cache usage refers to the amount of memory used for current session cache reassembly. For example, session cache usage could be 80% cache utilization.

[0106] Processor load refers to the current utilization of the processor. For example, the processor load could be 90%.

[0107] Queue latency refers to the time a data packet or instruction waits in a queue. For example, queue latency can be 50ms.

[0108] In some embodiments, the processor determines the second risk correction factor based on the current system resource load by comparing session cache usage, processor load, and queue latency with preset thresholds respectively, and calculating the second risk correction factor according to the degree to which the thresholds are exceeded, with the second risk correction factor being larger as resources become more strained.

[0109] In other embodiments, the processor determines the second risk correction factor based on the current system resource load by: setting the second risk correction factor to 1.0 if the session cache usage, processor load, and queue latency are all below a preset threshold; and increasing the second risk correction factor proportionally if any parameter exceeds the preset threshold.

[0110] Step 206: Determine the risk score based on the basic risk score, the first risk correction factor, and the second risk correction factor.

[0111] In some embodiments, the processor determines the risk score based on the base risk score, the first risk correction factor, and the second risk correction factor by: multiplying the base risk score by the first risk correction factor to obtain a first correction result, multiplying the first correction result by the second risk correction factor to obtain a second correction result, and limiting the second correction result to a preset score range to obtain the risk score.

[0112] In some embodiments of this application, the risk weight of behavior type is determined by querying the risk weight mapping relationship based on semantic tags and opcodes, and the parameter risk weight is obtained by combining the parameter field. This enables the risk score to reflect both the instruction behavior and the parameter content. By introducing session behavior history and system resource load to correct the basic risk score, the risk score can be dynamically adjusted according to historical violations, data outflow, login failures and resource constraints, thereby solving the problem of misjudgment caused by static rules being difficult to adapt to changes in session context and resource status.

[0113] Figure 3 This is an exemplary flowchart illustrating the generation of a set of actions according to some embodiments of this application. Figure 3As shown, the process may include the following operations.

[0114] Step 301: Determine the target matching mode from the preset multi-level strategy matching modes based on the risk threshold range corresponding to the risk score.

[0115] The multi-level strategy matching mode includes a fast matching mode and a deep matching mode, wherein the matching field corresponding to the fast matching mode is less than the matching field corresponding to the deep matching mode.

[0116] A risk threshold range refers to a pre-defined range of values ​​used to characterize the risk score. For example, a risk threshold range could be 0 to 30 for low risk, 31 to 70 for medium risk, and 71 to 100 for high risk.

[0117] A preset multi-level strategy matching pattern refers to a set of pre-defined strategy matching patterns with different numbers of matching fields. For example, a preset multi-level strategy matching pattern may include a fast matching pattern and a deep matching pattern.

[0118] Quick matching mode refers to a strategy matching mode that involves a small number of fields in the matching process. For example, quick matching mode can match only semantic tags and opcodes.

[0119] Deep matching mode refers to a strategy matching mode that involves a large number of fields in the matching process. For example, deep matching mode can match semantic tags, opcodes, parameter fields, length information, and session phases.

[0120] Matching fields refer to the fields that are compared during the policy matching process. For example, matching fields can be semantic tags, opcodes, URLs, filenames, email addresses, or frame types.

[0121] The target matching mode refers to the mode selected from the multi-level policy matching modes for policy matching of the current unified instruction intermediate representation. For example, the target matching mode can be a fast matching mode or a deep matching mode.

[0122] In some embodiments, the processor determines the target matching mode from the preset multi-level strategy matching modes based on the risk threshold interval corresponding to the risk score, including: comparing the risk score with multiple preset risk threshold intervals to determine the target risk threshold interval in which the risk score falls; querying the preset mode mapping relationship based on the target risk threshold interval; selecting the fast matching mode as the target matching mode if the target risk threshold interval is a low-risk interval; and selecting the deep matching mode as the target matching mode if the target risk threshold interval is a high-risk interval.

[0123] Step 302: In the target matching mode, the unified instruction intermediate representation is matched with the preset strategy.

[0124] In some embodiments, the processor matches the unified instruction intermediate representation with a preset strategy in the target matching mode, including: if the target matching mode is a fast matching mode, extracting semantic tags and opcodes from the unified instruction intermediate representation, comparing the semantic tags and opcodes with the fast matching table in the preset strategy to obtain a matching result; if the target matching mode is a deep matching mode, extracting semantic tags, opcodes, parameter fields, length information, and session stage from the unified instruction intermediate representation, comparing the above fields with the deep matching table in the preset strategy item by item to obtain a matching result.

[0125] Step 303: Generate the action set based on the target strategy that matches the unified instruction intermediate representation and the risk threshold range.

[0126] A target strategy refers to a preset strategy that indicates a successful match with a unified instruction. For example, a target strategy could be a domain blacklist strategy, an upload blocking strategy, or a sensitive word auditing strategy.

[0127] In some embodiments, the processor generates an action set based on a target policy and a risk threshold range by: reading candidate actions from the target policy, determining a risk level according to the risk threshold range, retaining blocking, redirection, and auditing actions from the candidate actions if the risk level is high, and retaining allowing and auditing actions from the candidate actions if the risk level is low, and forming an action set by retaining the actions.

[0128] In some embodiments of this application, by selecting a fast matching mode or a deep matching mode based on the risk threshold range corresponding to the risk score, low-risk instructions can complete policy matching with fewer matching fields, while high-risk instructions can complete policy matching with more matching fields. This reduces the number of matching fields for low-risk instructions while ensuring the control accuracy of high-risk instructions, thus solving the problem of resource consumption and response delay caused by using the same depth matching for all instructions.

[0129] In some embodiments, generating the action set based on the target policy matching the unified instruction intermediate representation and the risk threshold range may include the following operations: S21, determine the corresponding candidate action according to the target strategy.

[0130] Candidate actions refer to the actions defined in the target policy that can be used to process the intermediate representation of the unified instruction. For example, candidate actions can be one or more of the following: allow, block, field replacement, field injection, instruction injection, and redirection.

[0131] Allowing means not modifying the intermediate representation of the unified instruction and allowing it to be forwarded. For example, allowing means forwarding an HTTP request as is.

[0132] Blocking refers to the action of discarding or rejecting traffic represented by a unified instruction. For example, blocking can be returning a rejection response to the sender and stopping forwarding.

[0133] Field replacement refers to the action of replacing the original content of a modifiable field in a unified instruction intermediate representation with new content. For example, field replacement could be replacing the URL in an HTTP request with a preset secure address.

[0134] Field injection refers to the act of adding new fields to a unified directive intermediate representation. For example, field injection could be used to add an audit identifier field to an HTTP header.

[0135] Command injection refers to the act of adding new commands to a unified command intermediate representation. For example, command injection can be used to insert audit notification commands into an SMTP session.

[0136] Redirection refers to the action of redirecting a request corresponding to a unified instruction to another target address. For example, redirection can be used to redirect an HTTP request to an alert page.

[0137] In some embodiments, the processor determines the corresponding candidate action according to the target policy by: reading the policy identifier of the target policy, querying a preset action configuration table with the policy identifier as an index, and extracting a list of candidate actions corresponding to the target policy from the action configuration table. The list of candidate actions includes at least one of allow, block, field replacement, field injection, instruction injection, and redirection.

[0138] S22, Based on the risk threshold range, determine the risk level corresponding to the risk score.

[0139] Risk level refers to the level of risk within a preset risk threshold range. For example, risk level can be low risk, medium risk, or high risk.

[0140] In some embodiments, the processor determines the risk level corresponding to the risk score based on the risk threshold interval by: reading the risk score corresponding to the unified instruction intermediate representation, comparing the risk score with a plurality of preset risk threshold intervals, determining the target risk threshold interval into which the risk score falls, and querying a preset level mapping relationship based on the target risk threshold interval to obtain the risk level corresponding to the risk score.

[0141] In other embodiments, the processor determines the risk level corresponding to the risk score based on the risk threshold range as follows: if the risk score is less than a first threshold, the risk level is determined to be low risk; if the risk score is greater than or equal to the first threshold and less than a second threshold, the risk level is determined to be medium risk; and if the risk score is greater than or equal to the second threshold, the risk level is determined to be high risk.

[0142] S23, based on the risk level, enhance or weaken the candidate action to obtain the adjusted action.

[0143] Action enhancement refers to operations that increase the severity of candidate actions when the risk level is high. For example, action enhancement could be changing "allow" to "audit" or "field replacement" to "block".

[0144] Action reduction refers to operations that reduce the intensity of a candidate action when the risk level is low. For example, action reduction could be changing a block to a field replacement, or changing a field injection to an allow.

[0145] An adjusted action refers to the action obtained by enhancing or weakening a candidate action. For example, an adjusted action could be an enhanced blocking action or a weakened allowing action.

[0146] In some embodiments, the processor enhances or weakens candidate actions based on risk level, including: if the risk level is high, upgrading permitted actions to audit actions and upgrading field replacement actions to blocking actions; if the risk level is low, downgrading blocking actions to field replacement actions and downgrading field injection actions to permitted actions.

[0147] In other embodiments, the processor enhances or weakens candidate actions based on risk level by: querying a preset action adjustment table using the risk level and candidate action identifier as query keys to obtain the adjusted action; if no corresponding item exists in the action adjustment table, the candidate action is kept unchanged as the adjusted action.

[0148] S24, Based on the adjusted actions, generate the action set.

[0149] In some embodiments, the processor generates an action set based on the adjusted actions by: collecting all adjusted actions, removing duplicate actions, sorting the adjusted actions according to a preset priority, and assembling the sorted adjusted actions into an action set.

[0150] In other embodiments, the processor generates an action set based on the adjusted action by associating the adjusted action with a modifiable field of the unified instruction intermediate representation to generate an action set containing an action type, a target field path, and action parameters.

[0151] Some embodiments of this application determine candidate actions based on a target strategy and enhance or weaken the candidate actions based on the risk level determined by a risk threshold range. This enables the same strategy to produce different handling intensities at different risk levels, thereby solving the problem of low-risk false blocking or high-risk insufficient handling caused by the inability of fixed strategy actions to be dynamically adjusted with risk.

[0152] Figure 4 This is an exemplary flowchart illustrating the determination of the intermediate representation of modified instructions according to some embodiments of this application. For example... Figure 4 As shown, the process may include the following operations.

[0153] Step 401: Based on the action set, determine the field path and modification type to be modified in the unified instruction intermediate representation.

[0154] A field path is a location identifier used to locate the field to be modified in the intermediate representation of a unified command. For example, a field path can be the Host field path in an HTTP header, the payload field path in a WebSocket frame, or the recipient field path in an SMTP command.

[0155] Modification type refers to the category of operations performed on a modifiable field. For example, modification type can be field replacement, field injection, instruction injection, or redirection.

[0156] In some embodiments, the processor determines the field path and modification type to be modified in the unified instruction intermediate representation based on the action set, including: extracting the target field identifier and action type from the action; searching for the corresponding field path in the structure tree of the unified instruction intermediate representation based on the target field identifier; mapping the action type to the modification type; determining the modification type as field replacement if the action type is field replacement; determining the modification type as field injection if the action type is field injection; determining the modification type as instruction injection if the action type is instruction injection; determining the modification type as redirection if the action type is redirection; and forming a modification task list by combining the field path and modification type.

[0157] Step 402: Perform structured modification on the modifiable field according to the field path and the modification type.

[0158] In some embodiments, the processor performs structured modification of a modifiable field based on the field path and modification type, including: locating the modifiable field in the unified instruction intermediate representation according to the field path, reading the current value of the modifiable field, performing a replacement, injection, or redirection operation on the current value according to the modification type; if the modification type is field replacement, replacing the current value with a new value specified in the action set; if the modification type is field injection, inserting new field content after or before the current value; if the modification type is instruction injection, adding a new instruction node in the unified instruction intermediate representation; if the modification type is redirection, replacing the target address field with a specified redirection address; and writing the modified field value back to the unified instruction intermediate representation.

[0159] Step 403: During the structured modification process, mark the associated fields in the unified instruction intermediate representation that are affected by the modification type.

[0160] Associated fields are fields in the unified instruction intermediate representation that have a dependency on modifiable fields and need to be adjusted synchronously as the modifiable fields change. For example, associated fields can be the Content-Length field in HTTP, the payload length field and frame header field in a WebSocket frame, or the boundary separator field in SMTP.

[0161] In some embodiments, the processor marks the associated fields in the Unified Instruction Intermediate Representation affected by the modification type during the structured modification process as follows: before modifying the modifiable fields, the processor queries the field dependency table of the Unified Instruction Intermediate Representation, determines the affected associated fields according to the modification type, and marks the length field and check field as associated fields if the modification type is field replacement, marks the length field and delimiter field as associated fields if the modification type is field injection, marks the session stage field and sequence number field as associated fields if the modification type is instruction injection, and marks the target address field and status code field as associated fields if the modification type is redirection.

[0162] Step 404: Based on the modification result of the modifiable field, recalculate the value of the associated field.

[0163] In some embodiments, the processor recalculates the value of the associated field based on the modification result of the modifiable field, including: determining the calculation rule of the associated field according to the protocol type; if the associated field is a length field, calculating the byte length of the modified modifiable field after modification and updating the length field value; if the associated field is a mask field, regenerating the mask value according to the modified payload; and if the associated field is a delimiter field, redetermining the delimiter position according to the modified field content.

[0164] Step 405: Combine the recalculated associated fields with the modified modifiable fields to generate the modified intermediate representation of the instruction.

[0165] In some embodiments, the processor combines the recalculated associated field with the modified modifiable field to generate the modified instruction intermediate representation, which includes: writing the modified modifiable field value into the corresponding field position of the unified instruction intermediate representation, writing the recalculated associated field value into the corresponding field position of the unified instruction intermediate representation, keeping the original values ​​of the unmodified fields in the unified instruction intermediate representation unchanged, and reassembling the unified instruction intermediate representation according to the field structure relationship to obtain the modified instruction intermediate representation.

[0166] In some embodiments of this application, by determining the field path and modification type based on the action set, performing structured modifications on modifiable fields, and marking and recalculating the affected associated fields, it is possible to synchronously update associated fields such as length, frame header, and delimiter after field modification, thereby solving the problem of inconsistent protocol fields and parsing failure at the peer end caused by directly modifying the byte stream.

[0167] Reference Figure 5 The diagram shown is a functional module schematic of the multi-protocol traffic processing device 100 of this application.

[0168] The multi-protocol traffic processing device 100 described in this application is installed in an electronic device. Depending on its functions, the multi-protocol traffic processing device 100 includes an acquisition module 110, a first determination module 120, a generation module 130, a second determination module 140, a verification module 150, and a forwarding module 160. These modules can also be referred to as units, which are a series of computer program segments that can be executed by the processor of an electronic device and perform a fixed function, and are stored in the memory of the electronic device.

[0169] In this embodiment, the functions of each module / unit are as follows: The acquisition module 110 is used to acquire the unified instruction intermediate representation output by the preset protocol plugin; wherein, the unified instruction intermediate representation is obtained by the protocol plugin parsing the continuous byte stream after session reassembly, and the unified instruction intermediate representation includes protocol type, direction, session stage, opcode, semantic label, parameter field, length information and modifiable field; The first determining module 120 is used to determine the risk score corresponding to the intermediate representation of the unified instruction according to a preset risk scoring rule; The generation module 130 is used to perform single-instruction strategy matching on the unified instruction intermediate representation based on the preset strategy and the risk score to generate an action set; The second determining module 140 is used to perform structured modification on the modifiable fields in the unified instruction intermediate representation according to the action set, so as to obtain the modified instruction intermediate representation; Verification module 150 is used to verify the legality of the modified instruction intermediate representation; The forwarding module 160 is used to reserialize the modified instruction intermediate representation that has passed the legality verification into a legal byte stream according to the syntax rules of the corresponding protocol, and output the legal byte stream for forwarding.

[0170] The specific implementation of the multi-protocol traffic processing device in this application is largely the same as the specific implementation of the multi-protocol traffic processing method described above, and will not be repeated here.

[0171] Reference Figure 6 The diagram shown is a schematic representation of a preferred embodiment of the electronic device of this application.

[0172] The electronic device includes a processor 111, a communication interface 112, a memory 113, and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114. Memory 113 is used to store computer programs, such as multi-protocol traffic processing programs; In some embodiments, the processor 111 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor 111 is typically used to control the overall operation of the electronic device, such as performing data interaction or communication-related control and processing. In this embodiment, the processor 111 is used to run program code stored in the memory 113 or process data.

[0173] The communication interface 112 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The communication interface 112 may also be used to establish a communication connection between the electronic device and other electronic devices.

[0174] The memory 113 includes at least one type of readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 113 may be an internal storage unit of the electronic device, such as the hard disk or memory of the electronic device. In other embodiments, the memory 113 may also be an external storage device of the electronic device, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc. of the electronic device. Of course, the memory 113 may include both internal storage units and external storage devices of the electronic device. In this embodiment, the memory 113 is typically used to store the operating system and various computer programs installed on the electronic device, such as program code for multi-protocol traffic processing programs. In addition, the memory 113 may also be used to temporarily store various types of data that have been output or will be output.

[0175] Figure 6 Only an electronic device having a processor 111, a communication interface 112, a memory 113 and a communication bus 114 is shown. However, it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.

[0176] In one embodiment of this application, when the processor 111 executes the program stored in the memory 113, it implements the multi-protocol traffic processing method provided in any of the foregoing method embodiments, including: Obtain the unified instruction intermediate representation output by the preset protocol plugin; wherein, the unified instruction intermediate representation is obtained by the protocol plugin parsing the continuous byte stream after session reassembly, and the unified instruction intermediate representation includes protocol type, direction, session stage, opcode, semantic tag, parameter field, length information and modifiable fields; The risk score corresponding to the intermediate representation of the unified instruction is determined by a preset risk scoring rule; Based on the preset strategy and the risk score, single-instruction strategy matching is performed on the unified instruction intermediate representation to generate an action set. Based on the set of actions, the modifiable fields in the unified instruction intermediate representation are structurally modified to obtain the modified instruction intermediate representation; The legality of the modified instruction intermediate representation is verified; The modified instruction intermediate representation that has passed the legality verification is reserialized into a legal byte stream according to the syntax rules of the corresponding protocol, and the legal byte stream is output for forwarding.

[0177] For a detailed explanation of the above steps, please refer to the above. Figure 1 Description of the flowchart of an embodiment of a multi-protocol traffic processing method.

[0178] Furthermore, this application also proposes a computer-readable storage medium that is both non-volatile and volatile. This computer-readable storage medium is any one or any combination of several of the following: hard disk, multimedia card, SD card, flash memory card, SMC, read-only memory (ROM), erasable programmable read-only memory (EPROM), portable compact disc read-only memory (CD-ROM), USB memory, etc. The computer-readable storage medium includes a data storage area and a program storage area. The program storage area stores a multi-protocol traffic processing program, which, when executed by a processor, performs the following operations: Obtain the unified instruction intermediate representation output by the preset protocol plugin; wherein, the unified instruction intermediate representation is obtained by the protocol plugin parsing the continuous byte stream after session reassembly, and the unified instruction intermediate representation includes protocol type, direction, session stage, opcode, semantic tag, parameter field, length information and modifiable fields; The risk score corresponding to the intermediate representation of the unified instruction is determined by a preset risk scoring rule; Based on the preset strategy and the risk score, single-instruction strategy matching is performed on the unified instruction intermediate representation to generate an action set. Based on the set of actions, the modifiable fields in the unified instruction intermediate representation are structurally modified to obtain the modified instruction intermediate representation; The legality of the modified instruction intermediate representation is verified; The modified instruction intermediate representation that has passed the legality verification is reserialized into a legal byte stream according to the syntax rules of the corresponding protocol, and the legal byte stream is output for forwarding.

[0179] The specific implementation of the computer-readable storage medium in this application is largely the same as the specific implementation of the multi-protocol traffic processing method described above, and will not be repeated here.

[0180] It should be noted that the sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, apparatus, article, or method. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, apparatus, article, or method that includes that element.

[0181] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware simulation platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device to execute the methods described in the various embodiments of this application.

[0182] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.

Claims

1. A method for processing multi-protocol traffic, characterized in that, The method includes: Obtain the unified instruction intermediate representation output by the preset protocol plugin; wherein, the unified instruction intermediate representation is obtained by the protocol plugin parsing the continuous byte stream after session reassembly, and the unified instruction intermediate representation includes protocol type, opcode, semantic label, parameter field and modifiable field; The risk score corresponding to the unified instruction intermediate representation is determined by a preset risk scoring rule, wherein the preset risk scoring rule refers to a set of rules pre-set for determining the risk score based on the instruction semantics and parameters; Based on the preset strategy and the risk score, single-instruction strategy matching is performed on the unified instruction intermediate representation to generate an action set. The preset strategy refers to a set of rules pre-configured for controlling the unified instruction intermediate representation. Based on the set of actions, the modifiable fields in the unified instruction intermediate representation are structurally modified to obtain the modified instruction intermediate representation; The legality of the modified instruction intermediate representation is verified; The modified instruction intermediate representation that has passed the legality verification is reserialized into a legal byte stream according to the syntax rules of the corresponding protocol, and the legal byte stream is output for forwarding.

2. The method according to claim 1, characterized in that, The step of determining the risk score corresponding to the unified instruction intermediate representation through preset risk scoring rules includes: Based on the semantic tags and the operation codes, a preset risk weight mapping relationship is queried to determine the behavior type risk weight corresponding to the unified instruction intermediate representation; Based on the parameter fields, determine the parameter risk weight corresponding to the intermediate representation of the unified instruction; Based on the behavior type risk weight and the parameter risk weight, the basic risk score of the unified instruction intermediate representation is determined; Based on the behavioral history of the session, a first risk correction factor is determined for the session, wherein the behavioral history includes at least one of the following: number of historical violations, size of historical data sent out, and number of historical login failures. Based on the current system resource load, a second risk correction factor is determined under the current resource constraints, wherein the resource load includes at least one of session cache usage, processor load, and queue latency; The risk score is determined based on the basic risk score, the first risk correction factor, and the second risk correction factor.

3. The method according to claim 1, characterized in that, Based on the preset strategy and the risk score, single-instruction strategy matching is performed on the unified instruction intermediate representation to generate an action set, including: Based on the risk threshold range corresponding to the risk score, a target matching mode is determined from a preset multi-level strategy matching mode, wherein the multi-level strategy matching mode includes a fast matching mode and a deep matching mode, and the matching field corresponding to the fast matching mode is less than the matching field corresponding to the deep matching mode. In the target matching mode, the unified instruction intermediate representation is matched with the preset strategy; The action set is generated based on the target strategy that matches the intermediate representation of the unified instruction and the risk threshold range.

4. The method according to claim 3, characterized in that, The generation of the action set based on the target strategy matched with the unified instruction intermediate representation and the risk threshold range includes: Based on the target strategy, corresponding candidate actions are determined, wherein the candidate actions include at least one of allow, block, field replacement, field injection, instruction injection, and redirection; Based on the risk threshold range, determine the risk level corresponding to the risk score; Based on the risk level, the candidate actions are enhanced or weakened to obtain the adjusted actions; Based on the adjusted actions, the action set is generated.

5. The method according to claim 4, characterized in that, The step of performing structured modifications on the modifiable fields in the unified instruction intermediate representation based on the action set to obtain the modified instruction intermediate representation includes: Based on the set of actions, determine the field path and modification type to be modified in the unified instruction intermediate representation, wherein the modification type includes at least one of field replacement, field injection, instruction injection, and redirection; Based on the field path and the modification type, perform structured modification on the modifiable field; During the structured modification process, the associated fields in the unified instruction intermediate representation that are affected by the modification type are marked; Based on the modification result of the modifiable field, recalculate the value of the associated field; The recalculated associated fields are combined with the modified modifiable fields to generate the modified intermediate representation of the instruction.

6. The method according to claim 1, characterized in that, The validity verification of the modified instruction intermediate representation includes: Based on the protocol type corresponding to the modified instruction, determine the set of legality constraints; Based on the set of legality constraints, the modified intermediate representation of the instruction is verified; Specifically, when the protocol type is HTTP, the modified instruction intermediate representation is verified for consistency of the length field and the chunked transmission boundary; when the protocol type is WebSocket, the modified instruction intermediate representation is verified for consistency of the frame header and the mask field; when the protocol type is FTP, the modified instruction intermediate representation is verified for consistency of the command and data connection states; and when the protocol type is SMTP, the modified instruction intermediate representation is verified for consistency of the command phase and the data phase boundary.

7. The method according to claim 1, characterized in that, The step of reserializing the modified instruction intermediate representation that has passed the validity verification into a valid byte stream according to the syntax rules of the corresponding protocol includes: Before modification, obtain the original byte reference of the unified instruction intermediate representation, the original byte reference indicating the unmodified byte range in the unified instruction intermediate representation; Based on the original byte reference, the unmodified byte range is preserved; The modified fields in the modified instruction intermediate representation are serialized according to the syntax rules of the corresponding protocol to obtain the modified byte segment; The modified byte segment and the unmodified byte range are concatenated in their original order to obtain the valid byte stream.

8. A multi-protocol traffic processing device, characterized in that, The device includes: The acquisition module is used to acquire the unified instruction intermediate representation output by the preset protocol plugin; wherein, the unified instruction intermediate representation is obtained by the protocol plugin parsing the continuous byte stream after session reassembly, and the unified instruction intermediate representation includes protocol type, opcode, semantic label, parameter field and modifiable field; The first determining module is used to determine the risk score corresponding to the unified instruction intermediate representation through a preset risk scoring rule, wherein the preset risk scoring rule refers to a set of rules pre-set for determining the risk score based on the instruction semantics and parameters; The generation module is used to perform single-instruction strategy matching on the unified instruction intermediate representation based on the preset strategy and the risk score, and generate an action set, wherein the preset strategy refers to a set of rules pre-configured for controlling the unified instruction intermediate representation. The second determining module is used to perform structured modifications on the modifiable fields in the unified instruction intermediate representation based on the action set, so as to obtain the modified instruction intermediate representation; The verification module is used to verify the legality of the modified intermediate representation of the instruction; The forwarding module is used to reserialize the modified instruction intermediate representation that has passed the legality verification into a legal byte stream according to the syntax rules of the corresponding protocol, and output the legal byte stream for forwarding.

9. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the multiprotocol traffic processing method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the multiprotocol traffic processing method as described in any one of claims 1 to 7.