Application detection method, device, computer equipment and readable storage medium

By dividing and analyzing code blocks in application code, the method of identifying SDK solves the problem of low SDK detection efficiency in the existing technology, achieving fast and accurate SDK identification and security improvement.

CN112148305BActive Publication Date: 2024-09-10TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 11 Cites 0 Cited by

Patent Information

Application Number
CN202011171532.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-10-28
Publication Date
2024-09-10
Estimated Expiration
2040-10-28

AI Technical Summary

Technical Problem

The existing technology is inefficient when detecting third-party SDKs integrated in applications, and has security risks, making it difficult to quickly identify the existence of different types of SDKs.

Method used

By splitting the code block from the target application code and performing similarity analysis with the reference code block to determine the matching code block, add target tag information to indicate the SDK to which the code block belongs. There is no need to obtain the source package or jar package of the SDK. Quickly detect SDK.

Benefits of technology

It improves the efficiency of application detection, can quickly identify the type of SDK integrated in the target application, and enhances the accuracy and security of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112148305B
    Figure CN112148305B
Patent Text Reader

Abstract

The embodiment of the present invention provides an application detection method, apparatus, computer equipment and readable storage medium, wherein the method comprises: in response to a code detection operation for a target application, dividing a target code block from a program code of the target application; calculating the code similarity between the target code block and at least one reference code block, wherein one reference code block corresponds to a software development kit; determining a matching code block that matches the target code block from the at least one reference code block according to the code similarity between the target code block and each reference code block; adding target tag information to the target code block according to the matching code block, wherein the target tag information is used to indicate that the target code block belongs to the software development kit corresponding to the matching code block, so that the SDK included in the application can be quickly detected, thereby improving the efficiency of application detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the field of computer technology, and in particular, to an application detection method, apparatus, computer equipment, and readable storage medium. Background Art

[0002] At present, in order to improve development efficiency and reduce costs, application developers generally use third-party software development kits (SDKs). Generally speaking, an officially launched application (Application, APP) will integrate about 20 or even more third-party SDKs. While third-party SDKs are widely used, their related security issues are also becoming more and more frequent, such as SDK's own security vulnerabilities, private collection of user privacy data, and some malicious SDKs using APP to perform malicious operations, etc., and different types of SDKs will have different security risks. Therefore, it is necessary to detect what types of third-party SDKs are integrated in the APP. At present, third-party SDK detection is mainly based on feature matching, extracting certain features in the SDK code package to identify a certain SDK, and then in APP detection, if the feature is found, it is identified that this SDK is integrated in the APP. This method mainly relies on the SDK code package and has low detection efficiency. Summary of the invention

[0003] The embodiments of the present invention provide an application detection method, an apparatus, a computer device and a readable storage medium, which can quickly detect an SDK included in an application and improve the efficiency of application detection.

[0004] In one aspect, an embodiment of the present invention provides an application detection method, the method comprising:

[0005] In response to a code detection operation for a target application, segmenting a target code block from a program code of the target application;

[0006] Calculating code similarity between the target code block and at least one reference code block, one reference code block corresponding to one software development kit;

[0007] Determining a matching code block that matches the target code block from the at least one reference code block according to code similarities between the target code block and each reference code block;

[0008] Target tag information is added to the target code block according to the matching code block, where the target tag information is used to indicate that the target code block belongs to a software development kit corresponding to the matching code block.

[0009] On the other hand, an embodiment of the present application provides an application detection device, the device comprising:

[0010] a segmentation unit, configured to segment a target code block from a program code of the target application in response to a code detection operation on the target application;

[0011] a calculation unit, configured to calculate a code similarity between the target code block and at least one reference code block, wherein one reference code block corresponds to one software development kit;

[0012] a determining unit, configured to determine, from the at least one reference code block, a matching code block that matches the target code block according to code similarities between the target code block and each reference code block;

[0013] An adding unit is used to add target tag information to the target code block according to the matching code block, wherein the target tag information is used to indicate that the target code block belongs to a software development kit corresponding to the matching code block.

[0014] On the other hand, an embodiment of the present application provides a computer device, the computer device includes an input device, an output device, and the computer device further includes:

[0015] a processor adapted to implement one or more instructions; and,

[0016] A computer storage medium storing one or more instructions, wherein the one or more instructions are suitable for being loaded by the processor and executing the following steps:

[0017] In response to a code detection operation for a target application, segmenting a target code block from a program code of the target application;

[0018] Calculating code similarity between the target code block and at least one reference code block, one reference code block corresponding to one software development kit;

[0019] Determining a matching code block that matches the target code block from the at least one reference code block according to code similarities between the target code block and each reference code block;

[0020] Target tag information is added to the target code block according to the matching code block, where the target tag information is used to indicate that the target code block belongs to a software development kit corresponding to the matching code block.

[0021] On the other hand, an embodiment of the present application provides a computer storage medium, wherein the computer storage medium stores one or more instructions, wherein the one or more instructions are suitable for being loaded by the processor and executing the following steps:

[0022] In response to a code detection operation for a target application, segmenting a target code block from a program code of the target application;

[0023] Calculating code similarity between the target code block and at least one reference code block, one reference code block corresponding to one software development kit;

[0024] Determining a matching code block that matches the target code block from the at least one reference code block according to code similarities between the target code block and each reference code block;

[0025] Target tag information is added to the target code block according to the matching code block, where the target tag information is used to indicate that the target code block belongs to a software development kit corresponding to the matching code block.

[0026] In an embodiment of the present invention, in response to a code detection operation for a target application, a computer device segments a target code block from the program code of the target application, calculates the code similarity between the target code block and at least one reference code block, and then determines a matching code block that matches the target code block from at least one reference code block based on the code similarity between the target code block and each reference code block; and adds target tag information to the target code block based on the matching code block. The computer device does not need to obtain the source package (short for source code package) or jar package (short for a Java compressed code package) of the SDK to extract the features of the SDK itself. It only needs to cut the program code of the target application and perform similarity analysis between the cut code block and the reference code block to quickly detect the SDK integrated in the target application, which can effectively improve the efficiency of application detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0028] Figure 1 is a structural diagram of an application detection system provided by an embodiment of the present invention;

[0029] Figure 2a It is a flowchart of an application detection solution provided by an embodiment of the present invention;

[0030] Figure 2b is a structural schematic diagram of a computer device provided by an embodiment of the present invention;

[0031] Figure 3 is a flow chart of an application detection method provided by an embodiment of the present invention;

[0032] Figure 4a It is a schematic diagram of a hierarchical structure style of a program code provided by an embodiment of the present invention;

[0033] Figure 4b is a schematic diagram of a code provided by an embodiment of the present invention;

[0034] Figure 5 is a flow chart of another application detection method provided by an embodiment of the present invention;

[0035] Figure 6a It is a schematic diagram of a hash value of a calculation operation instruction provided by an embodiment of the present invention;

[0036] Figure 6b is a schematic diagram of calculating a target hash value and a reference hash value provided by an embodiment of the present invention;

[0037] Figure 7 It is a flowchart of a specific application detection method provided by an embodiment of the present invention;

