Network protocol fuzz testing method and system based on multi-source knowledge guided mutation

By building a mutation knowledge base and using protocol constraint information to guide message mutation, the problem of test cases not conforming to the protocol format in network protocol fuzz testing is solved, achieving automated generation and saving test costs.

CN118413466BActive Publication Date: 2024-09-06NAT UNIV OF DEFENSE TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410881375.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-03
Publication Date
2024-09-06
Estimated Expiration
2044-07-03

AI Technical Summary

Technical Problem

The existing network protocol fuzz testing mutation process lacks effective information guidance, making it difficult to generate test cases that meet the protocol format, resulting in a waste of testing resources.

Method used

By extracting the constraint information of the protocol request message from the protocol RFC document and the network service target program, a mutation knowledge base is constructed, using order constraints, syntax constraints and semantic constraints to guide message mutation, and generate test cases that conform to the protocol format.

Benefits of technology

It realizes the automatic generation of test cases that meet the protocol format, reduces the waste of testing resources, and improves the testing efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118413466B
    Figure CN118413466B
Patent Text Reader

Abstract

The present invention proposes a network protocol fuzz testing method and system based on multi-source knowledge-guided mutation, which belongs to the field of network protocol fuzz testing technology. The present invention extracts relevant constraint information of protocol request messages from protocol RFC documents and network service target programs, constructs a mutation knowledge base about the target protocol format, and realizes automatic generation of test cases that meet the protocol format. The present invention mainly solves the problem that the existing network protocol fuzz testing mutation process lacks effective information guidance and is difficult to generate test cases that meet the protocol format.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of network protocol fuzzy testing, and in particular to a network protocol fuzzy testing method and system based on multi-source knowledge guided variation. Background Art

[0002] With the continuous development of Internet technology, the importance of network protocols in the field of information technology is increasing. Network protocols are the basis for communication and information exchange between entities in computer networks. They determine the way different entities communicate in the network and specify in detail the format, meaning, sequence and operation rules of information exchange between communicating entities. However, due to coding errors, protocol complexity, and failure to update in a timely manner, potential security vulnerabilities may be introduced in the specific implementation of network protocols. These vulnerabilities provide attackers with the possibility to maliciously exploit weaknesses in network protocols to carry out various attacks and illegal activities.

[0003] At present, network protocol vulnerability mining technologies include program static analysis, dynamic taint analysis, dynamic symbolic execution, and fuzz testing. With the gradual growth of software system scale and complexity, several vulnerability mining technologies other than fuzz testing either have problems such as path explosion, state explosion, difficulty in solving constraints and long time consumption, or have disadvantages such as high false positive rate and missed rate. Fuzz testing has the advantages of high degree of automation, no dependence on target program source code, good applicability and high accuracy, and has become the mainstream method of network protocol vulnerability mining technology.

[0004] Since the request messages of network protocols usually have format constraints, and the current network protocol fuzz testing mutation process lacks effective information guidance and is too blind, it is difficult to generate test cases that meet the protocol format constraints. As a result, the test cases are discarded by the server program at the beginning because they do not conform to the format, resulting in a large waste of testing resources.

[0005] From the perspective of the prior art, there are two types of existing network protocol fuzzy test message mutation schemes that are closest to the present invention: one is request message mutation based on AFLNET, and the other is request message mutation based on syntax format.

[0006] The first category is the request message mutation scheme based on AFLNET. This scheme mutates each field of the request message. There are two mutation strategies: one is message-level mutation, which performs mutation operations such as flipping the mutated request message in bits or bytes; the other is sequence-level mutation, which randomly selects a message in the message sequence and performs mutation operations such as replacement, insertion, deletion or duplication on the mutated request message. Figure 1As shown, first determine the location of the message to be mutated in the seed file, and then directly perform indiscriminate message-level mutation and sequence-level mutation on all fields of the message to be mutated.

[0007] The second type is a request message mutation scheme based on the syntax format. This type of scheme obtains various types of request message syntax format templates, determines the variable fields in the format template, and then only performs mutation operations on the variable fields of the request message format during the mutation process. Figure 2 As shown, firstly, the syntax format template of the protocol request message is obtained, the variable fields in the message to be mutated are determined according to the syntax format template, and then the message-level mutation is performed on the variable fields in the message to be mutated.

