Fuzz testing method, device and storage medium for stateful network protocol

By building a Petri network model to obtain program execution information of protocol status and generate high-quality test cases, the problem of low quality of stateful network protocol fuzzy test cases in the prior art is solved, and the testing efficiency and coverage are improved.

CN113326181BInactive Publication Date: 2024-11-19HUAWEI TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202010132978.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-02-29
Publication Date
2024-11-19
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

When the prior art performs fuzz testing on stateful network protocols, the generation quality of test cases is low, resulting in low testing efficiency.

Method used

By building a Petri network model, a program execution information of the protocol status is obtained, and a new test case is generated based on the quality score provided by the monitor, improving the quality of the test case, thereby improving the efficiency of fuzz testing.

Benefits of technology

Improve the efficiency of fuzz testing and the quality of test cases, ensuring sufficient coverage and abnormal detection capabilities of stateful network protocols.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113326181B_ABST
    Figure CN113326181B_ABST
Patent Text Reader

Abstract

The present application discloses a fuzz testing method, device and storage medium for a stateful network protocol, belonging to the field of security testing. The method is applied to a fuzz tester, including: generating a test case for fuzz testing a first protocol state of a stateful network protocol, and determining the program execution information corresponding to the first protocol state; sending the test case to a target program to perform a fuzz test on the first protocol state, the target program using a stateful network protocol; sending the program execution information to a monitor, the monitor determining the quality score of the test case based on the program execution information and the execution path of the target program; when receiving the quality score sent by the monitor, if the quality score is greater than or equal to the score threshold, a new test case for fuzz testing the first protocol state is generated according to the test case. The present application can improve the quality of the test case, thereby improving the efficiency of fuzz testing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of security testing, and in particular to a fuzzy testing method, device and storage medium for a stateful network protocol. Background Art

[0002] As the complexity and importance of various network services increase, the security of the network protocols that network services rely on is becoming increasingly important. However, due to the complexity of network protocols, security vulnerabilities are inevitably introduced during the design and implementation of network protocols. Fuzz testing, as an important means of discovering security vulnerabilities, plays an important role in network protocol vulnerability mining. The basic principle of fuzz testing is to discover security vulnerabilities by constructing a large amount of mutated data and sending it to the target program, and monitoring whether the target program is abnormal.

[0003] In order to perform fuzz testing on stateful network protocols, the finite state machine model is currently used to generate all the state transition paths of the stateful network protocols, and then fuzz testing is performed on each state transition path. The monitor is responsible for monitoring whether the network traffic and process status are abnormal. The test cases are generated based on the original data samples and the finite state machine model, which can cover all the protocol states of the stateful network protocols.

[0004] However, in the above method, the generation of test cases mainly depends on the original sample data and the finite state machine model, and the generation method is simple, which leads to low quality of the generated test cases. Summary of the invention

[0005] The present application provides a fuzz testing method, device and computer storage medium for a stateful network protocol, which can improve the efficiency of fuzz testing. The technical solution is as follows:

[0006] In a first aspect, a fuzz testing method for a stateful network protocol is provided, which is applied to a fuzz tester.

[0007] In the method, a test case for fuzz testing a first protocol state of a stateful network protocol is generated, and program execution information corresponding to the first protocol state is determined; the test case is sent to the target program to perform fuzz testing on the first protocol state, and the target program uses the stateful network protocol; the program execution information is sent to a monitor, and the monitor determines the quality score of the test case based on the program execution information and the execution path of the target program; when the quality score sent by the monitor is received, if the quality score is greater than or equal to a score threshold, a new test case for fuzz testing the first protocol state is generated based on the test case.

[0008] In the present application, when the fuzz tester receives the quality score sent by the monitor, if the quality score is greater than or equal to the score threshold, it means that the quality of the test case is good. Then, a new test case for fuzz testing the first protocol state is generated based on the test case. At this time, the quality of the new test case is also good, thereby improving the efficiency of fuzz testing.

[0009] Optionally, the method further comprises: constructing a Petri net model according to the description information of the stateful network protocol, wherein the Petri net model is used to describe the protocol state, the migration relationship, and the program execution information corresponding to the protocol state. Accordingly, determining the program execution information corresponding to the first protocol state comprises: obtaining the program execution information corresponding to the first protocol state from the Petri net model.

