Multi-entry testing method based on coverage guidance for Android application program

Through a multi-entry testing method based on coverage guidance, combined with gray box fuzz testing and symbolic execution, the problem of insufficient test coverage of Android applications is solved, achieving deeper code coverage and more efficient testing efficiency, and enhancing crash detection capabilities. .

CN118747151AActive Publication Date: 2024-10-08JIANGXI NORMAL UNIV

Patent Information

Application Number
CN202410768230.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-14
Publication Date
2024-10-08
Estimated Expiration
2044-06-14

AI Technical Summary

Technical Problem

Existing technologies have insufficient test coverage for Android applications and are unable to discover deep vulnerabilities and missing structures, and the fuzz testing methods lack diversity and path sensitivity, resulting in the inability to fully test applications.

Method used

Adopt a multi-entry testing method based on coverage guidance, combine gray box fuzz testing and symbolic execution, detect methods and branches through instrumentation tools, use Jimple to analyze bytecode, generate effective intent test cases, and implement dynamic multi-entry through APE tools Explore strategies to improve testing efficiency and coverage.

Benefits of technology

Effectively extract intent attribute values, cover more deep code blocks, improve application exploration efficiency and crash detection capabilities, generate efficient user events, and enhance test coverage and diversity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118747151A_ABST
    Figure CN118747151A_ABST
Patent Text Reader

Abstract

The invention discloses an Android application program-oriented multi-entry test method based on coverage guidance, which comprises the following steps of: firstly, executing static analysis on an Android application program to extract path constraints related to intention attributes, and generating proper attribute values for the intention attributes by analyzing different constraints; then, a fuzzy Activity starting context is constructed in combination with an intention fuzzy testing technology; designing a dynamic Activity recommendation algorithm according to the characteristics of a multi-entry test, and then realizing a self-adaptive multi-entry exploration strategy in combination with an exploration tool APE; and finally, introducing a coverage rate guided grey box fuzzy test thought to realize a multi-entrance test method based on coverage guidance. According to the method, the testing efficiency of the application program can be effectively improved, and potential errors which are difficult to find in the program can be successfully detected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of application error / fault detection, and in particular relates to a coverage-guided multi-entry testing method for Android applications. Background Art

[0002] In order to meet market demand and competitive pressure, mobile applications are usually launched quickly and updated frequently, which may lead to a series of error / fault detection problems in applications, such as fragmented version compatibility, imperfect error handling and fault tolerance mechanisms, exploitation of security vulnerabilities, and insufficient test coverage. When these problems are not discovered and fixed in time, they may cause serious economic losses. Therefore, it is particularly important to improve the stability, reliability, and security of Android applications. In order to meet these challenges, researchers are actively exploring suitable solutions.

[0003] In recent years, a large number of researchers have focused on improving the test coverage of applications to discover more potential errors and failures. They have proposed many advanced testing techniques and tools to improve the quality of applications and user experience. These techniques specifically include test case generation, test case selection, test case reuse, and test case recording and reproduction methods. Compared with traditional manual testing methods, these techniques can be combined with automated testing methods to make full use of test cases to automatically generate random or specific rules and scenarios based event sequences. By injecting these events into applications, they can highly simulate the user's interaction process with the application, thereby covering different functional scenarios, realizing automated crash location, and are expected to verify the correctness and compatibility of applications on multiple Android versions.

[0004] On the other hand, fuzz testing is a widely used testing method that is conducive to discovering and fixing security vulnerabilities in mobile applications, and has obvious advantages in improving the security and robustness of applications. It can effectively detect security vulnerabilities such as buffer overflow, malicious code injection, and cross-site scripting attacks, as well as crashes caused by digital format exceptions, null pointer exceptions, and array out-of-bounds exceptions. Depending on the input generation method, fuzz testing is usually divided into generation-based fuzz testing and mutation-based fuzz testing. The core idea of ​​traditional fuzz testing is to inject randomly generated or mutated input data into the target application to discover security vulnerabilities and abnormal behaviors that may occur when the application handles abnormal or invalid input. However, it belongs to the black-box testing method and lacks the understanding of the internal structure of the target program. In order to make up for the shortcomings of this method, researchers have developed a gray-box fuzz testing method by introducing monitoring and analysis of the internal execution of the target application.

[0005] In addition, researchers have combined the advantages of program analysis and applied fuzz testing technology to Android's ICC mechanism, making important progress in the field of inter-process communication fuzz testing. For Android intent fuzz testing, since the birth of nullintent fuzzer, researchers have begun to use fuzz testing technology to detect security issues related to application intent processing, such as intent injection, malicious intent hijacking, and intent parsing vulnerabilities. Some typical works include Intent Fuzzer, IntentDroid, and FuzzDroid. These tools use program analysis techniques such as static analysis, dynamic analysis, or local symbolic execution to extract intent-related attribute values ​​from the bytecode and configuration files of the application with the help of control flow graphs and data flow graphs. By combining methods such as random value generation and mutation, they successfully constructed fuzzy intent test cases. However, since only simple program analysis methods are used, these methods cannot guarantee the integrity of the structure of the constructed intent test cases, and there are problems of missing structures and missing attributes, which will cause them to fail to cover important functions of the application. In addition, these methods do not consider different execution paths and conditional branches, and are path-insensitive methods that cannot guide the program to trigger more paths and enter deep code locations.