[0008] The first type of scheme is the mutation strategy of AFLNET, the mainstream tool for gray-box network protocol fuzz testing. This scheme performs random mutation on the mutated message without format constraints and is adopted by most gray-box fuzz testing tools. There are two main problems with this scheme. The first problem is that the message-level mutation does not consider the grammatical constraints and semantic constraints of the request message, resulting in the request message not being correctly processed by the server program. The second problem is that the sequence-level mutation does not consider the order constraints of the request message. The generated request message is very likely not to follow the previous message, resulting in the request message not being received by the server program.

[0009] The second type of solution first performs the step of obtaining the syntax format of the target protocol. This step can locate which fields in the message are fixed fields in the protocol request message and which fields are fields that change with the changes in the server and client data. When mutating the message to be mutated, only the message-level mutation operation is performed on the variable fields. This type of solution does not consider the order constraints and semantic constraints of the request message, and the generated request message is likely to be invalid. Summary of the invention

[0010] In order to solve the above technical problems, the present invention proposes a network protocol fuzz testing scheme based on multi-source knowledge-guided mutation. The present invention extracts the relevant constraint information of the protocol request message from the protocol RFC document and the network service target program, constructs a mutation knowledge base about the target protocol format, and realizes the automatic generation of test cases that meet the protocol format. The present invention mainly solves the problem that the existing network protocol fuzz testing mutation process lacks effective information guidance and is difficult to generate test cases that meet the protocol format.

[0011] The first aspect of the present invention proposes a network protocol fuzz testing method based on multi-source knowledge guided variation. The method comprises:

[0012] Step S1, obtaining the constraint knowledge of the protocol request message based on the protocol RFC document and the network service target program, and constructing a variant knowledge base covering various types of protocol constraint information by integrating the constraint knowledge of the protocol request message;

[0013] Step S2: The network program fuzz tester locates the position of the message to be mutated from the selected seed file, and uses the mutation knowledge base to guide the message to be mutated to perform a mutation operation, thereby generating a test case that conforms to the protocol constraint information.

[0014] According to the method of the first aspect of the present invention, in step S1, the constraint knowledge of the protocol request message includes first constraint knowledge and second constraint knowledge; wherein:

[0015] Using a large language model to obtain first constraint knowledge of the protocol request message from the protocol function description, message format, status code and error handling strategy in the protocol RFC document, including sequence constraints, grammatical constraints and semantic constraints of the protocol;

[0016] Acquiring the second constraint knowledge of the protocol request message from the interpretation description and execution process of the input access instruction in the network service target program by means of dynamic taint analysis, including the grammatical constraint and semantic constraint of the protocol;

[0017] The first constraint knowledge and the second constraint knowledge are integrated to construct the variation knowledge base covering various types of protocol constraint information.

[0018] According to the method of the first aspect of the present invention, in step S2, the network program fuzz tester selects the seed file from the corpus, the seed file contains a message sequence consisting of multiple request messages, and the network program fuzz tester locates the position of the message to be mutated from the message sequence consisting of multiple request messages contained in the seed file; wherein:

[0019] The message sequence includes a prefix message, an infix message and a suffix message;

[0020] The prefix message is a sequence of request messages used to guide the server to be tested to reach a target state;

[0021] The infix message is a sequence of request messages sent to the server under test in the target state;

[0022] The suffix message is a sequence of other messages except the prefix message and the infix message;

[0023] The position of the message to be mutated is located in the infix message.

[0024] According to the method of the first aspect of the present invention, in the step S2, the mutation knowledge base is used to guide the message to be mutated to perform a mutation operation; specifically comprising:

[0025] The sequence constraint is used to guide the mutation operation so that the type of the current request message matches the type of the previous request message;

[0026] The grammatical constraint is used to guide the mutation operation, so that the current request message to be mutated conforms to the relevant grammatical format;

[0027] The semantic constraint is used to guide the mutation operation, so that the field value in the current request message to be mutated is within a preset range.

[0028] The second aspect of the present invention proposes a network protocol fuzzy testing system based on multi-source knowledge guided variation. The system comprises:

[0029] The first processing unit is configured to: obtain constraint knowledge of the protocol request message based on the protocol RFC document and the network service target program, and construct a variant knowledge base covering various types of protocol constraint information by fusing the constraint knowledge of the protocol request message;

[0030] The second processing unit is configured as follows: the network program fuzz tester locates the position of the message to be mutated from the selected seed file, and uses the mutation knowledge base to guide the message to be mutated to perform mutation operations, thereby generating a test case that conforms to the protocol constraint information.

