A software testing method and device, electronic equipment and storage medium
Patent Information
- Application Number
- CN202211586174.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-09
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2042-12-09
AI Technical Summary
然而在相关技术中,对配网的测试依赖人工分析,漏洞挖掘效率及漏洞覆盖率较低
[0019] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description.
Smart Images

Figure CN116302923B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and more particularly to the fields of testing and Bluetooth technology, specifically to a software testing method, apparatus, electronic device, storage medium, and computer program product. Background Technology
[0002] Provisioning refers to the process of adding un-provisioned electronic devices to a network. Software used for provisioning faces security threats such as code defects. Provisioning software from different vendors often varies. However, in related technologies, testing provisioning relies on manual analysis, resulting in low efficiency and coverage of vulnerability discovery. Therefore, vulnerability discovery is difficult through manual auditing. Summary of the Invention
[0003] This disclosure provides a software testing method, apparatus, electronic device, storage medium, and computer program product.
[0004] According to one aspect of this disclosure, a software testing method is provided, comprising:
[0005] When configuring the network with the target device, an initial test case is sent to the target device; wherein, the initial test case is used to test whether there are vulnerabilities in the software implementing the network configuration protocol, and the initial test case includes at least one segmented data packet;
[0006] In response to feedback from the target device regarding the initial test cases, the segmented data packets in the initial test cases are classified.
[0007] Based on the classification results, the segmented data packets in the initial test cases are iterated, and after the iteration is completed, the step of sending the initial test cases to the target device is returned until the test termination condition is met.
[0008] According to one aspect of this disclosure, a software testing apparatus is provided, comprising:
[0009] The data sending module is used to send initial test cases to the target device when performing network configuration with the target device; wherein, the initial test cases are used to test whether there are vulnerabilities in the software implementing the network configuration protocol, and the initial test cases include at least one segmented data packet;
[0010] The classification module is used to classify the segmented data packets in the initial test cases in response to the feedback information from the target device to the initial test cases;
[0011] The iteration module is used to iterate over the segmented data packets in the initial test cases according to the classification results, and after the iteration is completed, return to execute the step of sending the initial test cases to the target device until the test termination condition is met.
[0012] According to another aspect of this disclosure, an electronic device is provided, comprising:
[0013] At least one processor; and
[0014] A memory that is communicatively connected to at least one processor; wherein,
[0015] The memory stores instructions that can be executed by at least one processor, which enables the at least one processor to perform the software testing method of any embodiment of this disclosure.
[0016] According to another aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions for causing a computer to execute a software testing method according to any embodiment of this disclosure.
[0017] According to another aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements a software testing method according to any embodiment of this disclosure.
[0018] Based on the technology disclosed herein, security vulnerabilities in the software implementation layer of power distribution protocols can be efficiently and comprehensively identified.
[0019] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0020] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:
[0021] Figure 1a This is a flowchart illustrating a software testing method provided in an embodiment of this disclosure;
[0022] Figure 1b This is a logical diagram of software testing provided in an embodiment of this disclosure;
[0023] Figure 2 This is a flowchart illustrating yet another software testing method provided in this disclosure embodiment;
[0024] Figure 3 This is a flowchart illustrating yet another software testing method provided in this disclosure embodiment;
[0025] Figure 4 This is a flowchart illustrating yet another software testing method provided in this disclosure embodiment;
[0026] Figure 5This is a schematic diagram of the structure of a software testing device provided in an embodiment of this disclosure;
[0027] Figure 6 This is a block diagram of an electronic device used to implement the software testing method of the embodiments of this disclosure. Detailed Implementation
[0028] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0029] Figure 1a This is a flowchart illustrating a software testing method according to an embodiment of the present disclosure. This embodiment is applicable to testing whether software implementing a network configuration protocol has security vulnerabilities, typically applicable to scenarios where software implementing a Bluetooth mesh network configuration protocol has vulnerabilities. This method can be executed by a software testing device, which is implemented in software and / or hardware and integrated into an electronic device, such as an attack device used for testing.
[0030] For details, see Figure 1a The software testing methods are as follows:
[0031] S101. When configuring the network with the target device, send the initial test cases to the target device.
[0032] In this embodiment, the software implementing the network configuration protocol can be pre-deployed on the target device. To test whether the software implementing the network configuration protocol has security vulnerabilities, the attacking device first needs to configure the network with the target device. The network configuration process is as follows: the attacking device sends a connection request to the target device. After establishing a wireless connection with the target device, it enters the public key exchange phase and then enters the network based on the public key. Optionally, during the public key exchange phase, the attacking device sends initial test cases to the target device. The initial test cases are used to test whether the software implementing the network configuration protocol has vulnerabilities, and the initial test cases include at least one segmented data packet. It should be noted that the initial test cases can be randomly generated by the attacking device in advance, or they can be obtained by the attacking device from other devices in advance; no specific limitation is made here.
[0033] S102. In response to the feedback information from the target device regarding the initial test case, classify the segmented data packets in the initial test case.
[0034] In this embodiment, the feedback information from the target device to the initial test case includes both information on whether the distribution process on the target device has crashed and the response information of the target device to each segmented data packet in the initial test case. If the feedback information determines that the distribution process on the target device has crashed, it is determined that the initial test case triggered a security vulnerability in the distribution protocol software, thereby uncovering a security vulnerability in the software implementation layer of the distribution protocol. At this point, it is only necessary to save the initial test case and end the test. Subsequent analysis of the existing security vulnerability can be performed based on the initial test case. If the distribution process on the target device has not crashed, the software implementing the distribution protocol may also have security vulnerabilities. For example, if the target device receives and saves segmented data packets that violate the distribution protocol specifications, it indicates that the software implementing the distribution protocol has a security vulnerability for such segmented data packets. Therefore, if the distribution process on the target device has not crashed, the segmented data packets in the initial test case can be classified according to the response information of the target device to each segmented data packet in the initial test case. For example, segmented data packets that are received by the target device and violate the distribution protocol specifications can be classified into one category, and segmented data packets that are rejected by the target device and violate the distribution protocol specifications can be classified into another category. Then, based on the classification results, it can be determined which segment data packets the software implementing the distribution network protocol has security vulnerabilities for.
[0035] S103. Based on the classification results, iterate through the segmented data packets in the initial test case, and after the iteration is completed, return to the step of sending the initial test case to the target device until the test termination condition is met.
[0036] In this embodiment, after determining the type of each segmented data packet through step S102, in order to improve the efficiency of software testing, the segmented data packets in the initial test case can be iterated according to the classification results. For example, the segmented data packets in the initial test case can be iterated based on a genetic algorithm. After the iteration is completed, it is determined whether the test termination condition is met. If yes, the test ends; if no, the test returns to step S101. The test termination condition is exemplarily the following: the number of iterations of the segmented data packets in the initial test case is equal to a preset number threshold, or the proportion of a certain type of segmented data packets in the initial test case exceeds a preset proportion threshold.
[0037] For a detailed explanation of the entire software testing process, please refer to the appendix. Figure 1bThe diagram illustrates the logic of software testing. Specifically, during the network configuration phase, the attacker's transmitter first sends a link establishment data packet to the target device, and then sends a series of segmented data packets constituting the test cases to the target device for testing. The attacker's receiver then receives feedback information from the target device regarding the segmented data packets constituting the test cases (including network configuration end messages and serial port logs), and transmits this feedback information to the crash detection device and the response verification device. The crash detection device determines whether the target device's network configuration process has crashed based on the feedback information; if so, it stops the test and saves the test cases. The response verification device classifies the segmented data packets based on the feedback information and then feeds the classification results back to the test case optimization device. The test case optimization device iteratively updates each segmented data packet based on the classification results to obtain new test cases, and then continues testing using the new test cases according to the above process.
[0038] In this embodiment, by continuously iterating over the segmented data packets in the test cases, not only can security vulnerabilities in the software implementation of the power distribution protocol be efficiently and comprehensively discovered, but testing efficiency can also be improved.
[0039] Figure 2 This is a flowchart illustrating another software testing method according to an embodiment of the present disclosure. This embodiment adds a process for the attack device to generate initial test cases; see [link to relevant documentation]. Figure 2 The specific software testing methods are as follows:
[0040] S201. Obtain test samples.
[0041] In this embodiment, the test sample is data used to test whether the distribution network protocol software has security vulnerabilities, and it consists of a series of data packets. Optionally, the test sample includes an expected data packet P. TSP and at least one segmented data packet for testing Among them, the expected data packet P TSP This is the first data packet of the test sample, and the expected data packet records the total length of the test sample (TotalLength) and the total number of data packets (SegN) (i.e., the total number of expected data packets and segmented data packets).
[0042] S202. Determine the encoding information corresponding to each segment of the data packet.
[0043] In one optional implementation, the encoding information corresponding to each segmented data packet is determined by encoding, for example, by using truth value encoding to encode the fields related to message segmentation and reassembly in the segmented data packet to obtain the corresponding encoding information; wherein, the encoding information includes the data packet number Seg_idx and the data packet payload length data_len of the segmented data packet.
[0044] S203. Initialize the segmented data packets according to the preset value range of the data packet number and data packet payload length to obtain the initial test cases.
[0045] The preset value range for the data packet number seg_idx is [1, 63], and the preset value range for the data packet payload length data_len is [23, 33]. These ranges can be set according to the network distribution protocol specifications. Thus, when initializing any segmented data packet, based on the preset value ranges of the data packet number seg_idx and the data packet payload length data_len, the values of seg_idx and data packet payload length are randomly reassigned to the data packet. Then, based on the reassignment results, the segmented data packet is reconstructed to obtain an initial test case composed of multiple segmented data packets. Because this embodiment incorporates a genetic algorithm for testing, the initial test cases obtained can be regarded as the initial population. Subsequent iterations of the initial test cases generate a new population.
[0046] S204. When configuring the network with the target device, send the initial test cases to the target device.
[0047] The initial test cases are used to test whether the software implementing the distribution network protocol has vulnerabilities, and each initial test case includes at least one segmented data packet. Before sending the randomly generated initial test cases to the target device, the expected data packets are first sent to the target device, so that the target device knows the initial test cases to be received based on the total length of the expected data packets (TotalLength) and the total number of data packets (SegN); then, each segmented data packet in the initial test cases is sent sequentially.
[0048] S205. In response to the feedback information from the target device regarding the initial test case, classify the segmented data packets in the initial test case.
[0049] S206. Based on the classification results, iterate through the segmented data packets in the initial test cases, and after the iteration is completed, return to the step of sending the initial test cases to the target device until the test termination condition is met.
[0050] The specific implementation process of S204-S206 can be found in the above embodiments, and will not be repeated here.
[0051] In this embodiment, the attacking device randomly generates initial test cases, providing a foundation for subsequent software testing.
[0052] Figure 3This is a flowchart illustrating another software testing method according to an embodiment of the present disclosure. This embodiment elaborates on the process of classifying segmented data packets; see [link to relevant documentation]. Figure 3 The specific software testing methods are as follows:
[0053] S301. Obtain test samples.
[0054] In this embodiment, the test sample is data used to test whether the distribution network protocol software has security vulnerabilities, and it consists of a series of data packets. Optionally, the test sample includes an expected data packet P. TSP and at least one segmented data packet for testing Among them, the expected data packet P TSP This is the first data packet of the test sample, and the expected data packet records the total length of the test sample (TotalLength) and the total number of data packets (SegN) (i.e., the total number of expected data packets and segmented data packets).
[0055] S302. Determine the encoding information corresponding to each segmented data packet.
[0056] In one optional implementation, the encoding information corresponding to each segmented data packet is determined by encoding, for example, by using truth value encoding to encode the fields related to message segmentation and reassembly in the segmented data packet to obtain the corresponding encoding information; wherein, the encoding information includes the data packet number seg_idx and the data packet payload length data_len of the segmented data packet.
[0057] S303. Initialize the segmented data packets according to the preset value range of the data packet number and data packet payload length to obtain the initial test cases.
[0058] The preset value range for the data packet number seg_idx is [1, 63], and the preset value range for the data packet payload length data_len is [23, 33]. These ranges can be set according to the network distribution protocol specifications. Thus, when initializing any segmented data packet, based on the preset value ranges of the data packet number seg_idx and the data packet payload length data_len, the values of seg_idx and data packet payload length are randomly reassigned to the data packet. Then, based on the reassignment results, the segmented data packet is reconstructed to obtain an initial test case composed of multiple segmented data packets.
[0059] S304. When configuring network with the target device, send the initial test cases to the target device.
[0060] The initial test cases are used to test whether the software implementing the distribution network protocol has vulnerabilities, and each initial test case includes at least one segmented data packet. Before sending the randomly generated initial test cases to the target device, the expected data packets are first sent to the target device, so that the target device can understand the initial test cases to be received based on the total length of the expected data packets (TotalLength) and the total number of data packets (SegN); then, each segmented data packet in the initial test cases is sent sequentially.
[0061] S305. Obtain feedback information from the target device for the initial test case, including the distribution network end message and / or the target device's serial port log.
[0062] The network configuration end message is used to characterize the network configuration process in the target device. After the network configuration of the target device is completed, the network configuration end message, also known as Link Close, can be generated and sent. Link Close can only be sent if the Bluetooth communication process obtained during network configuration is still alive. If the network configuration process crashes during the configuration process, the network configuration end message cannot be sent.
[0063] S306. Based on the distribution network termination message and / or the target device's serial port log, determine whether the segmented data packets in the initial test case were received by the target device.
[0064] In this embodiment, when determining whether segmented data packets in the initial test case are received by the target device, either the network end message or the target device's serial port log can be used alone, or both can be used in combination; no specific limitation is made here. When using the network end message alone, the following steps can be taken to determine whether segmented data packets are received by the target device: If the network end message is received during the segmented data packet transmission process, it is determined that only the segmented data packets before the network end message was triggered were received by the target device, and other subsequently sent segmented data packets were not received; if the network end message is triggered due to a timeout, it is determined that all segmented data packets have been received by the target device. If the feedback information is only the serial port log, it is only necessary to determine all the data received by the target device based on the serial port log, and then determine which segmented data packets were received. In this way, through the above process, it is possible to accurately determine whether segmented data packets are received by the target device. Subsequently, whether segmented data packets are received by the target device can be used as a classification indicator to ensure the accurate classification of segmented data packets.
[0065] S307. Determine whether the segmented data packets in the initial test cases meet the network distribution protocol specifications.
[0066] Optionally, for any segmented data packet, if the following conditions (1)-(3) are met, then the segmented data packet is determined to meet the distribution network protocol specification:
[0067] (1) The data packet number of the segmented data packet is less than or equal to the total number of data packets; that is, the seg_idx of the segmented data packet is less than or equal to SegN.
[0068] (2) If the data packet number is less than the total number of data packets, the data packet payload length of the segmented data packet is the first threshold (e.g., 23); if the data packet number is equal to the total number of data packets, the data packet payload length of the segmented data packet is within the first preset range (e.g., [1,23]).
[0069] (3) Based on the packet number and payload length of the segmented data packet, determine whether the length of the segmented data packet buffered in the target device is less than or equal to the total data length. Specifically, for any segmented data packet, the following formula can be used for judgment: 20 + 23 × (seg_idx - 1) + l TCP ≤TotalLength; where, l TCP 20 represents the payload length of the segmented data packet determined by condition (2); 20 represents the payload length of the expected data packet; (seg_idx-1) represents the number of segmented data packets already cached by the target device; 20+23×(seg_idx-1) represents the length of the expected data packet and segmented data packets already cached by the target device; TotalLength represents the total data length.
[0070] In this way, through the above process, it can be accurately determined whether segmented data packets meet the distribution network protocol specifications. Subsequently, whether segmented data packets meet the distribution network protocol specifications can be used as a classification indicator to ensure the accurate classification of segmented data packets.
[0071] S308. Determine whether the segmented data packets in the initial test case exceed the target device's preset buffer area when cached in the target device.
[0072] Optionally, if, based on the packet number and payload length of the segmented data packet, the length of the segmented data packet buffered in the target device is determined to be greater than the length of the target device's preset buffer, then the segmented data packet is determined to have exceeded the buffer area when buffered in the target device. Specifically, if the following judgment formula is satisfied, it is determined to have exceeded the buffer area: 20 + 23 × (seg_idx - 1) + l TCP >l pbuf Among them, l TCP 20 represents the payload length of the segmented data packet determined by condition (2) in S307; 20 represents the payload length of the expected data packet; (seg_idx-1) represents the number of segmented data packets already cached by the target device; 20+23×(seg_idx-1) represents the length of the expected data packet and the segmented data packet already cached by the target device; l pbufIt is set by the target device based on the total length of data recorded in the expected data packet (TotalLength), and l pbuf Greater than or equal to TotalLength.
[0073] In this way, through the above process, it can be accurately determined whether the segmented data packets exceed the buffer area. Subsequently, whether the segmented data packets exceed the buffer area can be used as a classification indicator to ensure the accurate classification of segmented data packets.
[0074] S309. Determine the type of segmented data packet based on whether the segmented data packet is received by the target device, whether it meets the network distribution protocol specifications, and whether it exceeds the target device's preset buffer area.
[0075] Optionally, segmented data packets that are received by the target device and exceed the preset buffer area and violate the network distribution protocol specifications are classified as first-type segmented data packets;
[0076] Segmented data packets that violate the network distribution protocol specifications and are received by the target device but do not exceed the buffer are classified as second-type segmented data packets.
[0077] Segmented data packets that are received by the target device and do not exceed the buffer area and conform to the network distribution protocol specifications are classified as Category 3 segmented data packets.
[0078] Segmented data packets that are rejected by the target device and violate the distribution network protocol specifications are classified as Category 4 segmented data packets.
[0079] In this way, by using different classification indicators, the goal of accurately classifying segmented data packets is achieved. It should be noted that the existence of the first type of segmented data packets indicates a serious security vulnerability in the distribution network protocol software; this type of segmented data packet can be directly inherited by the next generation. The existence of the second type of segmented data packets indicates that the distribution network protocol software has security vulnerabilities targeting this type of data packet, requiring iterative processing. The existence of the third or fourth type of segmented data packets indicates that the distribution network protocol software does not have security vulnerabilities targeting these types of data packets, requiring further iteration to uncover more segmented data packets that confirm the existence of security vulnerabilities in the distribution network protocol software.
[0080] S310. Based on the classification results, iterate through the segmented data packets in the initial test cases, and after the iteration is completed, return to the step of sending the initial test cases to the target device until the test termination condition is met.
[0081] Optionally, based on the determined classification results, a genetic algorithm is used to iterate over the segmented data packets in the initial test cases. After the iteration is completed, if it is determined that the test termination condition is not met, the process returns to the step of sending the initial test cases to the target device, thereby starting a new round of testing.
[0082] In this embodiment, segmented data packets are accurately classified according to different classification indicators, which provides a guarantee for subsequent iterations of segmented data packets.
[0083] Figure 4 This is a flowchart of a software testing method according to an embodiment of this disclosure. See also... Figure 4 The software testing methods are as follows:
[0084] S401. When configuring the network with the target device, send the initial test cases to the target device.
[0085] The initial test cases are used to test whether the software implementing the distribution network protocol has vulnerabilities, and the initial test cases include at least one segmented data packet.
[0086] S402. In response to the feedback information from the target device regarding the initial test case, classify the segmented data packets in the initial test case.
[0087] S403. Based on the classification results, calculate the fitness of different types of segmented data packets.
[0088] Fitness measures the probability of fragmented data packets exceeding the target device's preset buffer size when buffering them. Optionally, based on the classification results, fitness is calculated for different types of fragmented data packets, including:
[0089] Based on the classification results, the classification weight *w* of the segmented data packets is determined. For example, the classification weight *w* for the second type of segmented data packets is 3; the classification weight *w* for the third type of segmented data packets is 2; and the classification weight *w* for the fourth type of segmented data packets is 1. It should be noted that since the first type of segmented data packets can be directly inherited by the next generation without iterative updates, no classification weight needs to be assigned to calculate the fitness of the first type of segmented data packets. Based on the determined classification weights, considering that the root cause of memory corruption in the target device is that segmented data packets are cached outside the allocated buffer, the closer the boundary of the cached data packets is to the boundary of the buffer, the more likely it is to trigger memory corruption. Therefore, this type of segmented data packet should have a higher fitness. Thus, the fitness of the segmented data packets is calculated based on the classification weight, the data packet number of the segmented data packet, and the data packet payload length. Optionally, for any segmented data packet, the fitness is calculated using the following function: fitness = w × (20 + 23 × (seg_idx - 1) + data_len); where data_len is the payload length of the segmented data packet for which fitness is to be calculated; seg_idx is the data packet number of the segmented data packet for which fitness is to be calculated; w is the classification weight corresponding to the segmented data packet for which fitness is to be calculated; 20 is the expected payload length of the data packet; 23 is the payload length of the segmented data packet specified by the distribution network protocol; and 23 × (seg_idx - 1) represents the total payload length of all segmented data packets whose data packet numbers precede the segmented data packet for which fitness is to be calculated. It should be noted that considering classification weights when calculating fitness can avoid the problem of excessively large differences in fitness among segmented data packets of the same type.
[0090] S404. Based on the fitness of the segmented data packets, use genetic operations to iterate the segmented data packets in the initial test case, and after the iteration is completed, return to the step of sending the initial test case to the target device, until the test termination condition is met.
[0091] For example, the initial test case contains N segmented data packets, of which M are of the first type. These M first-type segmented data packets can be directly inherited to the next generation. For the remaining NM segmented data packets, iterative inheritance operations such as selection, crossover, and mutation can be performed. For instance, the roulette wheel algorithm can be used to repeatedly select NM segmented data packets to form a set C1. The segmented data packets in set C1 are used as parent packets, with a crossover probability P. cDecide whether to cross-segment the parent packet. If cross-segmentation is performed, randomly select a segmented data packet from the remaining individuals in C1 as the parent packet, reassemble the encoded information of the parent and parent packets, and then reconstruct a new segmented data packet based on the repeated encoded information; if cross-segmentation is not performed, use the parent packet as the new segmented data packet. After cross-segmentation, NM new segmented data packets are obtained, forming a set C2. Iterate through the segmented data packets in C2 with a mutation probability P. m A decision is made as to whether to mutate the segmented data packet. After mutation, NM new segmented data packets are obtained, forming set C3. Finally, the M severe first-class segmented data packets are merged with set C3 to form the iteratively updated segmented data packets. This achieves the iterative update of the segmented data packets in the initial test case.
[0092] In this embodiment, through continuous iteration, segmented data packets that indicate security vulnerabilities in the distribution network protocol software can be accurately filtered out, facilitating subsequent vulnerability analysis based on the filtered segmented data packets.
[0093] Figure 5 This is a schematic diagram of a software testing apparatus according to an embodiment of the present disclosure. This embodiment is applicable to testing whether software implementing a network configuration protocol has security vulnerabilities, typically applicable to scenarios where software implementing a Bluetooth mesh network configuration protocol has vulnerabilities. See also Figure 5 The device includes:
[0094] The data sending module 501 is used to send initial test cases to the target device when performing network configuration with the target device; wherein, the initial test cases are used to test whether there are vulnerabilities in the software implementing the network configuration protocol, and the initial test cases include at least one segmented data packet;
[0095] The classification module 502 is used to classify the segmented data packets in the initial test cases in response to the feedback information from the target device to the initial test cases;
[0096] The iteration module 503 is used to iterate over the segmented data packets in the initial test case according to the classification results, and after the iteration is completed, return to execute the step of sending the initial test case to the target device until the test termination condition is met.
[0097] Optionally, based on the above embodiments, an initial test case generation module is also included, used for:
[0098] Obtain a test sample; wherein the test sample includes an expected data packet and at least one segmented data packet for testing; the expected data packet includes the total length of the test sample data and the total number of data packets;
[0099] Determine the encoding information corresponding to each segmented data packet; the encoding information includes the data packet number and the data packet payload length of the segmented data packet;
[0100] The segmented data packets are initialized based on the preset value ranges of the data packet number and the data packet payload length to obtain the initial test cases.
[0101] Based on the above embodiments, optionally, the feedback information includes a distribution network end message and / or the serial port log of the target device;
[0102] The classification module includes:
[0103] The receiving verification unit is used to determine whether the segmented data packets in the initial test case are received by the target device based on the distribution network end message and / or the serial port log of the target device;
[0104] The specification verification unit is used to determine whether the segmented data packets in the initial test cases meet the distribution network protocol specifications.
[0105] The out-of-range verification unit is used to determine whether the segmented data packets in the initial test case exceed the preset buffer area of the target device when they are cached in the target device.
[0106] The classification unit is used to determine the type of segmented data packets based on whether the segmented data packets are received by the target device, whether they meet the network distribution protocol specifications, and whether they exceed the target device's preset buffer area.
[0107] Optionally, based on the above embodiments, the receiving verification unit is further configured to:
[0108] If the distribution network end message is received during the segmented data packet transmission process, it is determined that only the segmented data packets prior to triggering the distribution network end message were received by the target device.
[0109] If the network distribution end message is triggered by a timeout, it confirms that all segmented data packets have been received by the target device.
[0110] Based on the above embodiments, optionally, the specification verification unit is also used for:
[0111] For any segmented data packet, if the following conditions are met, then the segmented data packet is determined to conform to the distribution network protocol specification:
[0112] The packet number of a segmented data packet is less than or equal to the total number of data packets;
[0113] If the data packet number is less than the total number of data packets, the data packet payload length of the segmented data packet is the first threshold.
[0114] If the data packet number equals the total number of data packets, the data packet payload length of the segmented data packet is within the first preset range;
[0115] Based on the packet number and packet payload length of the segmented data packets, determine whether the length of the segmented data packets cached in the target device is less than or equal to the total data length.
[0116] Based on the above embodiments, optionally, the out-of-range verification unit is further configured to:
[0117] If, based on the packet number and payload length of the segmented data packet, it is determined that the length of the segmented data packet cached in the target device is greater than the length of the target device's preset buffer, then it is determined that the segmented data packet exceeds the buffer area when cached in the target device.
[0118] Based on the above embodiments, optionally, the classification unit is also used for:
[0119] Segmented data packets that are received by the target device and exceed the preset buffer area and violate the network distribution protocol specifications are classified as first-class segmented data packets;
[0120] Segmented data packets that violate the network distribution protocol specifications and are received by the target device but do not exceed the buffer are classified as second-type segmented data packets.
[0121] Segmented data packets that are received by the target device and do not exceed the buffer area and conform to the network distribution protocol specifications are classified as Category 3 segmented data packets.
[0122] Segmented data packets that are rejected by the target device and violate the distribution network protocol specifications are classified as Category 4 segmented data packets.
[0123] Based on the above embodiments, optionally, the iteration module includes:
[0124] The fitness determination unit is used to calculate the fitness of different types of segmented data packets based on the classification results; wherein, the fitness is used to measure the probability of exceeding the target device's preset buffer when caching segmented data packets;
[0125] The iteration unit is used to iterate the segmented data packets in the initial test case using genetic operations based on the fitness of the segmented data packets, and after the iteration is completed, return to execute the step of sending the initial test case to the target device, until the test termination condition is met.
[0126] Based on the above embodiments, optionally, the fitness determination unit is further configured to:
[0127] Based on the classification results, determine the classification weights of the segmented data packets;
[0128] The fitness of the segmented data packets is calculated based on the classification weight, the data packet number of the segmented data packets, and the data packet payload length.
[0129] In addition to the above embodiments, optionally, the following further includes:
[0130] The save module is used to save the initial test cases and end the test if the network configuration process on the target device is determined to have crashed based on the feedback information.
[0131] The software testing apparatus provided in this disclosure can execute the software testing methods provided in any embodiment of this disclosure, and has the corresponding functional modules and beneficial effects for executing the methods. Content not described in detail in this embodiment can be referred to the descriptions in any method embodiment of this disclosure.
[0132] The acquisition, storage, and application of user personal information involved in the technical solution disclosed herein comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0133] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0134] Figure 6 A schematic block diagram of an example electronic device 600 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0135] like Figure 6 As shown, device 600 includes a computing unit 601, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 602 or a computer program loaded from storage unit 608 into random access memory (RAM) 603. RAM 603 may also store various programs and data required for the operation of device 600. The computing unit 601, ROM 602, and RAM 603 are interconnected via bus 604. Input / output (I / O) interface 605 is also connected to bus 604.
[0136] Multiple components in device 600 are connected to I / O interface 605, including: input unit 606, such as keyboard, mouse, etc.; output unit 607, such as various types of monitors, speakers, etc.; storage unit 608, such as disk, optical disk, etc.; and communication unit 609, such as network card, modem, wireless transceiver, etc. Communication unit 609 allows device 600 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0137] The computing unit 601 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 601 performs the various methods and processes described above, such as software testing methods. For example, in some embodiments, the software testing method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on device 600 via ROM 602 and / or communication unit 609. When the computer program is loaded into RAM 603 and executed by the computing unit 601, one or more steps of the software testing method described above may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to perform software testing methods by any other suitable means (e.g., by means of firmware).
[0138] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0139] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0140] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0141] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0142] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0143] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.
[0144] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0145] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A software testing method, comprising: When configuring the network with the target device, an initial test case is sent to the target device; wherein, the initial test case is used to test whether there are vulnerabilities in the software implementing the network configuration protocol, and the initial test case includes at least one segmented data packet; In response to the feedback information from the target device regarding the initial test case, the segmented data packets in the initial test case are classified. The feedback information includes a distribution network completion message and / or the serial port log of the target device; The classification of segmented data packets in the initial test cases includes: Based on the network distribution end message and / or the serial port log of the target device, determine whether the segmented data packets in the initial test case are received by the target device; Determine whether the segmented data packets in the initial test case meet the network distribution protocol specifications; Determine whether the segmented data packets in the initial test case exceed the preset buffer area of the target device when cached in the target device; The type of the segmented data packet is determined based on whether the segmented data packet is received by the target device, whether it meets the network distribution protocol specifications, and whether it exceeds the preset buffer of the target device. Based on the classification results, determine the classification weight of the segmented data packets; The fitness of the segmented data packets is calculated based on the classification weight, the data packet number of the segmented data packets, and the data packet payload length, so that the segmented data packets closer to the boundary of the target device's preset buffer have a higher fitness; wherein, the fitness is used to measure the probability of the segmented data packets exceeding the target device's preset buffer when caching them; Based on the fitness of the segmented data packets, the segmented data packets in the initial test case are iterated using genetic operations. After the iteration is completed, the process returns to the step of sending the initial test case to the target device until the test termination condition is met.
2. The method according to claim 1, wherein, The process of generating the initial test cases includes: Obtain a test sample; wherein the test sample includes an expected data packet and at least one segmented data packet for testing; the expected data packet includes the total data length and the total number of data packets of the test sample; Determine the encoding information corresponding to each segmented data packet; wherein, the encoding information includes the data packet number and data packet payload length of the segmented data packet; The segmented data packets are initialized according to the preset value ranges of the data packet number and the data packet payload length to obtain the initial test cases.
3. The method according to claim 2, wherein, Based on the network distribution end message, determine whether the segmented data packets in the initial test case are received by the target device, including: If the distribution network end message is received during the segmented data packet transmission process, it is determined that only the segmented data packets prior to triggering the distribution network end message were received by the target device. If the network distribution end message is triggered by a timeout, it is determined that all segmented data packets have been received by the target device.
4. The method according to claim 2, wherein, Determining whether the segmented data packets in the initial test case meet the network distribution protocol specifications includes: For any of the segmented data packets, if the following conditions are met, then the segmented data packet is determined to conform to the distribution network protocol specification: The data packet number of the segmented data packet is less than or equal to the total number of data packets; If the data packet number is less than the total number of data packets, the data packet payload length of the segmented data packet is a first threshold. If the data packet number is equal to the total number of data packets, the data packet payload length of the segmented data packet is within a first preset range; Based on the packet number and packet payload length of the segmented data packets, it is determined that the length of the segmented data packets cached in the target device is less than or equal to the total data length.
5. The method according to claim 2, wherein, Determining whether the segmented data packets in the initial test case exceed the preset buffer area of the target device when cached in the target device includes: If, based on the data packet number and data packet payload length of the segmented data packet, it is determined that the length of the segmented data packet cached in the target device is greater than the length of the target device's preset buffer, then it is determined that the segmented data packet exceeds the buffer area when cached in the target device.
6. The method according to claim 2, wherein, The type of the segmented data packet is determined based on whether the segmented data packet is received by the target device, whether it meets the network distribution protocol specifications, and whether it exceeds the target device's preset buffer area, including: Segmented data packets that are received by the target device and exceed the preset buffer area and violate the network distribution protocol specifications are classified as first-type segmented data packets. Segmented data packets that violate the network distribution protocol specifications and are received by the target device but do not exceed the buffer area are classified as second-type segmented data packets. Segmented data packets that are received by the target device and do not exceed the buffer area and conform to the network distribution protocol specifications are classified as third-type segmented data packets; Segmented data packets that are rejected by the target device and violate the distribution network protocol specifications are classified as fourth-type segmented data packets.
7. The method according to claim 1, further comprising: If the feedback information indicates that the network configuration process on the target device has crashed, the initial test case will be saved and the test will be terminated.
8. A software testing apparatus, comprising: The data sending module is used to send initial test cases to the target device when performing network configuration with the target device; wherein, the initial test cases are used to test whether there are vulnerabilities in the software implementing the network configuration protocol, and the initial test cases include at least one segmented data packet; A classification module is used to classify the segmented data packets in the initial test case in response to the feedback information from the target device to the initial test case; The feedback information includes a distribution network completion message and / or the serial port log of the target device; The classification module includes: The receiving verification unit is used to determine whether the segmented data packets in the initial test case are received by the target device based on the network distribution end message and / or the serial port log of the target device; A standard verification unit is used to determine whether the segmented data packets in the initial test case meet the distribution network protocol specifications. An out-of-range verification unit is used to determine whether the segmented data packets in the initial test case exceed the preset buffer area of the target device when cached in the target device. The classification unit is used to determine the type of the segmented data packet based on whether the segmented data packet is received by the target device, whether it meets the distribution network protocol specifications, and whether it exceeds the preset buffer of the target device. The iteration module is used to iterate the segmented data packets in the initial test case according to the classification result, and return to the step of sending the initial test case to the target device after the iteration is completed, until the test termination condition is met; The iterative module includes: The fitness determination unit is used to calculate the fitness of different types of segmented data packets based on the classification results; wherein, the fitness is used to measure the probability of exceeding the preset buffer of the target device when caching the segmented data packets; the fitness determination unit is also used to determine the classification weight of the segmented data packets based on the classification results; and to calculate the fitness of the segmented data packets based on the classification weight, the data packet number of the segmented data packets, and the data packet payload length, so that the segmented data packets closer to the boundary of the preset buffer of the target device have higher fitness; An iteration unit is used to iterate over the segmented data packets in the initial test case using genetic operations based on the fitness of the segmented data packets, and after the iteration is completed, return to execute the step of sending the initial test case to the target device until the test termination condition is met.
9. The apparatus according to claim 8, further comprising an initial test case generation module, used for: Obtain test samples; among which, The test sample includes a target data packet and at least one segmented data packet for testing; the target data packet includes the total length of the test sample and the total number of data packets. Determine the encoding information corresponding to each segmented data packet; wherein, the encoding information includes the data packet number and data packet payload length of the segmented data packet; The segmented data packets are initialized according to the preset value ranges of the data packet number and the data packet payload length to obtain the initial test cases.
10. The apparatus according to claim 9, wherein, The receiving verification unit is also used for: If the distribution network end message is received during the segmented data packet transmission process, it is determined that only the segmented data packets prior to triggering the distribution network end message were received by the target device. If the network distribution end message is triggered by a timeout, it is determined that all segmented data packets have been received by the target device.
11. The apparatus according to claim 9, wherein, The specification verification unit is also used for: For any of the segmented data packets, if the following conditions are met, then the segmented data packet is determined to conform to the distribution network protocol specification: The data packet number of the segmented data packet is less than or equal to the total number of data packets; If the data packet number is less than the total number of data packets, the data packet payload length of the segmented data packet is a first threshold. If the data packet number is equal to the total number of data packets, the data packet payload length of the segmented data packet is within a first preset range; Based on the packet number and packet payload length of the segmented data packets, it is determined that the length of the segmented data packets cached in the target device is less than or equal to the total data length.
12. The apparatus according to claim 9, wherein, The out-of-range verification unit is also used for: If, based on the data packet number and data packet payload length of the segmented data packet, it is determined that the length of the segmented data packet cached in the target device is greater than the length of the target device's preset buffer, then it is determined that the segmented data packet exceeds the buffer area when cached in the target device.
13. The apparatus according to claim 9, wherein, The classification unit is also used for: Segmented data packets that are received by the target device and exceed the preset buffer area and violate the network distribution protocol specifications are classified as first-type segmented data packets. Segmented data packets that violate the network distribution protocol specifications and are received by the target device but do not exceed the buffer area are classified as second-type segmented data packets. Segmented data packets that are received by the target device and do not exceed the buffer area and conform to the network distribution protocol specifications are classified as third-type segmented data packets; Segmented data packets that are rejected by the target device and violate the distribution network protocol specifications are classified as fourth-type segmented data packets.
14. The apparatus of claim 8, further comprising: The save module is used to save the initial test case and end the test if it is determined from the feedback information that the network configuration process on the target device has crashed.
15. An electronic device comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the software testing method according to any one of claims 1-7.
16. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to execute the software testing method according to any one of claims 1-7.
17. A computer program product comprising a computer program that, when executed by a processor, implements the software testing method according to any one of claims 1-7.
Citation Information
Patent Citations
Modbus TCP fuzzy testing method based on genetic algorithm
CN112769654A
Method and device for testing network distribution function of software
CN114978644A