[0010] In the embodiment of the present application, a Petri net model is constructed to accurately obtain the program execution information corresponding to the first protocol state through the Petri net model, so that the actual execution effect of the test case can be accurately determined subsequently, that is, the quality of the test case can be determined.

[0011] Optionally, the method further includes: if the fuzzy test on the first protocol state meets a preset condition, determining a protocol state among the protocol states adjacent to and reachable from the first protocol state as a second protocol state through the Petri net model; and performing a fuzzy test on the second protocol state.

[0012] It should be noted that there may be one or more protocol states that are adjacent to the first protocol state. In this case, when there is only one protocol state that is adjacent to the first protocol state, this one can be directly used as the second protocol state. When there are multiple protocol states that are adjacent to the first protocol state, one of the multiple protocol states can be selected as the second protocol state.

[0013] In addition, preset conditions can be set in advance, and the preset conditions include at least one of the following three items: no new path is triggered within a preset time period; the coverage rate of the program code of the target program reaches a preset ratio; the number of test cases executed reaches a preset number.

[0014] In the present application, when the fuzzy test on the first protocol state meets the preset conditions, it indicates that the fuzzy test on the first protocol state is relatively sufficient, so the fuzzy test on the second protocol state can be continued.

[0015] Optionally, the quality score of the test case is determined by the monitor based on the detection results after detecting whether the test case reaches an adjacent reachable protocol state, triggers a new path, and triggers a program exception based on the program execution information and the execution path of the target program.

[0016] In a second aspect, a fuzzy testing device for a stateful network protocol is provided, and the fuzzy testing device for a stateful network protocol has the function of implementing the behavior of the fuzzy testing method for a stateful network protocol in the first aspect. The fuzzy testing device for a stateful network protocol includes at least one module, and the at least one module is used to implement the fuzzy testing method for a stateful network protocol provided in the first aspect.

[0017] In a third aspect, a fuzzy testing device for a stateful network protocol is provided, wherein the structure of the fuzzy testing device for a stateful network protocol includes a processor and a memory, wherein the memory is used to store a program that supports the fuzzy testing device for a stateful network protocol to execute the fuzzy testing method for a stateful network protocol provided in the first aspect, and to store data involved in implementing the fuzzy testing method for a stateful network protocol described in the first aspect. The processor is configured to execute the program stored in the memory. The fuzzy testing device for a stateful network protocol may also include a communication bus, which is used to establish a connection between the processor and the memory.

[0018] In a fourth aspect, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is run on a computer, the computer executes the fuzz testing method for the stateful network protocol described in the first aspect.

[0019] In a fifth aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute the fuzz testing method for a stateful network protocol as described in the first aspect.

[0020] The technical effects obtained by the above-mentioned second, third, fourth and fifth aspects are similar to the technical effects obtained by the corresponding technical means in the above-mentioned first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 is a schematic diagram of a test system provided in an embodiment of the present application;

[0022] Figure 2 It is a flow chart of a fuzzy testing method for a stateful network protocol provided in an embodiment of the present application;

[0023] Figure 3 is a schematic diagram of a stateful network protocol provided in an embodiment of the present application;

[0024] Figure 4 is a schematic diagram of a Petri net model provided in an embodiment of the present application;

[0025] Figure 5 It is a structural schematic diagram of a fuzzy testing device for a stateful network protocol provided in an embodiment of the present application;

[0026] Figure 6 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0027] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.

[0028] Before explaining the embodiments of the present application in detail, the application scenarios of the embodiments of the present application are first described.

[0029] Figure 1 is a schematic diagram of a test system provided in an embodiment of the present application. Figure 1 The test system includes a fuzz tester 101 and a tested machine 102. The fuzz tester 101 includes a testing part 1011 and an auxiliary part 1012. The tested machine 102 includes a target program 1021 and a monitor 1022.

[0030] The test part 1011 is used for generating test cases and session management. The generation of test cases can be obtained by mutating the protocol message, or by combining multiple test cases using a genetic algorithm. Session management is responsible for managing which protocol state is fuzzy tested. The auxiliary part 1012 is used to send test cases to the target program 1021. Specifically, the auxiliary part 1012 includes a controller 10121 and a driver module 10122. The controller 10121 is used to process the test case into a message that can be transmitted to the tested machine 102, and the driver module 10122 is used to send the message processed by the controller 10121 to the target program 1021 in the tested machine 102. The monitor 1022 is responsible for monitoring and controlling the running state of the target program 1021.