[0006] To achieve this research goal, some cutting-edge researchers have proposed innovative solutions Fax and DALT. They use symbolic execution to carry out Activity startup testing and improve some of the shortcomings of symbolic execution. By solving the path constraints related to ICC with the help of SMT solvers, ICC messages with suitable attribute values ​​are generated, and effective intent test cases are constructed. Although these methods effectively improve the sensitivity of the path and further improve the ability of the program to discover deep vulnerabilities. However, they still cannot fully test the application and face the challenge of coverage requirements, which means that some potential errors and failures remain undetected. And when the intent attributes involve complex or special data types, finding vulnerabilities under their related constraints will be limited. In addition, due to the use of simple value filling or mutation strategies, the generated fuzzy test cases lack diversity. Summary of the invention

[0007] The purpose of the present invention is to propose a coverage-guided multi-entry testing method for Android applications in response to the deficiencies in the prior art. The multi-entry testing method is combined with the coverage-guided gray-box fuzz testing idea, and the application code is tested for methods and branches with the help of a plug-in tool to verify the testing efficiency of the application and detect potential errors within it.

[0008] In order to achieve the above technical objectives, the present invention adopts the following technical solutions.

[0009] A coverage-guided multi-entry testing system for Android applications includes a preprocessing module, a static analysis module, a fuzzy Activity startup context building module, and a coverage-guided multi-entry exploration module; the preprocessing module is used to expose the Internal Activity of APK as ExportedActivity, and perform method-level and branch-level detection on the exposed APK; the static analysis module is used to perform inter-procedural, context-sensitive, flow-sensitive, and path-sensitive analysis, and Jimple is selected as the intermediate language of Soot to analyze the bytecode of the application to obtain inter-procedural control flow graph, method call graph, static Activity transition graph, and three program complexity features of the number of statements, the number of branches, and the number of calling method types; the fuzzy Activity startup context building module adopts symbolic execution, path reversal, and path reversal to analyze the bytecode of the application. Reversal and intent fuzzing testing IntentFuzzing methods pre-mutate the generated ICC messages to construct effective intent test cases; the coverage-guided multi-entry exploration module combines the principles of coverage-guided gray-box fuzz testing, the designed Activity recommendation algorithm and the exploration tool APE to perform multi-entry testing on all exploration entries of the application in a targeted manner.

[0010] A testing method for the coverage-guided multi-entry testing system for Android applications as described above comprises the following steps:

[0011] Step S1, the preprocessing module uses the Android reverse tool APKTool to decompile the APK file to obtain the manifest file, resource file and Smali code information; then uses DOM to parse the decompiled manifest file, and changes the exported attribute of the Activity node to realize component exposure; continues to use the back compilation function provided by APKTool to perform signature verification and repackage the file into an executable APK;

[0012] Step S2: The preprocessing module uses the instrumentation tool to perform method-level and branch-level detection on the Smali code of the exposed APK to facilitate the statistical calculation of method coverage and branch coverage;

[0013] Step S3, the static analysis module uses Jimple as the intermediate language of Soot to analyze the bytecode of the application program, and obtains the inter-procedural control flow graph, method call graph, static Activity transition graph, and three program complexity features: the number of statements, the number of branches, and the number of called method types;

[0014] Step S4, the static analysis module uses the Jadx tool to obtain the source code of the APK, and then tracks the API methods related to layout view loading; after obtaining the layout file bound to the Activity, recursively traverse all resource file paths and analyze their corresponding ElementTrees; according to different label nodes in the tree, the types and quantities of common UI controls are counted to obtain the characteristic value of the number of UI controls of the Activity;

[0015] Step S5: construct a fuzzy Activity startup context module to generate ICC messages using symbolic execution; and analyze the path constraints to extract key intent attribute values;

[0016] Step S6: pass these key values ​​to the intent fuzz test program to participate in the pre-mutation process of the ICC message, and then use rich data sources to increase the diversity of test cases and generate effective fuzzy Activity startup context;

[0017] Step S7: The coverage-guided multi-entry exploration module implements an Activity recommendation algorithm using static analysis results and runtime information, and integrates the exploration tool APE to implement a dynamic multi-entry exploration strategy;

[0018] Step S8: Combine the coverage-guided grey-box fuzz testing concept to implement coverage-guided fuzz testing with feedback.

[0019] Specifically, the step S5 of constructing the fuzzy Activity startup context module to generate an ICC message using symbolic execution includes the following steps:

[0020] Step S51, modeling the intent object according to different intent attribute types, wherein the intent attribute types include basic attribute types and additional parameter types; traversing the execution path of the application along the inter-procedural control flow graph, and analyzing the corresponding bytecode;

[0021] Step S52: Check whether the application uses a predefined method related to intent acquisition to obtain an intent receiving variable;

[0022] Step S53: Use the def-use technology to track the use points of these intent receiving variables, and check whether the Units where they are located use methods related to the acquisition of intent attributes, and obtain the intent attribute receiving variables. For additional parameter types, it is also necessary to obtain their type-key fields.

[0023] Step S54, continue to track the usage points of these intent attribute receiving variables, and analyze the conditional expressions related to these variables and their intermediate transfer variables, and construct path constraints, wherein the path constraints related to the additional parameters will be used to analyze the key values, and the path constraints related to the basic attributes will be passed to the Z3 solver for attribute verification and solving, so as to prune infeasible paths and find potential attribute values ​​that meet the given constraint conditions;

