Malicious software detection method and device
By establishing a feature code set, API call relationship and sequence vector database, combining the software's feature code and API call characteristics, the target software is comprehensively detected, which solves the problem of low recognition accuracy of malware in the existing technology and improves the unknown The accuracy of detection of malware.
Patent Information
- Application Number
- CN202411172284.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2024-12-03
AI Technical Summary
Among the existing malware detection methods, signature detection has low accuracy in identifying variants of known malicious programs and unknown malicious programs, resulting in low recognition accuracy.
By establishing the malware's signature set, API call relationship vector database, and API call sequence vector database, combining the software's signature code, API call relationship and API call sequence, the target software is comprehensively detected to determine whether it is malware.
It improves the accuracy of malware identification, avoids the missed identification of unknown malware by the signature recognition method, and enhances the detection ability of unknown malware.
Smart Images

Figure CN119066655A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information security technology, and in particular to a malware detection method and device. Background Art
[0002] With the development of information technology, a variety of application software has emerged. For example, these application software can be used for online shopping, reading news, chatting and watching short videos. It can be said that application software is becoming more and more important in daily life. However, there are also some malicious applications in these application software, such as illegal collection of personal information, pop-up ads that cannot be turned off, background deductions, and forced, excessive and frequent requests for permissions. Before users use application software or before application software is put on the application market, it is of great significance to analyze and detect application software to identify whether it is malicious software, which is of great significance to protecting user privacy and property safety.
[0003] Existing malware detection methods usually use signature code detection. A signature code is a sequence of one or more data segments that are determined to exist only in malware. Normal software does not have such a data sequence. This data sequence is usually a certain code segment or assembly instruction sequence in a code file. Signature code is a widely used malware detection technology with the characteristics of fast detection speed and high accuracy. However, signature codes can only detect known malicious programs, and are powerless against variants of known malicious programs or unknown malicious programs, resulting in low accuracy of existing malware detection methods. Summary of the invention
[0004] The present invention provides a malware detection method and device to solve the problem of low malware identification accuracy in the existing feature code malware detection method.
[0005] In a first aspect, the present invention provides a malware detection method, comprising: obtaining multiple malware samples. Based on the correspondence between feature codes and APIs of multiple malware samples, a feature code set is established; based on the API call relationship features of multiple malware samples, an API call relationship vector database is established; the API call relationship features represent the correspondence between an API and other APIs called; based on the API call sequence features of multiple malware samples, an API call sequence vector database is established; the API call sequence features represent the order in which an API calls other APIs; obtaining feature codes, API call relationships, and API call sequence features of target software; and based on the feature code set, the API call relationship vector database, and the API call sequence vector database, a comprehensive detection is performed on the target software to determine whether the target software is malware.
[0006] In one possible implementation, the establishment of an API call relationship vector database based on API call relationship features of multiple malware samples includes: for any risk API in any malware sample, obtaining the name of the API called by the risk API; based on the name of the API called by the risk API, obtaining the call relationship vector of the risk API; and establishing an API call relationship vector database based on the call relationship vectors of each risk API in each malware sample.
[0007] In a possible implementation, before obtaining the name of the API called by any risk API in any malware sample, the method further includes: obtaining a malware sample library; the malware sample library includes multiple malware samples; obtaining a normal software sample library; the normal software sample library includes multiple normal software samples; for any API in the malware sample, based on the frequency of occurrence of the API in the malware sample library and the normal software sample library, obtaining a risk coefficient of the API; if the risk coefficient of the API is greater than a preset value, determining the API as a risk API.
[0008] In a possible implementation, obtaining the risk coefficient of the API based on the frequency of occurrence of the API in the malware sample library and the normal software sample library includes: obtaining the risk coefficient of the API based on the following formula:
[0009]
[0010] Among them, Rf represents the risk factor of the API; X represents the total number of APIs in the normal software sample library; Y represents the total number of APIs in the malware sample library; f y Indicates the frequency of the API appearing in malware; f x Indicates the frequency of the API appearing in normal software.
[0011] In a possible implementation, before obtaining the call relationship vector of the risk API based on the name of the API called by the risk API, it also includes: obtaining a name vector based on the name of each risk API of each malware sample; each element of the name vector corresponds to a risk API, and the value of each element indicates whether to call the risk API of the name; accordingly, obtaining the call relationship vector of the risk API based on the name of the API called by the risk API includes: for the name of any API called by the risk API, searching the name vector for an element with the same name; and modifying the value of the element with the same name to call the risk API of the name to obtain the call relationship vector.
[0012] In one possible implementation, the establishment of an API call sequence vector database based on API call sequence features of multiple malware samples includes: for any API of any malware sample, obtaining the sequence of API calls in a simulated run of the sample; obtaining a call sequence vector of the API based on the sequence of API calls; and obtaining an API call sequence vector database based on the call sequence vectors of each API of each malware sample.
[0013] In a possible implementation, before establishing an API call sequence vector database based on the API call sequence features of multiple malware samples, it also includes: obtaining a name vector based on the name of each risk API of each malware sample; each element of the name vector corresponds to a risk API; accordingly, obtaining the call sequence vector of the API based on the order of calling the API includes: for any API called by the API, based on the name of the called API, determining the sequence number of the corresponding element of the called API in the name vector; arranging the sequence of each API called by the API in the order of being called to obtain the call sequence vector of the API.
[0014] In one possible implementation, the detection of the target software to determine whether the target software is malware includes: obtaining a first API that matches the feature code based on the feature code of the target software and the feature code set; performing distance calculation based on the API call relationship feature of the target software and the API call relationship vector database to obtain a second API whose distance value is less than a threshold; performing distance calculation based on the API call sequence feature of the target software and the API call sequence vector database to obtain a third API whose distance value is less than a threshold; and determining whether the target software is malware based on the first API, the second API, and the third API of the target software.
[0015] In the second aspect, the present invention provides a malware detection device, including: a malware acquisition module, used to acquire multiple malware samples. A first establishment module, used to establish a feature code set based on the correspondence between feature codes and APIs of multiple malware samples; a second establishment module, used to establish an API call relationship vector database based on the API call relationship features of multiple malware samples; the API call relationship features represent the correspondence between the API and other called APIs; a third establishment module, used to establish an API call sequence vector database based on the API call sequence features of multiple malware samples; the API call sequence features represent the order in which the API calls other APIs; a target software acquisition module, used to acquire the feature code, API call relationship and API call sequence features of the target software; a detection module, used to perform comprehensive detection on the target software based on the feature code set, the API call relationship vector database and the API call sequence vector database to determine whether the target software is malware.
[0016] In one possible implementation, the second establishing module is specifically used to obtain the name of the API called by any risk API in any malware sample; based on the name of the API called by the risk API, obtain the calling relationship vector of the risk API; and based on the calling relationship vectors of each risk API in each malware sample, establish an API calling relationship vector database.
[0017] The present invention provides a malware detection method and device. The present invention establishes a malware feature code set, an API call relationship vector database, and an API call sequence feature vector database. The API call relationship represents the corresponding relationship between an API and other called APIs, and the API call sequence feature represents the sequence feature of the API calling other APIs. There are similarities between the API call relationship and API call sequence features of malware. Therefore, the present invention performs a comprehensive detection on the target software based on the feature code of the software, combined with the API call relationship and the API call sequence, which can avoid the problem of missed recognition of unknown malware by the feature code recognition method and improve the accuracy of malware recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description 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.
[0019] Figure 1is an application scenario diagram of the malware detection method provided by an embodiment of the present invention;
[0020] Figure 2 is a flowchart of an implementation of a malware detection method provided by an embodiment of the present invention;
[0021] Figure 3 It is a schematic diagram of the structure of a malware detection device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0022] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present invention. However, it should be clear to those skilled in the art that the present invention may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present invention.
[0023] In order to make the purpose, technical solutions and advantages of the present invention more clear, specific embodiments will be described below in conjunction with the accompanying drawings.
[0024] Figure 1 FIG. 1 is an application scenario diagram of the malware detection method provided by an embodiment of the present invention. Figure 1 As shown, the software to be detected can be input into the server in a variety of ways. The server extracts information of the software to be detected, such as a feature code, and compares the extracted information with features pre-stored in the database to determine whether the software to be detected is malware. Please note that before the detection is completed, it cannot be determined whether the software to be detected is normal software or malware, nor can it be determined whether it is known malware or unknown malware.
[0025] The embodiment of the present invention comprehensively detects and identifies malware based on software feature codes combined with API call relationships and API call sequences, so as to solve the problem of low malware identification accuracy in existing feature code malware detection methods.
[0026] Figure 2 The implementation flow chart of the malware detection method provided by the embodiment of the present invention is detailed as follows:
[0027] Step 201, obtaining multiple malware samples.
[0028] First, let’s explain how to obtain the above malware samples.
[0029] In some embodiments, crawler technology is used to obtain malware samples from a malware database publicly available on the Internet to establish a malware sample library. Exemplarily, the malware sample library includes a feature code set consisting of malware feature codes.
[0030] Exemplarily, in step A1, a network address, i.e., URL, of a malware database is obtained. For example, the malware database may be VirusShare, Malware Dataset from Kaggle, or Kaspersky Lab Dataset.
[0031] Step A2: Design a crawler strategy for the webpage structure of each page corresponding to the URL. For example, the crawler strategy may be breadth-first crawling or depth-first crawling.
[0032] Step A3: crawl and collect the above network address related data based on the Scrapy crawler tool, and recursively download and save it. For example, the crawled content may include malware and the signature code set of the malware.
[0033] Step A4: By comparing the MD5 values of the crawled malware, duplicate samples are removed to establish a malware sample library.
[0034] Step 202: Establish a signature set based on the correspondence between signatures of multiple malware samples and APIs.
[0035] A signature is a sequence of one or more data segments that can only exist in malware. Normal software does not have such a sequence of data. This data sequence is usually a segment of code or an assembly instruction sequence in a code file. Signature codes are a widely used malware detection technology with the characteristics of fast detection speed and high accuracy. However, signature codes can only detect known malicious programs and are powerless against variants of known malicious programs or unknown malicious programs.
[0036] The embodiment of the present invention can detect and judge known malicious program variants or unknown malicious programs based on the calling relationship characteristics between APIs and the calling sequence characteristics of APIs (ie, the order of API calls).
[0037] Step 203: Based on the API call relationship features of the multiple malware samples, an API call relationship vector database is established. The API call relationship features represent the corresponding relationship between an API and other called APIs.
[0038] It should be noted that the risky behavior of malware is usually executed through API calls of data. API calls can reveal the specific behavior and functions of malware. For example, some malware will use specific APIs to download other malware, capture screens, or perform keyboard logging. A certain API usually calls multiple other APIs. The embodiment of the present invention extracts the relationship features of each API in the malware calling other APIs, and establishes an API call relationship vector database for subsequent malware detection. The following embodiment illustrates how to establish an API call relationship vector database.
[0039] In a possible implementation, establishing an API call relationship vector database based on API call relationship features of multiple malware samples includes:
[0040] Step 2031, for any risk API in any malware sample, obtain the name of the API called by the risk API.
[0041] Exemplarily, any API in the malware can be used as a risk API. In another exemplary embodiment, an API with a higher risk level in the malware can also be used as a risk API. This will be explained in the subsequent embodiments through the calculation of the risk coefficient.
[0042] Step 2032: Based on the name of the API called by the risk API, obtain the calling relationship vector of the risk API.
[0043] Exemplarily, the risk API call relationship vector represents the relationship between a certain API calling other APIs. Further, the elements of the risk API call relationship vector may represent a certain API called by the risk API. The vector form will be described in the subsequent embodiments.
[0044] Step 2033: Building an API call relationship vector database based on the call relationship vectors of each risky API in each malware sample.
[0045] Exemplarily, for each risk API in each malware sample, the above steps 2031 to 2032 are executed to obtain the call relationship vector of each risk API. The call relationship vectors of all risk APIs constitute an API call relationship vector database.
[0046] In the above embodiments, each API in the malware can be regarded as a risky API. However, in malware, not every function is risky, and some functions may be normal. The following embodiments are used to illustrate how to filter out APIs with higher risks, thereby reducing the amount of data calculation and improving the execution efficiency of the method.
[0047] In a possible implementation, before obtaining the name of the API called by any risk API in any malware sample, the following steps are further included:
[0048] Step B1, obtaining a malware sample library. The malware sample library includes multiple malware samples.
[0049] As for how to obtain the malware sample library, for example, please refer to the above steps A1-A4.
[0050] Step B2, obtaining a normal software sample library. The normal software sample library includes a plurality of normal software samples.
[0051] For example, a crawler is used to obtain legitimate applications from application stores to establish a normal software sample library. For example, application stores include Tencent App Store, Apple App Store, or Huawei App Market. The above application stores have a certain degree of supervision and screening of the applications on their shelves, and they can be considered as normal application software.
[0052] Step B3: for any API in the malware sample, based on the frequency of occurrence of the API in the malware sample library and the normal software sample library, obtain the risk coefficient of the API.
[0053] Exemplarily, based on a normal software sample library and a malware sample library, a risk factor of each API in the malware sample is calculated.
[0054] For example, the higher the frequency of a certain API appearing in a normal software sample library, the lower its risk level is. For another example, the higher the frequency of a certain API appearing in a malware sample library, the higher its risk level is.
[0055] Step B4: If the risk factor of the API is greater than a preset value, the API is determined to be a risky API.
[0056] For example, APIs with low risk factors are filtered out, the number of risky APIs is reduced, and APIs with higher risks are screened out, thereby reducing the amount of data calculation and improving the execution efficiency and accuracy of the method.
[0057] The above embodiment provides a method for screening out APIs with a higher risk level from all APIs of malware based on the risk coefficient. The following embodiment describes how to calculate the risk coefficient.
[0058] In a possible implementation, based on the frequency of occurrence of the API in a malware sample library and a normal software sample library, the risk factor of the API is obtained, including:
[0059] The risk factor of the API is obtained based on the following formula:
[0060]
[0061] Among them, Rf represents the risk factor of the API; X represents the total number of APIs in the normal software sample library; Y represents the total number of APIs in the malware sample library; f y Indicates the frequency of the API appearing in malware; f x Indicates the frequency of the API appearing in normal software. From the above formula, it can be seen that if the risk factor Rf of an API is higher, then the probability of the API appearing in malicious application software is higher.
[0062] Exemplarily, the number of APIs of each software sample in the normal software sample library is added together to obtain the total number of APIs in the normal software sample library. Exemplarily, the number of APIs of each software sample in the malware sample library is added together to obtain the total number of APIs in the malware sample library.
[0063] The above embodiments illustrate how to reduce the dimensions of the risk API of malware and then establish a call relationship vector of the risk API. The following embodiments illustrate the specific form of the call relationship vector.
[0064] In a possible implementation, before obtaining the call relationship vector of the risk API based on the name of the API called by the risk API, the method further includes: obtaining a name vector based on the name of each risk API of each malware sample. Each element of the name vector corresponds to a risk API, and the value of each element indicates whether to call the risk API of the name.
[0065] Exemplarily, by traversing the malware sample library, decompiling each sample, obtaining the corresponding code file, analyzing the code file, obtaining the API, and establishing an API name vector of the malware sample library. The API name vector may represent the name of each risk API of each malware sample.
[0066] As a further example, a decompilation tool may be selected according to the software type of the sample. For example, IDAPro or Chidra may be used for Windows application software. As another example, JD-GUI or Pyocyon may be used for Java bytecode-based application software. As another example, a decompilation tool such as APKTool may be used for Android application software. As a further example, the executable file or library file of the sample is loaded into the decompilation tool, and the file structure of the executable file or library file is analyzed using the decompilation tool to obtain the code file.
[0067] Further exemplary, the API name is extracted from the code file according to the API keyword, and an API name vector is established using all API names extracted from the malware sample library, which can be expressed as API NameVector. The API keyword may include a reserved keyword (such as method, function), input parameter or return value of a function or method. Each API is located according to the reserved keyword to obtain the name of the API.
[0068] The above APINameVector can be expressed as:
[0069] APINameVector=[APIName1,APIName2,…,APIName N ]
[0070] Among them, APIName N is the name of the Nth API. In addition, the method of screening risky APIs in the above steps B1-B4 can be regarded as reducing the dimension of APINameVector and filtering out dimensions with smaller risk coefficients.
[0071] In the present invention, APINameVector can be regarded as an index table for establishing an API call relationship vector and an API call sequence feature vector. The following first describes how to establish an API call relationship vector based on an API name vector.
[0072] Accordingly, based on the name of the API called by the risk API, obtaining the call relationship vector of the risk API includes: searching for an element with the same name in the name vector for the name of any API called by the risk API, and modifying the value of the element with the same name to call the risk API with the same name, to obtain the call relationship vector.
[0073] For example, for each API in the code file of each sample, find APINameVector according to the name of the API called by the API, and establish the calling feature vector CallingVector of the API i , i is the i-th API called by the API, and i is an integer greater than 0.
[0074] Furthermore, CallingVector i The elements of are composed of a set of 0 and 1. Among them, 0 means that the API has not called APIName k , 1 means APIName is called k ,k∈[1,N].CallingVector iThe length is the same as that of APINameVector. The API call feature vector database may contain the call feature vectors of all APIs of each sample in the malware sample library.
[0075] For example, for an API in the code file of the current sample, it calls three APIs, namely API1, API2 and API3. The subscript order of API1, API2 and API3 in APINameVector is a, b, c respectively. Then, in the calling feature vector of the above API, the value of the position element with the subscript order of a, b, c is set to 1, and the value of the other position elements is 0.
[0076] Exemplarily, a call feature vector of each risky API is established based on the API name vector of the malware sample library. Based on each risky API call feature vector, an API call feature vector database is constructed.
[0077] Step 204: Based on the API call sequence features of multiple malware samples, an API call sequence vector database is established. The API call sequence features represent the order in which an API calls other APIs.
[0078] In some embodiments, the malware sample library is traversed, each sample is run in a simulation environment, the API call sequence of each sample at runtime is recorded to form an API call sequence, and an API call sequence feature vector database is constructed.
[0079] In a possible implementation, establishing an API call sequence vector database based on API call sequence features of multiple malware samples includes: for any API of any malware sample, obtaining the sequence of API calls in the simulated operation of the sample. Based on the sequence of API calls, obtaining the call sequence vector of the API. Based on the call sequence vectors of each API of each malware sample, obtaining the API call sequence vector database.
[0080] In a possible implementation, before establishing an API call sequence vector database based on the API call sequence features of multiple malware samples, it also includes: obtaining a name vector based on the name of each risk API of each malware sample. Each element of the name vector corresponds to a risk API. Accordingly, based on the order in which the API calls the API, obtaining the call sequence vector of the API includes: for any API called by the API, based on the name of the called API, determining the sequence number of the corresponding element of the called API in the name vector. Arrange the sequences of the APIs called by the API in the order in which they are called to obtain the call sequence vector of the API.
[0081] For example, for each sample in the malware sample library, a corresponding simulator is selected, the sample is run in the simulator, the corresponding component is triggered by simulation, the API call sequence of each sample at runtime is recorded, an API call sequence is formed, and the API call sequence is converted into an API call sequence feature vector SequenceVector according to APINameVector i , that is, the API call sequence vector.
[0082] The above converts the API call sequence into the API call sequence feature vector SequenceVector according to APINameVector i The steps are:
[0083] Step C1, traverse the API call sequence and obtain APIName p ;APIName p The name of the pth API in the API call sequence.
[0084] Step C2, using APIName p Look up in APINameVector and get APIName p The subscript number q in APINameVector, q∈[1,N].
[0085] Step C3, put the subscript number q into SequenceVector i The pth position of .
[0086] For example, for an API in the code file of the current sample, it calls three APIs, in the order of API1, API2, and API3. The subscript order of API1, API2, and API3 in APINameVector is a, b, and c, respectively. Then the calling sequence feature vector of the API is [a, b, c].
[0087] Step C4: If all API call sequences of each sample in the malware sample library have been converted into API call sequence feature vectors, the tails of other API call sequence feature vectors are padded with zeros according to the length of the longest API call sequence feature vector to achieve vector alignment.
[0088] Step 205, obtaining the characteristic code, API call relationship and API call sequence characteristics of the target software.
[0089] Exemplarily, the source code file of the target software to be detected is obtained, and feature codes, API call relationships, and API call sequence features are extracted according to the source code file.
[0090] Exemplarily, the target software has multiple feature codes, API call relationships, and API call sequence features, which respectively constitute a feature code set, an API call relationship vector set, and an API call sequence vector set.
[0091] Exemplarily, yarGen and YARA tools may be used to extract the signature code of the software to be detected.
[0092] Exemplarily, for the API call relationship vector set, the method of step 203 can be used to calculate. Exemplarily, for the API call sequence vector set, the method of step 204 can be used to calculate.
[0093] Step 206, performing a comprehensive detection on the target software based on the feature code set, the API call relationship vector database, and the API call sequence vector database to determine whether the target software is malware.
[0094] In some embodiments, the target software is detected based on its feature code, API call relationship feature and API call sequence feature, as well as feature code set, API call relationship vector database and API call sequence vector database to determine whether the target software is malware.
[0095] In some embodiments, the software to be detected is identified based on the above-mentioned feature code set, API call relationship vector database and API call sequence vector database, and whether the target software is malware is determined based on the identification result. Exemplarily, an API risk identification report of the software to be detected can also be generated based on the identification result.
[0096] In a possible implementation, detecting the target software to determine whether the target software is malware includes:
[0097] Step 2061: Based on the feature code and feature code set of the target software, obtain a first API matching the feature code.
[0098] Exemplarily, the feature code of the target software is used to traverse the feature code set consisting of the feature codes of the malware, and if there is a matching feature code, the name of the corresponding API, ie, the first API, is output.
[0099] Step 2062: Perform distance calculation based on the API call relationship feature of the target software and the API call relationship vector database to obtain a second API whose distance value is less than a threshold.
[0100] Exemplarily, the distance calculation is performed between the API call relationship vector of the target software and the vector of the API call feature vector database. If the distance is less than a preset threshold, the name of the corresponding API, ie, the second API, is output.
[0101] Step 2063: Perform distance calculation based on the API call sequence features of the target software and the API call sequence vector database to obtain a third API with a distance value less than a threshold.
[0102] Exemplarily, the distance calculation is performed between the API call sequence vector of the target software and the vector of the API call sequence feature vector database. If the distance is less than a preset threshold value T2, the name of the corresponding API, ie, the third API, is output.
[0103] Step 2064, determining whether the target software is malware based on the first API, the second API, and the third API of the target software.
[0104] In some embodiments, an API risk identification report of the software to be detected is generated based on the output API name. The API risk identification report includes at least the name of the risk API, the feature code matching situation, the call feature analysis situation (including which API call features of which malware have a high similarity), and the call sequence analysis situation (including which API call sequence features of which malware have a high similarity).
[0105] The embodiment of the present invention establishes a feature code set of malware, an API call relationship vector database, and an API call sequence feature vector database. The API call relationship represents the corresponding relationship between an API and other APIs called, and the API call sequence feature represents the sequence feature of the API calling other APIs. There are similarities between the API call relationship and API call sequence features of malware. Therefore, the present invention performs a comprehensive detection of the target software based on the feature code of the software, combined with the API call relationship and the API call sequence, which can avoid the problem of missing unknown malware by the feature code recognition method and improve the accuracy of malware recognition.
[0106] The embodiments of the present invention can automatically identify APIs with malicious risks, and can remind users to pay attention to APIs with malicious risks, thereby preventing malicious software from entering the market and avoiding leakage of user privacy data and property losses.
[0107] The present invention identifies the software to be detected by establishing a feature code set, an API call feature vector database and an API call sequence feature vector database, and can also generate an API risk identification report of the software to be detected based on the identification results.
[0108] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0109] The following is an embodiment of the device of the present invention. For details not described in detail therein, reference may be made to the corresponding method embodiment described above.
[0110] Figure 3 The following is a schematic diagram showing the structure of a malware detection device provided by an embodiment of the present invention. For ease of explanation, only the parts related to the embodiment of the present invention are shown, which are described in detail as follows:
[0111] like Figure 3 As shown, a malware detection device 3 includes:
[0112] A malware acquisition module 31, used to acquire multiple malware samples;
[0113] The first establishing module 32 is used to establish a feature code set based on the correspondence between feature codes and APIs of multiple malware samples.
[0114] The second establishing module 33 is used to establish an API calling relationship vector database based on the API calling relationship features of multiple malware samples. The API calling relationship features represent the corresponding relationship between an API and other called APIs.
[0115] The third building module 34 is used to build an API call sequence vector database based on the API call sequence features of multiple malware samples. The API call sequence features represent the order in which an API calls other APIs.
[0116] The target software acquisition module 35 is used to acquire the characteristic code, API call relationship and API call sequence characteristics of the target software.
[0117] The detection module 36 is used to perform a comprehensive detection on the target software according to the feature code set, the API call relationship vector database and the API call sequence vector database to determine whether the target software is malware.
[0118] The embodiment of the present invention establishes a feature code set of malware, an API call relationship vector database, and an API call sequence feature vector database. The API call relationship represents the corresponding relationship between an API and other APIs called, and the API call sequence feature represents the sequence feature of the API calling other APIs. There are similarities between the API call relationship and API call sequence features of malware. Therefore, the present invention performs a comprehensive detection of the target software based on the feature code of the software, combined with the API call relationship and the API call sequence, which can avoid the problem of missing unknown malware by the feature code recognition method and improve the accuracy of malware recognition.
[0119] In one possible implementation, the second establishing module 33 is specifically used to obtain the name of the API called by any risk API in any malware sample; based on the name of the API called by the risk API, obtain the call relationship vector of the risk API; based on the call relationship vectors of each risk API in each malware sample, establish an API call relationship vector database.
[0120] In a possible implementation, before obtaining the name of the API called by any risk API in any malware sample, the method further includes: obtaining a malware sample library; the malware sample library includes multiple malware samples; obtaining a normal software sample library; the normal software sample library includes multiple normal software samples; for any API in the malware sample, based on the frequency of occurrence of the API in the malware sample library and the normal software sample library, obtaining a risk coefficient of the API; if the risk coefficient of the API is greater than a preset value, determining the API as a risk API.
[0121] In a possible implementation, obtaining the risk coefficient of the API based on the frequency of occurrence of the API in the malware sample library and the normal software sample library includes: obtaining the risk coefficient of the API based on the following formula:
[0122]
[0123] Among them, Rf represents the risk factor of the API; X represents the total number of APIs in the normal software sample library; Y represents the total number of APIs in the malware sample library; f y Indicates the frequency of the API appearing in malware; f x Indicates the frequency of the API appearing in normal software.
[0124] In a possible implementation, before obtaining the call relationship vector of the risk API based on the name of the API called by the risk API, it also includes: obtaining a name vector based on the name of each risk API of each malware sample; each element of the name vector corresponds to a risk API, and the value of each element indicates whether to call the risk API of the name; accordingly, obtaining the call relationship vector of the risk API based on the name of the API called by the risk API includes: for the name of any API called by the risk API, searching the name vector for an element with the same name; and modifying the value of the element with the same name to call the risk API of the name to obtain the call relationship vector.
[0125] In one possible implementation, the establishment of an API call sequence vector database based on API call sequence features of multiple malware samples includes: for any API of any malware sample, obtaining the sequence of API calls in a simulated run of the sample; obtaining a call sequence vector of the API based on the sequence of API calls; and obtaining an API call sequence vector database based on the call sequence vectors of each API of each malware sample.
[0126] In a possible implementation, before establishing an API call sequence vector database based on the API call sequence features of multiple malware samples, it also includes: obtaining a name vector based on the name of each risk API of each malware sample; each element of the name vector corresponds to a risk API; accordingly, obtaining the call sequence vector of the API based on the order of calling the API includes: for any API called by the API, based on the name of the called API, determining the sequence number of the corresponding element of the called API in the name vector; arranging the sequence of each API called by the API in the order of being called to obtain the call sequence vector of the API.
[0127] In one possible implementation, the detection of the target software to determine whether the target software is malware includes: obtaining a first API that matches the feature code based on the feature code of the target software and the feature code set; performing distance calculation based on the API call relationship feature of the target software and the API call relationship vector database to obtain a second API whose distance value is less than a threshold; performing distance calculation based on the API call sequence feature of the target software and the API call sequence vector database to obtain a third API whose distance value is less than a threshold; and determining whether the target software is malware based on the first API, the second API, and the third API of the target software.
[0128] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0129] Those of ordinary skill in the art will appreciate that the templates, 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 depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0130] If the module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, it can implement the steps of the above-mentioned malware detection method embodiments. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device that can carry the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory, random access memory, electrical carrier signal, telecommunication signal and software distribution medium.
[0131] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A malware detection method, characterized in that: include: Obtain multiple malware samples; Establishing a signature set based on the correspondence between the signatures of the plurality of malware samples and the APIs; Based on the API call relationship features of the multiple malware samples, an API call relationship vector database is established; the API call relationship features represent the corresponding relationship between an API and other called APIs; Establishing an API call sequence vector database based on the API call sequence features of the multiple malware samples; the API call sequence features represent the order in which an API calls other APIs; Obtain the target software’s signature code, API call relationship, and API call sequence features; Based on the feature code set, the API call relationship vector database and the API call sequence vector database, a comprehensive detection is performed on the target software to determine whether the target software is malware.
2. The malware detection method according to claim 1, characterized in that: The API call relationship features of the multiple malware samples are established The API call relationship vector database includes: For any risky API in any malware sample, obtain the name of the API called by the risky API; Based on the name of the API called by the risk API, obtain a call relationship vector of the risk API; Based on the call relationship vectors of each risky API in each malware sample, an API call relationship vector database is established.
3. The malware detection method according to claim 2, characterized in that: Before obtaining the name of the API called by any risk API in any malware sample, the method further includes: Obtain a malware sample library; the malware sample library includes multiple malware samples; Acquire a normal software sample library; the normal software sample library includes a plurality of normal software samples; For any API in the malware sample, based on the appearance frequency of the API in the malware sample library and the normal software sample library, obtain the risk coefficient of the API; If the risk factor of the API is greater than the preset value, the API is determined to be a risky API.
4. The malware detection method according to claim 3, characterized in that: The risk factor of the API is obtained based on the appearance frequency of the API in the malware sample library and the normal software sample library, including: The risk factor of the API is obtained based on the following formula: Among them, Rf represents the risk factor of the API; X represents the total number of APIs in the normal software sample library; Y represents the total number of APIs in the malware sample library; f y Indicates the frequency of the API appearing in malware; f x Indicates the frequency of the API appearing in normal software.
5. The malware detection method according to claim 2, characterized in that: Before obtaining the call relationship vector of the risk API based on the name of the API called by the risk API, the method further includes: Based on the name of each risk API of each malware sample, a name vector is obtained; each element of the name vector corresponds to a risk API, and the value of each element indicates whether to call the risk API of the name; Correspondingly, the calling relationship vector of the risk API is obtained based on the name of the API called by the risk API, including: For the name of any API called by the risky API, search for an element with the same name in the name vector; The value of the element with the same name is modified to call the risk API with the same name, and a call relationship vector is obtained.
6. The malware detection method according to claim 1, characterized in that: The step of establishing an API call sequence vector database based on the API call sequence features of the plurality of malware samples includes: For any API of any malware sample, obtain the order in which the API is called during the simulated operation of the sample; Based on the order in which the API calls the API, a calling sequence vector of the API is obtained; Based on the call sequence vectors of each API of each malware sample, an API call sequence vector database is obtained.
7. The malware detection method according to claim 6, characterized in that: Before establishing an API call sequence vector database based on the API call sequence features of the plurality of malware samples, the method further includes: Based on the name of each risk API of each malware sample, a name vector is obtained; each element of the name vector corresponds to a risk API; Correspondingly, obtaining the calling sequence vector of the API based on the order of calling the API by the API includes: For any API called by the API, based on the name of the called API, determine the sequence number of the corresponding element of the called API in the name vector; The sequences of the APIs called by the API are arranged in the order of being called, so as to obtain a calling sequence vector of the API.
8. The malware detection method according to claim 1, characterized in that: The detecting the target software to determine whether the target software is malware includes: Based on the feature code of the target software and the feature code set, obtaining a first API matching the feature code; Performing distance calculation based on the API call relationship feature of the target software and the API call relationship vector database to obtain a second API whose distance value is less than a threshold; Performing distance calculation based on the API call sequence features of the target software and the API call sequence vector database to obtain a third API whose distance value is less than a threshold; According to the first API, the second API and the third API of the target software, it is determined whether the target software is malware.
9. A malware detection device, characterized in that: include: Malware acquisition module, used to acquire multiple malware samples; A first establishing module, configured to establish a signature set based on the correspondence between the signatures of the plurality of malware samples and the APIs; A second establishing module is used to establish an API call relationship vector database based on the API call relationship features of the multiple malware samples; the API call relationship features represent the corresponding relationship between an API and other called APIs; A third establishment module is used to establish an API call sequence vector database based on the API call sequence features of the multiple malware samples; the API call sequence features represent the order in which the API calls other APIs; A target software acquisition module is used to acquire the characteristic code, API call relationship and API call sequence characteristics of the target software; The detection module is used to perform comprehensive detection on the target software according to the feature code set, the API call relationship vector database and the API call sequence vector database to determine whether the target software is malware.
10. The malware detection device according to claim 9, characterized in that: The second establishing module is specifically used to obtain the name of the API called by any risk API in any malware sample; Based on the name of the API called by the risk API, obtain a call relationship vector of the risk API; Based on the call relationship vectors of each risky API in each malware sample, an API call relationship vector database is established.