[0038] Figure 8 is a structural schematic diagram of an application detection device provided by an embodiment of the present invention;

[0039] Fig. 9 It is a structural schematic diagram of a computer device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0040] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0041] In order to better detect which software development kits are integrated into the application, the software development kits mentioned here can be: third-party login sharing SDK, payment SDK, push SDK, advertising SDK, data statistics SDK, etc. The embodiment of the present application proposes an application detection scheme; the executor of the application detection scheme can be a computer device, and the computer device mentioned here can be a terminal device (hereinafter referred to as a terminal) or a server. When the computer device is a server, the embodiment of the present application also proposes a Figure 1The application detection system shown; the application detection system may include at least one terminal 101 and a server (i.e., a computer device) 102. In the application detection system, the terminal 101 and the server 102 may be directly or indirectly connected via wired or wireless communication, and the embodiments of the present application are not limited here. It should be noted that the terminals mentioned above may be smart phones, tablet computers, laptop computers, desktop computers, etc.; the server may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), as well as big data and artificial intelligence platforms and other basic cloud computing services, etc.

[0042] In actual applications, when a developer or other user wants to perform an application detection on a target application, the developer or other user may send a code detection operation for the target application to the computer device through the application detection interface. In one embodiment, the application detection interface may include an application identifier input box; in this embodiment, the code detection operation may be an operation of inputting the application identifier of the target application in the application detection box. In another embodiment, the application detection interface may include at least an application icon for the target application; in this embodiment, the code detection operation may be a trigger operation for the application icon of the target application, such as a click operation, a press operation, etc. Accordingly, the computer device may respond to the code detection operation for the target application and use the application detection solution proposed in the embodiment of the present application to detect which software toolkits are integrated into the target application. See. Figure 2a As shown, the general principle of the application detection scheme is as follows: the computer device can first perform code block cutting on the program code of the target application to obtain at least one code block. For any code block obtained by cutting, the code block can be analyzed for similarity with at least one reference code block; then, according to the analysis results and the SDK corresponding to each reference code block, the code block can be marked as an SDK code block to mark the SDK to which the code block belongs. Based on this marking principle, it is possible to implement SDK code block marking on each code block obtained by cutting. Since each code block is cut out from the program code of the target application, that is, each target code block is part of the program code of the target application; therefore, by marking each code block as an SDK code block, the SDK detection result of the target application can be output, and the SDK detection result is used to indicate which SDKs are integrated in the target application.

[0043] In a feasible embodiment, in order to better implement the relevant steps of the above-mentioned application detection solution, the embodiment of the present application can deploy the following modules on the computer device: a detection control module, a code block cutting module, and a code block marking module, such as Figure 2b As shown. In a specific implementation, the detection control module is mainly used to: call the code block cutting module and the code block marking module to detect the integration of the SDK in the target application, and output the SDK detection result indicating which SDKs are integrated in the target application. Specifically, the detection control module may first call the code block cutting module to perform code block cutting on the program code of the target application and obtain the characteristic parameters of each code block obtained by cutting. For any code block obtained by cutting, the detection control module may call the code block marking module to calculate the similarity between the characteristic parameters of the any code block and the characteristic parameters of at least one reference code block, and mark the code block of any code block according to the similarity calculation result and the SDK corresponding to each reference code block. Optionally, before detecting the target application, the detection control module may also call the code block marking module to perform cluster analysis on at least one reference code block, and use a marking strategy to mark the SDK code block of each reference code block according to the cluster analysis result to determine the SDK corresponding to each reference code block.

[0044] It can be seen that the application detection scheme proposed in the embodiment of the present application can have the following beneficial effects: through the above-mentioned application detection implementation process, the computer device does not need to obtain the source package (short for source code package) or jar package (short for Java compressed code package) of the SDK to extract the characteristics of the SDK itself, but only needs to cut the program code of the target application and perform similarity analysis between the cut code blocks and the reference code blocks to quickly detect the SDK integrated in the target application, which can effectively improve the efficiency of application detection.

[0045] See also Figure 3 , Figure 3 The following is a flow chart of an application detection method provided by an embodiment of the present invention. The application detection method can be executed by the above-mentioned computer device, and may include the following steps S301-S304:

[0046] S301 , in response to a code detection operation on a target application, a target code block is segmented from a program code of the target application.

[0047] The target application may be a social application, a multimedia player application, a browser application, etc. In a specific implementation, when a user wants to detect which software development kits (SDKs) are integrated into the target application, a code detection operation for the target application may be input. Accordingly, the computer device may split the program code of the target application into target code blocks in response to the code detection operation for the target application.

[0048] Specifically, the computer device first obtains the code file of the target application, and decompiles the code file to obtain the hierarchical structure of the program code; wherein the code file may include but is not limited to: Android application package (APK), IOS application package, WP application package, Windows application package, etc.; for the sake of ease of explanation, the following description will take the code file as APK as an example. The hierarchical structure may include at least one level, and each level may include at least one code package identifier; and for each code package identifier in any level except the top level, the corresponding parent code package identifier may be found in the level above the level. The structural style of the hierarchical structure may be a tree structure style or a Figure 4a After obtaining the hierarchical structure, the program code of the target application can be segmented according to the hierarchical structure to obtain at least one code block; then, the target code block can be obtained from the at least one code block.

[0049] In the process of performing code cutting on the program code of the target application according to the hierarchical structure to obtain at least one code block, in order to make the code of the same SDK be cut into the same code block as much as possible, the computer device can adopt a cutting strategy proposed based on practical results to perform code cutting on the program code of the target application. The cutting strategy is used to indicate that the code package identifier that meets the cutting list is searched in the hierarchical structure from bottom to top, and the code cutting is performed by cutting down one layer based on the found code package identifier. Accordingly, the specific implementation method of performing code cutting on the program code of the target application according to the hierarchical structure to obtain at least one code block can be:

[0050] Get a preset cutting list, which includes the code package identifiers that need to be cut. After obtaining the hierarchical structure of the program code, the starting level to be traversed can be determined from the hierarchical structure, and each code package identifier in the starting level can be traversed; if the target code package identifier currently traversed is in the preset cutting list, the code corresponding to each code package identifier in the level below the starting level is cut into different code blocks. If the target code package identifier currently traversed is not in the cutting list, it is determined whether the first parent code package identifier corresponding to the target code package identifier in the first level is in the cutting list, and the first level refers to the level above the starting level. If the first parent code package identifier is in the cutting list, the code corresponding to the target code package identifier is cut into a code block; if the first parent code package identifier is not in the cutting list, it is determined whether the second parent code package identifier corresponding to the first parent code package identifier in the second level is in the cutting list, and the second level refers to the level above the first level. If the second parent code package identifier is in the cutting list, the codes corresponding to each code package identifier in the first level are cut into different code blocks respectively; if the second parent code package identifier is not in the cutting list, it is determined whether the third parent code package identifier corresponding to the second parent code package identifier in the third level is in the cutting list, and the third level refers to the level above the second level, and so on.