[0024] Step S55: After the constraint solving is completed, the basic ICC message is extracted from the solving result, which mainly includes basic attributes with specific data and additional parameters including the type-key field.

[0025] Furthermore, the analysis of the path constraints in step S5 to extract key intent attribute values ​​includes the following steps:

[0026] Step S56, extracting additional path constraints related to additional parameters along different execution paths;

[0027] Step S57, invert the path constraints, construct different attribute paths, and reversely derive key values ​​that satisfy these constraints, where the key values ​​related to the basic attribute constraints are used to mutate the solved ICC message, and the key values ​​related to the additional parameter constraints are used to fill the corresponding additional parameter fields in the ICC message.

[0028] Specifically, the process of generating a valid fuzzy Activity startup context in step S6 is as follows:

[0029] Step S61: pass these key values ​​to the intent fuzz test program, and then compare the basic attribute values ​​of the basic ICC message with the declared data in the intent filter of the target component. If the match fails, first determine the target component to be sent, and then mutate it using the data declared in the corresponding intent filter and the key values ​​extracted from the constraints to generate a set of mutated ICC messages that are closer to the expected ones.

[0030] Step S62: For each ICC message, data is filled in a variety of ways according to the type and key name of the additional parameter, and the data sources include key values, fixed values, boundary values, randomly generated strings, positive and negative values, null values, and null references related to the additional parameter constraints;

[0031] Step S63: Generate a set of fuzzy Activity startup contexts by combining the name, startup flag, communication mode and other information of the target component.

[0032] Specifically, the coverage-guided multi-entry exploration module in step S7 implements an Activity recommendation algorithm using static analysis results and runtime information, including the following steps:

[0033] Step S71, calculating the priority value for each Activity component, and determining the Activity with the largest priority value, namely maxAct;

[0034] Step S72, determine whether maxAct is an exploration entry. If maxAct is an exploration entry, then give priority to valid intent test cases containing key values ​​as recommended results to be returned. If there is no such valid test case containing key values, then randomly select test cases from the valid test case set of maxAct and return them. If maxAct is not an exploration entry, determine whether maxAct is an isolated node. If it is an isolated node, there is no exploration entry in the ATG that can reach the node, so the return result of the algorithm is empty. If it is not an isolated node, calculate the distance from all exploration entries to maxAct according to the Activity transition graph, and recommend test cases for the Activity with the closest distance.

[0035] Step S73, determine whether there are multiple results with the shortest distance. If there are multiple results, calculate the average call depth from the lifecycle method and event handling method to the intent sending method according to the method call graph, and then recommend test cases for the Activity with the shortest distance. If the result is unique, directly recommend test cases for it.

[0036] Furthermore, the integrated exploration tool APE in step S7 implements a dynamic multi-entry exploration strategy, including the following steps:

[0037] Step S74: first use APE to explore the main entry point of the application for a fixed time to collect initial information;

[0038] Step S75, then iteratively call the Activity recommendation algorithm to obtain the intent test case to be sent. If the return value is empty, that is, there is no test case for recommendation, then randomly select a valid test case. If the return value is not empty, the exploration time is calculated based on the scale of the reachable nodes of its corresponding Activity in the Activity transition graph.

[0039] Specifically, the gray-box fuzz testing idea guided by coverage is combined in step S8 to implement the coverage-guided fuzz testing with feedback, including the following steps:

[0040] Step S81: Select a high-quality test case from the valid test case set of the recommended Activity as the initial seed for this round of iteration, and then add it to the test case queue. If there is no qualified high-quality initial seed, randomly select a valid test case as the initial seed for fuzzy testing;

[0041] Step S82, obtain the test sample from the test case queue and execute it, and save its runtime information to a global data structure; use the branch coverage information as the execution feedback of the current test case during the fuzz testing process. If the program monitors that the current test case can enable the application to cover a new branch path, the test sample will be quickly mutated according to the pre-mutation method, that is, it will regard the valid test case with different intent attribute values ​​that is pre-mutated from the same basic ICC message as the test sample as its mutated sample;

[0042] Step S83, adding the variant sample as an input of interest to the test case queue to continue testing it;

[0043] Step S84: Repeat the above fuzzy testing process continuously. If the current execution does not generate any new feedback, the program starts the next round of recommendation exploration.

[0044] Furthermore, in step S71, the priority value is calculated as follows:

[0045]

[0046] In the above formula, eFlag represents the exploration entry flag of Activity. If an Activity can be successfully started, it will be regarded as an exploration entry and eFlag will be assigned a value of 1. On the contrary, if the Activity cannot be started, its eFlag value is 0.5; mCov represents the mapping of Activity to its method coverage, reflecting the proportion of the number of currently covered methods to the number of all methods. After each round of exploration, mCov will be incrementally calculated and dynamically updated; rewardrNum[act] represents the reward of Activity, where the default value of reward is 2, rNum represents the number of times the Activity has not made any contribution to mCov after being recommended, and its initial value is 0; cConst is a program complexity constant, which is used to describe the mapping of program complexity and is calculated by the weighted entropy method. The calculation process is as follows:

[0047]