[0031] Figure 2 is a flow chart of a fuzzy testing method for a stateful network protocol provided by an embodiment of the present application. Figure 2 , the method comprising:

[0032] Step 201: The fuzz tester generates a test case for fuzz testing a first protocol state of a stateful network protocol, and determines program execution information corresponding to the first protocol state.

[0033] It should be noted that a network protocol refers to a set of rules that must be followed when exchanging information between peer entities communicating with each other in a computer network. A stateful network protocol refers to a protocol whose protocol state is related to the previous request. That is, after receiving a request from a client, the server will return a corresponding response, and the response to the next request will be affected by this request. A request can only get a correct response when the server is in a specific protocol state.

[0034] In addition, the program execution information corresponding to a certain protocol state refers to the relevant information of the program code that can be executed in this protocol state, such as program execution function, program execution address, etc. Moreover, after executing the program code indicated by the corresponding program execution information in a certain protocol state, the protocol state adjacent to this protocol state can be reached. The protocol state adjacent to a certain protocol state refers to the next protocol state that can be directly reached through the corresponding interaction information when in this protocol state.

[0035] For example, the program execution information corresponding to the first protocol state refers to the relevant information of the program code that can be executed in the first protocol state. After executing the program code indicated by the corresponding program execution information in the first protocol state, the protocol state adjacent to the first protocol state can be reached.

[0036] When the fuzz tester generates a test case for fuzz testing a first protocol state of a stateful network protocol, the protocol message in the first protocol state may be mutated to obtain a test case for fuzz testing the first protocol state; or, an old test case previously used for fuzz testing the first protocol state may be modified to obtain the test case to be used this time. Of course, a test case for fuzz testing the first protocol state may also be generated in other ways, which is not limited in the embodiments of the present application.

[0037] When the fuzz tester determines the program execution information corresponding to the first protocol state, the program execution information corresponding to the first protocol state can be obtained from the Petri net model.

[0038] It should be noted that the Petri net model can be constructed by the fuzz tester according to the description information of the stateful network protocol. The Petri net model is used to describe the protocol state, migration relationship and program execution information corresponding to the protocol state.

[0039] In addition, the Petri net model includes a place set, a transition set and a flow relationship. In the present application, the place set includes multiple places, each place indicates a protocol state; the transition set includes multiple transitions, each transition indicates a program execution information; a place has a flow relationship with a transition, which means that the protocol state indicated by this place corresponds to the program execution information indicated by this transition; a place has a flow relationship with a transition, and this transition has a flow relationship with another place, which means that the protocol state indicated by this place has a migration relationship with the protocol state indicated by another place, that is, the protocol state adjacent to the protocol state indicated by this place is the protocol state indicated by another place.

[0040] Among them, when the fuzz tester constructs the Petri net model according to the description information of the stateful network protocol, it can determine all protocol states in the stateful network protocol and the migration relationship between each protocol state according to the description information of the stateful network protocol, and determine the relevant information of the program code that can be executed in each protocol state as the corresponding program execution information, and then use the protocol state as the library place and the program execution information as the transition, and construct the flow relationship between the library place and the transition according to the migration relationship and the corresponding relationship between the protocol state and the program execution information to obtain the Petri net model.

[0041] For example, in Figure 3 In the stateful network protocol shown, it can be determined that there are five protocol states in the stateful network protocol: protocol state 1: receive request 1 and return response 1; protocol state 2: receive request 2 and return response 2; protocol state 3: receive request 3 and return response 3 and message 1; protocol state 4: receive message 2 and return message 3; protocol state 5: receive message 4. And, the migration relationship of these five protocol states is from protocol state 1 to protocol state 5 in sequence. At this time, the program execution information corresponding to each of the five protocol states can be obtained to obtain five program execution information. Afterwards, take protocol state 1 to protocol state 5 as library place 0 to library place 4, and take these five program execution information as transition 0 to transition 4. According to the migration relationship and correspondence between these five protocol states and these five program execution information, the flow relationship between library places and transitions is constructed, and the following is obtained. Figure 4 The Petri net model shown.

