Android Intent fuzzy testing method and device based on gene mutation
Through the fuzz testing method based on the gene mutation algorithm, the problem of insufficient security analysis of the Android Intent mechanism is solved, and more comprehensive Intent security testing coverage and vulnerability discovery is achieved, the application robustness and detection accuracy are enhanced, and automated Test the solution.
Patent Information
- Application Number
- CN202411257093.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-09
- Publication Date
- 2024-12-27
AI Technical Summary
The security analysis of the Intent mechanism in the Android operating system has been ignored, resulting in potential security vulnerabilities and attack threats. It is difficult for existing fuzz testing tools to detect Intent-related security threats, especially the lack of comprehensive intent testing based on UI interaction testing.
Using a fuzz testing method based on gene mutation algorithm, a large number of mutations of Intent test cases are generated through Intent initialization, seed screening, seed mutation and test detection, representative seeds are screened using Jaccard distance and minimum editing distance, and mutation operations are performed in combination with the gene algorithm. And detect device status differences through image similarity algorithms, and potential vulnerabilities and boundary anomalies are found.
Improves the security test coverage and vulnerability discovery capabilities of the Intent mechanism of Android applications, enhances the robustness of the application, provides an automated Intent security testing solution, reduces the workload of manual testing, improves detection accuracy and comprehensive testing sex.
Smart Images