[0048] In the above formula, each Activity is associated with four program complexity features, including the number of user interface controls ui, the number of calling method types m, the number of statements un and the number of branches b. The algorithm will normalize their feature values ​​and calculate the probability value Pi[act] of each data, where the value range of i is [1,4], corresponding to the above four features respectively; Ei represents the information entropy of different features; Wi is their entropy weight; and aNum is the number of activities of the application.

[0049] Furthermore, the calculation formula of the exploration time in step S75 is as follows:

[0050]

[0051] In the above formula, nodereach is the number of nodes contained in the relevant subgraph of the Activity node corresponding to the test case in ATG; nodeall is the number of all nodes in ATG; time is a preset value, which is adjusted according to the total exploration time of the application.

[0052] Compared with the prior art, the present invention has the following beneficial effects:

[0053] 1. The method of the present invention can effectively extract and generate intent attribute values ​​that can enter different path conditions by adding analysis of path constraints related to additional attributes of intent, thereby covering more deep code blocks and discovering more deep vulnerabilities.

[0054] 2. The method of the present invention combines the model-based testing tool APE and makes full use of the advantages of the multi-entry testing method. By designing a dynamic Activity recommendation algorithm and introducing the coverage-guided gray-box fuzz testing concept, it can generate efficient user events and reasonably allocate exploration time. Compared with existing testing methods, it effectively improves the exploration efficiency and crash detection capabilities of the application. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present disclosure and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying creative work.

[0056] Figure 1 It is a flow chart of a coverage-guided multi-entry testing method for Android applications of the present invention;

[0057] Figure 2 It is the file structure after APK decompilation in the present invention;

[0058] Figure 3 This is the process of using the instrumentation tool to detect the Smali code of the Android application;

[0059] Figure 4 It is the layout and UI control commonly used in Android in the present invention;

[0060] Figure 5 is the key value extraction process in the embodiment of the present invention;

[0061] Figure 6 It is the pre-mutation process in the embodiment of the present invention;

[0062] Figure 7 This is the workflow of the Activity recommendation algorithm in the embodiment of the present invention. DETAILED DESCRIPTION

[0063] In order to enable those skilled in the art to better understand the technical solutions in this specification, a real-world application Padland will be used as an example to clearly and completely describe the technical solutions described in this specification in combination with the exemplary embodiments disclosed in this specification.

[0064] Example 1

[0065] The following example 1 shows an example related to intent reception and intent attribute manipulation, in which there is a difficult-to-find error. First, PadListActivity receives the intent passed to it by a component in the application and obtains the additional parameters "action" and "pad_id"; then the two attributes are judged. If the first condition is met, check whether the value of the "action" attribute is "delete"; if so, delete the corresponding records from the database one by one according to the id value in the "pad_id" attribute list, and pop up a prompt box to inform the user that the pad has been deleted; it can be noted that the "pad_id" attribute values ​​are stored in a StringArrayList type data structure, which are defined as String type, and these values ​​are parsed as Long type data in line 12; if the program does not restrict the value of the id in advance, when a string containing non-numeric characters (such as "a11") is used as an element of the "pad_id" attribute list, a NumberFormatException exception will be triggered.

[0066] Example 1

[0067]

[0068] A coverage-guided multi-entry testing system for Android applications includes a preprocessing module, a static analysis module, a fuzzy Activity startup context building module, and a coverage-guided multi-entry exploration module; the preprocessing module is used to expose the Internal Activity of APK as ExportedActivity, and perform method-level and branch-level detection on the exposed APK; the static analysis module is used to perform inter-procedural, context-sensitive, flow-sensitive, and path-sensitive analysis, and Jimple is selected as the intermediate language of Soot to analyze the bytecode of the application to obtain inter-procedural control flow graph, method call graph, static Activity transition graph, and three program complexity features of the number of statements, the number of branches, and the number of calling method types; the fuzzy Activity startup context building module adopts symbolic execution, path reversal, and path reversal to analyze the bytecode of the application. Reversal and intent fuzzing testing IntentFuzzing methods pre-mutate the generated ICC messages to construct effective intent test cases; the coverage-guided multi-entry exploration module combines the principles of coverage-guided gray-box fuzz testing, the designed Activity recommendation algorithm and the exploration tool APE to perform multi-entry testing on all exploration entries of the application in a targeted manner.

[0069] like Figure 1 As shown, the test method based on the above-mentioned coverage-guided multi-entry test system for Android applications includes the following steps:

[0070] Step S1: The preprocessing module uses the Android reverse tool APKTool to decompile the APK file and obtain the following Figure 2 The manifest file, resource file, and Smali code information shown in the figure are shown in the figure. Then, the decompiled manifest file is parsed using DOM, and the component is exposed by changing the exported attribute of the Activity node. The back compilation function provided by APKTool is continued to be used to verify the signature and repackage the file into an executable APK.

[0071] Step S2: Figure 3 As shown, the preprocessing module uses the instrumentation tool to perform method-level and branch-level detection on the Smali code of the exposed APK to facilitate the statistics of method coverage and branch coverage;

[0072] This example shows a Smali code snippet about the detected application Conversations in the dataset and its corresponding Java code snippet:

[0073] Smali code snippet for the Conversations app

[0074]

[0075] Corresponding Java code snippet

[0076]