[0042] Step 202: The fuzz tester sends the test case to the target program to perform fuzz testing on the first protocol state.

[0043] It should be noted that the target program uses the stateful network protocol. After the target program receives the test case, it triggers the running of the target program, specifically triggering the execution of the corresponding program code in the target program. In this way, during the running of the target program, it is possible to monitor whether an exception occurs, thereby realizing the fuzzy test of the first protocol state.

[0044] Step 203: The fuzz tester sends the program execution information corresponding to the first protocol state to the monitor.

[0045] It should be noted that the monitor can monitor the operation of the target program. That is, after the target program receives the test case sent by the fuzz tester, the monitor can monitor the execution path of the target program, which is the program code executed by the target program.

[0046] Step 204: When the monitor receives the program execution information corresponding to the first protocol state sent by the fuzz tester, the quality score of the test case is determined according to the program execution information and the execution path of the target program.

[0047] It should be noted that the quality score of the test case can reflect the quality of the test case. That is, the higher the quality score of the test case, the better the quality of the test case, which means that the test case can more effectively cause errors in the target program, that is, it can more easily cause failures. In this way, using high-quality test cases can greatly improve test efficiency.

[0048] In an embodiment of the present application, the monitor can accurately evaluate the quality of the test case based on the program execution information that should be triggered in the first protocol state and the actual execution path of the target program to obtain the quality score of the test case.

[0049] Specifically, the monitor can detect whether the test case reaches the adjacent reachable protocol state, whether a new path is triggered, and whether a program exception is triggered based on the program execution information and the execution path of the target program, and determine the quality score of the test case based on the detection results.

[0050] It should be noted that the monitor can determine that the test case reaches an adjacent reachable protocol state when the execution path of the target program includes the program indication information. When the execution path of the target program includes a path that has not appeared in the previous fuzzy test of the first protocol state, it is determined that the test case triggers a new path. When the execution path of the target program is abnormal, it is determined that the test case triggers a program abnormality.

[0051] In addition, when determining the quality score of the test case according to the test result, a correspondence between the test result and the quality score may be preset, and then the quality score corresponding to the test result is obtained from the correspondence as the quality score of the test case.

[0052] In one possible approach, the monitor may first detect whether the test case reaches an adjacent reachable protocol state based on the program execution information and the execution path of the target program; if the test case reaches an adjacent reachable protocol state, the quality score of the test case may be directly determined to be a first score; if the test case does not reach an adjacent reachable protocol state, it may be determined whether the test case triggers a new path; if the test case triggers a new path, the test case continues to be monitored to determine whether it triggers a program exception; if the test case does not trigger a program exception, the quality score of the test case may be determined to be a second score; if the test case triggers a program exception, the quality score of the test case may be determined to be a third score.

[0053] It should be noted that the first score, the second score, and the third score can all be set in advance, and the first score is less than the second score, and the second score is less than the third score. In other words, the quality of the test case that does not reach the adjacent reachable protocol state but triggers a new path and triggers a program exception is the best; the quality of the test case that does not reach the adjacent reachable protocol state but triggers a new path but does not trigger a program exception is the second best; the quality of the test case that reaches the adjacent reachable protocol state is the worst. For example, the first score can be 1 point, the second score can be 3 points, and the third score can be 5 points.

[0054] Step 203: The monitor sends the quality score of the test case to the fuzz tester.

[0055] Step 204: When the fuzz tester receives the quality score of the test case sent by the monitor, if the quality score of the test case is greater than or equal to the score threshold, a new test case for fuzz testing the first protocol state is generated according to the test case.

[0056] It should be noted that the score threshold can be set in advance, and the score threshold can be set larger. For example, when the first score is 1 point, the second score is 3 points, and the third score is 5 points, the score threshold can be set to 3 points.

[0057] If the quality score of the test case is greater than or equal to the score threshold, it means that the quality of the test case is good, and thus the quality of the new test case generated according to the test case for fuzz testing the first protocol state is also good. In addition, as the number of test cases increases, the quality of the test cases will continue to improve, thereby greatly improving the overall quality of the test cases and the efficiency of the fuzz test.