[0031] According to the system of the second aspect of the present invention, the constraint knowledge of the protocol request message includes first constraint knowledge and second constraint knowledge; the first processing unit is configured to:

[0032] Using a large language model to obtain first constraint knowledge of the protocol request message from the protocol function description, message format, status code and error handling strategy in the protocol RFC document, including sequence constraints, grammatical constraints and semantic constraints of the protocol;

[0033] Acquiring the second constraint knowledge of the protocol request message from the interpretation description and execution process of the input access instruction in the network service target program by means of dynamic taint analysis, including the grammatical constraint and semantic constraint of the protocol;

[0034] The first constraint knowledge and the second constraint knowledge are integrated to construct the variation knowledge base covering various types of protocol constraint information.

[0035] According to the system of the second aspect of the present invention, the second processing unit is specifically configured as follows: the network program fuzz tester selects the seed file from the corpus, the seed file contains a message sequence consisting of multiple request messages, and the network program fuzz tester locates the position of the message to be mutated from the message sequence consisting of multiple request messages contained in the seed file; wherein:

[0036] The message sequence includes a prefix message, an infix message and a suffix message;

[0037] The prefix message is a sequence of request messages used to guide the server to be tested to reach a target state;

[0038] The infix message is a sequence of request messages sent to the server under test in the target state;

[0039] The suffix message is a sequence of other messages except the prefix message and the infix message;

[0040] The position of the message to be mutated is located in the infix message.

[0041] According to the system of the second aspect of the present invention, the second processing unit is configured to: use the mutation knowledge base to guide the message to be mutated to perform a mutation operation; specifically including:

[0042] The sequence constraint is used to guide the mutation operation so that the type of the current request message matches the type of the previous request message;

[0043] The grammatical constraint is used to guide the mutation operation, so that the current request message to be mutated conforms to the relevant grammatical format;

[0044] The semantic constraint is used to guide the mutation operation, so that the field value in the current request message to be mutated is within a preset range.

[0045] The third aspect of the present invention discloses an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the network protocol fuzzy testing method based on multi-source knowledge guided mutation according to the first aspect of the present disclosure is implemented.

[0046] The fourth aspect of the present invention discloses a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the network protocol fuzzy testing method based on multi-source knowledge guided mutation according to the first aspect of the present disclosure.

[0047] In summary, the technical effects brought about by the technical solution of the present invention include: (1) more comprehensive acquisition of the constraint information of the protocol format; (2) automatic generation of test cases that meet the protocol format; and (3) saving of testing costs.

[0048] First, this application obtains protocol constraint information from two dimensions: protocol RFC documents and network service target programs. The knowledge from the two sources complements and integrates each other to build a relatively complete variant knowledge base of the target protocol.

[0049] Second, this application uses the constructed mutation knowledge base to guide the message mutation process. Mutation is performed under the guidance of sequence constraints, grammatical constraints, and semantic constraints to ensure that the request message type matches the type of the previous message and that the request message conforms to the basic grammatical and semantic format, thereby ensuring that the server program can correctly receive, parse, and process the request message.

[0050] Third, this application can save the testing cost of network protocol fuzz testing. For network protocol fuzz testing, if the request message in the test case does not conform to the protocol format constraints, it will be rejected and discarded by the server program at the beginning, resulting in a waste of a large number of testing resources for fuzz testing. However, this application guides the message mutation process by building a mutation knowledge base of the target protocol, and the generated test cases conform to the protocol format constraints, which can effectively test the server program. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0052] Figure 1 The figure is a flow chart of the first type of solution in the prior art.

[0053] Figure 2 The figure is a flow chart of the second type of solution in the prior art.

[0054] Figure 3 A flowchart of a network protocol fuzz testing method based on multi-source knowledge guided mutation according to an embodiment of the present invention.

[0055] Figure 4 A schematic diagram of a mutation operation process according to an embodiment of the present invention.

[0056] Figure 5 A flowchart of a specific example according to an embodiment of the present invention.

[0057] Figure 6 The figure is a structural diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0058] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0059] Network protocol: A collection of rules, standards or conventions established for data exchange in a computer network.

[0060] RFC: Technical documents developed by the Internet Engineering Task Force (IETF), which cover the specifications, instructions and best practices of various Internet technologies, protocols and standards. The RFC documents of network protocols detail the syntax, semantics, message format, state machine and other aspects of the protocol to ensure that various devices and systems on the Internet can correctly understand and implement these protocols.

