Black-box fuzz testing method, device and computer-readable storage medium

By obtaining test case models and generating test case messages, the problem of low effectiveness of traditional black box fuzz testing is solved, test coverage and efficiency are improved, and more efficient equipment and protocol testing is achieved.

WO2024199050A1PCT designated stage expired Publication Date: 2024-10-03ZTE CORP

Patent Information

Application Number
PCT/CN2024/082784
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-03-29
Filing Date
2024-03-20
Publication Date
2024-10-03

AI Technical Summary

Technical Problem

Traditional black-box fuzz testing solutions have low effectiveness when generating test case messages and cannot effectively utilize the internal structure and characteristics of device programs, resulting in insufficient testing efficiency and coverage.

Method used

By obtaining the test case model, including the mutable field characteristics of the protocol fields, generating test case messages and executing test tasks, the effectiveness of the test cases is improved.

Benefits of technology

Improved the effectiveness of test case messages for black box fuzz testing, enhanced test coverage of devices and protocols, and improved testing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024082784_03102024_PF_FP_ABST
    Figure CN2024082784_03102024_PF_FP_ABST
Patent Text Reader

Abstract

Disclosed in the present application are a black-box fuzz testing method and apparatus, and a device and a computer-readable storage medium. The method comprises: acquiring a test case model, wherein the test case model comprises field features of variable fields among protocol fields in a message, which requires to be sent in a test task; generating a test case message according to the test case model, wherein a field value of at least one variable field in the test case message is generated according to a preset variation policy corresponding to the field features of the variable fields; and executing the test task by using the test case message.
Need to check novelty before this filing date? Find Prior Art

Description

Black box fuzz testing method, device and computer-readable storage medium

[0001] Related applications

[0002] This application claims priority to Chinese patent application No. 202310335835.1 filed on March 29, 2023, the entire contents of which are incorporated by reference into this application. Technical Field

[0003] The present application relates to the field of computer testing technology, and in particular to a black box fuzz testing method, device, and computer-readable storage medium. Background Art

[0004] With the rapid development of IoT smart devices and mobile terminal technologies, security testing of related devices and protocols has become increasingly important. Fuzz testing, due to its high efficiency and exploratory nature, has been recognized as the most effective testing tool in the software testing field over the years.

[0005] In the field of black-box fuzz testing, generating efficient test cases is particularly important because the internal structure and characteristics of device programs are not known by default. Traditional black-box fuzz testing solutions generate test data by randomly changing existing data samples. However, the test case messages generated in this field are extremely ineffective.

[0006] Summary of the Invention

[0007] The main purpose of this application is to provide a black box fuzz testing method, device and computer-readable storage medium, aiming to provide a black box fuzz testing solution, which improves the effectiveness of the test case messages of the black box fuzz testing by generating test case messages based on the test case model for testing.

[0008] To achieve the above objectives, the present application provides a black box fuzz testing method, which includes the following steps:

[0009] Acquire a test case model, wherein the test case model includes field characteristics of mutable fields in each protocol field in a message to be sent in the test task;

[0010] Generating a test case message according to the test case model, wherein a field value of at least one of the mutable fields in the test case message is generated according to a preset mutation strategy corresponding to a field feature of the mutable field;

[0011] The test task is executed using the test case message.

[0012] To achieve the above-mentioned objectives, the present application also provides a black box fuzz testing device, which includes: a memory, a processor, and a black box fuzz testing program stored on the memory and executable on the processor. When the black box fuzz testing program is executed by the processor, the steps of the black box fuzz testing method described above are implemented.

[0013] In addition, to achieve the above objectives, the present application also proposes a computer-readable storage medium, on which a black box fuzz testing program is stored. When the black box fuzz testing program is executed by a processor, the steps of the black box fuzz testing method described above are implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] FIG1 is a schematic diagram of the structure of the hardware operating environment involved in the embodiment of the present application;

[0015] FIG2 is a flowchart of a first embodiment of the black box fuzz testing method of the present application;

[0016] FIG3 is a schematic diagram of a black box module testing system architecture according to an embodiment of the present application;

[0017] FIG4 is a flow chart of a black box module testing method according to an embodiment of the present application.

[0018] The realization of the objectives, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0019] It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application.

[0020] As shown in FIG1 , FIG1 is a schematic diagram of the device structure of the hardware operating environment involved in the embodiment of the present application.

[0021] The black box fuzz testing device of the embodiment of the present application can be a smart phone, a personal computer, a server and other devices, without specific limitation here.

[0022] As shown in Figure 1, the black box fuzz testing device may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0023] Those skilled in the art will understand that the device structure shown in FIG1 does not constitute a limitation on the black box fuzz testing device, and may include more or fewer components than shown in the figure, or a combination of certain components, or a different arrangement of components.

[0024] As shown in FIG1 , memory 1005 , a computer storage medium, may include an operating system, a network communication module, a user interface module, and a black-box fuzz testing program. The operating system is a program that manages and controls the hardware and software resources of a device and supports the execution of the black-box fuzz testing program and other software or programs. In the device shown in FIG1 , user interface 1003 is primarily used for data communication with a client; network interface 1004 is primarily used for establishing a communication connection with a server; and processor 1001 may be used to invoke the black-box fuzz testing program stored in memory 1005 and perform the following operations:

[0025] Acquire a test case model, wherein the test case model includes field characteristics of mutable fields in each protocol field in a message to be sent in the test task;

[0026] Generating a test case message according to the test case model, wherein a field value of at least one of the mutable fields in the test case message is generated according to a preset mutation strategy corresponding to a field feature of the mutable field;

[0027] The test task is executed using the test case message.

[0028] In one feasible implementation, the operation of obtaining the test case model includes:

[0029] Get sample messages;

[0030] A test case model is generated according to the field information of each protocol field in the sample message, wherein the test case model includes field features of the variable fields in each protocol field in the sample message.

[0031] In one feasible implementation, the operation of generating a test case model according to the field information of each protocol field in the sample message includes:

[0032] Matching the field information of the protocol field in the sample message with preset information, and obtaining a variation of the protocol field according to the matching result, wherein the matching result indicates whether the preset information exists in the field information of the protocol field, and the variation indicates whether the protocol field is variable;

[0033] extracting a field feature of the protocol field from the field information of the protocol field;

[0034] The test case model is generated according to the variation of each protocol field and the field characteristics.

[0035] In one feasible implementation, the operation of generating a test case model according to the field information of each protocol field in the sample message includes:

[0036] According to the protocol to be tested corresponding to the test task, an analysis strategy corresponding to the protocol to be tested is selected from the analysis strategies corresponding to various preset communication protocols to analyze the field information of each protocol field in the sample message, and a test case model is obtained according to the analysis results.