[0058] When a new test case for performing a fuzzy test on the first protocol state is generated according to the test case, the test case can be modified to obtain a new test case for performing a fuzzy test on the first protocol state.

[0059] It should be noted that when modifying the test case, the test case can be modified directly. It is also possible to obtain a new test case for fuzzy testing the first protocol state through a genetic algorithm based on the test case and other test cases for fuzzy testing the first protocol state and having a quality score greater than a score threshold.

[0060] It is worth noting that after obtaining the new test case, the process may return to step 202 to continue to perform fuzzy testing on the first protocol state using the new test case.

[0061] Furthermore, when the fuzzy test on the first protocol state meets the preset conditions, the fuzz tester can determine a protocol state among the protocol states adjacent to and reachable from the first protocol state as the second protocol state through the above Petri net model, and then perform fuzzy testing on the second protocol state.

[0062] It should be noted that there may be one or more protocol states that are adjacent to the first protocol state. In this case, when there is only one protocol state that is adjacent to the first protocol state, this one can be directly used as the second protocol state. When there are multiple protocol states that are adjacent to the first protocol state, one of the multiple protocol states can be selected as the second protocol state.

[0063] In addition, the method of performing fuzzy testing on the second protocol state is similar to the method of performing fuzzy testing on the first protocol state in the present application, and the embodiments of the present application will not be repeated here.

[0064] Furthermore, the preset condition can be set in advance. When the fuzzy test on the first protocol state meets the preset condition, it indicates that the fuzzy test on the first protocol state is relatively sufficient, so the fuzzy test on the second protocol state can continue.

[0065] For example, the preset conditions may include at least one of the following three items: no new path is triggered within a preset time period; the coverage rate of the program code of the target program reaches a preset ratio; the number of executed test cases reaches a preset number.

[0066] It should be noted that the preset duration can be set in advance, and the preset duration can be set larger, such as the preset duration can be 24 hours. The preset ratio can also be set in advance, and the preset ratio can be set larger, such as the preset ratio can be 80%. The preset number can also be set in advance, and the preset number can be set larger, such as the preset number can be 100,000.

[0067] In addition, the triggering of new paths within the preset time, the coverage of the program code of the target program, and the number of test cases executed can all be counted by the monitor and returned to the fuzz tester.

[0068] In an embodiment of the present application, a test case for fuzz testing a first protocol state of a stateful network protocol is generated, and after determining the program execution information corresponding to the first protocol state, the test case is sent to the target program to perform a fuzz test on the first protocol state. Afterwards, the fuzz tester sends the program execution information to the monitor, and the monitor determines the quality score of the test case based on the program execution information and the execution path of the target program and sends it to the fuzz tester. When the fuzz tester receives the quality score sent by the monitor, if the quality score is greater than or equal to the score threshold, indicating that the quality of the test case is good, a new test case for fuzz testing the first protocol state is generated based on the test case, and the quality of the new test case is also good at this time, thereby improving the efficiency of fuzz testing.

[0069] Figure 5 Schematic diagram of the structure of a fuzzy testing device for a stateful network protocol provided in an embodiment of the present application. Figure 5 As shown, the device 500 includes:

[0070] A generating module 501, for generating a test case for performing a fuzzy test on a first protocol state of a stateful network protocol, and determining program execution information corresponding to the first protocol state;

[0071] A sending module 502, for sending a test case to a target program to perform a fuzzy test on a first protocol state, the target program using a stateful network protocol;

[0072] The sending module 502 is further used to send the program execution information to the monitor, and the monitor determines the quality score of the test case according to the program execution information and the execution path of the target program;

[0073] The generating module 501 is further configured to generate a new test case for performing fuzzy testing on the first protocol state according to the test case when receiving the quality score sent by the monitor if the quality score is greater than or equal to the score threshold.

[0074] Optionally, the device 500 further includes:

[0075] A construction module, used to construct a Petri net model according to the description information of the stateful network protocol, wherein the Petri net model is used to describe the protocol state, the migration relationship and the program execution information corresponding to the protocol state;

[0076] Generate modules for:

[0077] The program execution information corresponding to the first protocol state is obtained from the Petri net model.

[0078] Optionally, the device 500 further includes:

[0079] A determination module, configured to determine, through a Petri net model, a protocol state among the protocol states adjacent to and reachable from the first protocol state as a second protocol state if a fuzzy test on the first protocol state satisfies a preset condition;

[0080] The testing module is used to perform fuzz testing on the second protocol state.

[0081] Optionally, the preset condition includes at least one of the following three items:

[0082] No new path is triggered within the preset time;

[0083] The coverage rate of the program code of the target program reaches a preset ratio;

[0084] The number of test cases executed reaches the preset number.

[0085] Optionally, the quality score of the test case is determined by the monitor based on the program execution information and the execution path of the target program, after detecting whether the test case reaches an adjacent reachable protocol state, triggers a new path, and triggers a program exception.

[0086] In an embodiment of the present application, a test case for fuzz testing a first protocol state of a stateful network protocol is generated, and after determining the program execution information corresponding to the first protocol state, the test case is sent to the target program to perform a fuzz test on the first protocol state. Afterwards, the fuzz tester sends the program execution information to the monitor, and the monitor determines the quality score of the test case based on the program execution information and the execution path of the target program and sends it to the fuzz tester. When the fuzz tester receives the quality score sent by the monitor, if the quality score is greater than or equal to the score threshold, indicating that the quality of the test case is good, a new test case for fuzz testing the first protocol state is generated based on the test case, and the quality of the new test case is also good at this time, thereby improving the efficiency of fuzz testing.

[0087] It should be noted that: the fuzzy testing device for stateful network protocols provided in the above embodiment only uses the division of the above functional modules as an example when performing fuzzy testing of stateful network protocols. In actual applications, the above functional distribution can be completed by different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the fuzzy testing device for stateful network protocols provided in the above embodiment and the fuzzy testing method embodiment of stateful network protocols belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0088] Figure 6 is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. Figure 6 The computer device includes at least one processor 601 , a communication bus 602 , a memory 603 and at least one communication interface 604 .

[0089] The processor 601 may be a microprocessor (including a central processing unit (CPU), etc.), an application-specific integrated circuit (ASIC), or may be one or more integrated circuits for controlling the execution of the program of the present application.

[0090] Communication bus 602 may include a pathway for transmitting information between the above-mentioned components.