[0061] Sequence constraint: During the communication between the client and the server, the server restricts the order of request messages sent by the client to ensure the correctness and effectiveness of the communication process. This sequence constraint is stipulated by the communication protocol, which stipulates the order of sending and receiving request messages to ensure the consistency and correctness of communication. For example, the SMTP protocol requires the client to send the "HELO" or "EHLO" command before sending the "MAIL FROM", "RCPT TO" and "DATA" commands to transmit emails.

[0062] Syntax constraints: When constructing a request message for a network protocol, specific formats, structures, or syntax rules must be followed to ensure that the server can correctly parse and process the request. By complying with syntax constraints, the client can send request messages in the correct format, and the server can accurately parse and process these messages. For example, the syntax constraints of an HTTP request message include: Request line: must contain the HTTP method, the requested URI, and the HTTP protocol version number. Header fields: include the name and value of the request header field, and the fields are separated by colons. Blank line: There must be a blank line after the request line and the header field. Request body: HTTP method, the request message can contain a request body, whose format is usually specified by the Content-Type header field.

[0063] Semantic constraints: The format and field value restrictions of network protocol request messages ensure that the request messages not only conform to the protocol format template, but also conform to specific semantic rules. For example, in the PLAY request message of the RTSP protocol, the CSeq field specifies the sequence number of the request to ensure that the order of the request is correct. The value of this field is usually a non-negative integer.

[0064] The first aspect of the present invention proposes a network protocol fuzz testing method based on multi-source knowledge guided mutation. Figure 3 As shown, the method includes:

[0065] Step S1, obtaining the constraint knowledge of the protocol request message based on the protocol RFC document and the network service target program, and constructing a variant knowledge base covering various types of protocol constraint information by integrating the constraint knowledge of the protocol request message;

[0066] Step S2: The network program fuzz tester locates the position of the message to be mutated from the selected seed file, and uses the mutation knowledge base to guide the message to be mutated to perform a mutation operation, thereby generating a test case that conforms to the protocol constraint information.

[0067] According to the method of the first aspect of the present invention, in step S1, the constraint knowledge of the protocol request message includes first constraint knowledge and second constraint knowledge; wherein:

[0068] Using a large language model to obtain first constraint knowledge of the protocol request message from the protocol function description, message format, status code and error handling strategy in the protocol RFC document, including sequence constraints, grammatical constraints and semantic constraints of the protocol;

[0069] Acquiring the second constraint knowledge of the protocol request message from the interpretation description and execution process of the input access instruction in the network service target program by means of dynamic taint analysis, including the grammatical constraint and semantic constraint of the protocol;

[0070] The first constraint knowledge and the second constraint knowledge are integrated to construct the variation knowledge base covering various types of protocol constraint information.

[0071] In some embodiments, network protocol constraint information is obtained from two dimensions: one is the protocol RFC document, which describes in detail the functions, message formats, status codes, error handling, etc. of the protocol. The order constraints, grammatical constraints, and semantic constraints of the protocol can be extracted from the RFC document; the other is the network service target program itself. The code semantics of the target program always includes the format of the input, and the knowledge of the input format is usually implicit in the interpretation and execution of the input access instructions of the target program. The grammatical constraints and semantic constraints of the protocol can be obtained from the network service target program.

[0072] In some embodiments, a large language model is used to obtain the constraint knowledge of the protocol request message from the RFC document, and dynamic taint analysis is used to obtain the constraint knowledge of the protocol request message from the network service target program. Then, the constraint knowledge from the two sources is merged to finally form a variant knowledge base covering various types of constraint information.

[0073] According to the method of the first aspect of the present invention, in step S2, the network program fuzz tester selects the seed file from the corpus, the seed file contains a message sequence consisting of multiple request messages, and the network program fuzz tester locates the position of the message to be mutated from the message sequence consisting of multiple request messages contained in the seed file; wherein:

[0074] The message sequence includes a prefix message, an infix message and a suffix message;

[0075] The prefix message is a sequence of request messages used to guide the server to be tested to reach a target state;

[0076] The infix message is a sequence of request messages sent to the server under test in the target state;

[0077] The suffix message is a sequence of other messages except the prefix message and the infix message;

[0078] The position of the message to be mutated is located in the infix message.