[0037] In one feasible implementation, the operation of generating a test case model according to the field information of each protocol field in the sample message includes:

[0038] The relationship between the protocol fields in the sample message is parsed. If the parsing shows that there are parent protocol fields and child protocol fields between the protocol fields, a test case model is generated according to the field information of the child protocol fields.

[0039] In one feasible implementation, the test case model further includes a default value for each of the protocol fields, where the default value for the protocol field is a default field value for the protocol field. The operation of generating a test case message according to the test case model includes:

[0040] Generate a default message according to the default value of each protocol field in the test case model;

[0041] For at least one of the mutable fields, generating a mutation value of the mutable field according to a preset mutation strategy corresponding to the field characteristics of the mutable field;

[0042] The default value of the mutable field in the default message is replaced by the mutated value of the mutable field, and a test case message is obtained according to the default message after the default value is replaced.

[0043] In one feasible implementation, the test case model further includes association information of associated fields in each of the protocol fields, the association information including the protocol field and association type associated with the associated field. The operation of obtaining a test case message based on the default message after replacing the default value includes:

[0044] According to the association algorithm corresponding to the association type of the association field, the generated value of the association field is calculated based on the mutated value replacement message, wherein the mutated value replacement message is a default message after replacing the default value;

[0045] The generated value of the associated field is used to replace the mutated value to replace the field value of the associated field in the message, so as to obtain a test case message.

[0046] In one feasible implementation, the field characteristics include a field type and a field length, and the operation of generating a mutation value of the mutable field according to a preset mutation strategy corresponding to the field characteristics of the mutable field includes:

[0047] For the variable field whose field type is an integer field or a long bit field, generating a mutation value of the variable field according to a preset mutation strategy corresponding to the field length of the variable field;

[0048] For the variable field whose field type is a string field, inserting preset characters into the default value of the variable field to obtain a variable value of the variable field;

[0049] For the variable field whose field type is a universal field, the selectable values ​​of each bit of the variable field are arranged and combined to obtain multiple variable values ​​of the variable field.

[0050] In one feasible implementation, the operation of generating the default value in the test case model includes:

[0051] Determining a configuration field in each of the protocol fields according to field information of each of the protocol fields;

[0052] Obtaining a configuration value of the configuration field, and using the configuration value as a default value corresponding to the configuration field in the test case model;

[0053] For the remaining fields in each of the protocol fields except the configuration field, the field values ​​of the remaining fields in the sample message are extracted as the default values ​​corresponding to the remaining fields in the test case model.

[0054] In one feasible implementation, after the operation of generating a test case message according to the test case model, the processor 1001 may be configured to call a black box fuzz testing program stored in the memory 1005 and perform the following operations:

[0055] The test case message generated according to the test case model is used as a mutation corpus, and a mutation operation is performed on the mutation corpus to obtain a new test case message.

[0056] In one feasible implementation, the operation of executing the test task using the test case message includes:

[0057] Sending the test case message to the device under test;

[0058] Recording the response of the device under test to the test case message in a log;

[0059] The log is output in response to a log viewing request.

[0060] In one feasible implementation, the test task includes multiple test phases, and the operation of obtaining the sample message includes:

[0061] Receive sample messages of any target test phase uploaded by users;

[0062] The operation of using the test case message to execute the test task includes:

[0063] Execute each test phase in the order of each test phase, wherein, when executing the target test phase, the test case message generated based on the test case model is sent to the device under test, and when executing a test phase other than the target test phase, a message generated based on a preset default model corresponding to the test phase is sent to the device under test.

[0064] In one feasible implementation, the processor 1001 may be configured to call the black box fuzz testing program stored in the memory 1005 and perform the following operations:

[0065] Obtaining the current test status of the test task, where the current test status includes the current test progress of each test phase in the test task;

[0066] The current test status is visually output.

[0067] Based on the above structure, various embodiments of the black box fuzz testing method are proposed.

[0068] Refer to Figure 2, which is a flow chart of the first embodiment of the black box fuzz testing method of the present application. The embodiment of the present application provides an embodiment of the black box fuzz testing method. It should be noted that although the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in an order different from that here. The execution subject of the black box fuzz testing method of the present application can be a personal computer, server and other devices, which is not limited in this embodiment. For the sake of convenience of description, the execution subject is omitted to explain each embodiment. In this embodiment, the black box fuzz testing method includes:

[0069] Step S10: Acquire a test case model, wherein the test case model includes field characteristics of variable fields in each protocol field in a message to be sent in the test task;

[0070] The test task can be a task of testing a certain communication protocol, or it can be a task of testing a certain function of a device (hereinafter referred to as the device under test) that uses a certain communication protocol to communicate. The device under test can be a smart device such as a smartphone, an Internet of Things terminal device, etc., and is not limited in this embodiment. In this embodiment, there is no restriction on the setting of the test task. The black box fuzzy testing method in this embodiment can be applied to any structured protocol and supports the testing of communication protocols at layers above the link layer. For example, it can be applied to communication protocols such as IEEE 802.11 (IEEE 802.11 is a common standard for wireless local area networks today. It is a standard for wireless network communication defined by the Institute of Electrical and Electronics Engineers (IEEE)), Bluetooth, NFC (Near Field Communication), etc. For example, in a feasible implementation, the test task can be a task of testing the authentication link in the access process of the IEEE 802.11 protocol.

[0071] A message refers to a communication protocol message. A test task requires sending a message to the device under test. In this embodiment, for any type of message, a test case model corresponding to that type of message can be obtained. This test case model includes the field characteristics of the mutable fields in each protocol field within that type of message. The field characteristics of the mutable fields can be features used to distinguish the mutation strategy for the mutable fields. A mutable field refers to a field in a message that can be mutated.

[0072] In this embodiment, there is no restriction on the method of obtaining the test case model. For example, it can be uploaded by the user, or the test case model uploaded by the user can be saved locally in advance and obtained locally when needed. For example, the test case model can be generated based on a sample message.

[0073] Step S20: generating a test case message according to the test case model, wherein the field value of at least one of the mutable fields in the test case message is generated according to a preset mutation strategy corresponding to the field characteristics of the mutable field;