[0051] In the specific implementation, Figure 4a The following example shows a hierarchical structure consisting of three levels obtained by decompiling the code file of the target application, and each level includes at least one code package identifier. Figure 4aWhen performing code segmentation on the program code of the target application according to the hierarchical structure, the computer device can determine that the starting level to be traversed is the third level from the three-level hierarchical structure, and traverse each code package identifier in the third level; if the target code package identifier currently traversed is soloade and the target code package identifier soloade is not in the segmentation list, then determine whether the first parent code package identifier faebook corresponding to the target code package identifier soloader in the second level (i.e., the first level above the starting level) is in the segmentation list; if the first parent code package identifier faebook is in the segmentation list, then segment the code corresponding to the target code package identifier soloader into one code block; if the first parent code package identifier faebook is not in the cutting list, then determine whether the second parent code package identifier com corresponding to the first parent code package identifier faebook in the first level (that is, the second level above the first level) is in the cutting list; if the second parent code package identifier com is in the cutting list, then the codes corresponding to each code package identifier in the second level are cut into different code blocks respectively, that is, the code corresponding to the code package identifier faebook is cut into a code block, the code corresponding to the code package identifier donking is cut into a code block, the code corresponding to the code package identifier aplipay is cut into a code block, and so on.

[0052] S302: Calculate code similarity between a target code block and at least one reference code block.

[0053] In a specific implementation, the computer device may first obtain at least one reference code block, where one reference code block corresponds to one software development kit; specifically, the computer device may obtain at least one reference code block from the local storage space of the computer device or from the feature library of the software development kit. Then, the code similarity between the target code block and the at least one reference code block is calculated. In one embodiment, the computer device may compare the program code of the target code block with each reference code block, determine the repetition between the target code block and each reference code block, and calculate the code similarity between the target code block and the at least one reference code block based on the repetition.

[0054] In another implementation, in the current development ecosystem, for the sake of code protection, third-party software development kit providers usually require application developers to obfuscate the SDK code when integrating the SDK, resulting in different code content of the same SDK in different APPs. Among them, code obfuscation can be used for program source code or for intermediate code compiled from the program; it refers to the behavior of converting the program code into a form that is functionally equivalent but difficult to read and understand. Then, in order to overcome the impact of code obfuscation on the calculation of code block similarity, when calculating the code similarity between the target code block and at least one reference code block, the computer device can obtain the characteristic parameters of the target code block and the characteristic parameters of each reference code block to perform similarity calculation, and obtain the code similarity between the target code block and at least one reference code block.

[0055] Among them, characteristic parameters refer to parameters that will not change due to code obfuscation. Studies have shown that in code obfuscation technology, in order to reduce the readability of program code, meaningful parameters such as class names, function names, and variable names in the program code will be replaced with difficult-to-read and meaningless names. However, in order to ensure the consistency of code functions, code obfuscation generally does not process the opcode or operation instruction part of the program code. Figure 4b The code shown in the figure includes variable names such as v3 and v6; these variable names are usually replaced with other names during code obfuscation. Therefore, the computer device can extract the operation instructions in the target code block as the characteristic parameters of the target code block to effectively defeat most code obfuscation schemes. In addition, since code obfuscation usually does not affect the hierarchical structure of the code block, the computer device can also obtain the hierarchical structure of the target code block as the characteristic parameter of the target code block.

[0056] S303: Determine a matching code block that matches the target code block from at least one reference code block according to the code similarity between the target code block and each reference code block.

[0057] In a specific implementation, the computer device selects a reference code block having the greatest code similarity with the target code block from at least one reference code block according to the code similarity between the target code block and each reference code block as a matching code block that matches the target code block. That is, in this specific implementation, the matching code block refers to the reference code block having the greatest code similarity with the target code block.

[0058] In another specific implementation, the computer device can determine whether the code similarity between the target code block and each reference code block is greater than a threshold; wherein the threshold can be set according to experience and needs. If there is a code similarity greater than the threshold, it is considered that the target code block corresponding to the existing code similarity is similar to the reference code block, and then the reference code block corresponding to the code similarity greater than the threshold can be determined as a matching code block that matches the target code block. That is, in this specific implementation, the matching code block refers to a reference code block whose code similarity with the target code block is greater than the threshold.

[0059] In another specific implementation, the computer device can determine whether the code similarity between the target code block and each reference code block is greater than a threshold; if there is a code similarity greater than the threshold, the maximum code similarity is determined from the existing code similarities, and the reference code block corresponding to the maximum code similarity is determined as the matching code block that matches the target code block. That is, in this specific implementation, the matching code block refers to a reference code block whose code similarity with the target code block is greater than the threshold and has the maximum code similarity.

[0060] S304: Add target mark information to the target code block according to the matching code block.

[0061] Research has shown that the software development kits corresponding to two similar code blocks are usually the same; therefore, after determining the matching code block that matches the target code block (i.e., the code block that is similar to the target code block), the software development kit corresponding to the matching code block can be directly determined as the software development kit to which the target code block belongs, thereby adding target tag information to the target code block, and the target tag information is used to indicate that the target code block belongs to the software development kit corresponding to the matching code block. Among them, the target tag information may include the type identifier of the software development kit corresponding to the matching code block; by adding the target tag information to the target code block, it is convenient to directly determine that the software development kit corresponding to the matching code block is integrated in the target application according to the target tag information when performing security testing on the target application in the future, and use the security detection strategy corresponding to the software development kit to detect the target application in a targeted manner, thereby improving the detection efficiency and accuracy.

[0062] In an embodiment of the present invention, a computer device can respond to a code detection operation for a target application, segment a target code block from the program code of the target application, and calculate the code similarity between the target code block and at least one reference code block. Further, based on the code similarity between the target code block and each reference code block, a matching code block that matches the target code block is determined from at least one reference code block, and target tag information is added to the target code block based on the matching code block. Since the target code block is cut out from the program code of the application, by determining the SDK to which the target code block belongs, it can be identified that the application has integrated the SDK, without extracting the features of the SDK itself, thereby quickly detecting the type of SDK included in the application, and effectively improving the efficiency of application detection.

[0063] See also Figure 5 , Figure 5 A flowchart of another application detection method provided in an embodiment of the present invention, which can be executed by the above-mentioned computer device. In the embodiment of the present invention, the reference code block is obtained from the software development kit feature library as an example; then before executing the application detection method proposed in the embodiment of the present invention, the computer device can pre-build the software development kit feature library. The specific construction process is as follows:

[0064] First, the program codes of at least two reference applications may be obtained, and the program codes of at least two reference applications may be divided into a plurality of reference code blocks. Secondly, the computer device may perform cluster analysis on the plurality of reference code blocks, and group the plurality of reference code blocks according to the analysis results; the reference code blocks in a group belong to the same software development kit. Specifically, the computer device may calculate the similarity between any two reference code blocks, and determine that any two reference code blocks with a similarity greater than a threshold belong to the same class, thereby clustering the two reference code blocks. Alternatively, the computer device may also call a clustering model to perform clustering processing on the plurality of reference code blocks, so as to perform group processing on the plurality of reference code blocks; wherein the clustering model is obtained by pre-training a neural network model using a large amount of sample data. After the group processing, the computer device may obtain the label information of each reference code block according to the group information of each reference code block, and the label information of any reference code block is generated after the feature joint analysis is performed on each reference code block in the group to which any reference code block belongs, so as to determine the software development kit to which any reference code block belongs. Each reference code block and corresponding tag information may then be added to the SDK feature library.