Figure CN119201707A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer software, and in particular relates to an Android Intent fuzzy testing method and device based on gene mutation. Background Art
[0002] The Android operating system has an important share in the field of smartphones, but it also has some security risks. Among them, the Intent mechanism is an important way of inter-process communication in Android. If used improperly, it may cause unauthorized access and attack to application components, thus endangering user data and device security.
[0003] As the basic means of inter-process communication (IPC) within Android, the Intent mechanism plays a key role in system security. Intent is a message passing object used to request other application components to perform operations. It can be divided into explicit Intent (specifying the target component name) and implicit Intent (indicating the type of operation to be performed and responding to components that meet the specified criteria). Improper use of intent may allow attackers to gain unauthorized access and perform attacks through exposed components.
[0004] At present, when using inter-process communication (IPC), Android developers often ignore the security analysis of the Intent mechanism and lack robustness checks and exception handling for Intent input data, which results in potential security vulnerabilities in applications when processing Intents. On the other hand, the current mainstream Android application security testing tools mostly focus on interactive testing at the UI level, which cannot fully cover the underlying communication mechanisms such as Intent, making it difficult to discover security threats related to Intents.
[0005] As a classic software testing technology, fuzz testing can discover possible defects and security vulnerabilities in applications when processing abnormal inputs by inputting illegal, abnormal or random data into the program. Applying fuzz testing to Intent mechanism testing has the potential to discover Intent-related security issues. However, some existing fuzz testing tools mainly emphasize testing the interaction with UI components and are insufficient in conducting comprehensive intent testing. Summary of the invention
[0006] To solve the above problems, the present invention proposes a fuzzy testing method and device based on a genetic mutation algorithm for potential security vulnerabilities related to data transmission in Android, which is used to generate a large number of mutated Intent test cases, so as to discover potential vulnerabilities and boundary anomalies that may exist when Android applications process Intents. The present invention mainly includes two main parts: intent initialization and intent seed mutation. These components collaborate using a third-party tool DroidBot to discover potential vulnerabilities in app data transmission and generate detailed reports.
[0007] To achieve the above object, the technical solution of the present invention is as follows:
[0008] An Android Intent fuzz testing method based on gene mutation includes the following steps:
[0009] Step 1: Intent initialization
[0010] Collect intent samples of different functions and operations, establish an initial intent seed set, randomly select heuristic rules and mutated fields, mutate the intent seeds, and generate mutated seeds;
[0011] Step 2: Intent seed screening
[0012] Calculate the Jaccard distance and minimum edit distance between the newly generated variant Intent and the existing seed Intent; select the Intents whose Jaccard distance and minimum edit distance are both lower than the preset threshold as more representative seeds;
[0013] Step 3: Intent seed mutation
[0014] Adopting the principle of genetic algorithm, the mutated Intent is generated through mutation operation. Each time a mutation occurs, the mutation operation and mutation position are randomly generated.
[0015] Step 4: Intent test detection
[0016] The mutated Intent is sent to the target device, the device status log and screenshots are captured, and the logs are recorded; the screenshots and status logs before and after the Intent execution are compared using the image similarity algorithm to determine the degree of difference in the device status; when the similarity is lower than a certain threshold, it is considered that an abnormal state has occurred and there is a potential vulnerability.
[0017] Furthermore, in step 1, the sources of collecting intent samples include: application source code, test cases, and usage logs.
[0018] Furthermore, in step 1, the means of collecting intent samples includes: clicking on components on the APP interface, collecting normal intents, and recording screenshots and status.
[0019] Furthermore, in step 1, the heuristic rules include:
[0020] d) Parameter variation: modify parameter values in Intent, add / delete parameters;
[0021] e) Parameter order variation: rearrange the order of parameters in the Intent;
[0022] f) Parameter type variation: Change the data type of a specific parameter.
[0023] Furthermore, in step three, the mutation rules include: single-byte / multi-byte addition, deletion, modification, fragment exchange, adding null values, and extreme length extension.
[0024] The present invention also provides an Android Intent fuzzy testing device based on gene mutation, comprising: an adapter module, a core framework module and a log module;
[0025] The adapter module is used to connect the device to the Android Intent fuzzy testing device based on gene mutation, perform data communication between the two, monitor the device status and record logs;
[0026] The core framework module is used to generate an Intent event and send it to the device through the adapter module; the core framework module performs Intent initialization, Intent seed screening, Intent seed mutation, and Intent test detection for each Intent event to be sent;
[0027] The log module is used to record the status of the device after each intent is sent.
[0028] Furthermore, the functions implemented by the core framework module include:
[0029] Collect different intent samples from application source code and other channels to build an intent seed library; design heuristic rules to generate new variant intents, including parameter variation, parameter order variation, parameter type variation, and intent structure variation;
[0030] Use Jaccard solution distance and minimum edit distance to screen out high-quality representative seeds;
[0031] Based on the selected seed intent, the genetic algorithm principle is used to mutate the intent through single-byte / multi-byte operations, fragment exchange, and length extension to generate a large number of abnormal test inputs;
[0032] The mutated Intent is sent to the target Android device, and the screenshots before and after the Intent execution are compared using an image similarity algorithm to determine the degree of abnormality of the device status; if the similarity is lower than the preset threshold, it indicates that there may be an Intent security vulnerability.
[0033] The beneficial effects of the present invention are:
[0034] 1. The present invention improves the security testing coverage of the Android application program Intent mechanism. The present invention generates abnormal Intent input by simulating gene mutation to evaluate the application's ability to handle abnormal situations. It can test more boundary conditions and abnormal situations, increase the possibility of discovering Intent-related vulnerabilities, and thus improve the coverage and vulnerability discovery capabilities of Intent security testing. Compared with traditional UI interaction fuzzy testing, the present invention expands the test scope and improves the comprehensiveness of the test.
[0035] 2. The present invention improves the accuracy of intent security vulnerability detection. The present invention uses an image similarity comparison method to accurately detect application state anomalies caused by abnormal intent input, thereby discovering potential intent security vulnerabilities. Compared with static code analysis and other methods, the present invention is more intuitive and efficient.
[0036] 3. The present invention enhances the robustness of Android applications. The present invention discovers the weak links of applications in processing abnormal Intent input through fuzzy testing, and developers can repair them in time, thereby enhancing the robustness of applications and improving user experience.
[0037] 4. The present invention provides an automated Intent security testing solution. The present invention integrates the Intent fuzzy testing method into the famous mobile application testing framework DroidBot, realizes the automation and intelligence of Intent security testing, and reduces the workload of manual testing.
[0038] 5. This method is innovative. Existing tools mainly focus on fuzzy testing of UI interfaces, and there are few specialized testing tools for Intent mechanisms. This invention proposes a novel fuzzy testing solution based on gene mutation for Intent security issues, which is innovative.
[0039] 6. The present invention enhances the security of Android applications. The present invention can be widely used in the fields of security testing of mobile applications, application robustness assessment, vulnerability mining, etc., and has important theoretical significance and application value. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 This is a structural diagram of the Android Intent fuzzy testing device based on gene mutation provided by the present invention.
[0041] Figure 2 This is the execution flow chart of the core framework module. DETAILED DESCRIPTION
[0042] The technical solution provided by the present invention will be described in detail below in conjunction with specific embodiments. It should be understood that the following specific implementation methods are only used to illustrate the present invention and are not used to limit the scope of the present invention.
[0043] Figure 1 The figure shows a structural diagram of an Android Intent fuzzy testing device based on gene mutation provided by the present invention, which includes an adapter module, a core framework module and a log module.
[0044] The adapter module provides solutions for device connection, transmission of intent and other information. To test the application on the device, you first need to connect to the device through ADB. The device can be any Android device, including a smartphone or an Android emulator. The adapter module connects the connected device to the tool, performs data communication between the two, monitors the device status and records logs, etc.
[0045] The core framework module is responsible for generating Intent events according to certain rules and sending them to the device through the adapter. Figure 1 As shown in the figure, the core framework module mainly includes four parts: Intent initialization, Intent seed screening, Intent seed mutation, and Intent test detection. For each Intent event to be sent, the Intent is initialized first, then the seed is screened, followed by the seed mutation operation, and finally the Intent test detection is performed to find vulnerabilities and evaluate system performance. The main functions of these four parts are as follows:
[0046] 1.Intent initialization:
[0047] First, based on the source code of the application, known test cases, and the usage records of the application, various intent samples of different functions and operations are collected as initial intent seeds to establish the initial intent seed set. Specifically, at the beginning, normal intents are collected by clicking on components of the APP interface, and screenshots and status are recorded for subsequent comparison and use. Next, heuristic rules are constructed for these intent samples to mutate the intent seeds and generate a large number of mutated intent seeds. The heuristic rules include: (1) Parameter mutation: modify the value of one of the parameters of the intent, or add or delete parameters; (2) Parameter order mutation: change the order of certain parameters in the intent; (3) Parameter type mutation: change the data type of certain parameters, such as changing numeric data to strings; (4) Intent structure mutation: Intent structure mutation: generate similar but slightly different intent structures based on known intent samples, such as changing the action, data, category, etc. of the intent. When performing heuristic mutation, the method used and the specific fields that need to be mutated will be randomly selected, and an Intent structure similar to the known sample but with slight changes will be generated.
[0048] Specifically, the Intent initialization algorithm accepts a parameter num, which indicates the number of Intents that need to be initialized. First, a set of strings is randomly generated according to the number of tags of each Intent through the generate_strings function. The length of each string is between 5 and 15, and it consists of randomly selected letters and numbers. Next, the generated strings are fuzzified through the fuzz_strings function to increase their diversity. This step randomly selects a letter or number at each position of each string to replace, generating a set of slightly different strings. Finally, the initialized and fuzzed string list is returned as output.
[0049] These variant intents can include new intents generated by heuristic rules or manually constructed intent samples. In the intent initialization phase, we need to initialize the intent seed more comprehensively and continuously expand and improve the intent sample set to provide more representative data for subsequent testing work, thereby improving the coverage and effectiveness of the test.
[0050] 2.Intent seed screening:
[0051] In this stage, the Jaccard decoding distance and the minimum edit distance are used to screen the Intent seeds to select better quality and more representative seeds, which can reduce repeated testing work and improve testing efficiency.
[0052] The decoding distance is used to measure the difference or similarity between two strings. In our application, we can use the decoding distance to measure the similarity between a new Intent and an existing seed Intent. Generally speaking, the smaller the decoding distance, the more similar the two strings are.
[0053] The minimum edit distance refers to the minimum number of operations required to convert a string into another string by inserting, deleting, and replacing it. In our scenario, the minimum edit distance can be used to measure the difference between a new intent and the initial intent. Similar to the card-solving distance, the smaller the minimum edit distance, the higher the similarity between the two intents.
[0054] When filtering intents, we first need to determine a threshold. Then, for the newly generated intent, calculate its card-solving distance and minimum edit distance with the existing seed intent, and filter out intents whose card-solving distance and minimum edit distance are both less than the threshold. These intents can be considered semantically similar or close, and serve as one of the more representative seeds.
[0055] 3.Intent seed mutation:
[0056] In this stage, the Intent seed is mutated using the gene mutation method. Gene mutation is a powerful test case generation technology that simulates the process of gene mutation in biology and generates diverse test cases by introducing random mutations. When applied to the Intent seed, gene mutation can help us generate more different Intents, thereby expanding the coverage of test cases and discovering potential problems and vulnerabilities. Through the gene mutation method, more different Intents can be generated. These Intents may conform to grammatical specifications or may be illegal.
[0057] First, we need to randomly select mutation operations for the Intent, including but not limited to single-byte addition, deletion and modification, random multi-byte addition, deletion and modification, catastrophic string growth, etc. Then, we still use random methods to select mutation positions and mutation results. Specifically, gene mutation can include the following operations: (1) Single-byte addition, deletion and modification: Randomly select a position in the Intent and perform single-byte addition, deletion or modification operations on it. For example, you can add an extra character to the parameter value, delete a character, or replace a character with another character. (2) Multi-byte addition, deletion and modification: Similar to single-byte operations, it can introduce greater changes in the Intent to increase the diversity of test cases. When adding bytes, null values can also be added. (3) Catastrophic string growth: This is a very aggressive operation. By repeating a large number of fragments or introducing a large number of extra characters, the length of the Intent increases dramatically until it reaches the maximum acceptable length. This can help test the robustness of the system and verify the performance and stability of the system when processing large amounts of data. In addition, you can apply mutation operations multiple times as needed to generate more diverse mutated Intents. This helps increase the diversity of test cases and improve test coverage and effectiveness.
[0058] 4.Intent test detection:
[0059] After sending the Intent to the device, the adapter will record the device status and take a screenshot to save. In this section, we use image similarity to detect the state change after the Intent test. Specifically, after sending the Intent, call the DroidBot method to take a screenshot and record the status, including the displayed interface, the running status of the application, etc. For the original seed Intent or the compliant representative Intent, the screenshots taken after they are run can be used as representative screenshots. These representative screenshots will be used as references to compare with the screenshots taken after other Intents are run. Use image similarity algorithms (such as SSIM, MSE, etc.) to compare the similarity between the screenshots after the test and the reference screenshots to quantify the degree of difference between the two images. According to specific needs, a similarity threshold can be defined to determine whether the two images are similar. If the similarity of the two images exceeds the set threshold, it is considered that there is no significant change between them; otherwise, it means that there is a significant difference between the images. If the similarity is lower than the threshold, it means that the state of the device has changed significantly, which may be due to the impact of the execution of the Intent. This can help us discover potential problems or vulnerabilities and make timely repairs and optimizations. Finally, it is best to perform manual verification to determine whether the issue is real and not a false positive.
[0060] The above four methods are the main contents of the Android Intent fuzzy testing method based on gene mutation provided by the present invention.
[0061] The log module can record the status of the device after each intent is sent, including all components on the interface, processes running in the foreground and background, etc. Through the log, relevant indicators and feedback information can be collected. These indicators can include correctness, accuracy, recall rate, etc., which are used to discover vulnerabilities and evaluate the performance and effectiveness of the system. Through testing and detection, the system can understand its recognition capabilities and make further optimizations and improvements.
[0062] When implementing the scheme of the present invention, first, the Android Intent fuzzy test device based on gene mutation is connected to the Android device, and the ADB function is enabled. Subsequently, the Android Intent fuzzy test device based on gene mutation is started by Python, and the program can be run. After startup, the Android Intent fuzzy test device based on gene mutation will be connected to the Android device through ADB, install the test program and the APP to be tested, and record the status of the device, send information such as the status to the log module at any time, and the log module will record, store and output. After the preliminary preparations such as device connection are completed, the Android Intent fuzzy test device based on gene mutation will call the Android Intent fuzzy test method based on gene mutation provided by the present invention for automated testing.
[0063] It should be noted that the above content only illustrates the technical idea of the present invention and cannot be used to limit the protection scope of the present invention. For ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications all fall within the protection scope of the claims of the present invention.
Claims
1. An Android Intent fuzzy testing method based on gene mutation, characterized in that: The steps include: Step 1: Intent initialization Collect intent samples of different functions and operations, establish an initial intent seed set, randomly select heuristic rules and mutated fields, mutate the intent seeds, and generate mutated seeds; Step 2: Intent seed screening Calculate the Jaccard distance and minimum edit distance between the newly generated variant Intent and the existing seed Intent; select the Intents whose Jaccard distance and minimum edit distance are both lower than the preset threshold as more representative seeds; Step 3: Intent seed mutation Adopting the principle of genetic algorithm, the mutated Intent is generated through mutation operation. Each time a mutation occurs, the mutation operation and mutation position are randomly generated. Step 4: Intent test detection The mutated Intent is sent to the target device, the device status log and screenshots are captured, and the logs are recorded; the screenshots and status logs before and after the Intent execution are compared using the image similarity algorithm to determine the degree of difference in the device status; when the similarity is lower than a certain threshold, it is considered that an abnormal state has occurred and there is a potential vulnerability.
2. The Android Intent fuzzy testing method based on gene mutation according to claim 1 is characterized in that: In the step 1, the sources of intent sample collection include: application source code, test cases, and usage logs.
3. The Android Intent fuzzy testing method based on gene mutation according to claim 1 is characterized in that: In the step 1, the means of collecting intent samples includes: clicking on components on the APP interface, collecting normal intents, and recording screenshots and status.
4. The Android Intent fuzzy testing method based on gene mutation according to claim 1 is characterized in that: In step 1, the heuristic rules include: a) Parameter variation: modify parameter values in Intent, add / delete parameters; b) Parameter order variation: rearrange the order of parameters in the Intent; c) Parameter type mutation: changing the data type of a specific parameter.
5. The Android Intent fuzzy testing method based on gene mutation according to claim 1 is characterized in that: In step three, mutation rules include: single-byte / multi-byte addition, deletion, modification, fragment exchange, adding null values, and extreme length extension.
6. An Android Intent fuzzy testing device based on gene mutation, characterized in that: The method for implementing the Android Intent fuzz testing method based on gene mutation described in any one of claims 1 to 5 comprises: an adapter module, a core framework module and a log module; The adapter module is used to connect the device to the Android Intent fuzzy testing device based on gene mutation, perform data communication between the two, monitor the device status and record logs; The core framework module is used to generate an Intent event and send it to the device through the adapter module; the core framework module performs Intent initialization, Intent seed screening, Intent seed mutation, and Intent test detection for each Intent event to be sent; The log module is used to record the status of the device after each intent is sent.
7. The Android Intent fuzzy testing device based on gene mutation according to claim 6 is characterized in that: The functions implemented by the core framework module include: Collect different intent samples from application source code and other channels to build an intent seed library; design heuristic rules to generate new variant intents, including parameter variation, parameter order variation, parameter type variation, and intent structure variation; Use Jaccard solution distance and minimum edit distance to screen out high-quality representative seeds; Based on the selected seed intent, the genetic algorithm principle is used to mutate the intent through single-byte / multi-byte operations, fragment exchange, and length extension to generate a large number of abnormal test inputs; The mutated Intent is sent to the target Android device, and the screenshots before and after the Intent execution are compared using an image similarity algorithm to determine the degree of abnormality of the device status; if the similarity is lower than the preset threshold, it indicates that there may be an Intent security vulnerability.