[0074] After obtaining the test case model, a test case message can be generated based on the test case model. In the test case message generated based on the test case model, the field value of at least one mutable field may be generated according to a preset mutation strategy corresponding to the field characteristics of the mutable field. In a specific embodiment, in addition to the protocol fields in the test case message whose field values ​​are generated according to the mutation strategy, the field values ​​of other protocol fields may adopt the field values ​​of the corresponding protocol fields in the sample message, or may adopt pre-set default values. In one feasible embodiment, the test case model may include default values ​​for each protocol field. If no mutation is performed on the protocol field, the default value of the protocol field may be used as the field value of the protocol field in the test case message. The test case model may have one or more mutable fields. If there are multiple mutable fields, depending on the specific embodiment, mutated values ​​may be generated for one or more of the mutable fields according to a corresponding mutation strategy, either specified or randomly. In the specified case, each mutable field may be displayed in a visual interface for user selection. In a test case message, the field value of at least one protocol field is generated according to a corresponding mutation strategy. In a specific implementation, the correspondence between field features and mutation strategies can be pre-set, that is, different field features correspond to different mutation strategies. For example, the field type is a field feature, and the mutation strategies corresponding to integer and string fields are different; based on the correspondence, the mutation strategy corresponding to the mutable field is determined, and then the field value of the mutable field is generated according to the mutation strategy.

[0075] Step S30: Execute the test task using the test case message.

[0076] According to the needs of the specific application scenario, one or more test case messages can be generated according to the test case model. If multiple test case messages are generated, each test case message can be used to execute the test task separately. For example, after executing a test task once with one test case message, the next test case message can be used to execute the test task again. Using each test case message to execute the test task separately may obtain different test results. The specific process of executing the test task using the test case message is not limited in this embodiment. For example, in a feasible implementation method, the test result can be obtained according to the response of the device under test by sending a test case message to the device under test. In a specific implementation method, when configuring the test task, the device information of the device under test can be configured, such as the SSID, MAC address, test channel, encryption method and other information of the device under test. This information can be used as the default value of the corresponding field when generating the test case message, or when sending the test case message. By configuring the device information, the normal execution of the test task is guaranteed. For example, the SSID, MAC address, and test channel can be pre-set as configuration fields. The acquired SSID, MAC address, and test channel of the device under test can be used as the configuration values ​​of the configuration fields to generate a test case model based on these configuration values. The device information of the device under test can be entered by the user in the human-computer interaction interface, or the test equipment can sniff airborne messages and extract specific fields from the messages to obtain the device information. The device information of each device can be displayed on the human-computer interaction interface, allowing the user to select the required device information and configure it as the device information of the device under test. The device information that users select most frequently can be set as the default value to improve configuration convenience.

[0077] In a specific implementation, test case models may be generated based on different types of sample messages, and test case messages may be generated based on various test case models. Each test case message may be used to execute a different test task.

[0078] In this embodiment, a test case model is obtained, and the test case model includes the field characteristics of the variable fields in each protocol field in the message to be sent in the test task, and a test case message is generated according to the test case model, wherein the field value of at least one variable field in the test case message is generated according to the preset mutation strategy corresponding to the field characteristics of the variable field, and the test task is executed using the test case message. The embodiment of the present application provides an efficient black box fuzz testing solution. Compared with generating test data by randomly changing existing data samples, the embodiment of the present application generates a test case message for testing through a test case model. Since the test case model includes the field characteristics of the variable fields, and the field values ​​of the variable fields in the test case message are generated according to the mutation strategy corresponding to the field characteristics of the variable fields, the test case message generated for the black box fuzz test is more effective.

[0079] Based on the above first embodiment, a second embodiment of the black box fuzz testing method of the present application is proposed. In this embodiment, step S10 includes:

[0080] Step S101, obtaining a sample message;

[0081] A sample message refers to a message used as a sample, and a test case message refers to a message used as a test case. That is, a test case message is generated using a sample message as a template, and the test case message is used to execute the test task. The purpose of the test case message generated based on the sample message is the same as the purpose of the sample message. The purpose of the sample message to be used can be determined based on the test task. This embodiment does not limit the type of sample message. In one feasible implementation, the test task can be a task for testing the authentication phase of the access process of the IEEE 802.11 protocol, and messages from the authentication phase can be obtained as sample messages.

[0082] The method of obtaining the sample message is not limited in this embodiment. For example, the sample message may be a message uploaded by a user, or a message sent by another device may be received as a sample message.

[0083] Step S102 : generating a test case model according to the field information of each protocol field in the sample message, wherein the test case model includes field features of the variable fields in each protocol field in the sample message.

[0084] In a specific embodiment, the sample message can be converted into a format that facilitates analysis and reading of field information, and then a test case model can be generated based on the sample message in this converted format. In this embodiment, there is no limitation on the format of the conversion; a format that facilitates analysis and reading of field information can be selected. For example, the format can be converted into PDML (Page Discrimination Markup Language). The following is an example snippet of a message in PDML format:

[0085] ...................

[0086] <field name="wlan.duration"showname=".000 0001 0011 1010=Duration:314 microseconds"size="2"pos="32"show="314"value="13A"unmaskedvalue="3a01" / >

[0087] <field name="wlan.ra"showname="Receiver address:2e:54:35:5c:07:cf(2e:54:35:5c:07:cf)"size="6"pos="34"show="2e:54:35:5c:07:cf"value="2e54355c07cf" / >

[0088] <field name="wlan.ra_resolved"showname="Receiver address(resolved):2e:54:35:5c:07:cf"hide="yes"size="6"pos="34"show="2e:54:35:5c:07:cf"value="2e54355c07cf" / >

[0089] <field name="wlan.addr"showname="Hardware address:2e:54:35:5c:07:cf(2e:54:35:5c:07:cf)"hide="yes"size="6"pos="34"show="2e:54:35:5c:07:cf"value="2e54355c07cf" / >

[0090] <field name="wlan.addr_resolved"showname="Hardware address(resolved):2e:54:35:5c:07:cf"hide="yes"size="6"pos="34"show="2e:54:35:5c:07:cf"value="2e54355c07cf" / >

[0091] <field name="wlan.da"showname="Destination address:2e:54:35:5c:07:cf(2e:54:35:5c:07:cf)"size="6"pos="34"show="2e:54:35:5c:07:cf"value="2e54355c07cf" / >

[0092] .....................

[0093] The content defined by the <> symbol is the field information of a protocol field. Field name is the field name of the protocol field, showname is the field description information of the protocol field, size is the field length of the protocol field, pos is the offset position of the protocol field in the message, hide indicates whether the protocol field can be hidden, and value is the field value of the protocol field.