[0065] Among them, according to the group information of each reference code block, a specific implementation method of obtaining the tag information of each reference code block can be: the group information of each reference code block can be pushed to the manager, so that the manager performs a feature joint analysis on each reference code block in the group to which any reference code block belongs according to the group information to determine the software development kit to which any reference code block belongs; then the corresponding tag information added by each reference code block in each group is input into the computer device. Correspondingly, the computer device can obtain the tag information of each reference code block input by the manager. That is, in this implementation method, the manager manually performs the feature joint analysis to determine the tag information of the reference code block. Alternatively, according to the group information of each reference code block, another specific implementation method of obtaining the tag information of each reference code block can be: directly perform a feature joint analysis on each reference code block in the group to which any reference code block belongs to determine the software development kit to which any reference code block belongs, and then obtain the tag information of each reference code block according to the group information of each reference code block. That is, in this implementation method, the computer device automatically performs the feature joint analysis to determine the tag information of the reference code block.

[0066] After the software development kit feature library is constructed based on the above steps, the computer device can detect the code detection operation for the target application through Figure 5 The detection method shown is used for detection processing. For details, please refer to the relevant description of the following steps S501-S507:

[0067] S501 , in response to a code detection operation on a target application, a code file of the target application is obtained, where the code file includes a program code of the target application.

[0068] S502, decompile the code file to obtain the hierarchical structure of the program code.

[0069] S503: Perform code segmentation on the program code of the target application according to the hierarchical structure to obtain at least one code block.

[0070] S504: Select a target code block from at least one code block.

[0071] The implementation of steps S501-S504 can be found in the embodiment. Figure 3 The specific implementation method of step S301 will not be repeated here.

[0072] S505 , calculating code similarity between the target code block and at least one reference code block, where one reference code block corresponds to one software development kit.

[0073] In a specific implementation, since the code similarity calculation between the target code block and each reference code block is the same, the following embodiment of the present application takes how to calculate the code similarity between the target code block and any reference code block as an example to illustrate. Specifically, step S505 may include the following steps s11-s12:

[0074] s11, obtaining characteristic parameters of the target code block and characteristic parameters of any reference code block.

[0075] As can be seen from the foregoing, the characteristic parameter can be an operation instruction or a hierarchical structure. Among them, when the characteristic parameter is an operation instruction, and the operation instruction includes multiple target instruction fragments, the specific implementation method of the computer device obtaining the characteristic parameter of the target code block can be: at least one class can be obtained from the target code block, each class includes at least one method and at least one variable, and each method in each class is subjected to instruction extraction processing to obtain multiple candidate instruction fragments, and multiple target instruction fragments are selected from the multiple candidate instruction fragments.

[0076] Specifically, the computer device may directly use each of the multiple candidate instruction fragments as a target instruction fragment, thereby obtaining multiple target instruction fragments. Alternatively, the computer device may first determine the instruction length of each candidate instruction fragment, and determine whether the instruction length of each candidate instruction fragment is greater than a length threshold, and select a candidate instruction fragment whose instruction length is greater than the length threshold from the multiple candidate instruction fragments as the target instruction fragment. In this way, candidate instruction fragments with shorter instruction lengths can be effectively filtered out to improve the efficiency of subsequent similarity calculations.

[0077] It should be noted that the implementation method of obtaining the operation instruction of any reference code block can refer to the implementation method of obtaining the operation instruction of the target code block, which will not be repeated here.

[0078] s12, calculating feature similarity between the feature parameters of the target code block and the feature parameters of any reference code block, and obtaining the code similarity between the target code block and any reference code block. Depending on the feature parameters, step s12 may have different implementations, as described below:

[0079] (i) The characteristic parameter is an operation instruction, and the specific implementation of step s12 is as follows:

[0080] First, a target hash algorithm can be used to perform a hash operation on the operation instructions of the target code block to obtain a target hash value. The target hash algorithm can be a local sensitive hash algorithm used for large-scale text similarity calculation; the local sensitive hash algorithm can map a high-dimensional feature vector into a low-dimensional feature vector, so that the distance between the two vectors can be used to determine whether the code blocks are highly similar. The operation instructions of the target code block include multiple target instruction fragments, which can be found in Figure 6a As shown: the computer device can first perform hash operations on each target instruction fragment in the multiple target instruction fragments to obtain a hash value set, which includes the hash value of each instruction fragment. Secondly, the weight value of each hash value can be determined according to the number of times each hash value appears in the hash value set. Then, the weight value of each hash value can be used to perform weighted summation on each hash value to obtain the target hash value.

[0081] Among them, one implementation method of determining the weight value of each hash value according to the number of times each hash value appears in the hash value set is: the number of times each hash value appears in the hash value set is directly used as the weight value of each hash value. For example, in a hash value set, the hash value "100101" appears 2 times in the hash value set, then the weight value of the hash value "100101" is 2; the hash value "101011" appears 3 times in the hash value set, then the weight value of the hash value "101011" is 3. Or, according to the number of times each hash value appears in the hash value set, another implementation method of determining the weight value of each hash value is: the computer device can determine the repetition of each hash value in the hash value set according to the number of times each hash value appears in the hash value set, and use the weight value corresponding to the repetition corresponding to each hash value as the weight value of each hash value. In a specific implementation, the relationship between the repetition and the weight value corresponding to each hash value is pre-set. Suppose the repetition is 0, the corresponding weight value is 1, the repetition is 20% and the corresponding weight value is 2, and so on. If there are 5 hash values ​​in the hash value set, and the hash value "100101" appears once in the hash value set, it can be determined that the repetition rate of the hash value "100101" is 20%. Then, the weight value corresponding to the repetition rate can be determined to be 2 based on the repetition rate of 20%.

[0082] Each hash value includes at least one of the following: at least one first numerical value (e.g., numerical value "0") and at least one second numerical value (e.g., numerical value "1"); accordingly, the specific implementation method of weighting and summing each hash value using the weight value of each hash value to obtain the target hash value may be: for any hash value, according to the preset multiplication principle, the weight value of any hash value is used to multiply and weight each bit of any hash value to obtain the weighted result of any hash value. The preset multiplication principle is used to indicate: if the current bit of any hash value is the first numerical value, the weight value is used to perform positive multiplication on the current bit; if the current bit of any hash value is the second numerical value, the weight value is used to perform negative multiplication on the current bit. For example, any hash value is "100101", and the weight value of any hash value is 2; the value of the first bit of the hash value is 1, corresponding to the above-mentioned second value, the computer device multiplies the weight value 2 by the value 1 to obtain the value 2; the value of the second bit of the hash value is 0, corresponding to the above-mentioned first value, the computer device multiplies the weight value 2 by the value 0 to obtain the value -2, and so on, by weighting each bit of any hash value "100101", the final weighted result can be obtained, and the weighted result is "2-2-2 2-2 2".