[0077] Step S3, the static analysis module uses Jimple as the intermediate language of Soot to analyze the bytecode of the application program, and obtains the inter-procedural control flow graph, method call graph, static Activity transition graph, and three program complexity features: the number of statements, the number of branches, and the number of called method types;

[0078] Step S4: The static analysis module uses the Jadx tool to obtain the source code of the APK, and then tracks the API methods related to layout view loading; after obtaining the layout file bound to the Activity, recursively traverse all resource file paths and analyze their corresponding ElementTree, such as Figure 4 The following shows some common layout and UI control types in Android, as well as the inheritance relationship between them. The types and quantities of common UI controls are counted according to different label nodes in the tree, and the characteristic value of the number of UI controls in the Activity is obtained.

[0079] Step S5: Construct a fuzzy Activity startup context module and generate an ICC message using symbolic execution. The basic ICC message format extracted from the solution result is as follows, which mainly includes basic attributes with specific data and additional parameters including a type-key field;

[0080] ICC message format

[0081]

[0082] Step S51, modeling the intent object according to different intent attribute types, wherein the intent attribute types include basic attribute types and additional parameter types; traversing the execution path of the application along the inter-procedural control flow graph, and analyzing the corresponding bytecode;

[0083] Step S52: Check whether the application uses a predefined method related to intent acquisition to obtain an intent receiving variable;

[0084] Step S53: Use the def-use technology to track the use points of these intent receiving variables, and check whether the Units where they are located use methods related to the acquisition of intent attributes, and obtain the intent attribute receiving variables. For additional parameter types, it is also necessary to obtain their type-key fields.

[0085] Step S54, continue to track the usage points of these intent attribute receiving variables, and analyze the conditional expressions related to these variables and their intermediate transfer variables, and construct path constraints, wherein the path constraints related to the additional parameters will be used to analyze the key values, and the path constraints related to the basic attributes will be passed to the Z3 solver for attribute verification and solving, so as to prune infeasible paths and find potential attribute values ​​that meet the given constraint conditions;

[0086] Step S55: After the constraint solving is completed, extract the basic ICC message from the solving result, which mainly includes basic attributes with specific data and additional parameters including the type-key field;

[0087] Analyze path constraints and extract key intent attribute values;

[0088] Step S56, extracting additional path constraints related to additional parameters along different execution paths;

[0089] Step S57: invert the path constraint conditions, construct different attribute paths, and reversely derive key values ​​that satisfy these constraint conditions, wherein the key values ​​related to the basic attribute constraints are used to mutate the solved ICC message, and the key values ​​related to the additional parameter constraints are used to fill the corresponding additional parameter fields in the ICC message;

[0090] For example, for the additional parameter "action" in Example 1, the process of extracting the key value of its intent attribute is as follows: Figure 5 As shown, first extract the constraints related to it (actionStr,!=,null) and (actionStr,equals,"delete"), then negate the constraints to get three attribute paths: [(actionStr,!=,null), (actionStr,equals,"delete")], [(actionStr,!=,null),! (actionStr,equals,"delete")], [! (actionStr,!=,null)], then reverse them to get the key values ​​{"delete","delete"+suffix,null}, finally fill these values ​​as valid data into the "action" additional parameter field of the ICC message to generate a valid Activity startup context, thereby triggering deep code blocks and covering more paths;

[0091] Step S6: pass these key values ​​to the intent fuzz test program to participate in the pre-mutation process of the ICC message, and then use rich data sources to increase the diversity of test cases and generate effective fuzzy Activity startup context;

[0092] Step S61: pass these key values ​​to the intent fuzz test program, and then compare the basic attribute values ​​of the basic ICC message with the declared data in the intent filter of the target component. If the match fails, first determine the target component to be sent, and then mutate it using the data declared in the corresponding intent filter and the key values ​​extracted from the constraints to generate a set of mutated ICC messages that are closer to the expected ones.

[0093] Step S62: For each ICC message, data is filled in a variety of ways according to the type and key name of the additional parameter, and the data sources include key values, fixed values, boundary values, randomly generated strings, positive and negative values, null values, and null references related to the additional parameter constraints;

[0094] Step S63: Generate a set of fuzzy Activity startup contexts by combining the name, startup flag, and communication mode of the target component;

[0095] like Figure 6 The figure shows the pre-mutation process of Example 1. Since there are no constraints related to basic attributes in the ICC path corresponding to this example, the basic attribute values ​​of the basic ICC message are all null, so the basic attributes of the intent are not mutated. Next, the attribute key values ​​extracted above and the diversified data from other data sources are used to mutate the basic ICC message according to the types of "action" and "pad_id" (i.e., String and StringArrayList), and a set of mutated ICC messages (such as ICC1-4) are generated. Then, the component name "padListActivity", the startup flag "true" and the explicit communication method are added to these mutated ICC messages, and a set of fuzzy Activity startup contexts that can reach the deep code of the program can be constructed. For example, when the Activity startup context corresponding to ICC2 is used as the intent test case to be sent, the program can enter the deepest position and cover as many paths as possible.

[0096] Step S7: The coverage-guided multi-entry exploration module implements an Activity recommendation algorithm using static analysis results and runtime information, and integrates the exploration tool APE to implement a dynamic multi-entry exploration strategy;

[0097] Step S71, calculating the priority value for each Activity component, and determining the Activity with the largest priority value, namely maxAct;