[0094] The sample message includes multiple protocol fields and field values ​​of each protocol field. In black box fuzz testing, the test case message can be generated by mutating the field values ​​of one or more protocol fields in the sample message. In this embodiment, a test case model is first generated based on the field information of each protocol field in the sample message, and then a test case message is generated based on the test case model. The test case model includes but is not limited to the field characteristics of the mutable fields in each protocol field in the sample message. Among them, the field information of the protocol field may include information for determining whether the protocol field is a mutable field, and may include information for extracting the field characteristics of the protocol field. The field characteristics of the mutable field may be characteristics for distinguishing the mutation strategy of the mutable field. The mutable field refers to a field in the sample message that can be mutated. In a specific embodiment, the correspondence between the field information of the protocol field and whether the protocol field is variable can be pre-set, that is, when the field information of the protocol field is pre-set, which information is included, it indicates that the protocol field is a variable field, and when it is included or not included, it indicates that the protocol field is not a variable field. According to the correspondence, the field information of the protocol field is analyzed to determine whether the protocol field is a variable field. By analyzing whether each protocol field is a variable field and only mutating the variable fields, the effectiveness of the generated test case message can be improved. In a specific embodiment, the correspondence between the field information of the protocol field and the field characteristics can also be pre-set, that is, when the field information of the protocol field is pre-set, which information is included, it indicates which field characteristics the protocol field has. According to the correspondence, the field information of the protocol field is analyzed to obtain the field characteristics of the protocol field.

[0095] In this embodiment, a sample message is obtained, and a test case model is generated based on the field information of each protocol field in the sample message, wherein the test case model includes the field characteristics of the variable fields in each protocol field in the sample message; a test case message is generated based on the test case model, wherein the field value of at least one variable field in the test case message is generated according to a preset mutation strategy corresponding to the field characteristics of the variable field; and the test task is executed using the test case message. This embodiment provides an efficient black-box fuzz testing solution, which improves the testing efficiency of black-box fuzz testing by automatically generating a test case model based on a sample message, and then generating a test case message based on the test case model for testing.

[0096] Based on the first and / or second embodiments above, a third embodiment of the black box fuzz testing method of the present application is proposed. In this embodiment, step S102 includes:

[0097] Step S1021: Match the field information of the protocol field in the sample message with preset information, and obtain a variation of the protocol field based on the matching result, wherein the matching result indicates whether the preset information exists in the field information of the protocol field, and the variation indicates whether the protocol field is variable.

[0098] The preset information can be information that needs to be included in the field information of a variable protocol field, or it can be information that cannot be included in the field information of a variable protocol field (in other words, information that needs to be included in the field information of a non-variable protocol field). It can be obtained in advance by analyzing the communication protocol rules to which the sample message belongs. For each protocol field in the sample message, the field information of the protocol field can be matched with the preset information to obtain a matching result of whether the preset information exists in the field information of the protocol field. Based on the matching result, the variation of the protocol field can be obtained, that is, based on the matching result, it can be determined whether the protocol field can be mutated, that is, whether it is a variable field. If the preset information is information that needs to be included in the field information of the variable protocol field, then when the preset information exists in the field information of the protocol field, it can be determined that the protocol field is a variable field; if the preset information is information that cannot be included in the field information of the variable protocol field, then when the preset information exists in the field information of the protocol field, it can be determined that the protocol field is not a variable field.

[0099] Step S1022: extracting the field feature of the protocol field from the field information of the protocol field;

[0100] The method of extracting the field features of the protocol field from the field information of the protocol field is not limited in this embodiment. In a specific embodiment, the field features may include features related to the mutation strategy, such as the field type and the field length. The correspondence between the field information and the field features can be preset, that is, the field information can be preset to correspond to which field feature. For example, after the sample message is converted into the pdml format, each protocol field corresponds to field information such as the hidden layer field (hide), the offset position field (pos), the protocol field description information (showname field), and the length field (size). The showname field can be analyzed. If address, channel, RSN, SSID, or algorithm exists, it is determined that the field type of the field is a string type. If there are alternating 1s and 0s or minutes, seconds, number, db, or time, it is determined that the field type of the field is an integer type.

[0101] Step S1023: Generate the test case model according to the variation of each protocol field and the field characteristics.

[0102] The generated test case model can include the field characteristics of the mutable fields. That is, according to the mutation of each protocol field, the mutable fields in each protocol field can be determined, and then the test case model can be generated according to the field characteristics of the mutable fields.

[0103] In one feasible implementation, step S102 includes:

[0104] Step S1024, according to the protocol to be tested corresponding to the test task, select the analysis strategy corresponding to the protocol to be tested from the preset analysis strategies corresponding to various communication protocols to analyze the field information of each protocol field in the sample message, and obtain a test case model based on the analysis results.

[0105] The test task can be a task to test a certain communication protocol, or it can be a task to test a certain function of a device that uses a certain communication protocol for communication. The communication protocol is the protocol to be tested. The protocols to be tested for different test tasks may be different. For example, they can be protocols such as IEEE 802.11, Bluetooth, or NFC. The protocol rules of different communication protocols have commonalities, but there may also be some differences. Different analysis strategies can be pre-set for different communication protocols. After determining the protocol to be tested for the test task, the field information of each protocol field in the sample message can be analyzed according to the analysis strategy corresponding to the protocol to be tested, and then a test case model is obtained based on the analysis results. By pre-setting corresponding analysis strategies for different communication protocols, the applicable protocol range of the black box fuzz testing method can be increased. In a feasible implementation, different analysis strategies can be reflected in different corresponding relationships between the field information of the protocol field and whether the protocol field is variable (partially different or completely different), or reflected in different corresponding relationships between the field information of the protocol field and the field characteristics (partially different or completely different). Exemplarily, the analysis strategies may be as follows: the 802.11 protocol may use strategies a, b, c, e, g, and h; the Bluetooth protocol may use strategies c, d, e, f, and h; and the NFC protocol may use strategies a, d, and f.

[0106] a) If the showname field of a protocol field contains an address / channel / RSN (classification: display type identifier) ​​string, the protocol field is determined to be a string type field and an immutable field;

[0107] b) If the showname field of a protocol field contains an SSID string (category: descriptive identifier), the protocol field is determined to be a string type field and a mutable field;

[0108] c) If the showname field of a protocol field contains the string "Algorithm" (category: algorithm-type identifier), determine that the protocol field is a string type field and is a mutable field;

[0109] d) If the showname field of a protocol field contains alternating 1s and 0s or a string such as minutes\seconds\number\db\time (categorized as time / random number identifier), the protocol field is determined to be an integer field and a mutable field.

[0110] e) If the showname field of a protocol field contains characters such as flag, true, and false (categorized as flags / Boolean flags), the protocol field is determined to be a universal field and a variable field.

[0111] f) If the showname field of a protocol field contains a size character (classification: time / random number type identifier), the protocol field is determined to be an immutable field. It can also be determined that the protocol field is an associated field, and the association type is length;

[0112] g) If a mask field appears in the field information of a protocol field, it can be determined that the protocol field is a mask field and is a variable field.

[0113] h) If the words "CRC" appear in the showname field of a protocol field (category: checksum type identifier), it is determined that the protocol field is an immutable field, and it can be determined that the protocol field is an associated field, and the association type is CRC checksum.

[0114] In one feasible implementation, step S102 includes:

[0115] Step S1025 , parsing the relationship between the protocol fields in the sample message, and if parsing reveals that there are parent protocol fields and child protocol fields between the protocol fields, generating a test case model according to the field information of the child protocol fields.

[0116] When the protocol fields of the sample message contain parent protocol fields and sub-protocol fields, field deduplication can be performed and a test case model can be generated based on the field information of the sub-protocol fields. The method of parsing the relationship between the protocol fields in the sample message is not limited in this embodiment.

[0117] Based on the first, second and / or third embodiments above, a fourth embodiment of the black box fuzz testing method of the present application is proposed. In this embodiment, step S20 includes:

[0118] Step S201, generating a default message according to the default values ​​of each protocol field in the test case model;

[0119] The test case model also includes the default value of each protocol field, and the default value of the protocol field is the default field value of the protocol field. The source of the default value of each protocol field in the test case model is not limited in this embodiment. For example, in a feasible implementation, the field value of each protocol field in the sample message can be used as the default value of each protocol field in the test case model. A message can be generated based on the default value of each protocol field in the test case model, and the message is used as the default message. In a feasible implementation, a message including each protocol field can be generated, and the default value of each protocol field is used as the field value of each protocol field in the message, and the message is used as the default message.

[0120] Step S202: for at least one of the mutable fields, generating a mutation value of the mutable field according to a preset mutation strategy corresponding to the field characteristics of the mutable field;

[0121] For at least one mutable field in the test case model, a mutation value for the mutable field can be generated according to a preset mutation strategy corresponding to the field characteristics of the mutable field. For example, the field characteristics may include the field type of the protocol field. For integer fields, the mutation value can be generated by inverting bits, and for string fields, the mutation value can be generated by inserting characters.

[0122] Step S203: replacing the default value of the mutable field in the default message with the mutated value of the mutable field, and obtaining a test case message according to the default message after replacing the default value.

[0123] After generating a mutated value for a mutable field, the mutated value of the mutable field can be used to replace the default value of the mutable field in the default message. In a specific embodiment, the default message after replacing the default value can be directly used as a test case message, or the default message after replacing the default value can be processed further to obtain a test case message according to specific needs.

[0124] In one feasible implementation, the step of obtaining the test case message according to the default message after replacing the default value in step S203 includes:

[0125] Step S2031: According to the association algorithm corresponding to the association type of the association field, the field value of the protocol field associated with the association field in the message is replaced according to the mutated value to calculate a generated value of the association field, wherein the mutated value replacement message is a default message after replacing the default value;

[0126] The test case model may also include association information of associated fields in each protocol field. An associated field refers to a field that has an association relationship with other protocol fields. The association information includes the protocol field associated with the associated field (that is, the field that has an association relationship with the associated field) and the association type (the type of the association relationship). When the field value of the protocol field associated with the associated field changes, the field value of the associated field also changes. The association information of the associated fields in each protocol field can be extracted from the field information of each protocol field. In a specific embodiment, a correspondence between the field information of the protocol field and whether the protocol field is an associated field can be pre-set, and a parsing rule can be set to parse the protocol field and the association type associated with the associated field from the field information of the associated field. Based on the correspondence and the field information of the protocol field, it can be determined whether the protocol field is an associated field. If the protocol field is an associated field, the protocol field and the association type associated with the protocol field can be obtained according to the parsing rule.

[0127] Different association types correspond to different association algorithms. A default message that replaces the default value with a mutated value is referred to as a mutated value replaced message to distinguish them. The generated value for the association field can be calculated by replacing the value of the protocol field associated with the association field in the message with the mutated value according to the association algorithm corresponding to the association field's association type.

[0128] Step S2032: Replace the field value of the associated field in the message with the generated value of the associated field to obtain a test case message.

[0129] In one feasible implementation, when the associated field itself is used as a field that needs to be mutated, the field values ​​of other protocol fields except the associated field can all adopt default values, and only the field value of the associated field is mutated according to the corresponding mutation strategy; since the field values ​​of other protocol fields adopt default values, the field value of the associated field is mutated, so the field value of the associated field must be wrong, so that the response of the device under test to an erroneous message can be tested.

[0130] In one feasible implementation, step S202 includes:

[0131] Step S2021: For the variable field whose field type is an integer field or a long bit field, generate a mutation value of the variable field according to a preset mutation strategy corresponding to the field length of the variable field;

[0132] The field characteristics of the protocol field may include the field type and field length of the protocol field.

[0133] When the variable field is an integer field or a long bit field, a value within the field length range of the variable field can be generated as the variation value of the protocol field. Different field lengths can set different variation strategies to improve the effectiveness of the generated test case message. In a specific embodiment, for an integer field or a long bit field whose field length is less than a preset length, the selectable values ​​of each bit of the variable field (i.e., 0 and 1) can be arranged and combined to generate multiple variation values ​​of the variable field, and each variation value can be used to replace the default value of the variable field to generate a test case message. For an integer field or a long bit field whose field length is greater than or equal to the preset length, in order to avoid generating too many test case messages by the arrangement and combination method, a special value can be used as the variation value of the variable field; illustratively, in a feasible embodiment, the maximum value within the field length (number of bits) of the variable field can be calculated, i.e., 2 比特位数 , set to max_num, for example, if the length of the variable field is 16 bits, then max_num = 2 16 , calculate the special value (0, max_num / 2, max_num / 3, max_num / 4, max_num / 8, max_num / 16, max_num / 32, max_num / 64)±10 as the mutation value of the mutable field.

[0134] Step S2022: For the variable field whose field type is a string field, inserting a preset character into the default value of the variable field to obtain a variable value of the variable field;

[0135] When the mutable field is a string field, the mutation value of the mutable field can be obtained by inserting preset characters into the default value of the mutable field. The preset characters can be set in advance as needed and are not limited in this embodiment. For example, they can be special characters or invisible characters that may cause anomalies collected through research. In some feasible implementations, for string fields, mutation values ​​can also be generated by performing random bit reversal, over-length case, inserting blank fields, and other conventional mutation strategies.

[0136] Step S2023: For the variable field whose field type is a universal field, the selectable values ​​of each bit of the variable field are arranged and combined to obtain multiple variant values ​​of the variable field.

[0137] When a mutable field is a universal field, such as a flag field or a Boolean field, you can permutate the selectable values ​​(i.e., 0 and 1) of each bit of the mutable field to generate multiple variant values ​​for the mutable field. For example, if a mutable field is a universal field with a field length of 2 bits, the four variant values ​​00, 01, 10, and 11 can be generated.

[0138] In one feasible implementation, the step of generating the default value in the test case model in step S102 includes:

[0139] Step S1026, determining the configuration field in each of the protocol fields according to the field information of each of the protocol fields;