[0083] Based on this weighted principle, the weighted result of each hash value can be obtained. The weighted results of all hash values ​​are summed to obtain a candidate hash value; and the target hash value is determined based on the candidate hash value. In one embodiment, the candidate hash value can be directly used as the target hash value; in another embodiment, in order to facilitate subsequent calculations, the candidate hash value can also be subjected to dimensionality reduction processing to obtain the target hash value. The so-called dimensionality reduction processing means: for any bit in the candidate hash value, if any bit is greater than zero, then any bit is updated to the second value; if any bit is less than or equal to 0, then any bit is updated to the first value.

[0084] For example, there are two hash values, hash value A is "100101", and hash value B is "101011"; the weight value of hash value A is 2, and the weight value of hash value B is 3. According to the above weighting principle, the weighted result of hash value A is "2-2-22-2 2", and the weighted result of hash value B is "3-3 3-3 3 3". The weighted results of the two hash values ​​are summed, that is, the corresponding bits in the weighted results of the two hash values ​​are added, "(2+3)((-2)+(-3))((-2)+3)(2+(-3))((-2)+3)(2+3)", and the candidate hash value is "5-5 1-1 1 5". Then, the candidate hash value "5-5 1-1 1 5" is subjected to dimensionality reduction processing; since the value of the first bit of the candidate hash value is 5, which is greater than 0, the value of the first bit can be updated to 1. Since the value of the second digit of the candidate hash value is -5, which is less than 0, the value of the second digit can be updated to 0, and so on, the target hash value can be obtained as "1 0 1 0 1 1".

[0085] Secondly, a target hash algorithm is used to perform a hash operation on the operation instructions of any reference code block to obtain a reference hash value. It should be noted that the implementation method of the computer device using the target hash algorithm to perform a hash operation on the operation instructions of any reference code block to obtain a reference hash value can be referred to the implementation method of using the target hash algorithm to perform a hash operation on the operation instructions of the target code block to obtain a target hash value, which will not be repeated here.

[0086] Then, the target hash value and the reference hash value can be operated on to obtain the code similarity between the target code block and any reference code block. The distance operation between the target hash value and the reference hash value can be performed using distance calculation formulas such as the Hamming distance formula, the Hamming distance formula, and the Euclidean distance formula. Figure 6bAs shown, the specific implementation method of performing distance calculation on the target hash value and the reference hash value to obtain the code similarity between the target code block and any reference code block can be: using the Hamming distance formula to perform distance calculation on the target hash value and the reference hash value to obtain the Hamming distance between the target code block and any reference code block, and the code similarity between the target code block and any reference code block can be determined by the obtained Hamming distance, so that the target code block and any reference code block are subsequently judged to be similar according to the similarity. In a specific implementation, the computer device can perform XOR calculation on the target hash value and the reference hash value. During the XOR calculation, the result is 1 only when the two compared bits are different, and the result is 0 when they are the same. The number of 1s obtained by the XOR calculation of the target hash value and the reference hash value is the Hamming distance, and the Hamming distance is the code similarity between the target code block and any reference code block. For example, the target hash value is "101001" and the reference hash value is "110101". The Hamming distance algorithm is used to perform an XOR calculation on the target hash value "101001" and the reference hash value "110101". The number of "1"s is 3, and the code similarity between the target code block and any reference code block is 3.

[0087] (ii) The characteristic parameters are hierarchical structures, and the specific implementation of step s12 is as follows:

[0088] The computer device may compare the hierarchical structure of the target code block with the hierarchical structure of any reference code block from multiple dimensions, and determine the code similarity between the target code block and any reference code block based on the comparison result, so as to ensure that the reference code block that best matches the target code block can be determined from at least one reference code block based on the code similarity. The multiple dimensions may be the number of levels corresponding to the hierarchical structure, the code package identifier included in the hierarchical structure, and other dimensions.

[0089] S506: Determine a matching code block that matches the target code block from at least one reference code block according to the code similarity between the target code block and each reference code block.

[0090] S507 , adding target tag information to the target code block according to the matching code block, where the target tag information is used to indicate that the target code block belongs to a software development kit corresponding to the matching code block.

[0091] Among them, the specific implementation of steps S506-S507 can refer to the above steps S302-S303, which will not be repeated here. Further, since the matching code block is obtained from the software development kit feature library, and the matching code block is cut out from the program code corresponding to a reference application, and the target code block is cut out from the program code of the target application, and the target code block is similar to the reference code block, it can also be determined through the embodiment of the present application that different applications use the same code block.

[0092] In an embodiment of the present invention, a computer device can respond to a code detection operation for a target application, segment a target code block from the program code of the target application, and for any reference code block, obtain a characteristic parameter of the target code block and a characteristic parameter of any reference code block, further perform similarity calculation on the characteristic parameter of the target code block and the characteristic parameter of any reference code block, obtain the code similarity between the target code block and any reference code block, and determine a matching code block that matches the target code block from at least one reference code block based on the code similarity between the target code block and each reference code block, and add target tag information to the target code block based on the matching code block. By determining the SDK to which the target code block belongs, it can be identified that the application integrates the SDK without extracting the characteristics of the SDK itself, thereby quickly detecting the type of SDK included in the application, effectively improving the efficiency of application detection.

[0093] Based on the application detection method provided above, the present application embodiment also provides a Figure 7 A more specific application detection method is shown. In the embodiment of the present invention, the code file of the target application is APK as an example for description. The specific process is as follows:

[0094] First, you can obtain the APK (Android application package) of the target application; after decompiling the APK, you can get the hierarchical structure of the program code of the target application, and then cut the program code according to the hierarchical structure of the program code to obtain Figure 7 There are n code blocks in the code block (i.e., code block 1, code block 2, ... code block n). Furthermore, the computer device performs hash calculation on the operation instructions of each code block in the n code blocks. When performing hash calculation on the operation instructions of each code block, the following four steps are required: (1) extracting multiple instruction fragments in the code block; (2) performing hash calculation on each instruction fragment in the multiple instruction fragments; (3) after performing hash calculation on each instruction fragment, weightedly merging the hash values ​​of the multiple instruction fragments; (4) after weighted merging the hash values ​​of the multiple instruction fragments, performing dimensionality reduction operation on the merged result, thereby obtaining the hash value of the operation instruction of the code block.

[0095] According to the above method, the hash values ​​corresponding to N code blocks can be obtained. After obtaining the hash values ​​of N code blocks, the computer device can perform similarity calculation on the hash value of each code block with the hash value of at least one reference code block in the software development kit feature library, and output the recognition result of the code block according to the result of the similarity calculation. By comparing the similarity of the code blocks by calculating the hash value of the operation instruction of the code block and the hash value of the operation instruction of the reference code block, the SDK integrated in the application can be identified more accurately. Among them, before the computer device can perform similarity calculation on the hash value of each code block with the hash value of at least one reference code block in the software development kit feature library, the software development kit feature library can be generated by cluster analysis.