[0091] The memory 603 may be a read-only memory (ROM), a random access memory (RAM), an electrically erasable programmable read-only memory (EEPROM), an optical disc (including a compact disc read-only memory (CD-ROM), a compressed optical disc, a laser disc, a digital versatile disc, a Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 603 may exist independently and be connected to the processor 601 via the communication bus 602. The memory 603 may also be integrated with the processor 601.

[0092] The communication interface 604 uses any transceiver or other device for communicating with other devices or communication networks, such as Ethernet, radio access network (RAN), wireless local area network (WLAN), etc.

[0093] In a specific implementation, as an embodiment, the processor 601 may include one or more CPUs, such as Figure 6 CPU0 and CPU1 are shown in the figure.

[0094] In a specific implementation, as an embodiment, a computer device may include multiple processors, such as Figure 6 601 and processor 605 shown in FIG. Each of these processors may be a single-core processor or a multi-core processor. A processor herein may refer to one or more devices, circuits, and / or processing cores for processing data (such as computer program instructions).

[0095] In a specific implementation, as an embodiment, the computer device may further include an output device 606 and an input device 607. The output device 606 communicates with the processor 601 and may display information in a variety of ways. For example, the output device 606 may be a liquid crystal display (LCD), a light emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector. The input device 607 communicates with the processor 601 and may receive user input in a variety of ways. For example, the input device 607 may be a mouse, a keyboard, a touch screen device, or a sensor device.

[0096] The above-mentioned computer device can be a general-purpose computer device or a special-purpose computer device. In a specific implementation, the computer device can be a desktop computer, a portable computer, a network server, a handheld computer, a mobile phone, a tablet computer, a wireless terminal device, a communication device or an embedded device. The embodiment of the present application does not limit the type of computer device.

[0097] The memory 603 is used to store the program code 610 for executing the solution of the present application, and the processor 601 is used to execute the program code 610 stored in the memory 603. The computer device can implement the above by the processor 601 and the program code 610 in the memory 603. Figure 2 An embodiment provides a fuzz testing method for a stateful network protocol.

[0098] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (for example: coaxial cable, optical fiber, data subscriber line (Digital Subscriber Line, DSL)) or wireless (for example: infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access, or a data storage device such as a server or data center that includes one or more available media integrations. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a digital versatile disc (DVD)), or a semiconductor medium (eg, a solid state disk (SSD)).

[0099] The above-mentioned embodiments are provided for the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A fuzz testing method for a stateful network protocol, characterized in that: Applied to a fuzz tester, the method comprises: Generating a test case for fuzz testing a first protocol state of a stateful network protocol, and determining program execution information corresponding to the first protocol state; Sending a test case to a target program to perform fuzz testing on the first protocol state, the target program using the stateful network protocol; Sending the program execution information to a monitor, wherein the monitor determines the quality score of the test case according to the program execution information and the execution path of the target program; When the quality score sent by the monitor is received, if the quality score is greater than or equal to a score threshold, a new test case for performing fuzz testing on the first protocol state is generated according to the test case.

2. The method according to claim 1, characterized in that The method further comprises: Constructing a Petri net model according to the description information of the stateful network protocol, wherein the Petri net model is used to describe the protocol state, migration relationship, and program execution information corresponding to the protocol state; The determining the program execution information corresponding to the first protocol state includes: The program execution information corresponding to the first protocol state is obtained from the Petri net model.

3. The method according to claim 2, characterized in that The method further comprises: If the fuzzy test on the first protocol state meets a preset condition, determining a protocol state among the protocol states adjacent to and reachable from the first protocol state as a second protocol state through the Petri net model; The second protocol state is subjected to fuzz testing.

4. The method according to claim 3, characterized in that The preset condition includes at least one of the following three items: No new path is triggered within the preset time; The coverage rate of the program code of the target program reaches a preset ratio; The number of test cases executed reaches the preset number.

5. The method according to any one of claims 1 to 4, characterized in that: The quality score of the test case is determined by the monitor based on the program execution information and the execution path of the target program, after detecting whether the test case reaches the adjacent reachable protocol state, whether a new path is triggered, and whether a program exception is triggered.

6. A fuzzy testing device for a stateful network protocol, characterized in that: The device comprises: A generating module, configured to generate a test case for fuzz testing a first protocol state of a stateful network protocol, and to determine program execution information corresponding to the first protocol state; A sending module, used for sending a test case to a target program to perform a fuzzy test on the first protocol state, wherein the target program uses the stateful network protocol; The sending module is further used to send the program execution information to a monitor, and the monitor determines the quality score of the test case according to the program execution information and the execution path of the target program; The generating module is further configured to generate, when receiving the quality score sent by the monitor, a new test case for performing fuzz testing on the first protocol state according to the test case if the quality score is greater than or equal to a score threshold.

7. The device according to claim 6, characterized in that The device also includes: A construction module, used to construct a Petri net model according to the description information of the stateful network protocol, wherein the Petri net model is used to describe the protocol state, migration relationship and program execution information corresponding to the protocol state; The generation module is used for: The program execution information corresponding to the first protocol state is obtained from the Petri net model.

8. The device according to claim 7, characterized in that The device also includes: A determination module, configured to determine, through the Petri net model, a protocol state among the protocol states adjacent to and reachable from the first protocol state as a second protocol state if a fuzzy test on the first protocol state satisfies a preset condition; A testing module is used to perform a fuzzy test on the second protocol state.

9. The device according to claim 8, characterized in that The preset condition includes at least one of the following three items: No new path is triggered within the preset time; The coverage rate of the program code of the target program reaches a preset ratio; The number of test cases executed reaches the preset number.

10. The device according to any one of claims 6 to 9, characterized in that: The quality score of the test case is determined by the monitor based on the program execution information and the execution path of the target program, after detecting whether the test case reaches the adjacent reachable protocol state, whether a new path is triggered, and whether a program exception is triggered.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the method according to any one of claims 1 to 5.

12. A computer program product comprising instructions, characterized in that When the method is executed on a computer, the computer is enabled to execute the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method for realizing fuzzing of software on the basis of state protocol

    CN102087631A

  • Fuzz testing system for stateful network protocol

    CN104796240A

  • Parallel fuzzy test scheduling method and device based on variation strategies

    CN110147310A