[0140] Some protocol fields in the sample message may be fields that require user configuration, such as the SSID and MAC address of the device under test. The configuration fields in each protocol field can be pre-determined based on the field information of each protocol field. In a specific embodiment, the information required to be included in the field information of the configuration field (hereinafter referred to as configuration field description information for distinction) can be pre-set. When the configuration field description information is present in the field information of a protocol field, it can be determined that the protocol field is a configuration field.

[0141] Step S1027, obtaining a configuration value of the configuration field, and using the configuration value as a default value corresponding to the configuration field in the test case model;

[0142] Step S1028: For the remaining fields in each of the protocol fields except the configuration field, extract the field values ​​of the remaining fields in the sample message as the default values ​​corresponding to the remaining fields in the test case model.

[0143] There are many ways to obtain the configuration value of the configuration field, for example, obtaining a configuration value pre-stored locally, or receiving a configuration value input by a user through a human-computer interaction interface.

[0144] In one feasible implementation manner, after step S20, the method further includes:

[0145] Step S40 : Using the test case message generated according to the test case model as a mutation corpus, performing a mutation operation on the mutation corpus to obtain a new test case message.

[0146] The mutation operations performed on the variant corpus are not limited in this embodiment and can be implemented using the mutation operations in conventional mutation-based test case message generation methods. For example, mutation operations such as randomly swapping the positions of parameters (protocol groups), adding / deleting random parameters, randomly adjusting the endianness of use case fields, testing overly large parameters (parameters that do not meet protocol requirements), and mutating specific connectors can be used. The new test case messages obtained by performing mutation operations on the variant corpus can also be used to execute test tasks, thereby enriching the number and types of test case messages and improving test coverage.

[0147] Based on the first, second, third and / or fourth embodiments above, a fifth embodiment of the black box fuzz testing method of the present application is proposed. In this embodiment, step S30 includes:

[0148] Step S301: Send the test case message to the device under test;

[0149] After the test case message is generated, the test case message may be sent to the device under test, so as to obtain a test result based on the response of the device under test to the test case message.

[0150] In one feasible implementation, as shown in FIG3 , the test software, i.e., the software for implementing the black box fuzz testing method in the embodiment of the present application, can be deployed on a test device. Depending on the communication protocol to be tested in the test task, the test device can be configured to connect to the corresponding test hardware via USB, so that the test device can communicate with the device under test through the test hardware via the communication protocol; for example, when the communication protocol is the IEEE 802.11 protocol, the device under test can be communicated with via a wireless network card that supports monitoring mode; when the communication protocol is the Bluetooth protocol, the device under test can be communicated with via a Bluetooth adapter; when the communication protocol is the NFC protocol, the device under test can be communicated with via the NFC reader / writer function; when the communication protocol is a wired protocol, the test device can maintain a connection with the device under test via Ethernet. If the test device itself has the function of communicating with the device under test according to the communication protocol, the test device can perform the test task without connecting to the corresponding test hardware. For example, if the test device has the function of communicating according to the wireless communication protocol IEEE 802.11, the test task can be performed without the need to connect to an additional wireless network card. In a specific embodiment, the test device can send test case messages to the device under test through the test hardware using a socket method when executing the test task. In a feasible embodiment, as shown in Figure 3, the test software can be composed of a front-end UI (User Interface), a background server and middleware. In a feasible embodiment, the test software can adopt a lightweight B / S architecture, and all functions can be used by opening a specified page with a browser. The browser front-end page and the server can be built together on the same host. In a specific embodiment, different communication protocols can be tested separately at the same time without interfering with each other. In a specific embodiment, the test software can include an interactive UI, a test environment plug-in, code, etc., which can be deployed to a Linux kernel device, or built and deployed in the form of a virtual machine or Docker, or deployed to a Windows system.

[0151] Step S302: Record the response of the device under test to the test case message in a log;

[0152] The device under test's response to a test case message may include information such as whether a response occurred, the duration of the response, the content of the response message, and whether the response was abnormal. In a specific embodiment, each time a test task is executed using a test case message, a response record is recorded. By sequentially executing test tasks using multiple test case messages, multiple log entries can be generated.

[0153] In a specific embodiment, the device under test responds after receiving the test case message. Since there are various messages in transmission in the environment and there is a lot of noise, the test device can call the status monitor to denoise the device response when monitoring the response status of the device under test in real time, that is, according to the device information of the device under test, remove the messages transmitted by other devices other than the device under test. In a feasible embodiment, the test device can send a non-mutated original probe message to the device under test and record the response of the device under test to the original probe message. According to the response of the device under test to the original probe message, it can be determined whether the device under test can communicate normally, thereby determining whether the device under test responds abnormally only to the test case message or responds abnormally to the test case message due to the abnormality of the device under test itself.

[0154] Step S303: output the log in response to the log viewing request.

[0155] The log viewing request can be triggered by the user, or triggered according to a custom trigger condition, which is not limited in this embodiment. The output log can be output to a visual interface for display, or can be output to a storage device for storage, or sent to other devices, which is not limited in this embodiment. In one feasible implementation, as shown in Figure 3, the log report module in the front-end UI can be used to output the display log, and the test case message and other test information can also be displayed, such as the test time, device information of the device under test, etc. The front end can also be provided with a use case reproduction module to provide a use case reproduction function, such as allowing users to select or input the test case message that needs to be reproduced, and the back-end server uses the test case message selected by the user to perform a retest, and records the test results to achieve vulnerability reproduction and location.

[0156] In one feasible implementation, the logs can be analyzed to obtain visual analysis results and display them on the front end, such as the change of test response time with test time, the correlation between test requests and test responses, the comparison of test model effects, etc. Based on the visual conclusions, users can be assisted in problem analysis and location.

[0157] In one feasible implementation, the step of obtaining a sample message in step S101 includes:

[0158] Step S1011, receiving a sample message of any target test phase uploaded by a user;

[0159] A test task can include multiple test phases, each of which must be executed in a specific order. Each test phase sends a different message to the device under test. Users can choose to automatically generate test case messages for one or more test phases within a test case using a test case model. This means users can upload sample messages for one or more test phases. The system receives the sample messages uploaded by the user for the target test phase and generates a test case message for that target test phase based on the sample messages.

[0160] The step S30 includes:

[0161] Step S304, execute each test phase in the order of each test phase, wherein, when executing the target test phase, the test case message generated based on the test case model is sent to the device under test, and when executing a test phase other than the target test phase, a message generated based on the preset default model corresponding to the test phase is sent to the device under test.

[0162] When executing a test task, each test stage can be executed in the order of each test stage, and when executing each test stage, the message of the test stage is sent to the device under test. Among them, when executing the target test stage, the message sent to the device under test is generated based on the test case model generated by the sample message of the target test stage, that is, the above-mentioned test case message. When executing a test stage other than the target test stage, the message sent is generated based on the preset default model corresponding to the test stage. That is, the default models corresponding to each test stage of the test task are pre-set, and the user can choose to use the default model or upload a sample message to automatically generate a model. The default model contains the same type of information as the test case model. For example, the default model corresponding to the test stage includes the default values ​​of each protocol field in the message that needs to be sent in the test stage and the field information of the variable field.