[0096] In an embodiment of the present invention, a computer device can respond to a code detection operation for a target application, segment a target code block from the program code of the target application, and for any reference code block, obtain a characteristic parameter of the target code block and a characteristic parameter of any reference code block, further perform similarity calculation on the characteristic parameter of the target code block and the characteristic parameter of any reference code block, obtain the code similarity between the target code block and any reference code block, and determine a matching code block that matches the target code block from at least one reference code block based on the code similarity between the target code block and each reference code block, and add target tag information to the target code block based on the matching code block. By determining the SDK to which the target code block belongs, it can be identified that the application integrates the SDK without extracting the characteristics of the SDK itself, thereby quickly detecting the type of SDK included in the application, effectively improving the efficiency of application detection.

[0097] Based on the description of the above application detection method embodiment, the present application embodiment also discloses an application detection device, which can be a computer program (including program code) running on the above-mentioned computer device. The application detection device can execute Figure 3 or Figure 5 See the method shown in Figure 8 , the application detection device can run the following units:

[0098] The segmentation unit 801 is used to segment a target code block from the program code of the target application in response to a code detection operation on the target application;

[0099] A calculation unit 802, configured to calculate a code similarity between the target code block and at least one reference code block, where one reference code block corresponds to one software development kit;

[0100] A determining unit 803 is configured to determine a matching code block that matches the target code block from the at least one reference code block according to code similarities between the target code block and each reference code block;

[0101] The adding unit 804 is used to add target tag information to the target code block according to the matching code block, wherein the target tag information is used to indicate that the target code block belongs to the software development kit corresponding to the matching code block.

[0102] In another implementation, the device further includes: an acquisition unit 805, wherein:

[0103] The acquisition unit 805 is used to acquire the characteristic parameters of the target code block and the characteristic parameters of any reference code block for any reference code block;

[0104] The calculation unit 802 is used to perform similarity calculation on the characteristic parameters of the target code block and the characteristic parameters of any reference code block to obtain the code similarity between the target code block and any reference code block.

[0105] In another implementation, the characteristic parameter is an operation instruction, and the operation instruction includes a plurality of target instruction fragments; the acquisition unit 805 is specifically used to:

[0106] Obtain at least one class from the target code block, each class including at least one method and at least one variable;

[0107] Performing instruction extraction processing on each method in each class to obtain multiple candidate instruction fragments;

[0108] A plurality of target instruction fragments are selected from the plurality of candidate instruction fragments.

[0109] In another implementation, the determining unit 803 is used to: determine the instruction length of each candidate instruction fragment;

[0110] The acquisition unit is used to select a candidate instruction fragment whose instruction length is greater than a length threshold from the multiple candidate instruction fragments as a target instruction fragment.

[0111] In another implementation, the characteristic parameter is an operation instruction, and the calculation unit 802 is specifically configured to:

[0112] Using a target hash algorithm to perform a hash operation on the operation instructions of the target code block to obtain a target hash value; and using the target hash algorithm to perform a hash operation on the operation instructions of any reference code block to obtain a reference hash value;

[0113] A distance operation is performed on the target hash value and the reference hash value to obtain a code similarity between the target code block and any one of the reference code blocks.

[0114] In another implementation, the operation instruction of the target code block includes multiple target instruction fragments, and the target hash algorithm is a locality sensitive hash algorithm; the computing unit 802 is specifically used to:

[0115] Performing hash operations on each of the multiple target instruction fragments to obtain a hash value set, wherein the hash value set includes the hash value of each of the target instruction fragments;

[0116] Determine a weight value of each hash value according to the number of times each hash value appears in the hash value set;

[0117] The weight values ​​of the hash values ​​are used to perform weighted summation on the hash values ​​to obtain a target hash value.

[0118] In yet another implementation, the determining unit 803 is specifically configured to:

[0119] The number of times each hash value appears in the hash value set is used as the weight value of each hash value; or,

[0120] According to the number of times each hash value appears in the hash value set, the repetition degree of each hash value in the hash value set is determined; and the weight value corresponding to the repetition degree corresponding to each hash value is used as the weight value of each hash value.

[0121] In another implementation, the segmentation unit 801 is specifically configured to:

[0122] In response to a code detection operation for a target application, obtaining a code file of the target application, the code file including a program code of the target application;

[0123] Decompiling the code file to obtain a hierarchical structure of the program code;

[0124] Performing code segmentation on the program code of the target application according to the hierarchical structure to obtain at least one code block;

[0125] A target code block is selected from the at least one code block.

[0126] In another implementation, the at least one reference code block is stored in a software development kit feature library; the apparatus further includes an analysis unit 806, wherein:

[0127] The acquisition unit 805 is further configured to: acquire program codes of at least two reference applications, and divide the program codes of the at least two reference applications into a plurality of reference code blocks;

[0128] The analysis unit 806 is used to perform cluster analysis on the multiple reference code blocks, and group the multiple reference code blocks according to the analysis result; the reference code blocks in a group belong to the same software development kit;

[0129] The acquisition unit 805 is further used to acquire the tag information of each reference code block according to the group information of each reference code block; the tag information of any reference code block is generated after performing a joint feature analysis on each reference code block in the group to which the any reference code block belongs to determine the software development kit to which the any reference code block belongs;

[0130] The adding unit 804 is further configured to add each reference code block and corresponding tag information to the software development kit feature library.

[0131] According to one embodiment of the present application, Figure 3 or Figure 5 Each step involved in the method shown can be performed by Figure 8 The various units in the application detection device shown are executed. For example, Figure 3 Step S301 shown is composed of Figure 8 The segmentation unit 801 shown in FIG. 8 is used to perform step S302. Figure 8 The calculation unit 802 shown in FIG. 1 is executed, and step S303 is performed by Figure 8 The determination unit 803 shown in FIG. 8 is executed, and step S304 is performed by Figure 8 804 shown in . For example, Figure 5 Steps 501 to S504 are shown as follows: Figure 8 The segmentation unit 801 shown in FIG. 8 is used to perform step S505. Figure 8 The calculation unit 802 shown in FIG. 8 is used to perform step S506. Figure 8 The determination unit 803 shown in FIG. 8 is executed, and step S507 is performed by Figure 8 The adding unit 804 shown in FIG. 8 is used to perform the above operation.

[0132] According to another embodiment of the present application, Figure 8The various units in the application detection device shown can be respectively or all merged into one or several other units to constitute, or some (some) units therein can also be split into multiple smaller units in function to constitute, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above-mentioned units are divided based on logical functions. In practical applications, the function of a unit can also be realized by multiple units, or the function of multiple units can be realized by one unit. In other embodiments of the present application, other units can also be included based on the application detection device. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented by the collaboration of multiple units.

[0133] According to another embodiment of the present application, the system can include a central processing unit (CPU), a random access storage medium (RAM), a read-only storage medium (ROM), and other processing elements and storage elements. For example, a general computing device such as a computer can execute the following operations: Figure 3 or Figure 5 A computer program (including program code) for each step involved in the corresponding method shown in Figure 8 The application detection device shown in the figure implements the application detection method of the embodiment of the present application. The computer program can be recorded on a computer-readable recording medium, for example, and loaded into the above-mentioned computer device through the computer-readable recording medium and run therein.