[0079] In some embodiments, when performing fuzz testing on a network program, the fuzz tester selects a suitable seed file from the corpus, and the seed file to be mutated contains a message sequence consisting of multiple request messages. In order to effectively mutate the seed, it is necessary to identify the position of the message to be mutated in the message sequence. The network protocol fuzz tester first divides the selected seed file into three parts: prefix message, infix message and suffix message. Among them, the prefix message is a series of request message sequences, which can guide the server to be tested to reach the target state; the infix message is a sequence of request messages sent to the server to be tested in the target state, and it is also a sequence of messages to be mutated that needs to be located; the suffix message is the remaining message sequence in the seed file except the prefix and infix messages.

[0080] According to the method of the first aspect of the present invention, in the step S2, the mutation knowledge base is used to guide the message to be mutated to perform a mutation operation; specifically comprising:

[0081] The sequence constraint is used to guide the mutation operation so that the type of the current request message matches the type of the previous request message;

[0082] The grammatical constraint is used to guide the mutation operation, so that the current request message to be mutated conforms to the relevant grammatical format;

[0083] The semantic constraint is used to guide the mutation operation, so that the field value in the current request message to be mutated is within a preset range.

[0084] In some embodiments, Figure 4 As shown in the figure, the protocol mutation knowledge base is used to guide the mutation of the message to be mutated. First, the sequential constraint knowledge is used to guide the message mutation to ensure that the type of the request message can match the type of the previous message, so as to ensure that the server program can receive and process this type of request message in the target state. Secondly, the grammatical constraint knowledge is used to guide the message mutation to ensure that the request message to be mutated conforms to its basic grammatical format, so as to ensure that the server can correctly parse and process the message. Finally, the semantic constraint is used to guide the message mutation to ensure that the values ​​of certain fields in the request message to be mutated are within a reasonable legal range, so as to ensure that the request message can be correctly processed by the server.

[0085] The second aspect of the present invention proposes a network protocol fuzzy testing system based on multi-source knowledge guided variation. The system comprises:

[0086] The first processing unit is configured to: obtain constraint knowledge of the protocol request message based on the protocol RFC document and the network service target program, and construct a variant knowledge base covering various types of protocol constraint information by fusing the constraint knowledge of the protocol request message;

[0087] The second processing unit is configured as follows: the network program fuzz tester locates the position of the message to be mutated from the selected seed file, and uses the mutation knowledge base to guide the message to be mutated to perform mutation operations, thereby generating a test case that conforms to the protocol constraint information.

[0088] According to the system of the second aspect of the present invention, the constraint knowledge of the protocol request message includes first constraint knowledge and second constraint knowledge; the first processing unit is configured to:

[0089] Using a large language model to obtain first constraint knowledge of the protocol request message from the protocol function description, message format, status code and error handling strategy in the protocol RFC document, including sequence constraints, grammatical constraints and semantic constraints of the protocol;

[0090] Acquiring the second constraint knowledge of the protocol request message from the interpretation description and execution process of the input access instruction in the network service target program by means of dynamic taint analysis, including the grammatical constraint and semantic constraint of the protocol;

[0091] The first constraint knowledge and the second constraint knowledge are integrated to construct the variation knowledge base covering various types of protocol constraint information.

[0092] According to the system of the second aspect of the present invention, the second processing unit is specifically configured as follows: the network program fuzz tester selects the seed file from the corpus, the seed file contains a message sequence consisting of multiple request messages, and the network program fuzz tester locates the position of the message to be mutated from the message sequence consisting of multiple request messages contained in the seed file; wherein:

[0093] The message sequence includes a prefix message, an infix message and a suffix message;

[0094] The prefix message is a sequence of request messages used to guide the server to be tested to reach a target state;

[0095] The infix message is a sequence of request messages sent to the server under test in the target state;

[0096] The suffix message is a sequence of other messages except the prefix message and the infix message;

[0097] The position of the message to be mutated is located in the infix message.

[0098] According to the system of the second aspect of the present invention, the second processing unit is configured to: use the mutation knowledge base to guide the message to be mutated to perform a mutation operation; specifically including:

[0099] The sequence constraint is used to guide the mutation operation so that the type of the current request message matches the type of the previous request message;

[0100] The grammatical constraint is used to guide the mutation operation, so that the current request message to be mutated conforms to the relevant grammatical format;