[0163] In a specific implementation, a test phase that requires mutation selected by a user can be received. When a test case message is generated based on the model of the test phase, the test case message is generated by generating a mutation value to replace the default value. For a test phase that does not require mutation, the default message generated according to the model can be directly used as the test case message.

[0164] In one possible implementation, the method further includes:

[0165] Step S50, obtaining the current test status of the test task, where the current test status includes the current test progress of each test phase in the test task;

[0166] The current test progress of a test phase may be progress information indicating whether the test phase has not yet started, is being executed, or has been completed.

[0167] Step S60: Visually output the current test status.

[0168] In a specific embodiment, the current test status can be visualized using a progress chart. For example, nodes are used to represent each test phase, arrows are used to indicate the execution order of each test phase, and text or symbols are used to indicate the current test progress of each test phase. In one possible embodiment, as shown in Figure 3, the current test status can be visualized using a status display module in the front-end UI.

[0169] In one feasible implementation, black box fuzz testing can be performed according to the process shown in Figure 4. The test target refers to the device to be tested, and the test protocol refers to the protocol to be tested. Creating a new task is to create a new test task, and the configuration parameters can be the parameters required for configuring the test, such as encryption method, time interval for sending test case messages, etc. Users can choose to use the built-in model (that is, the default model) or choose to automatically generate a model by uploading messages. During the test process, the corresponding response to the test case message that generates an exception can be recorded. After the test task is completed, the log can be compiled into a report for output.

[0170] In addition, an embodiment of the present application further provides a black box fuzzy testing device, the black box fuzzy testing device comprising:

[0171] An acquisition module, configured to acquire a test case model, wherein the test case model includes field characteristics of mutable fields in each protocol field in a message to be sent in a test task;

[0172] a generating module, configured to generate a test case message according to the test case model, wherein a field value of at least one of the mutable fields in the test case message is generated according to a preset mutation strategy corresponding to a field feature of the mutable field;

[0173] The test module is used to execute the test task using the test case message.

[0174] In one feasible implementation manner, the acquisition module is further configured to:

[0175] Get sample messages;

[0176] A test case model is generated according to the field information of each protocol field in the sample message, wherein the test case model includes field features of the variable fields in each protocol field in the sample message.

[0177] In one feasible implementation manner, the acquisition module is further configured to:

[0178] Matching the field information of the protocol field in the sample message with preset information, and obtaining a variation of the protocol field according to the matching result, wherein the matching result indicates whether the preset information exists in the field information of the protocol field, and the variation indicates whether the protocol field is variable;

[0179] extracting a field feature of the protocol field from the field information of the protocol field;

[0180] The test case model is generated according to the variation of each protocol field and the field characteristics.

[0181] In one feasible implementation manner, the acquisition module is further configured to:

[0182] According to the protocol to be tested corresponding to the test task, an analysis strategy corresponding to the protocol to be tested is selected from the analysis strategies corresponding to various preset communication protocols to analyze the field information of each protocol field in the sample message, and a test case model is obtained according to the analysis results.

[0183] In one feasible implementation manner, the acquisition module is further configured to:

[0184] The relationship between the protocol fields in the sample message is parsed. If the parsing shows that there are parent protocol fields and child protocol fields between the protocol fields, a test case model is generated according to the field information of the child protocol fields.

[0185] In one feasible implementation, the test case model further includes a default value of each of the protocol fields, where the default value of the protocol field is a default field value of the protocol field, and the acquisition module is further configured to:

[0186] Generate a default message according to the default value of each protocol field in the test case model;

[0187] For at least one of the mutable fields, generating a mutation value of the mutable field according to a preset mutation strategy corresponding to the field characteristics of the mutable field;

[0188] The default value of the mutable field in the default message is replaced by the mutated value of the mutable field, and a test case message is obtained according to the default message after the default value is replaced.

[0189] In one feasible implementation, the test case model further includes association information of associated fields in each of the protocol fields, the association information including the protocol field and association type associated with the associated field, and the generating module is further configured to:

[0190] According to the association algorithm corresponding to the association type of the association field, the generated value of the association field is calculated based on the mutated value replacement message, wherein the mutated value replacement message is a default message after replacing the default value;

[0191] The generated value of the associated field is used to replace the mutated value to replace the field value of the associated field in the message, so as to obtain a test case message.

[0192] In one feasible implementation, the field characteristics include a field type and a field length, and the generating module is further configured to:

[0193] For the variable field whose field type is an integer field or a long bit field, generating a mutation value of the variable field according to a preset mutation strategy corresponding to the field length of the variable field;

[0194] For the variable field whose field type is a string field, inserting preset characters into the default value of the variable field to obtain a variable value of the variable field;

[0195] For the variable field whose field type is a universal field, the selectable values ​​of each bit of the variable field are arranged and combined to obtain multiple variable values ​​of the variable field.

[0196] In one feasible implementation manner, the acquisition module is further configured to:

[0197] Determining a configuration field in each of the protocol fields according to field information of each of the protocol fields;

[0198] Obtaining a configuration value of the configuration field, and using the configuration value as a default value corresponding to the configuration field in the test case model;

[0199] For the remaining fields in each of the protocol fields except the configuration field, the field values ​​of the remaining fields in the sample message are extracted as the default values ​​corresponding to the remaining fields in the test case model.

[0200] In one feasible implementation, the black box fuzzy testing device further includes:

[0201] The mutation module is used to use the test case message generated according to the test case model as the mutation corpus, perform a mutation operation on the mutation corpus, and obtain a new test case message.

[0202] In one possible implementation, the testing module is further configured to:

[0203] Sending the test case message to the device under test;

[0204] Recording the response of the device under test to the test case message in a log;

[0205] The log is output in response to a log viewing request.

[0206] In one feasible implementation, the test task includes multiple test phases, and the acquisition module is further configured to include:

[0207] Receive sample messages of any target test phase uploaded by users;

[0208] The test module is also used to:

[0209] Execute each test phase in the order of each test phase, wherein, when executing the target test phase, the test case message generated based on the test case model is sent to the device under test, and when executing a test phase other than the target test phase, a message generated based on a preset default model corresponding to the test phase is sent to the device under test.

[0210] In a feasible implementation manner, the acquisition module is further configured to: acquire a current test status of the test task, where the current test status includes a current test progress of each test phase in the test task;

[0211] The black box fuzzy testing device also includes:

[0212] The output module is used to visually output the current test status.