[0134] In an embodiment of the present invention, in response to a code detection operation for a target application, a computer device divides a target code block from the program code of the target application, calculates the code similarity between the target code block and at least one reference code block, and then determines a matching code block that matches the target code block from at least one reference code block based on the code similarity between the target code block and each reference code block; and adds target tag information to the target code block based on the matching code block. The computer device does not need to obtain the source package or jar package of the SDK to extract the features of the SDK itself, but only needs to cut the program code of the target application and perform similarity analysis between the cut code blocks and the reference code blocks, so as to quickly detect the SDK integrated in the target application, which can effectively improve the efficiency of application detection.

[0135] Based on the description of the above application detection method embodiment, the present application embodiment also discloses a computer device, see Fig. 9The computer device may at least include a processor 901, an input device 902, an output device 903, and a computer storage medium 904. The processor 901, the input device 902, the output device 903, and the computer storage medium 904 in the computer device may be connected via a bus or other means.

[0136] The computer storage medium 904 is a memory device in a computer device for storing programs and data. It is understandable that the computer storage medium 904 here can include both the built-in storage medium of the computer device and the extended storage medium supported by the computer device. The computer storage medium 904 provides a storage space, which stores the operating system of the computer device. In addition, one or more instructions suitable for being loaded and executed by the processor 901 are also stored in the storage space. These instructions can be one or more computer programs (including program codes). It should be noted that the computer storage medium here can be a high-speed RAM memory; optionally, it can also be at least one computer storage medium away from the aforementioned processor. The processor can be called a central processing unit (CPU), which is the core and control center of the computer device, suitable for implementing one or more instructions, specifically loading and executing one or more instructions to achieve the corresponding method flow or function.

[0137] In a feasible embodiment, the processor 901 may load and execute one or more first instructions stored in a computer storage medium to implement the corresponding steps of the method in the above-mentioned application detection method embodiment; in a specific implementation, the processor 901 loads one or more first instructions in the computer storage medium and performs the following operations:

[0138] In response to a code detection operation for a target application, segmenting a target code block from a program code of the target application;

[0139] Calculating code similarity between the target code block and at least one reference code block, one reference code block corresponding to one software development kit;

[0140] Determining a matching code block that matches the target code block from the at least one reference code block according to code similarities between the target code block and each reference code block;

[0141] Target tag information is added to the target code block according to the matching code block, where the target tag information is used to indicate that the target code block belongs to a software development kit corresponding to the matching code block.

[0142] In yet another implementation, the processor 901 is specifically configured to:

[0143] For any reference code block, acquiring characteristic parameters of the target code block and characteristic parameters of any reference code block;

[0144] A similarity calculation is performed on the characteristic parameters of the target code block and the characteristic parameters of any one of the reference code blocks to obtain the code similarity between the target code block and any one of the reference code blocks.

[0145] In another implementation, the characteristic parameter is an operation instruction, and the operation instruction includes a plurality of target instruction fragments; the processor 901 is specifically configured to:

[0146] Obtain at least one class from the target code block, each class including at least one method and at least one variable;

[0147] Performing instruction extraction processing on each method in each class to obtain multiple candidate instruction fragments;

[0148] A plurality of target instruction fragments are selected from the plurality of candidate instruction fragments.

[0149] In yet another implementation, the processor 901 is specifically configured to:

[0150] Determine the instruction length of each candidate instruction fragment;

[0151] A candidate instruction fragment whose instruction length is greater than a length threshold is selected from the multiple candidate instruction fragments as a target instruction fragment.

[0152] In another implementation, the characteristic parameter is an operation instruction, and the processor 901 is specifically configured to:

[0153] Using a target hash algorithm to perform a hash operation on the operation instructions of the target code block to obtain a target hash value; and using the target hash algorithm to perform a hash operation on the operation instructions of any reference code block to obtain a reference hash value;

[0154] A distance operation is performed on the target hash value and the reference hash value to obtain a code similarity between the target code block and any one of the reference code blocks.

[0155] In another implementation, the operation instruction of the target code block includes multiple target instruction fragments, and the target hash algorithm is a locality sensitive hash algorithm; the processor 901 is specifically configured to:

[0156] Performing hash operations on each of the multiple target instruction fragments to obtain a hash value set, wherein the hash value set includes the hash value of each of the target instruction fragments;

[0157] Determine a weight value of each hash value according to the number of times each hash value appears in the hash value set;

[0158] The weight values ​​of the hash values ​​are used to perform weighted summation on the hash values ​​to obtain a target hash value.

[0159] In yet another implementation, the processor 901 is specifically configured to:

[0160] The number of times each hash value appears in the hash value set is used as the weight value of each hash value; or,

[0161] According to the number of times each hash value appears in the hash value set, the repetition degree of each hash value in the hash value set is determined; and the weight value corresponding to the repetition degree corresponding to each hash value is used as the weight value of each hash value.

[0162] In yet another implementation, the processor 901 is specifically configured to:

[0163] In response to a code detection operation for a target application, obtaining a code file of the target application, the code file including a program code of the target application;

[0164] Decompiling the code file to obtain a hierarchical structure of the program code;

[0165] Performing code segmentation on the program code of the target application according to the hierarchical structure to obtain at least one code block;

[0166] A target code block is selected from the at least one code block.

[0167] In yet another implementation, the at least one reference code block is stored in a software development kit feature library; the processor 901 is further configured to:

[0168] Obtaining program codes of at least two reference applications, and dividing the program codes of the at least two reference applications into a plurality of reference code blocks;

[0169] Performing cluster analysis on the multiple reference code blocks, and grouping the multiple reference code blocks according to the analysis results; the reference code blocks in a group belong to the same software development kit;

[0170] According to the group information of each reference code block, the tag information of each reference code block is obtained; the tag information of any reference code block is generated after performing a joint feature analysis on each reference code block in the group to which the any reference code block belongs to determine the software development kit to which the any reference code block belongs;

[0171] Each reference code block and corresponding tag information are added to a software development kit feature library.

[0172] In an embodiment of the present invention, in response to a code detection operation for a target application, a computer device divides a target code block from the program code of the target application, calculates the code similarity between the target code block and at least one reference code block, and then determines a matching code block that matches the target code block from at least one reference code block based on the code similarity between the target code block and each reference code block; and adds target tag information to the target code block based on the matching code block. The computer device does not need to obtain the source package or jar package of the SDK to extract the features of the SDK itself, but only needs to cut the program code of the target application and perform similarity analysis between the cut code blocks and the reference code blocks, so as to quickly detect the SDK integrated in the target application, which can effectively improve the efficiency of application detection.

[0173] It should be noted that the embodiment of the present application also provides a computer program product or a computer program, which includes a computer instruction, and the computer instruction is stored in a computer-readable storage medium. The processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the above-mentioned application detection method embodiment. Figure 3 or Figure 5 The steps performed in