[0098] like Figure 7 The figure shows the implementation process of the Activity recommendation algorithm, where the priority value is calculated as follows:

[0099]

[0100] In the above formula, eFlag represents the exploration entry flag of Activity. If an Activity can be successfully started, it will be regarded as an exploration entry and eFlag will be assigned a value of 1. On the contrary, if the Activity cannot be started, its eFlag value is 0.5; mCov represents the mapping of Activity to its method coverage, reflecting the proportion of the number of currently covered methods to the number of all methods. After each round of exploration, mCov will be incrementally calculated and dynamically updated; rewardrNum[act] represents the reward of Activity, where the default value of reward is 2, rNum represents the number of times the Activity has not made any contribution to mCov after being recommended, and its initial value is 0; cConst is a program complexity constant, which is used to describe the mapping of program complexity and is calculated by the weighted entropy method. The calculation process is as follows:

[0101]

[0102] In the above formula, each Activity is associated with four program complexity features, including the number of user interface controls ui, the number of call method types m, the number of statements un, and the number of branches b. The algorithm normalizes their feature values ​​and calculates the probability value Pi[act] of each data, where the value range of i is [1,4], corresponding to the above four features respectively; Ei represents the information entropy of different features; Wi is their entropy weight; and aNum is the number of activities of the application;

[0103] Step S72, determine whether maxAct is an exploration entry. If maxAct is an exploration entry, then give priority to valid intent test cases containing key values ​​as recommended results to be returned. If there is no such valid test case containing key values, then randomly select test cases from the valid test case set of maxAct and return them. If maxAct is not an exploration entry, determine whether maxAct is an isolated node. If it is an isolated node, there is no exploration entry in the ATG that can reach the node, so the return result of the algorithm is empty. If it is not an isolated node, calculate the distance from all exploration entries to maxAct according to the Activity transition graph, and recommend test cases for the Activity with the closest distance.

[0104] Step S73: determine whether there are multiple results with the shortest distance. If there are multiple results, calculate the average call depth from the lifecycle method and the event processing method to the intent sending method according to the method call graph, and then recommend a test case for the Activity with the shortest distance. If the result is unique, directly recommend a test case for it.

[0105] Integrate the exploration tool APE to implement a dynamic multi-entry exploration strategy;

[0106] Step S74: first use APE to explore the main entry point of the application for a fixed time to collect initial information;

[0107] Step S75, then iteratively call the Activity recommendation algorithm to obtain the intent test case to be sent. If the return value is empty, that is, there is no test case for recommendation, then randomly select a valid test case. If the return value is not empty, then calculate the exploration time according to the scale of the reachable nodes of its corresponding Activity in the Activity transition graph;

[0108] The calculation formula of the exploration time is as follows:

[0109]

[0110] In the above formula, nodereach is the number of nodes contained in the relevant subgraph of the Activity node corresponding to the test case in ATG; nodeall is the number of all nodes in ATG; time is a preset value, which is adjusted according to the total exploration time of the application;

[0111] Step S8: Combining the idea of ​​gray-box fuzz testing guided by coverage, implementing fuzz testing guided by coverage with feedback;

[0112] Step S81: Select a high-quality test case from the valid test case set of the recommended Activity as the initial seed for this round of iteration, and then add it to the test case queue. If there is no qualified high-quality initial seed, randomly select a valid test case as the initial seed for fuzzy testing;

[0113] Step S82, obtain the test sample from the test case queue and execute it, and save its runtime information to a global data structure; use the branch coverage information as the execution feedback of the current test case during the fuzz testing process. If the program monitors that the current test case can enable the application to cover a new branch path, the test sample will be quickly mutated according to the pre-mutation method, that is, it will regard the valid test case with different intent attribute values ​​that is pre-mutated from the same basic ICC message as the test sample as its mutated sample;

[0114] Step S83, adding the variant sample as an input of interest to the test case queue to continue testing it;

[0115] Step S84: Repeat the above fuzzy testing process continuously. If the current execution does not generate any new feedback, the program starts the next round of recommendation exploration.

[0116] For example, for Example 1, assume that padListActivity is recommended as an exploration entry in a certain iteration, and assume that the set of valid test cases related to padListActivity is {C1, C2, C3}, and these intention test cases correspond to {ICC1, ICC2, ICC3} in the ICC message format. It can be observed that the attribute "action" of ICC1 and ICC2 has the key value "delete", so C1 and C2 are screened as high-quality test cases. Assuming that C1 is selected as the initial seed for fuzz testing, and new branch coverage feedback information is successfully generated after obtaining and executing the sample, in this case, the valid test cases C2 and C3 that are pre-mutated from the same basic ICC message together with C1 will be regarded as its mutated samples, and they will be added to the test case queue as interesting test samples to continue testing them. By using this method, the seed can be mutated quickly without rebuilding the auxiliary application, thereby guiding the program into different branch paths.

[0117] The above is only a preferred embodiment of the present invention, and does not limit the present invention in other forms. Any technician familiar with the profession may use the above disclosed technical content to change or modify it into an equivalent embodiment with equivalent changes. However, any simple modification, equivalent change and modification made to the above embodiment according to the technical essence of the present invention without departing from the technical solution of the present invention still belongs to the protection scope of the technical solution of the present invention.

Claims