[0213] In addition, an embodiment of the present application further proposes a computer-readable storage medium, on which a black box fuzz testing program is stored. When the black box fuzz testing program is executed by a processor, the steps of the black box fuzz testing method described below are implemented.

[0214] The various embodiments of the black box fuzz testing device and computer-readable storage medium of the present application can refer to the various embodiments of the black box fuzz testing method of the present application, and will not be repeated here.

[0215] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.

[0216] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0217] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0218] The above are merely optional embodiments of the present application and do not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A black box fuzz testing method, wherein: The black box fuzz testing method comprises: Acquire a test case model, wherein the test case model includes field characteristics of variable fields in each protocol field in a message to be sent in the test task; Generate a test case message according to the test case model, wherein a field value of at least one of the mutable fields in the test case message is generated according to a preset mutation strategy corresponding to a field feature of the mutable field; The test case message is used to execute the test task.

2. The black box fuzz testing method according to claim 1, wherein: The step of obtaining the test case model includes: Get sample message; A test case model is generated according to the field information of each protocol field in the sample message, wherein the test case model includes field characteristics of the variable fields in each protocol field in the sample message.

3. The black box fuzz testing method as claimed in claim 2, wherein: The step of generating a test case model according to the field information of each protocol field in the sample message includes: Matching the field information of the protocol field in the sample message with the preset information, and obtaining the variation of the protocol field according to the matching result, wherein the matching result indicates whether the preset information exists in the field information of the protocol field, and the variation is used to indicate whether the protocol field is variable; Extracting a field feature of the protocol field from the field information of the protocol field; The test case model is generated according to the variation of each of the protocol fields and the field characteristics.

4. The black box fuzz testing method as claimed in claim 2, wherein: The step of generating a test case model according to the field information of each protocol field in the sample message includes: According to the protocol to be tested corresponding to the test task, an analysis strategy corresponding to the protocol to be tested is selected from the analysis strategies corresponding to various preset communication protocols to analyze the field information of each protocol field in the sample message, and a test case model is obtained according to the analysis results.

5. The black box fuzz testing method as claimed in claim 2, wherein: The step of generating a test case model according to the field information of each protocol field in the sample message includes: The relationship between the protocol fields in the sample message is parsed. If the parsing shows that there are parent protocol fields and sub-protocol fields between the protocol fields, a test case model is generated according to the field information of the sub-protocol fields.

6. The black box fuzz testing method as claimed in claim 2, wherein: The test case model also includes a default value of each of the protocol fields, where the default value of the protocol field is a default field value of the protocol field. The step of generating a test case message according to the test case model includes: Generate a default message according to the default values ​​of each of the protocol fields in the test case model; For at least one of the mutable fields, generating a mutation value of the mutable field according to a preset mutation strategy corresponding to the field characteristics of the mutable field; The default value of the variable field in the default message is replaced by the variable value of the variable field, and a test case message is obtained according to the default message after the default value is replaced.

7. The black box fuzz testing method according to claim 6, wherein: The test case model also includes association information of associated fields in each of the protocol fields, wherein the association information includes the protocol field and the association type associated with the associated field, and the step of obtaining the test case message according to the default message after replacing the default value includes: According to the association algorithm corresponding to the association type of the association field, the field value of the protocol field associated with the association field in the message is replaced according to the mutation value, and the generated value of the association field is calculated, wherein the mutation value replacement message is a default message after replacing the default value; The generated value of the associated field is used to replace the mutated value to replace the field value of the associated field in the message, so as to obtain a test case message.

8. The black box fuzz testing method according to claim 6, wherein: The field characteristics include field type and field length. The step of generating a mutation value of the variable field according to the preset mutation strategy corresponding to the field characteristics of the variable field includes: For the variable field whose field type is an integer field or a long bit field, generating a mutation value of the variable field according to a preset mutation strategy corresponding to the field length of the variable field; For the variable field whose field type is a string field, inserting a preset character into the default value of the variable field to obtain a variable value of the variable field; For the variable field whose field type is a universal field, the selectable values ​​of each bit of the variable field are arranged and combined to obtain multiple variable values ​​of the variable field.

9. The black box fuzz testing method according to claim 6, wherein: The steps of generating the default value in the test case model include: Determining a configuration field in each of the protocol fields according to field information of each of the protocol fields; Obtaining a configuration value of the configuration field, and using the configuration value as a default value corresponding to the configuration field in the test case model; For the remaining fields in each of the protocol fields except the configuration field, the field values ​​of the remaining fields in the sample message are extracted as the default values ​​corresponding to the remaining fields in the test case model.

10. The black box fuzz testing method according to claim 1, wherein: After the step of generating a test case message according to the test case model, the method further includes: The test case message generated according to the test case model is used as a variant corpus, and a mutation operation is performed on the variant corpus to obtain a new test case message.

11. The black box fuzz testing method according to claim 1, wherein: The step of using the test case message to execute the test task includes: Sending the test case message to the device under test; Recording the response of the device under test to the test case message in a log; The log is output in response to a log viewing request.

12. The black box fuzz testing method according to claim 2, wherein: The test task includes multiple test phases, and the step of obtaining a sample message includes: Receive sample messages of any target test phase uploaded by the user; The step of using the test case message to execute the test task includes: Execute each of the test phases in order, wherein when executing the target test phase, the test case message generated based on the test case model is sent to the device under test, and when executing a test phase other than the target test phase, a message generated based on a preset default model corresponding to the test phase is sent to the device under test.

13. The black box fuzz testing method according to any one of claims 1 to 12, wherein: The method further comprises: Obtaining the current test status of the test task, the current test status including the current test progress of each test stage in the test task; The current test status is visually output.

14. A black box fuzz testing device, wherein: The black box fuzz testing device includes: a memory, a processor, and a black box fuzz testing program stored in the memory and executable on the processor. When the black box fuzz testing program is executed by the processor, the black box fuzz testing method according to any one of claims 1 to 13 is implemented.

15. A computer-readable storage medium, wherein: The computer-readable storage medium stores a black-box fuzz testing program, which, when executed by a processor, implements the black-box fuzz testing method according to any one of claims 1 to 13.

Citation Information

Patent Citations

  • Industrial control protocol test method and system, electronic equipment and storage medium

    CN111123888A

  • Black box fuzzy test method and system for industrial control private protocol

    CN114281676A

  • Fuzzy test method and system for stateful network protocol

    CN114650163A

  • Fuzzy testing method based on grammar variation

    CN115712563A

Cited By

  • State protocol fuzzy testing method based on reinforcement learning, medium and product

    CN119299195A

  • Stateful protocol fuzzy test method and system based on path and response code conversion

    CN119561878A

  • Protocol fuzz testing method and system based on cross-multi-state

    CN119782191A