[0174] What is disclosed above is only a preferred embodiment of the present invention, and it certainly cannot be used to limit the scope of rights of the present invention. Ordinary technicians in this field can understand that all or part of the processes of the above embodiment and equivalent changes made according to the claims of the present invention still fall within the scope of the invention.

Claims

1. An application detection method, characterized in that: include: In response to a code detection operation for a target application, obtaining a code file of the target application, the code file including a program code of the target application; Decompiling the code file to obtain a hierarchical structure of the program code; Determining a starting level to be traversed from the hierarchical structure, and traversing each code package identifier in the starting level; If the target code package identifier currently traversed is in the preset cutting list, the codes corresponding to the code package identifiers in the level below the starting level are cut into different code blocks; If the target code package identifier is not in the cutting list, determining whether the first parent code package identifier corresponding to the target code package identifier in the first level is in the cutting list, where the first level refers to the level above the starting level; If the first parent code package identifier is in the cut list, the code corresponding to the target code package identifier is cut into a code block; If the first parent code package identifier is not in the cutting list, then based on the first level, search the hierarchical structure for a parent code package identifier that satisfies the cutting list in a bottom-up order, and when the parent code package identifier corresponding to the target level satisfies the cutting list, cut the codes corresponding to each code package identifier in the level below the target level into different code blocks; Selecting a target code block from at least one code block obtained by cutting; Calculating code similarity between the target code block and at least one reference code block, one reference code block corresponds to one software development kit, and the at least one reference code block is stored in a software development kit feature library; Determining, from the at least one reference code block, a matching code block that matches the target code block according to the code similarity between the target code block and each reference code block, wherein the matching code block refers to a reference code block having the greatest code similarity with the target code block; Target tag information is added to the target code block according to the matching code block, where the target tag information is used to indicate that the target code block belongs to a software development kit corresponding to the matching code block.

2. The method according to claim 1, characterized in that The calculating the code similarity between the target code block and at least one reference code block comprises: For any reference code block, acquiring characteristic parameters of the target code block and characteristic parameters of any reference code block; A similarity calculation is performed on the characteristic parameters of the target code block and the characteristic parameters of any one of the reference code blocks to obtain the code similarity between the target code block and any one of the reference code blocks.

3. The method according to claim 2, characterized in that The characteristic parameter is an operation instruction, and the operation instruction includes a plurality of target instruction fragments; the step of obtaining the characteristic parameter of the target code block includes: Obtain at least one class from the target code block, each class including at least one method and at least one variable; Performing instruction extraction processing on each method in each class to obtain multiple candidate instruction fragments; A plurality of target instruction fragments are selected from the plurality of candidate instruction fragments.

4. The method according to claim 3, characterized in that The selecting a plurality of target instruction fragments from the plurality of candidate instruction fragments comprises: Determine the instruction length of each candidate instruction fragment; A candidate instruction fragment whose instruction length is greater than a length threshold is selected from the multiple candidate instruction fragments as a target instruction fragment.

5. The method according to any one of claims 2 to 4, characterized in that: The characteristic parameter is an operation instruction, and the characteristic similarity calculation is performed on the characteristic parameter of the target code block and the characteristic parameter of any reference code block to obtain the code similarity between the target code block and any reference code block, including: Using a target hash algorithm to perform a hash operation on the operation instructions of the target code block to obtain a target hash value; and using the target hash algorithm to perform a hash operation on the operation instructions of any reference code block to obtain a reference hash value; A distance operation is performed on the target hash value and the reference hash value to obtain a code similarity between the target code block and any one of the reference code blocks.

6. The method according to claim 5, characterized in that The operation instructions of the target code block include multiple target instruction fragments, and the target hash algorithm is a locality sensitive hash algorithm; the target hash algorithm is used to perform a hash operation on the operation instructions of the target code block to obtain a target hash value, including: Performing hash operations on each of the multiple target instruction fragments to obtain a hash value set, wherein the hash value set includes the hash value of each of the target instruction fragments; Determine a weight value of each hash value according to the number of times each hash value appears in the hash value set; The weight values ​​of the hash values ​​are used to perform weighted summation on the hash values ​​to obtain a target hash value.

7. The method according to claim 6, characterized in that The determining the weight value of each hash value according to the number of times each hash value appears in the hash value set includes: The number of times each hash value appears in the hash value set is used as the weight value of each hash value; or, According to the number of times each hash value appears in the hash value set, the repetition degree of each hash value in the hash value set is determined; and the weight value corresponding to the repetition degree corresponding to each hash value is used as the weight value of each hash value.

8. The method according to claim 1, characterized in that The method further comprises: Obtaining program codes of at least two reference applications, and dividing the program codes of the at least two reference applications into a plurality of reference code blocks; Performing cluster analysis on the multiple reference code blocks, and grouping the multiple reference code blocks according to the analysis results; the reference code blocks in a group belong to the same software development kit; According to the group information of each reference code block, the tag information of each reference code block is obtained; the tag information of any reference code block is generated after performing a joint feature analysis on each reference code block in the group to which the any reference code block belongs to determine the software development kit to which the any reference code block belongs; Each reference code block and corresponding tag information are added to a software development kit feature library.

9. An application detection device, characterized in that: include: a segmentation unit, configured to obtain a code file of the target application in response to a code detection operation on the target application, wherein the code file includes a program code of the target application; The segmentation unit is further used to decompile the code file to obtain the hierarchical structure of the program code; Determining a starting level to be traversed from the hierarchical structure, and traversing each code package identifier in the starting level; If the target code package identifier currently traversed is in the preset cutting list, the codes corresponding to the code package identifiers in the level below the starting level are cut into different code blocks; If the target code package identifier is not in the cutting list, determining whether the first parent code package identifier corresponding to the target code package identifier in the first level is in the cutting list, where the first level refers to the level above the starting level; If the first parent code package identifier is in the cut list, the code corresponding to the target code package identifier is cut into a code block; If the first parent code package identifier is not in the cutting list, then based on the first level, search the hierarchical structure for a parent code package identifier that satisfies the cutting list in a bottom-up order, and when the parent code package identifier corresponding to the target level satisfies the cutting list, cut the codes corresponding to each code package identifier in the level below the target level into different code blocks; Selecting a target code block from at least one code block obtained by cutting; a calculation unit, configured to calculate a code similarity between the target code block and at least one reference code block, wherein one reference code block corresponds to one software development kit, and the at least one reference code block is stored in a software development kit feature library; a determining unit, configured to determine, from the at least one reference code block, a matching code block that matches the target code block according to the code similarity between the target code block and each reference code block, wherein the matching code block refers to a reference code block having the greatest code similarity with the target code block; An adding unit is used to add target tag information to the target code block according to the matching code block, wherein the target tag information is used to indicate that the target code block belongs to a software development kit corresponding to the matching code block.

Citation Information

Patent Citations

  • Virus characteristic code processing method and device

    CN106803040A

  • Open source class library monitoring method, device and equipment and computer storage medium

    CN109710299A

  • Android application program repackaged data processing method and device

    CN110175045A

  • Private data detection method and device and computer readable storage medium

    CN111190603A

  • Supply chain code identification method and device, server and readable storage medium

    CN111338622A