[0101] The semantic constraint is used to guide the mutation operation, so that the field value in the current request message to be mutated is within a preset range.

[0102] Specific examples

[0103] A researcher planned to conduct a security test on the Live555 server. When using traditional methods for testing, a large proportion of test cases were invalid and a large amount of test resources were wasted. Therefore, by applying the technology of this application, the message mutation link was improved, a mutation knowledge base for the RTSP protocol was built, and the mutation knowledge base was used to guide the message mutation process in the message mutation link, automatically generate test cases that meet the protocol format constraints, and improve the overall efficiency of the test.

[0104] like Figure 5As shown, dynamic taint analysis and large language model hint engineering are used to obtain the order constraints, grammatical constraints and semantic constraints of the RTSP protocol; the constraint knowledge obtained from the two dimensions is integrated to build a mutation knowledge base of the RTSP protocol; the position of the message to be mutated in the seed file is determined; the order constraints in the RTSP protocol are used to guide the order mutation of the message to be mutated; the grammatical constraints in the RTSP protocol are used to guide the grammatical mutation of the message to be mutated; the semantic constraints in the RTSP protocol are used to guide the semantic mutation of the message to be mutated; after the above mutation stages are completed for the message to be mutated, new test cases that meet the protocol order constraints, grammatical constraints and semantic constraints are generated.

[0105] The third aspect of the present invention discloses an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the network protocol fuzzy testing method based on multi-source knowledge guided mutation according to the first aspect of the present disclosure is implemented.

[0106] Figure 6 is a structural diagram of an electronic device according to an embodiment of the present invention, such as Figure 6 As shown, the electronic device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the electronic device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, an operator network, near field communication (NFC) or other technologies. The display screen of the electronic device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the electronic device can be a touch layer covered on the display screen, or a key, trackball or touchpad set on the housing of the electronic device, or an external keyboard, touchpad or mouse, etc.

[0107] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a structural diagram of the part related to the technical solution of the present disclosure, and does not constitute a limitation on the electronic device to which the technical solution of the present application is applied. The specific electronic device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0108] The fourth aspect of the present invention discloses a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the network protocol fuzzy testing method based on multi-source knowledge guided mutation according to the first aspect of the present disclosure.

[0109] In summary, the technical effects brought about by the technical solution of the present invention include: (1) more comprehensive acquisition of the constraint information of the protocol format; (2) automatic generation of test cases that meet the protocol format; and (3) saving of testing costs.

[0110] First, this application obtains protocol constraint information from two dimensions: protocol RFC documents and network service target programs. The knowledge from the two sources complements and integrates each other to build a relatively complete variant knowledge base of the target protocol.

[0111] Second, this application uses the constructed mutation knowledge base to guide the message mutation process. Mutation is performed under the guidance of sequence constraints, grammatical constraints, and semantic constraints to ensure that the request message type matches the type of the previous message and that the request message conforms to the basic grammatical and semantic format, thereby ensuring that the server program can correctly receive, parse, and process the request message.

[0112] Third, this application can save the testing cost of network protocol fuzz testing. For network protocol fuzz testing, if the request message in the test case does not conform to the protocol format constraints, it will be rejected and discarded by the server program at the beginning, resulting in a waste of a large number of testing resources for fuzz testing. However, this application guides the message mutation process by building a mutation knowledge base of the target protocol, and the generated test cases conform to the protocol format constraints, which can effectively test the server program.

[0113] Please note that the technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification. The above embodiments only express several implementation methods of the present application, and their descriptions are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that for ordinary technicians in this field, without departing from the concept of the present application, several variations and improvements can be made, which all belong to the scope of protection of the present application. Therefore, the scope of protection of the patent in this application shall be based on the attached claims.

Claims

1. A network protocol fuzz testing method based on multi-source knowledge guided mutation, characterized in that: The method comprises: Step S1, obtaining the constraint knowledge of the protocol request message based on the protocol RFC document and the network service target program, and constructing a variant knowledge base covering various types of protocol constraint information by integrating the constraint knowledge of the protocol request message; Step S2, the network program fuzz tester locates the position of the message to be mutated from the selected seed file, and uses the mutation knowledge base to guide the message to be mutated to perform a mutation operation, thereby generating a test case that conforms to the protocol constraint information; Wherein, in the step S1, the constraint knowledge of the protocol request message includes first constraint knowledge and second constraint knowledge; wherein: Using a large language model to obtain first constraint knowledge of the protocol request message from the protocol function description, message format, status code and error handling strategy in the protocol RFC document, including sequence constraints, grammatical constraints and semantic constraints of the protocol; Acquiring the second constraint knowledge of the protocol request message from the interpretation description and execution process of the input access instruction in the network service target program by means of dynamic taint analysis, including the grammatical constraint and semantic constraint of the protocol; The first constraint knowledge and the second constraint knowledge are integrated to construct the variation knowledge base covering various types of protocol constraint information.

