Method, device and equipment for detecting malicious code
By obtaining the function call graph and sensitive API call sequence of the APK file, a feature vector is constructed for malicious code detection, which solves the low accuracy problem caused by not considering the function call relationship in the existing technology, and achieves more accurate malicious code detection.
Patent Information
- Application Number
- CN202011593644.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-29
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2040-12-29
AI Technical Summary
The existing technology does not consider the calling relationship of functions in the application when detecting Android malicious code, resulting in low detection accuracy.
By obtaining the function call graph of the APK file to be tested, sensitive API call sequences and feature vectors are extracted, and input into the preset malicious code detection model for detection. The function call relationship of the APK file to be tested is taken into account to improve detection accuracy.
It improves the detection accuracy of Android malicious code, can more accurately identify malicious code, and enhances the protection of user privacy.
Smart Images

Figure CN112651024B
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication security technology, for example, to a method, apparatus and device for detecting malicious code. Background Art
[0002] At present, with the rapid development of mobile Internet and the popularity of smart devices, the threat of malicious code to the system security and user information security of smart devices has also increased. In recent years, the Android system has occupied most of the market for smart terminals. Due to its open source nature, the Android system has occupied more than 80% of the market. The Android platform has become the main target of malware attacks. Malicious applications are created to perform different types of attacks, such as stealing user private information, sending messages without user permission, luring users to visit malicious websites, etc., posing a serious threat to smartphone users. How to accurately detect Android malicious code and protect user privacy has become a hot topic in recent years.
[0003] In the process of implementing the embodiments of the present disclosure, it is found that there are at least the following problems in the related art:
[0004] The prior art does not consider the calling relationship of functions in the application, resulting in low accuracy in detecting Android malicious code. Summary of the invention
[0005] In order to provide a basic understanding of some aspects of the disclosed embodiments, a brief summary is given below. The summary is not an extensive review, nor is it intended to identify key / critical components or delineate the scope of protection of these embodiments, but rather serves as a prelude to the detailed description that follows.
[0006] The embodiments of the present disclosure provide a method, apparatus and device for detecting malicious code, so as to improve the accuracy of detecting malicious code on Android.
[0007] In some embodiments, the method for malicious code detection includes:
[0008] Get the first function call graph of the APK file to be tested;
[0009] Acquire a first sensitive API call sequence of the APK file to be tested according to the first function call graph;
[0010] Acquire a first feature vector of the APK file to be tested according to the first sensitive API call sequence;
[0011] The first feature vector is input into a preset malicious code detection model to obtain a detection result of whether the APK file to be tested is malicious code.
[0012] In some embodiments, the apparatus for malicious code detection includes a processor and a memory storing program instructions, and the processor is configured to execute the method for malicious code detection as described above when running the program instructions.
[0013] In some embodiments, the device includes the above-mentioned apparatus for malicious code detection.
[0014] The method, device and equipment for malicious code detection provided by the embodiments of the present disclosure can achieve the following technical effects: by obtaining the first function call graph FCG of the APK file to be tested, obtaining the first sensitive API call sequence according to the first function call graph, and obtaining the first feature vector of the APK file to be tested according to the first sensitive API call sequence; and by inputting the first feature vector into a preset malicious code detection model, obtaining the detection result of whether the APK file to be tested is malicious code. Compared with the prior art, the function call relationship of the APK file to be tested is taken into account when performing malicious code detection, and the Android detection malicious code can be detected more accurately.
[0015] The above general description and the following description are exemplary and explanatory only and are not intended to limit the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] One or more embodiments are exemplarily described by corresponding drawings, which do not limit the embodiments. Elements with the same reference numerals in the drawings are shown as similar elements, and the drawings do not constitute a scale limitation, and wherein:
[0017] Figure 1 is a schematic diagram of a method for malicious code detection provided by an embodiment of the present disclosure;
[0018] Figure 2 is a schematic diagram of a process of reconstructing a second function call graph provided by an embodiment of the present disclosure;
[0019] Figure 3 is a schematic diagram of a second sensitive API call graph provided by an embodiment of the present disclosure;
[0020] Figure 4 It is a schematic diagram of a device for malicious code detection provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0021] In order to be able to understand the features and technical contents of the embodiments of the present disclosure in more detail, the implementation of the embodiments of the present disclosure is described in detail below in conjunction with the accompanying drawings. The attached drawings are for reference only and are not used to limit the embodiments of the present disclosure. In the following technical description, for the convenience of explanation, a full understanding of the disclosed embodiments is provided through multiple details. However, one or more embodiments can still be implemented without these details. In other cases, to simplify the drawings, well-known structures and devices can be simplified for display.
[0022] The terms "first", "second", etc. in the specification and claims of the embodiments of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchanged where appropriate, so that the embodiments of the embodiments of the present disclosure described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions.
[0023] Unless otherwise stated, the term "plurality" means two or more.
[0024] In the embodiment of the present disclosure, the character " / " indicates that the preceding and following objects are in an "or" relationship. For example, A / B indicates: A or B.
[0025] The term "and / or" is a description of the association relationship between objects, indicating that three relationships can exist. For example, A and / or B means: A or B, or, A and B.
[0026] Combination Figure 1 As shown, the embodiment of the present disclosure provides a method for detecting malicious code, including:
[0027] Step S101, obtaining a first function call graph (FCG) of an APK (Android application package) file to be tested;
[0028] Step S102, obtaining a first sensitive API (Application Programming Interface) calling sequence of the APK file to be tested according to the first function call graph;
[0029] Step S103, obtaining a first feature vector of the APK file to be tested according to the first sensitive API call sequence;
[0030] Step S104: input the first feature vector into a preset malicious code detection model to obtain a detection result of whether the APK file to be tested is malicious code.
[0031] The method for malicious code detection provided by the embodiment of the present disclosure is adopted, by obtaining the first function call graph FCG of the APK file to be tested, obtaining the first sensitive API call sequence according to the first function call graph, and obtaining the first feature vector of the APK file to be tested according to the first sensitive API call sequence; and by inputting the first feature vector into a preset malicious code detection model, a detection result of whether the APK file to be tested is malicious code is obtained. Compared with the prior art, the function call relationship of the APK file to be tested is taken into account when performing malicious code detection, and the Android detection malicious code can be detected more accurately.
[0032] Optionally, call the FlowDroid tool to extract the first function call graph FCG from the APK file to be tested. Optionally, the first function call graph FCG is the function names in the APK file to be tested and the calling relationships between the functions. Optionally, the nodes in the first function call graph FCG are the functions in the APK file to be tested. Optionally, the functions include: one or more of the custom functions of the APK file to be tested, the function interfaces of the Android official documents, the Google API, etc. Optionally, the edges in the first function call graph FCG are the calls of one function to another function.
[0033] Optionally, obtaining the first sensitive API call sequence of the APK file to be tested according to the first function call graph includes: matching the nodes in the first function call graph with the API nodes in the preset sensitive API set, and determining the corresponding nodes in the first function call graph as the first sensitive API nodes when the nodes in the first function call graph are the same as the API nodes in the sensitive API set; or, when the nodes in the first function call graph are different from the API nodes in the sensitive API set, determining the corresponding nodes in the first function call graph as the first non-sensitive API nodes; deleting the first non-sensitive API nodes and their corresponding edges to obtain the first sensitive API call graph of the APK file to be tested; when there is at least one edge between the first sensitive API nodes in the first sensitive API call graph, adding a directed edge between the corresponding two first sensitive API nodes in the first sensitive API call graph to obtain the first sensitive API call sequence. In this way, the first sensitive API call graph of the APK file to be tested is obtained by deleting the first non-sensitive API nodes and their corresponding edges that are not related to malicious behavior. The first sensitive API call graph reduces a large number of nodes and edges relative to the first function call graph, thereby improving the efficiency of malicious code detection. In addition, the extracted first sensitive API call sequence is related to suspicious behaviors such as malicious code in the APK file to be tested, making the first sensitive API call sequence more effective. By using the first sensitive API call sequence as a feature, the accuracy of malicious code can be improved.
[0034] Optionally, the first feature vector of the APK file to be tested is obtained according to the first sensitive API call sequence, including: determining whether any first sensitive API call sequence appears in the APK file to be tested, and if so, determining that the feature value corresponding to the first sensitive API call sequence is "1", otherwise determining that the feature value corresponding to the first sensitive API call sequence is "0", and obtaining the first feature vector.
[0035] Optionally, before inputting the first feature vector into a preset malicious code detection model, the method further includes: obtaining a second function call graph FCG of the APK file sample, wherein the types of the APK file sample include: malicious APK file samples and benign APK file samples; obtaining a second sensitive API call sequence of the APK file sample according to the second function call graph; obtaining classification features of the APK file sample according to the second sensitive API call sequence; obtaining a second feature vector of the APK file sample according to the classification features; and training according to the second feature vector to construct a malicious code detection model.
[0036] Optionally, the FlowDroid tool is called to extract the second function call graph FCG from the APK file sample. Optionally, the second function call graph FCG is the functions in the APK file sample and the calling relationships between the functions. Optionally, the nodes in the second function call graph FCG are the functions in the APK file sample. Optionally, the functions include: one or more of the custom functions of the APK file sample, the function interfaces of the Android official documents, the Google API, etc. Optionally, the edges in the second function call graph FCG are the calls of one function to another function.
[0037] Optionally, before obtaining the second function call graph FCG of the APK file sample, the method further includes: preprocessing the APK file sample. Optionally, preprocessing the APK file sample includes: calling VirusTotal to filter all APK file samples. Optionally, for the malicious APK file sample data set, deleting the APK file samples that are identified as malicious by less than one anti-virus engine in VirusTotal. Optionally, for the benign APK file sample data set, deleting the APK file samples that are identified as malicious by one or more anti-virus engines in VirusTotal.
[0038] Optionally, obtaining a second sensitive API call sequence of the APK file sample according to the second function call graph includes: obtaining a second sensitive API call graph of the APK file sample according to the second function call graph; and obtaining a second sensitive API call sequence according to the second sensitive API call graph.
[0039] Optionally, obtaining the second sensitive API call graph of the APK file sample according to the second function call graph includes: matching the nodes in the second function call graph with the API nodes in the preset sensitive API set, and determining the corresponding node in the second function call graph as the second sensitive API node when the node in the second function call graph is the same as the API node in the sensitive API set; or, when the node in the second function call graph is different from the API node in the sensitive API set, determining the corresponding node in the second function call graph as the second non-sensitive API node; deleting the second non-sensitive API node and its corresponding edge to obtain the second sensitive API call graph of the APK file sample. In this way, the second sensitive API call graph of the APK file sample is obtained by deleting the second non-sensitive API node and its corresponding edge that are not related to malicious behavior, and the second sensitive API call graph reduces a large number of nodes and edges relative to the second function call graph, thereby improving the efficiency of malicious code detection.
[0040] Optionally, obtain the sensitive API set through the SUSI tool.
[0041] In some embodiments, the second function call graph is reconstructed, that is, the second non-sensitive API node and its corresponding edge in the second function call graph are deleted to obtain a second sensitive API call graph. Figure 2 and Figure 3 As shown, Figure 2 is a schematic diagram of the process of reconstructing the second function call graph, Figure 3 This is a schematic diagram of the reconstructed second sensitive API call graph. White circles represent non-sensitive API call nodes, gray circles represent sensitive API call nodes, solid lines represent call relationships in the function call graph, and dotted lines represent reconstructed edges. The second non-sensitive API node and its corresponding edge are deleted.
[0042] Optionally, obtaining a second sensitive API call sequence according to the second sensitive API call graph includes: when there is at least one edge between each second sensitive API node in the second sensitive API call graph, adding a directed edge between two corresponding second sensitive API nodes in the second sensitive API call graph to obtain a second sensitive API call sequence.
[0043] In this way, by deleting the second non-sensitive API node and its corresponding edge that are not related to malicious behavior, the second sensitive API call graph of the APK file sample is obtained, thereby obtaining the second sensitive API call sequence, and the second sensitive API call sequence related to suspicious behaviors such as malicious code in the APK file sample can be extracted, making the second sensitive API call sequence more effective, and the malicious code detection model obtained by training with the second sensitive API call sequence as a feature can detect malicious code more accurately.
[0044] Optionally, the classification feature of the APK file sample is obtained according to the second sensitive API call sequence, including: obtaining the support of the second sensitive API call sequence; determining the second sensitive API call sequence corresponding to the support that meets the preset conditions as the classification feature of the APK file sample. In this way, a frequent second sensitive API call sequence, that is, a frequent behavior pattern of the application program can be obtained, and malicious code can be detected according to the frequent behavior pattern of the application program, which can improve the accuracy of malicious code detection. At the same time, it can avoid the problem of imbalance of the second sensitive API call sequence between each APK file sample when extracting the second sensitive API call sequence from each APK file sample, that is, some APK file samples only extract one second sensitive API call sequence, while some APK file samples extract dozens or hundreds of second sensitive API call sequences.
[0045] Optionally, the support degree that meets a preset condition includes: a support degree that is greater than or equal to a set threshold.
[0046] Optionally, the classification features of the APK file sample are obtained according to the second sensitive API call sequence, including: mining the second sensitive API call sequence to extract the frequent second sensitive API call sequence; determining the frequent second sensitive API call sequence as the classification feature. Optionally, the frequent second sensitive API call sequence includes high-frequency subsequences commonly used in applications in the benign APK file sample and the malicious APK file sample set. In some embodiments, the malicious code and the benign code exhibit different behavior patterns, that is, the malicious code and the benign code exhibit different combinations of API call sequences, and the respective laws are discovered through high-frequency subsequences. By mining the potential relationship between the second sensitive API call sequences, the frequent second sensitive API call sequences are obtained, and the malicious APK file sample data set and the benign APK file sample data set are separately mined and processed to discover the respective behavior patterns of the malicious APK file sample and the benign APK file sample. It can more effectively distinguish malicious applications from benign applications and improve the accuracy and efficiency of detection. At the same time, the behavior patterns of malicious applications can be discovered, which is convenient for understanding the intentions of malicious applications.
[0047] Optionally, the frequent sensitive API call sequence is a second sensitive API call sequence whose support is greater than or equal to a threshold.
[0048] In some embodiments, the number of elements contained in the sensitive API call sequence is called the length of the sequence. For example, a sensitive API call sequence of length x is recorded as x-sensitive API call sequence. Optionally, mining the second sensitive API call sequence includes: obtaining 1-second sensitive API call sequence in the second sensitive API call sequence data set, and obtaining a candidate set C 1 , delete the 1-second sensitive API call sequences whose support is less than the set threshold to obtain the set L of frequent 1-second sensitive API call sequences 1 ; L 1 Connection pruning generates 2-second sensitive API call sequences and obtains candidate set C 2 , delete the 2-second sensitive API call sequences that are less than the set threshold to obtain the set L of frequent 2-second sensitive API call sequences 2 ; L 2 Connection pruning generates 3-second sensitive API call sequences and obtains candidate set C 3 , delete the 3-second sensitive API call sequences that are less than the set threshold to obtain the set L of frequent 3-second sensitive API call sequences 3 ; And so on, we get the set L of frequent n-second sensitive API call sequences n ; where n is a positive integer exponent.
[0049] Optionally, after mining the second sensitive API call sequence, all subsequences of the second sensitive API call sequence obtained by mining are retained. In this way, malicious applications and benign applications can be better distinguished, thereby improving the accuracy of malicious code detection.
[0050] Optionally, by calculating: w-supp k (s i )=S k (s i )*A k (s i ) obtain the support degree of the second sensitive API call sequence;
[0051] Among them, w-supp k (s i ) is the second sensitive API call sequence s i The support level in the APK file samples of type k, S k (s i ) is the second sensitive API call sequence s i The frequency of occurrence in the second sensitive API call sequence of all APK file samples of type k, A k (s i ) is the second sensitive API call sequence s iThe frequency of occurrence in all APK file samples of type k, where type k is a malicious APK file sample or a benign APK file sample.
[0052] Optionally, by calculating Get the second sensitive API call sequence s i The frequency of occurrence in the second sensitive API call sequence of all APK file samples of type k; where NS k is the number of the second sensitive API call sequences of all APK file samples of type k, Occ(s i ,NS k ) is the API sequence s i The number of times the second sensitive API call sequence appears in all APK file samples of type k.
[0053] Optionally, by calculating Get the second sensitive API call sequence s i The frequency of occurrence in all APK file samples of type k; NA k is the total number of APK file samples of type k, Occ(s i ,NA k ) is the sensitive API call sequence s contained in all APK file samples of type k i The number of APK file samples.
[0054] Optionally, after obtaining the classification features of the APK file sample according to the second sensitive API call sequence, it also includes: obtaining the intersection of the sensitive API call sequence set of the malicious APK file sample and the sensitive API call sequence set of the benign APK file sample in the classification features; deleting the intersection from the classification features. In this way, selecting frequent call sequences that only appear in malicious APK file samples or benign APK file samples as classification features can better distinguish between malware and benign software; and by deleting frequent call sequences that appear in both the malicious APK file sample set and the benign APK file sample set, the number of classification features is reduced and the detection efficiency is improved.
[0055] Optionally, the second feature vector of the APK file sample is obtained according to the classification feature, including: in the classification feature, determining whether any second sensitive API call sequence appears in the APK file sample, if yes, determining the feature value corresponding to the second sensitive API call sequence to be "1", otherwise determining the feature value corresponding to the second sensitive API call sequence to be "0", and obtaining the second feature vector. Optionally, the label of the malicious APK file sample is determined to be "1", and the label of the benign APK file sample is determined to be "0".
[0056] Optionally, training is performed based on the second feature vector to construct a malicious code detection model, including: training the second feature vector through a random forest (RF) algorithm to construct a malicious code detection model. This is a prior art and will not be described in detail here.
[0057] Optionally, the first feature vector of the APK file to be tested is input into a trained malicious code detection model to obtain a detection result of whether the APK file to be tested is malicious code. Optionally, when the output detection result is "1", the APK file to be tested is malware; when the output detection result is "0", the APK file to be tested is benign software. In this way, applying machine learning to malicious code analysis and detection achieves better performance than traditional machine learning algorithms, and achieves a higher degree of automation and accuracy.
[0058] The method for malicious code detection provided by the embodiment of the present disclosure can construct higher-level semantics by using frequent sensitive API sequence behavior patterns, making it easier for users to discover potential malicious behavior patterns, thereby enabling more accurate detection of malicious code in Android applications.
[0059] Combination Figure 4 As shown, an embodiment of the present disclosure provides a device for malicious code detection, including a processor 100 and a memory 101. Optionally, the device may also include a communication interface 102 and a bus 103. The processor 100, the communication interface 102, and the memory 101 may communicate with each other through the bus 103. The communication interface 102 may be used for information transmission. The processor 100 may call the logic instructions in the memory 101 to execute the method for malicious code detection of the above embodiment.
[0060] In addition, the logic instructions in the memory 101 described above may be implemented in the form of software functional units and when sold or used as independent products, may be stored in a computer-readable storage medium.
[0061] The memory 101 is a computer-readable storage medium that can be used to store software programs and computer executable programs, such as program instructions / modules corresponding to the method in the embodiment of the present disclosure. The processor 100 executes the function application and data processing by running the program instructions / modules stored in the memory 101, that is, the method for malicious code detection in the above embodiment is implemented.
[0062] The memory 101 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function; the data storage area may store data created according to the use of the terminal device, etc. In addition, the memory 101 may include a high-speed random access memory and may also include a non-volatile memory.
[0063] The device for malicious code detection provided by the embodiment of the present disclosure is adopted, by obtaining the first function call graph FCG of the APK file to be tested, obtaining the first sensitive API call sequence according to the first function call graph, and obtaining the first feature vector of the APK file to be tested according to the first sensitive API call sequence; and by inputting the first feature vector into a preset malicious code detection model, a detection result of whether the APK file to be tested is malicious code is obtained. Compared with the prior art, the function call relationship of the APK file to be tested is taken into account when performing malicious code detection, and the Android detection malicious code can be detected more accurately.
[0064] An embodiment of the present disclosure provides a device, comprising the above-mentioned apparatus for malicious code detection.
[0065] Optionally, the device includes a computer or a server, etc.
[0066] The device obtains the first function call graph FCG of the APK file to be tested, obtains the first sensitive API call sequence according to the first function call graph, and obtains the first feature vector of the APK file to be tested according to the first sensitive API call sequence; and obtains the detection result of whether the APK file to be tested is malicious code by inputting the first feature vector into a preset malicious code detection model. Compared with the prior art, the function call relationship of the APK file to be tested is taken into account when performing malicious code detection, and the Android detection malicious code can be detected more accurately.
[0067] An embodiment of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are configured to execute the above-mentioned method for malicious code detection.
[0068] An embodiment of the present disclosure provides a computer program product, which includes a computer program stored on a computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer executes the above-mentioned method for malicious code detection.
[0069] The computer-readable storage medium mentioned above may be a transient computer-readable storage medium or a non-transitory computer-readable storage medium.
[0070] The technical solution of the embodiment of the present disclosure can be embodied in the form of a software product, which is stored in a storage medium and includes one or more instructions for enabling a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in the embodiment of the present disclosure. The aforementioned storage medium may be a non-transient storage medium, including: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes, or a transient storage medium.
[0071] The above description and the accompanying drawings fully illustrate the embodiments of the present disclosure so that those skilled in the art can practice them. Other embodiments may include structural, logical, electrical, process and other changes. The embodiments represent only possible changes. Unless explicitly required, separate components and functions are optional, and the order of operation may vary. The parts and features of some embodiments may be included in or replace the parts and features of other embodiments. Moreover, the words used in this application are only used to describe the embodiments and are not used to limit the claims. As used in the description of the embodiments and the claims, unless the context clearly indicates, the singular forms of "a", "an" and "the" are intended to include plural forms as well. Similarly, the term "and / or" as used in this application refers to any and all possible combinations of listings containing one or more associated ones. In addition, when used in the present application, the term "comprise" and its variants "comprises" and / or comprising refer to the presence of stated features, wholes, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof. In the absence of further restrictions, the elements defined by the sentence "comprising a ..." do not exclude the presence of other identical elements in the process, method or device comprising the elements. In this article, each embodiment may focus on the differences from other embodiments, and the same and similar parts between the various embodiments may refer to each other. For the methods, products, etc. disclosed in the embodiments, if they correspond to the method part disclosed in the embodiments, then the relevant parts can refer to the description of the method part.
[0072] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software may depend on the specific application and design constraints of the technical solution. The technicians may use different methods for each specific application to implement the described functions, but such implementations should not be considered to exceed the scope of the embodiments of the present disclosure. The technicians may clearly understand that, for the convenience and simplicity of description, the specific working processes of the systems, devices and units described above may refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.
[0073] In the embodiments disclosed herein, the disclosed methods and products (including but not limited to devices, equipment, etc.) can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units can be only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between each other shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms. The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to implement this embodiment. In addition, each functional unit in the embodiment of the present disclosure may be integrated in a processing unit, or each unit may exist physically alone, or two or more units may be integrated in one unit.
[0074] The flowchart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to the embodiment of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. In some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. In the description corresponding to the flowchart and the block diagram in the accompanying drawings, the operations or steps corresponding to different boxes can also occur in a different order from the order disclosed in the description, and sometimes there is no specific order between different operations or steps. For example, two consecutive operations or steps can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. Each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented by a dedicated hardware-based system that performs the specified functions or actions, or may be implemented by a combination of dedicated hardware and computer instructions.
Claims
1. A method for detecting malicious code, characterized in that: include: Get the first function call graph of the APK file to be tested; Acquire a first sensitive API call sequence of the APK file to be tested according to the first function call graph; Acquire a first feature vector of the APK file to be tested according to the first sensitive API call sequence; Inputting the first feature vector into a preset malicious code detection model to obtain a detection result of whether the APK file to be tested is malicious code; Before inputting the first feature vector into the preset malicious code detection model, the method further includes: obtaining a second function call graph of the APK file sample, wherein the types of the APK file sample include: malicious APK file samples and benign APK file samples; obtaining a second sensitive API call sequence of the APK file sample according to the second function call graph; obtaining a classification feature of the APK file sample according to the second sensitive API call sequence; obtaining a second feature vector of the APK file sample according to the classification feature; and training according to the second feature vector to construct a malicious code detection model; Acquiring the classification feature of the APK file sample according to the second sensitive API call sequence, including: acquiring the support of the second sensitive API call sequence; determining the second sensitive API call sequence corresponding to the support that meets the preset condition as the classification feature of the APK file sample; By calculation: w-supp k (s i )=S k (s i )*A k (s i ) obtains the support of the second sensitive API call sequence; wherein w-supp k (s i ) is the second sensitive API call sequence s i The support level in the APK file samples of type k, S k (s i ) is the second sensitive API call sequence s i The frequency of occurrence in the second sensitive API call sequence of all APK file samples of type k, A k (s i ) is the second sensitive API call sequence s i The frequency of occurrence of all APK file samples of type k, where k is a malicious APK file sample or a benign APK file sample; By calculation Get the second sensitive API call sequence s i The frequency of occurrence in the second sensitive API call sequence of all APK file samples of type k; where NS k is the number of the second sensitive API call sequences of all APK file samples of type k, Occ(s i ,NS k ) is the API sequence s i The number of times the second sensitive API call sequence appears in all APK file samples of type k; By calculation Get the second sensitive API call sequence s i The frequency of occurrence in all APK file samples of type k; NA k is the total number of APK file samples of type k, Occ(s i ,NA k ) is the sensitive API call sequence s contained in all APK file samples of type k i The number of APK file samples.
2. The method according to claim 1, characterized in that Acquiring a second sensitive API call sequence of the APK file sample according to the second function call graph includes: Acquire a second sensitive API call graph of the APK file sample according to the second function call graph; The second sensitive API call sequence is obtained according to the second sensitive API call graph.
3. The method according to claim 2, characterized in that Acquiring a second sensitive API call graph of the APK file sample according to the second function call graph includes: Matching the nodes in the second function call graph with the API nodes in the preset sensitive API set, and if the nodes in the second function call graph are different from the API nodes in the sensitive API set, determining the corresponding nodes in the second function call graph as second non-sensitive API nodes; The second non-sensitive API node and its corresponding edge are deleted to obtain the second sensitive API call graph of the APK file sample.
4. The method according to claim 2, characterized in that: Acquiring the second sensitive API call sequence according to the second sensitive API call graph includes: When there is at least one edge between the second sensitive API nodes in the second sensitive API call graph, a directed edge is added between two corresponding second sensitive API nodes to obtain the second sensitive API call sequence.
5. The method according to any one of claims 1 to 4, characterized in that: After obtaining the classification feature of the APK file sample according to the second sensitive API call sequence, the method further includes: Obtaining an intersection of a sensitive API call sequence set of a malicious APK file sample and a sensitive API call sequence set of a benign APK file sample in the classification feature; The intersection is deleted from the classification features.
6. A device for detecting malicious code, comprising a processor and a memory storing program instructions, characterized in that: The processor is configured to execute the method for malicious code detection according to any one of claims 1 to 5 when running the program instructions.
7. A device, characterized in that: Comprising the device for malicious code detection as described in claim 6.
Citation Information
Cited By
Android malicious code detection method based on API enhancement sequence
CN114676431A