1. A coverage-guided multi-entry testing system for Android applications. It is characterized in that It includes a preprocessing module, a static analysis module, a fuzzy Activity startup context building module, and a coverage-guided multi-entry exploration module; the preprocessing module is used to convert the Internal The Activity is exposed as ExportedActivity, and the exposed APK is detected at the method level and branch level; the static analysis module is used to perform inter-procedural, context-sensitive, flow-sensitive and path-sensitive analysis, and Jimple is selected as the intermediate language of Soot to analyze the bytecode of the application to obtain the inter-procedural control flow graph, method call graph, static Activity transition graph and three program complexity features: the number of statements, the number of branches, and the number of called method types; The module for constructing the fuzzy Activity startup context adopts the symbolic execution, path reversal and intent fuzzing methods to pre-mutate the generated ICC message to construct a valid intent test case. The coverage-guided multi-entry exploration module combines the principle of coverage-guided gray-box fuzz testing, the designed Activity recommendation algorithm and the exploration tool APE to perform multi-entry testing on all exploration entrances of the application in a targeted manner.

2. A testing method for a coverage-guided multi-entry testing system for Android applications as claimed in claim 1, It is characterized in that The following steps are involved: Step S1, the preprocessing module uses the Android reverse tool APKTool to decompile the APK file to obtain the manifest file, resource file and Smali code information; then uses DOM to parse the decompiled manifest file, and changes the exported attribute of the Activity node to realize component exposure; continues to use the back compilation function provided by APKTool to perform signature verification and repackage the file into an executable APK; Step S2: The preprocessing module uses the instrumentation tool to perform method-level and branch-level detection on the Smali code of the exposed APK to facilitate the statistical calculation of method coverage and branch coverage; Step S3, the static analysis module uses Jimple as the intermediate language of Soot to analyze the bytecode of the application program, and obtains the inter-procedural control flow graph, method call graph, static Activity transition graph, and three program complexity features: the number of statements, the number of branches, and the number of called method types; Step S4, the static analysis module uses the Jadx tool to obtain the source code of the APK, and then tracks the API methods related to layout view loading; after obtaining the layout file bound to the Activity, recursively traverse all resource file paths and analyze their corresponding ElementTrees; according to different label nodes in the tree, the types and quantities of common UI controls are counted to obtain the characteristic value of the number of UI controls of the Activity; Step S5: construct a fuzzy Activity startup context module to generate ICC messages using symbolic execution; and analyze the path constraints to extract key intent attribute values; Step S6: pass these key values ​​to the intent fuzz test program to participate in the pre-mutation process of the ICC message, and then use rich data sources to increase the diversity of test cases and generate effective fuzzy Activity startup context; Step S7: The coverage-guided multi-entry exploration module implements an Activity recommendation algorithm using static analysis results and runtime information, and integrates the exploration tool APE to implement a dynamic multi-entry exploration strategy; Step S8: Combine the coverage-guided grey-box fuzz testing concept to implement coverage-guided fuzz testing with feedback.

3. According to claim 2, the coverage-guided multi-entry testing method for Android applications, It is characterized in that The step S5 of constructing the fuzzy Activity startup context module to generate an ICC message using symbolic execution includes the following steps: Step S51, modeling the intent object according to different intent attribute types, wherein the intent attribute types include basic attribute types and additional parameter types; traversing the execution path of the application along the inter-procedural control flow graph, and analyzing the corresponding bytecode; Step S52: Check whether the application uses a predefined method related to intent acquisition to obtain an intent receiving variable; Step S53: Use the def-use technology to track the use points of these intent receiving variables, and check whether the Units where they are located use methods related to the acquisition of intent attributes, and obtain the intent attribute receiving variables. For additional parameter types, it is also necessary to obtain their type-key fields. Step S54, continue to track the usage points of these intent attribute receiving variables, and analyze the conditional expressions related to these variables and their intermediate transfer variables, and construct path constraints, wherein the path constraints related to the additional parameters will be used to analyze the key values, and the path constraints related to the basic attributes will be passed to the Z3 solver for attribute verification and solving, so as to prune infeasible paths and find potential attribute values ​​that meet the given constraint conditions; Step S55: After the constraint solving is completed, the basic ICC message is extracted from the solving result, which mainly includes basic attributes with specific data and additional parameters including the type-key field.

4. According to claim 2, the coverage-guided multi-entry testing method for Android applications, It is characterized in that The analysis of the path constraints in step S5 to extract key intent attribute values ​​includes the following steps: Step S56, extracting additional path constraints related to additional parameters along different execution paths; Step S57, invert the path constraints, construct different attribute paths, and reversely derive key values ​​that satisfy these constraints, where the key values ​​related to the basic attribute constraints are used to mutate the solved ICC message, and the key values ​​related to the additional parameter constraints are used to fill the corresponding additional parameter fields in the ICC message.

5. According to claim 2, the coverage-guided multi-entry testing method for Android applications, It is characterized in that The process of generating a valid fuzzy Activity startup context in step S6 is as follows: Step S61: pass these key values ​​to the intent fuzz test program, and then compare the basic attribute values ​​of the basic ICC message with the declared data in the intent filter of the target component. If the match fails, first determine the target component to be sent, and then mutate it using the data declared in the corresponding intent filter and the key values ​​extracted from the constraints to generate a set of mutated ICC messages that are closer to the expected ones. Step S62: For each ICC message, data is filled in a variety of ways according to the type and key name of the additional parameter, and the data sources include key values, fixed values, boundary values, randomly generated strings, positive and negative values, null values, and null references related to the additional parameter constraints; Step S63: Generate a set of fuzzy Activity startup contexts by combining the name, startup flag, communication mode and other information of the target component.