2. According to claim 1, a network protocol fuzz testing method based on multi-source knowledge guided mutation is characterized in that: In the step S2, the network program fuzz tester selects the seed file from the corpus, the seed file contains a message sequence consisting of multiple request messages, and the network program fuzz tester locates the position of the message to be mutated from the message sequence consisting of multiple request messages contained in the seed file; wherein: The message sequence includes a prefix message, an infix message and a suffix message; The prefix message is a sequence of request messages used to guide the server to be tested to reach a target state; The infix message is a sequence of request messages sent to the server under test in the target state; The suffix message is a sequence of other messages except the prefix message and the infix message; The position of the message to be mutated is located in the infix message.

3. According to claim 2, a network protocol fuzz testing method based on multi-source knowledge guided mutation is characterized in that: In the step S2, the mutation knowledge base is used to guide the message to be mutated to perform a mutation operation; specifically, the step includes: The sequence constraint is used to guide the mutation operation so that the type of the current request message matches the type of the previous request message; The grammatical constraint is used to guide the mutation operation, so that the current request message to be mutated conforms to the relevant grammatical format; The semantic constraint is used to guide the mutation operation, so that the field value in the current request message to be mutated is within a preset range.

4. A network protocol fuzz testing system based on multi-source knowledge guided mutation, characterized in that: The system comprises: The first processing unit is configured to: obtain constraint knowledge of the protocol request message based on the protocol RFC document and the network service target program, and construct a variant knowledge base covering various types of protocol constraint information by fusing the constraint knowledge of the protocol request message; The second processing unit is configured to: the network program fuzz tester locates the position of the message to be mutated from the selected seed file, and uses the mutation knowledge base to guide the message to be mutated to perform a mutation operation, thereby generating a test case that conforms to the protocol constraint information; The constraint knowledge of the protocol request message includes first constraint knowledge and second constraint knowledge; and the first processing unit is configured to: Using a large language model to obtain first constraint knowledge of the protocol request message from the protocol function description, message format, status code and error handling strategy in the protocol RFC document, including sequence constraints, grammatical constraints and semantic constraints of the protocol; Acquiring the second constraint knowledge of the protocol request message from the interpretation description and execution process of the input access instruction in the network service target program by means of dynamic taint analysis, including the grammatical constraint and semantic constraint of the protocol; The first constraint knowledge and the second constraint knowledge are integrated to construct the variation knowledge base covering various types of protocol constraint information.

5. A network protocol fuzz testing system based on multi-source knowledge guided mutation according to claim 4, characterized in that: The second processing unit is specifically configured as follows: the network program fuzz tester selects the seed file from the corpus, the seed file contains a message sequence consisting of multiple request messages, and the network program fuzz tester locates the position of the message to be mutated from the message sequence consisting of multiple request messages contained in the seed file; wherein: The message sequence includes a prefix message, an infix message and a suffix message; The prefix message is a sequence of request messages used to guide the server to be tested to reach a target state; The infix message is a sequence of request messages sent to the server under test in the target state; The suffix message is a sequence of other messages except the prefix message and the infix message; The position of the message to be mutated is located in the infix message.

6. A network protocol fuzz testing system based on multi-source knowledge guided mutation according to claim 5, characterized in that: The second processing unit is configured to: use the mutation knowledge base to guide the message to be mutated to perform a mutation operation; specifically including: The sequence constraint is used to guide the mutation operation so that the type of the current request message matches the type of the previous request message; The grammatical constraint is used to guide the mutation operation, so that the current request message to be mutated conforms to the relevant grammatical format; The semantic constraint is used to guide the mutation operation, so that the field value in the current request message to be mutated is within a preset range.

7. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, it implements the network protocol fuzz testing method based on multi-source knowledge-guided mutation as described in any one of claims 1-3.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, it implements the network protocol fuzz testing method based on multi-source knowledge-guided mutation as described in any one of claims 1 to 3.