6. The coverage-guided multi-entry testing method for Android applications according to claim 2, It is characterized in that The coverage-guided multi-entry exploration module in step S7 implements an Activity recommendation algorithm using static analysis results and runtime information, including the following steps: Step S71, calculating the priority value for each Activity component, and determining the Activity with the largest priority value, namely maxAct; Step S72, determine whether maxAct is an exploration entry. If maxAct is an exploration entry, then give priority to valid intent test cases containing key values ​​as recommended results to be returned. If there is no such valid test case containing key values, then randomly select test cases from the valid test case set of maxAct and return them. If maxAct is not an exploration entry, determine whether maxAct is an isolated node. If it is an isolated node, there is no exploration entry in the ATG that can reach the node, so the return result of the algorithm is empty. If it is not an isolated node, calculate the distance from all exploration entries to maxAct according to the Activity transition graph, and recommend test cases for the Activity with the closest distance. Step S73, determine whether there are multiple results with the shortest distance. If there are multiple results, calculate the average call depth from the lifecycle method and event handling method to the intent sending method according to the method call graph, and then recommend test cases for the Activity with the shortest distance. If the result is unique, directly recommend test cases for it.

7. The coverage-guided multi-entry testing method for Android applications according to claim 2, It is characterized in that The integrated exploration tool APE described in step S7 implements a dynamic multi-entry exploration strategy, including the following steps: Step S74: first use APE to explore the main entry point of the application for a fixed time to collect initial information; Step S75, then iteratively call the Activity recommendation algorithm to obtain the intent test case to be sent. If the return value is empty, that is, there is no test case for recommendation, then randomly select a valid test case. If the return value is not empty, the exploration time is calculated based on the scale of the reachable nodes of its corresponding Activity in the Activity transition graph.

8. The coverage-guided multi-entry testing method for Android applications according to claim 2, It is characterized in that The gray-box fuzz testing idea guided by coverage described in step S8 is combined to realize the coverage-guided fuzz testing with feedback, including the following steps: Step S81: Select a high-quality test case from the valid test case set of the recommended Activity as the initial seed for this round of iteration, and then add it to the test case queue. If there is no qualified high-quality initial seed, randomly select a valid test case as the initial seed for fuzzy testing; Step S82, obtain the test sample from the test case queue and execute it, and save its runtime information to a global data structure; use the branch coverage information as the execution feedback of the current test case during the fuzz testing process. If the program monitors that the current test case can enable the application to cover a new branch path, the test sample will be quickly mutated according to the pre-mutation method, that is, it will regard the valid test case with different intent attribute values ​​that is pre-mutated from the same basic ICC message as the test sample as its mutated sample; Step S83, adding the variant sample as an input of interest to the test case queue to continue testing it; Step S84: Repeat the above fuzzy testing process continuously. If the current execution does not generate any new feedback, the program starts the next round of recommendation exploration.

9. The coverage-guided multi-entry testing method for Android applications according to claim 6, It is characterized in that In step S71, the priority value is calculated as follows: In the above formula, eFlag represents the exploration entry flag of Activity. If an Activity can be successfully started, it will be regarded as an exploration entry and eFlag will be assigned a value of 1. On the contrary, if the Activity cannot be started, its eFlag value is 0.5; mCov represents the mapping of Activity to its method coverage, reflecting the proportion of the number of currently covered methods to the number of all methods. After each round of exploration, mCov will be incrementally calculated and dynamically updated; rewardrNum[act] represents the reward of Activity, where the default value of reward is 2, rNum represents the number of times the Activity has not made any contribution to mCov after being recommended, and its initial value is 0; cConst is a program complexity constant, which is used to describe the mapping of program complexity and is calculated by the weighted entropy method. The calculation process is as follows: In the above formula, each Activity is associated with four program complexity features, including the number of user interface controls ui, the number of call method types m, the number of statements un, and the number of branches b. The algorithm normalizes their feature values ​​and calculates the probability value Pi[act] of each data, where the value range of i is [1,4], corresponding to the above four features respectively; Ei represents the information entropy of different features; Wi is their entropy weight; and aNum is the number of activities of the application.

10. The coverage-guided multi-entry testing method for Android applications according to claim 7, It is characterized in that The calculation formula of the exploration time in step S75 is as follows: In the above formula, nodereach is the number of nodes contained in the relevant subgraph of the Activity node corresponding to the test case in ATG; nodeall is the number of all nodes in ATG; time is a preset value, which is adjusted according to the total exploration time of the application.

Citation Information

Patent Citations

  • Method for detecting communication vulnerabilities of Android application components

    CN106294149A

  • Combined Android platform native program dynamic vulnerability mining system

    CN116541846A

  • Information leakage detection method for Android native layer

    CN117290849A

  • Methods and devices for determining stability of an application

    KR1020170077322A

  • Kind of android malicious code detection method on the base of community structure analysis

    US20180144132A1

Cited By

  • Fuzzy test drive generation system and method based on unit test

    CN118964217A