Sample virus detection method, device, computer equipment and storage medium

Through the comparison with anti-virus database and multi-mode matching algorithm to find feature records, the problem of too long response time in traditional anti-virus technology is solved, and fast and accurate virus detection is achieved, operating costs are reduced and cross-platform use is supported.

CN110457905BActive Publication Date: 2024-11-29TENCENT CLOUD COMPUTING (BEIJING) CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN201910740513.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-08-12
Publication Date
2024-11-29
Estimated Expiration
2039-08-12

AI Technical Summary

Technical Problem

Traditional anti-virus technology controls detection behavior through configuration files, resulting in the need to modify the engine code to identify new virus samples, resulting in the response time of sample virus detection and cannot meet the needs of fast response.

Method used

By obtaining the comparison of the samples to be detected with the anti-virus database, using a multi-mode matching algorithm to find matching feature records, determine the virus detection results, avoiding dependence on configuration files and shortening the detection response time.

Benefits of technology

It realizes fast and accurate virus detection results, improves detection efficiency, reduces operating costs, and supports cross-platform use.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110457905B_ABST
    Figure CN110457905B_ABST
Patent Text Reader

Abstract

The present invention relates to a sample virus detection method, device, computer equipment and storage medium, and belongs to the field of anti-virus technology. The method comprises: obtaining a sample to be detected; comparing the sample to be detected with a type record table in an anti-virus database, and obtaining a type identification result according to the comparison result; if the sample to be detected is determined to be type-identifiable according to the type identification result, searching for a matching feature record in the anti-virus database through a multi-mode matching algorithm; and determining the virus detection result of the sample to be detected according to the matching feature record. The above technical scheme solves the problem of too long response time for sample virus detection. Without the need for a configuration file, the virus detection result of the sample to be detected can be accurately determined through the anti-virus database, which can effectively reduce the response time of sample virus detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of anti-virus technology, and in particular to a virus detection method, device, computer equipment and storage medium for a sample. Background Art

[0002] Anti-virus technology is often implemented by using anti-virus engines to detect viruses on specific samples. Its detection function is powerful and complex, and different strategies and solutions are required for different application scenarios and needs. In traditional anti-virus technology, configuration files are often used to control the detection behavior and strategy of anti-virus engines. For example, configuration files are used to control the anti-virus engine to start or stop detection of a certain type of sample.

[0003] In the process of implementing the present invention, the inventors found that the traditional method has at least the following problems: the traditional anti-virus technology implemented through the configuration file needs to modify the engine code, because only by modifying the code can the engine increase the recognition of specific new virus samples. And the engine code must be modified to complete the standard test release process, which usually takes 1-2 weeks, which makes the response time of sample virus detection too long, which is not applicable in many practical scenarios. Summary of the invention

[0004] Based on this, the embodiments of the present invention provide a sample virus detection method, apparatus, computer equipment and storage medium, which can effectively reduce the response time of sample virus detection.

[0005] The contents of the embodiments of the present invention are as follows:

[0006] In a first aspect, an embodiment of the present invention provides a virus detection method for a sample, comprising the following steps: obtaining a sample to be detected; comparing the sample to be detected with a type record table in an anti-virus database, and obtaining a type identification result according to the comparison result; if it is determined that the sample to be detected is type-identifiable according to the type identification result, searching for a matching feature record in the anti-virus database through a multi-mode matching algorithm; and determining a virus detection result of the sample to be detected according to the matching feature record.

[0007] In one embodiment, the step of searching for matching feature records in the anti-virus database using a multi-mode matching algorithm includes: obtaining a registry key value of the sample to be detected; if the registry key value is a non-zero value, searching for matching feature records in the anti-virus database using a multi-mode matching algorithm; wherein the feature records are stored in the anti-virus database in a json standard format.

[0008] In one embodiment, after the step of obtaining the registry key value of the sample to be detected, the method further includes: if the registry key value is zero, stopping virus detection on the sample to be detected.

[0009] In one embodiment, the step of determining the virus detection result of the sample to be detected based on the matched feature record includes: determining the feature data in the matched feature record; judging whether the sample to be detected is a virus sample based on the feature data; and obtaining the virus detection result based on the judgment result.

[0010] In one embodiment, if the registry key value is a non-zero value, after the step of determining the virus detection result of the sample to be detected according to the matched feature record, it also includes: if the sample to be detected is determined to be a virus sample according to the virus detection result, determining a first maximum sample size according to the registry key value; if the sample size of the sample to be detected is less than or equal to the first maximum sample size, controlling the anti-virus engine to execute a preset virus detection and killing program on the sample to be detected.

[0011] In one embodiment, after the step of obtaining the sample to be detected, it also includes: obtaining the target type identifier of the sample to be detected; determining whether the sample to be detected is a recognizable type according to the target type identifier; if not, executing the step of comparing the sample to be detected with the type record table in the anti-virus database; if so, searching the anti-virus database for a target existing type record corresponding to the target type identifier, and performing a virus detection and killing operation according to the target existing type record.

[0012] In one embodiment, the step of performing a virus detection and killing operation according to the target existing type record includes: determining the sample size of the sample to be detected; adjusting the maximum sample size corresponding to the target sample in the target existing type record according to the sample size; and controlling the anti-virus engine to execute a preset virus detection and killing program on the sample to be detected according to the adjusted second maximum sample size.

[0013] In a second aspect, an embodiment of the present invention provides a virus detection device for a sample, comprising: a sample acquisition module, used to acquire a sample to be detected; a type identification module, used to compare the sample to be detected with a type record table in an anti-virus database, and obtain a type identification result according to the comparison result; a record search module, used to search for a matching feature record in the anti-virus database through a multi-mode matching algorithm if it is determined that the sample to be detected is of a recognizable type according to the type identification result; and a result determination module, used to determine the virus detection result of the sample to be detected according to the matching feature record.

[0014] In a third aspect, an embodiment of the present invention provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the following steps when executing the computer program: obtaining a sample to be detected; comparing the sample to be detected with a type record table in an anti-virus database, and obtaining a type identification result based on the comparison result; if it is determined that the sample to be detected is type-recognizable based on the type identification result, searching for a matching feature record in the anti-virus database through a multi-mode matching algorithm; and determining a virus detection result of the sample to be detected based on the matching feature record.

[0015] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the following steps: obtaining a sample to be detected; comparing the sample to be detected with a type record table in an anti-virus database, and obtaining a type identification result based on the comparison result; if it is determined that the sample to be detected is type-identifiable based on the type identification result, searching for a matching feature record in the anti-virus database through a multi-mode matching algorithm; and determining a virus detection result of the sample to be detected based on the matching feature record.

[0016] One of the above technical solutions has the following advantages or beneficial effects: after obtaining the sample to be detected, the sample to be detected is compared with the type record table in the anti-virus database to obtain the type identification result; according to the type identification result, it is determined whether the sample to be detected is type-identifiable, and if so, a matching feature record is searched in the anti-virus database through a multi-mode matching algorithm to determine the virus detection result of the sample to be detected. Without the need for a configuration file, the virus detection result of the sample to be detected can be accurately determined through the anti-virus database, which can effectively reduce the response time of sample virus detection and improve the efficiency of sample virus detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 A diagram of an application environment of a virus detection method of a sample in an embodiment;

[0018] Figure 2 A schematic diagram of a method for detecting a virus in a sample according to an embodiment;

[0019] Figure 3 A schematic diagram of the structure of an anti-virus database in one embodiment;

[0020] Figure 4 A schematic diagram of the structure of an anti-virus database in another embodiment;

[0021] Figure 5 A schematic diagram of an interface display in an embodiment;

[0022] Figure 6 A schematic diagram of a flow chart of a method for detecting a virus in a sample in another embodiment;

[0023] Figure 7 A schematic diagram of a flow chart of a method for detecting a virus in a sample in yet another embodiment;

[0024] Figure 8 A schematic diagram of a flow chart of a method for implementing virus detection of a sample through a configuration file in one embodiment;

[0025] Fig. 9 The structure block diagram of a virus detection device of a sample in an embodiment. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0027] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0028] The virus detection method of the sample provided in this application can be applied to Figure 1 The computer device shown in FIG. 1 may be a server or a terminal device, and its internal structure diagram may be as shown in FIG. Figure 1As shown. The computer device includes a processor, a memory, a network interface and a display screen connected through a system bus. Among them, the processor is used to provide computing and control capabilities; the memory includes a non-volatile storage medium and an internal memory, the non-volatile storage medium stores an operating system, a computer program (the computer program implements a sample virus detection method when executed by the processor) and a database, and the internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium; the database is used to store data involved in the execution of the sample virus detection method, for example: the database can store data such as existing type record tables, type record tables and feature record tables; the network interface is used to communicate with an external terminal through a network connection, for example: receiving a sample to be detected sent by an external terminal; the display screen can be a liquid crystal display or an electronic ink display screen. Furthermore, the server can be implemented as an independent server or a server cluster consisting of multiple servers, and the terminal device can be but is not limited to various personal computers, laptops, smart phones, tablet computers and portable wearable devices.

[0029] Those skilled in the art will understand that Figure 1 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0030] The embodiments of the present invention provide a method, device, computer equipment and storage medium for detecting viruses in a sample, which are described in detail below.

[0031] In one embodiment, the present invention provides a method for detecting viruses in a sample. Figure 1 It can also be applied to a certain application or function code (these applications and function codes can run on computer devices), such as anti-virus engines, anti-virus software, etc. Figure 2 As shown, the following is an example of applying the method to an anti-virus engine (also referred to as an engine in some embodiments of the present invention), which includes the following steps:

[0032] S201, obtaining a sample to be tested.

[0033] The anti-virus engine can be run on a computer device with the help of anti-virus software, etc. The anti-virus engine can detect the samples on the disk and external devices on the computer device in real time, and then determine the virus detection results of each sample, and perform virus cleaning when one or some samples are determined to be viruses. Among these samples, samples that have been determined to be viruses or non-viruses can be called detected samples, and samples that have not been determined to be viruses can be called samples to be detected. In addition, in addition to obtaining samples to be detected by the anti-virus engine detection method, samples to be detected can also be sent by external devices connected to the computer device.

[0034] Furthermore, the samples to be detected refer to samples of unknown danger, that is, samples that are uncertain whether they are viruses, usually new malicious file samples of unknown types (not detected by the anti-virus engine or no relevant information stored in the anti-virus database). The sample can be a program segment, application, etc., or it can be an entire file or part of the content in the file, which can include text, pictures, audio and other information.

[0035] In addition, the number of samples to be detected may be one, two or even more. For two or more cases, the anti-virus engine may perform virus detection on the samples in a synchronous or asynchronous manner.

[0036] S202: Compare the sample to be detected with the type record table in the anti-virus database, and obtain a type identification result according to the comparison result.

[0037] The anti-virus database refers to a database that stores information related to the anti-virus process (virus type, virus feature information, etc.). The anti-virus database can store a variety of sample feature information that has determined the virus detection results (virus or non-virus). The type recognition result can indicate whether the anti-virus engine has the ability to detect and kill viruses for a certain sample, which can include type recognition and type non-recognition. Among them, the type recognition can be considered as the situation where the anti-virus engine can detect and kill viruses. If the anti-virus database stores sample feature information of a sample to be detected, it is considered that the type of the sample to be detected is recognizable, and the anti-virus engine can perform virus detection and killing operations on the sample to be detected.

[0038] Furthermore, the type record table can record type-related information of samples with known virus detection results; and this sample can refer to a new sample that appeared within a set time period in the past, or it can refer to all samples with confirmed virus detection results. One of the type records (also called type features) in the type record table can be as follows:

[0039] "md5":"0005db9bfbeefff9aadddbb147608ba3",

[0040] "name": "bmp_vbs",

[0041] "id":"203",

[0042] "use": "1",

[0043] "bb_1":"424D0A062020EB6E90207620202820",

[0044] "fz":"800000"

[0045] Among them, the "md5" field describes a certain md5 value in this type of sample; "name" describes the name of this type of sample; "id" describes the type value of this type of sample, which is used to identify the value representation of this type of sample; "use" describes the validity of the record, 1 means that this record is valid, 0 means that this record is invalid, and the engine can ignore this record; "bb_1" describes the characteristic data of this type of sample, which is represented by a hexadecimal string here; "fz" describes the maximum value of the recognition size of this type of sample (that is, if the size of a sample in this type of sample exceeds the value corresponding to "fz", the engine cannot detect the sample). The above records allow the anti-virus engine to easily identify and detect a certain type of sample.

[0046] In some embodiments, the structure of the antivirus database may be as follows: Figure 3 As shown, the anti-virus database includes a type record table and a feature record table. Among them, the type record table can be used to record the type identification of the newly added identifiable samples; the feature record table is used to store feature records, and the feature record can record the feature data of the type recorded in the aforementioned type record table. A certain mapping relationship can be established between the type record table and the feature record table. For example, if the type record table records type A, type B, and type C, then the feature record table can record the feature information corresponding to type A, type B, and type C. Furthermore, the mapping relationship between the type record table and the feature record table can be one-to-one correspondence or not one-to-one correspondence.

[0047] S203: If it is determined according to the type identification result that the sample to be detected is of identifiable type, searching for a matching feature record in the antivirus database by using a multi-mode matching algorithm.

[0048] There may be multiple feature records in the anti-virus database. These feature records may contain feature data of multiple files. The feature data may be identification information that characterizes whether a specific sample is a virus. For example, a feature record contains a virus identification. When the identification is 1, it indicates that the specific sample is a virus. When the identification is 0, it indicates that the specific sample is not a virus.

[0049] Different subsequent operations can be performed for different type identification results. For example, when the type identification result is that the type is identifiable, the virus detection program of the sample to be detected can be continued, and when the type identification result is that the type is not identifiable, the virus detection program of the sample to be detected can be stopped.

[0050] This step searches for matching feature records based on the type identification result. When the type identification result is that the type is identifiable, the feature record search is performed. When the type identification result is that the type is not identifiable, the feature record search is not performed and the virus detection process for the sample to be detected is ended.

[0051] Furthermore, after determining the type identification result of the sample to be detected, this step searches for matching feature records. This detection logic can ensure the orderly progress of sample virus detection, while reducing the management cost of the sample virus detection process (when the type identification result is that the type is unrecognizable, the feature record search process can be omitted) and execution cost.

[0052] At the same time, a conventional multi-mode matching algorithm can be used to hit the feature record that matches the sample to be detected. The multi-mode matching algorithm can be various commonly used multi-mode matching algorithms, such as: Aho-Corasick algorithm, Wu-Manber algorithm, etc. Of course, in addition to the multi-mode matching algorithm, other matching algorithms can also be used to match feature records.

[0053] S204: Determine the virus detection result of the sample to be detected according to the matched feature record.

[0054] In this step, whether the sample to be detected is a virus sample can be determined based on the feature data in the feature record, and then the virus detection result can be obtained.

[0055] Of course, the virus detection results include not only whether the sample is a virus sample, but also information such as the virus danger level of the sample, the virus detection method, the sample size, and the number of samples in the computer device.

[0056] Furthermore, when the anti-virus engine loads the anti-virus database initially, it obtains the detection logic in the anti-virus database, and performs detection according to the detection logic in the subsequent file detection process. The detection logic of this embodiment is mainly as follows: the anti-virus engine first determines the type recognition result according to the type record table, and then searches for matching feature records according to the type recognition result to determine the virus detection result.

[0057] The file detection method provided by the above embodiment has the following technical effects: 1. The anti-virus engine can accurately determine the virus detection result of the sample to be detected through the type record table and feature record table in the anti-virus database according to the set control strategy, without the need for configuration files (which can refer to files with the ini suffix, generally saved in the directory where the anti-virus engine is located), and the update of the anti-virus database usually takes only a few hours, that is, the anti-virus engine can detect a certain unknown sample at most after a few hours, realize the response to unknown risks, effectively reduce the response time of sample virus detection, and greatly improve the emergency response capability of the engine. 2. The core control file of the anti-virus engine is used as the anti-virus database, which is a necessary file for the operation of the engine, and no longer relies on the configuration file strategy, so that the whole mechanism is flexible and cross-platform (platform can refer to operating system platforms such as Windows, Linux, MAC, etc.), and does not require the development support of external products (the product here can refer to anti-virus software containing anti-virus engines, such as Tencent Computer Manager), thereby reducing operating costs.

[0058] In one embodiment, the step of comparing the sample to be detected with the type record table in the anti-virus database and obtaining a type identification result according to the comparison result includes: obtaining a target type identifier of the sample to be detected; comparing the target type identifier with the type identification information in the type record table; if the target type identifier exists in the type identification information, obtaining a type identification result of type identifiable; if the target type identifier does not exist in the type identification information, obtaining a type identification result of type unidentifiable.

[0059] The type identifier may be a character string or a code with an identification function, and the "id" in the above embodiment may be used as the type identifier. Further, if the target type identifier of the sample to be detected is "203", it can be found that the type identifier of the sample with the category name "bmp_vbs" is consistent with the target type identifier by comparing with each record in the type record table of the anti-virus database, and the type identification result of the sample to be detected is determined as a type that is identifiable; on the contrary, if a type identifier that is consistent with the target type identifier is not found in the type record table, the type identification result of the sample to be detected is determined as a type that is not identifiable.

[0060] Furthermore, the anti-virus database may be a genlib.def database.

[0061] In one embodiment, after the step of obtaining the type identification result as the type being unrecognizable, the method further includes: executing a preset unknown virus detection program. The preset unknown virus detection program may be a predetermined Unk detection logic. Unk may be a default processing method for unknown samples that exists before the antivirus engine accesses the genlib.def database, or may be a more conventional sample processing method.

[0062] In some embodiments, the process of determining the type identification result can also be implemented according to a multi-mode matching algorithm, that is, determining whether there is a matching type identifier in the type record table through a multi-mode matching algorithm. If so, the type identification result is determined as a recognizable type; if not, the type identification result is determined as an unrecognizable type.

[0063] The sample virus detection method provided in the above embodiment determines the type identification result according to the comparison result between the target type identifier and the type record table in the anti-virus database, and can accurately determine whether the anti-virus engine has the ability to detect and kill viruses for the sample to be detected, so as to perform subsequent operations.

[0064] In one embodiment, before the step of comparing the sample to be detected with the type record table in the anti-virus database, the step further includes: obtaining multiple feature records; and processing the multiple feature records by a predetermined database generation tool to generate the anti-virus database.

[0065] Generally, an anti-virus database may include 1-N (the specific value of N can be determined according to actual conditions) feature records. Furthermore, the 1-N feature records can be used to generate an anti-virus database through a specific database generation tool, and the generated anti-virus database is loaded and used by the anti-virus engine. Furthermore, the feature records and type records can be processed through the database generation tool to generate an anti-virus database.

[0066] The above embodiment generates an anti-virus database according to the feature record and the type record. The anti-virus database generated in this way can be conveniently loaded and used by the anti-virus engine, so that the anti-virus engine implements file detection according to the set detection logic.

[0067] In one embodiment, the step of searching for matching feature records in the anti-virus database using a multi-mode matching algorithm includes: obtaining a registry key value of the sample to be detected; if the registry key value is a non-zero value, searching for matching feature records in the anti-virus database using a multi-mode matching algorithm.

[0068] The registry key value can be a DWORD value, etc. DWORD stands for Double Word, each word is 2 bytes in length, a DWORD double word is 4 bytes, each byte is 8 bits, a total of 32 bits. Furthermore, for the sake of the anti-virus engine and the anti-virus database operating performance (operating speed, etc.), certain restrictions will be placed on the sample size of samples processed by the anti-virus engine. The embodiment of the present invention uses a DWORD value to control whether the anti-virus engine can detect the sample to be detected (if the size of the sample to be detected is greater than the value corresponding to the DWORD value, the anti-virus engine cannot perform the detection). Specifically, a non-zero DWORD value is used to characterize the maximum sample size of each type of sample in the type record table; the maximum sample size is used to characterize the sample size that the anti-virus engine can execute when detecting and killing viruses.

[0069] Furthermore, if the registry key value is a non-zero value, after the step of determining the virus detection result of the sample to be detected according to the matched feature record, it also includes: if the sample to be detected is determined to be a virus sample according to the virus detection result, determining a first maximum sample size according to the registry key value; if the sample size of the sample to be detected is less than or equal to the first maximum sample size, controlling the anti-virus engine to execute a preset virus detection and killing program on the sample to be detected.

[0070] For example, the following two program segments set the maximum value (maximum sample size) of the anti-virus engine's detection sample size for 7z and zip formats to 0x1f0000 respectively:

[0071] Program segment 1:

[0072] "name": "@eng:7z",

[0073] "fz":"1f0000"

[0074] Program segment 2:

[0075] "name": "@eng:zip",

[0076] "fz":"1f0000"

[0077] If the sample size of a sample to be detected is greater than 0x1f0000, the anti-virus engine will not perform virus detection and elimination operations on it.

[0078] Furthermore, in one embodiment, after the step of obtaining the registry key value of the sample to be detected, the step further includes: if the registry key value is zero, stopping virus detection on the sample to be detected.

[0079] When the DWORD value is zero, the antivirus engine cannot detect the sample to be detected, and when the DWORD value is non-zero, the antivirus engine can detect the sample to be detected within the maximum sample size range.

[0080] In the above embodiment, the DWORD value of the anti-virus engine database is used to control the on / off function of the anti-virus engine for detecting samples of identifiable types, and the size of samples that can be detected by the anti-virus engine is also controlled, thereby realizing intelligent anti-virus detection.

[0081] In one embodiment, the feature record is stored in the anti-virus database in a JSON standard format.

[0082] In another embodiment, the type identification information may also be stored in the anti-virus database in a JSON standard format.

[0083] JSON is a lightweight data exchange format that is easy for humans to read and write, and is also easy for machines to parse and generate. In the above embodiment, the type identification information and feature records are stored in the JSON standard format, which can effectively improve the efficiency of database writing and use, and also improve the recording efficiency of the type record table and the feature record table, thereby improving the virus detection efficiency of the sample.

[0084] In one embodiment, the step of determining the virus detection result of the sample to be detected based on the matched feature record includes: determining the feature data in the matched feature record; judging whether the sample to be detected is a virus sample based on the feature data; and obtaining the virus detection result based on the judgment result.

[0085] The feature data in one feature record can be as follows:

[0086] "md5":"010df30f4f1e90d56ec9577b4aaa567c",

[0087] "name":"Trojan.Script.Agent",

[0088] "id":"203",

[0089] "fs_2":"Mailx.Attachments.Add(dirsystem&\"\\Mawanella.vbs\")",

[0090] "fs_3":"Mailx.DeleteAfterSubmit=True"

[0091] Among them, "name" describes the virus name of this feature, and "id" describes the number of this feature. The anti-virus engine can identify this feature based on this. For virus detection of unknown samples, only when the type feature is hit first, can the feature record with the same type feature be matched; "fs_2" and "fs_3" describe the feature data of this feature, which contains virus description information.

[0092] Furthermore, the anti-virus engine can determine whether the corresponding sample to be detected is a virus sample according to the virus description information in the feature data, and obtain the virus detection result accordingly.

[0093] Furthermore, the feature data may also include a type identifier of the corresponding type. After querying the type record table, the antivirus engine may query the corresponding feature record according to the type identifier and determine whether the sample to be detected is a virus sample according to the feature data in the feature record.

[0094] The feature data in the feature record hit in the above embodiment is used to determine whether the sample to be detected is a virus sample. The determination process is simple and efficient, and the efficiency of sample virus detection can be effectively improved.

[0095] In some embodiments, the structure of the anti-virus database can also be as follows: Figure 4 As shown, the anti-virus database includes a library mark, an existing type record table, a type record table (to distinguish it from the existing type record table, the type record table may also be called a new type record table) and a feature record table. The library mark is a mark of the current anti-virus database, which is used to distinguish it from other anti-virus databases (there may be multiple anti-virus databases in the embodiment of the present invention, and the anti-virus engine may access a specific anti-virus database according to the library mark, and different anti-virus databases may record information of different samples); the existing type record table may be used to record information such as the type, sample size, and feature data of samples that can be identified by the anti-virus engine. Furthermore, the existing types may include common types such as PE, Office, zip, and pdf; the description of the type record table and the feature record table may be consistent with that described in the above embodiment.

[0096] With the development of network technology, there are more and more types of viruses. The anti-virus database of the embodiment of the present invention records the information of various viruses that can be identified, and records the types of these viruses and other information through the type record table. In this way, a specific type of virus can be accurately identified, that is, multiple virus samples belonging to a certain type can be identified, which effectively improves the efficiency of sample virus detection. Of course, the type record table can also refer to the type information of a specific virus sample. In this way, virus detection of a specific virus sample can be achieved, and the accuracy of sample virus detection can be improved.

[0097] Furthermore, the information in the type record table and the feature record table can be regularly transferred to the existing type record table, and new type records and feature records can be added to ensure that the antivirus engine can detect more types of samples.

[0098] Furthermore, when it is determined that the type identification result of the sample to be detected is an unrecognizable type, the anti-virus database can be triggered to obtain information related to the sample to be detected (i.e., update the anti-virus database), and add the obtained information to the type record table and the feature record table, so that the anti-virus engine can detect the sample to be detected in a timely manner and determine its virus detection result.

[0099] In one embodiment, after the step of obtaining the sample to be detected, it also includes: obtaining the target type identifier of the sample to be detected; determining whether the sample to be detected is a recognizable type according to the target type identifier; if not, executing the step of comparing the sample to be detected with the type record table in the anti-virus database; if so, searching the anti-virus database for a target existing type record corresponding to the target type identifier, and performing a virus detection and killing operation according to the target existing type record.

[0100] Furthermore, the step of performing virus detection and killing operation according to the target existing type record includes: determining the sample size of the sample to be detected; if the sample size is a non-zero value, adjusting the second maximum sample size corresponding to the target sample in the target existing type record according to the sample size; according to the adjusted second maximum sample size, controlling the anti-virus engine to execute a preset virus detection and killing program on the sample to be detected; if the sample size is zero, stopping the virus detection on the sample to be detected. The virus detection and killing program may refer to a program for cleaning and greening viruses.

[0101] The implementation process of determining whether the sample to be detected is of a recognizable type according to the target type identifier may be: comparing the target type identifier with a recognizable type table stored in a memory or another database, and determining whether the sample to be detected is of a recognizable type according to the comparison result. Further, the recognizable type table may be determined according to the virus types that the antivirus engine has detected before.

[0102] Before controlling the anti-virus engine to execute a preset virus detection and killing program on the sample to be detected according to the adjusted second maximum sample size, the method may further include the step of detecting and analyzing the logic of the sample to be detected. The state of the sample to be detected and the location and processing method of the virus program contained therein can be obtained through the detection and analysis logic. Based on this, the anti-virus engine can smoothly execute the virus detection and killing program.

[0103] It should be noted that if the sample to be detected is not a virus sample, the virus detection and killing program can be a program that scans the sample to be detected or other programs, rather than a program that must execute a virus cleaning program.

[0104] Adjusting the maximum sample size can refer to limiting the size value of a target file in genlib.def to control whether the anti-virus engine detects the sample. For example, if the size of the sample to be detected is 3M, which exceeds the size limit of the engine detection sample, the engine will not process such samples before the maximum sample size in genlib.def is adjusted. However, after adjusting the maximum sample size in genlib.def, the anti-virus engine will process the sample according to the size set in genlib.def. If the maximum sample size corresponding to genlib.def is 4M at this time, and 4M>3M, the anti-virus engine will continue to process the sample. This processing method can greatly expand the range of files that the anti-virus engine can detect.

[0105] In the above embodiment, before comparing the sample to be detected with the information in the type record table of the anti-virus database, it is first determined whether it is a recognizable type. If it is a recognizable type, its maximum sample size is adjusted to ensure that the anti-virus engine can smoothly control the anti-virus engine to execute the preset virus detection program on the sample to be detected according to the adjusted maximum sample size. If it is an unrecognizable type, the anti-virus database is used to perform virus detection on the sample (i.e., the step of comparing the sample to be detected with the type record table in the anti-virus database is performed to determine the virus detection result). The above implementation method can be understood as hierarchical detection, first level: when it can be directly determined that the sample to be detected is a recognizable type, the anti-virus engine is directly controlled to execute the preset virus detection program on the sample to be detected according to the adjusted maximum sample size, and second level: if it is determined that the sample to be detected is an unrecognizable type, the sample to be detected is detected through the anti-virus database to obtain the virus detection result. Such a hierarchical processing method can effectively improve the efficiency of sample virus detection.

[0106] In one embodiment, the computer device where the anti-virus engine is located can display relevant information about the sample virus detection process on the interface. Figure 5 As shown in the figure, when the anti-virus engine obtains a sample to be detected (i.e., an unknown risk), it displays the Figure 5 (a); If it is determined that the sample to be tested is of identifiable type, the sample virus detection and killing process will be carried out, and the information can be displayed on the interface Figure 5 (b); If it is determined that the sample to be detected is of an unrecognizable type, the anti-virus database is queried and the type of the file to be detected is determined according to the logic of the anti-virus database and displayed on the interface Figure 5(c) Further determine whether the sample to be detected is recorded in the anti-virus database (i.e. whether the type is identifiable), and determine whether to conduct subsequent virus sample detection work accordingly. If yes, it will be displayed on the interface. Figure 5 (d) If not, display the Figure 5 (e) Further, when it is determined that the file to be detected is a virus file, it can also be displayed on the interface that "the unknown risk has been determined to be a risk file, and the virus file will be cleared", and the file to be detected is cleared.

[0107] In one embodiment, Figure 6 As shown, an embodiment of the present invention provides a sample virus detection method, which is described below by taking the method applied to an anti-virus engine as an example, and includes the following steps:

[0108] S601, obtaining a sample to be tested.

[0109] S602: Obtain a target type identifier of the sample to be detected; and determine whether the type of the sample to be detected is a recognizable type according to the target type identifier.

[0110] S603: If the type of the sample to be detected is a recognizable type, search the anti-virus database for an existing target type record corresponding to the target type identifier, and determine the sample size of the sample to be detected.

[0111] S6031. If the sample size is a non-zero value, adjust the second maximum sample size corresponding to the target sample in the target existing type record according to the sample size; and control the anti-virus engine to execute a preset virus detection and killing program on the sample to be detected according to the adjusted second maximum sample size.

[0112] S6032: If the sample size is zero, stop virus detection on the sample to be tested.

[0113] S604: If the type of the sample to be detected is an unrecognizable type, compare the target type identifier with the type identifier information in the type record table.

[0114] S605: If the target type identifier exists in the type identifier information, the type identification result is that the type is identifiable, and the DWORD value of the target type identifier is obtained.

[0115] S6051. If the DWORD value is a non-zero value, search for a matching feature record in the anti-virus database through a multi-mode matching algorithm, and determine a virus detection result of the sample to be detected according to the matching feature record.

[0116] S6052: If the DWORD value is zero, stop virus detection on the sample to be detected.

[0117] S606: If the target type identifier does not exist in the type identifier information, the type identification result is that the type is unrecognizable, and a preset unknown virus detection program is executed.

[0118] The sample virus detection method provided in the above embodiment can accurately determine the virus detection result of the sample to be detected through the anti-virus database without the need for a configuration file. On the other hand, when the anti-virus database cannot identify the sample to be detected, the virus detection function of the anti-virus engine for the sample to be detected can be updated by upgrading the anti-virus database. The upgrade of the anti-virus database is much more efficient than the test release of the configuration file, which can greatly reduce the response time of the sample virus detection.

[0119] In some embodiments, the anti-virus engine may refer to Tencent TAV's self-developed engine.

[0120] In one embodiment, in order to better understand the above method, Figure 7 As shown, the following takes the application of the method to an anti-virus engine as an example to explain in detail an application example of the virus detection method of the sample of the present invention.

[0121] S701: The antivirus engine receives a sample to be detected.

[0122] S702: The antivirus engine determines the type identifier of the sample to be detected.

[0123] S703: Determine whether the type of the sample to be detected is a recognizable type according to the type identifier.

[0124] S704: If the type of the sample to be detected is a recognizable type, determine the corresponding DWORD value in the existing type record table in the genlib.def database.

[0125] S7041. If the DWORD value is non-zero, the genlib.def database is controlled to adjust the maximum sample size in the existing type record table, and the virus detection / analysis logic of the sample to be detected is completed.

[0126] S7042. If the DWORD value is zero, the virus detection function for the sample to be detected is turned off.

[0127] S705. If the type of the sample to be detected is an unrecognizable type, enter the genlib.def detection logic (including the contents of S706, S707 and S708).

[0128] S706: Compare the type identification of the sample to be detected with the feature record table to determine whether the type of the sample to be detected is identifiable.

[0129] S707: The type of the sample to be detected can be identified, and a matching feature record is determined in the feature record table of the anti-virus database through a multi-mode matching algorithm, thereby determining the virus detection result of the sample to be detected.

[0130] S708: The type of the sample to be detected cannot be identified, and the Unk detection logic is executed.

[0131] In current anti-virus technology, configuration files are often used to implement anti-virus control, and configuration files are mainly used to control the opening or closing of a single engine function. For example, for performance reasons, virus detection for a certain type of sample may be closed, or if a certain detection function is found to have a false positive, the detection function may be closed; for the purpose of improving the detection rate, virus detection for a certain type of sample may be opened. Figure 8 As shown, the external product loads and parses the configuration file when the engine is initialized and sets the engine-related parameters according to the content of the configuration file. The anti-virus engine processes the samples according to the settings of the configuration file to obtain a set of virus samples. However, this technical solution of implementing anti-virus through configuration files has the following problems: 1. It is highly coupled with the product and requires the product to support the release of configuration files. When the engine is applied to scenarios with different requirements for performance, detection rate, and stability, the corresponding products also need to support the processing of configuration files. 2. It is not natively supported by the anti-virus engine and cannot be used across platforms. It requires the support of external products and upgrade strategies, which increases the development and operation costs. 3. For unknown new sample file formats, it is difficult for the engine to quickly detect and handle this risk without upgrading the code.

[0132] The sample virus detection method provided by the embodiment of the present invention has the following technical effects: 1. Low product coupling. The core control sample of the anti-virus engine exists as the anti-virus database sample of the engine, which is a necessary sample for the operation of the anti-virus engine, so that the detection of files does not rely on the additional support of the product. 2. The anti-virus engine is natively supported and can be used across platforms without increasing the development cost of external products; for example, Tencent Computer Manager is a product that incorporates an anti-virus engine. This configuration file is supported by the grayscale strategy of the client and backend of the computer manager. Because the computer manager is a product under Windows, it can only run under Windows. If it is to run under other systems (such as MACOSLINUX), it also needs to be redeveloped and the product needs to support the configuration file strategy. If the embodiment of the present invention runs under MACOSLINUX and other systems, it only needs to upgrade the anti-virus database without doing other work. 3. For unknown new risks, the anti-virus engine can respond quickly and effectively. In addition, after a large number of sample data testing processes, the inventor found that the embodiment of the present invention does not affect the performance and detection rate of the anti-virus engine and the anti-virus database.

[0133] It should be noted that, for the sake of convenience, the aforementioned method embodiments are all expressed as a series of action combinations, but those skilled in the art should know that the present invention is not limited to the described order of actions, because according to the present invention, certain steps can be performed in other orders or simultaneously.

[0134] Based on the same idea as the sample virus detection method in the above embodiment, the present invention also provides a sample virus detection device, which can be used to perform the sample virus detection method. For ease of explanation, the schematic diagram of the structure of the sample virus detection device embodiment only shows the parts related to the embodiment of the present invention. Those skilled in the art can understand that the illustrated structure does not constitute a limitation on the device, and may include more or fewer components than shown in the diagram, or combine certain components, or arrange the components differently.

[0135] like Fig. 9 As shown, the sample virus detection device includes a sample acquisition module 901, a type identification module 902, a record search module 903 and a result determination module 904, which are described in detail as follows:

[0136] The sample acquisition module 901 is used to acquire samples to be detected.

[0137] The type identification module 902 is used to compare the sample to be detected with the type record table in the anti-virus database, and obtain a type identification result according to the comparison result.

[0138] The record search module 903 is used to search for matching feature records in the antivirus database by using a multi-mode matching algorithm if it is determined that the sample to be detected is of identifiable type according to the type identification result.

[0139] The result determination module 904 is used to determine the virus detection result of the sample to be detected according to the matched feature record.

[0140] The sample virus detection device provided in this embodiment can accurately determine the virus detection result of the sample to be detected with the help of an anti-virus database without the need for a configuration file, and can effectively reduce the response time of the sample virus detection.

[0141] In one embodiment, the record search module 903 includes: a key value acquisition submodule, used to obtain the registry key value of the sample to be detected; a record search submodule, used to search for matching feature records in the anti-virus database through a multi-mode matching algorithm if the registry key value is a non-zero value; wherein the feature record is stored in the anti-virus database in the json standard format.

[0142] In one embodiment, the record search module 903 further includes: a detection stop submodule, which is used to stop the virus detection of the sample to be detected if the registry key value is zero.

[0143] In one embodiment, the result determination module 904 includes: a feature data determination submodule, used to determine the feature data in the matching feature record; a sample judgment submodule, used to judge whether the sample to be detected is a virus sample based on the feature data; and a detection result determination submodule, used to obtain the virus detection result based on the judgment result.

[0144] In one embodiment, if the registry key value is a non-zero value, the virus detection device for the sample further includes: a sample size determination module, which is used to determine a first maximum sample size according to the registry key value if the sample to be detected is determined to be a virus sample according to the virus detection result; and a first virus detection and killing module, which is used to control the anti-virus engine to execute a preset virus detection and killing program on the sample to be detected if the sample size of the sample to be detected is less than or equal to the first maximum sample size.

[0145] In one embodiment, the virus detection device for a sample further includes: a type identification acquisition module, used to obtain a target type identification of the sample to be detected; a type judgment module, used to determine whether the sample to be detected is a recognizable type according to the target type identification; a comparison execution module, used to, if not, execute the step of comparing the sample to be detected with the type record table in the anti-virus database; and a second virus detection module, used to, if yes, search the anti-virus database for a target existing type record corresponding to the target type identification, and perform a virus detection operation according to the target existing type record.

[0146] In one embodiment, the second virus detection and killing module includes: a sample size determination submodule, used to determine the sample size of the sample to be detected; a sample size adjustment submodule, used to adjust the second maximum sample size corresponding to the target sample in the target existing type record according to the sample size; and a virus detection and killing program execution submodule, used to control the anti-virus engine to execute a preset virus detection and killing program on the sample to be detected according to the adjusted second maximum sample size.

[0147] In one embodiment, the sample virus detection device provided in the present application can be implemented in the form of a computer program. The computer program can be Figure 1 The computer device shown in the figure is run. The memory of the computer device can store various program modules constituting the virus detection device of the sample, for example, Fig. 9The sample acquisition module, type identification module, record search module and result determination module shown. The computer program composed of each program module enables the processor to execute the steps of the sample virus detection method of each embodiment of the present application described in this specification. For example, Figure 1 The computer device shown can be Fig. 9 The sample acquisition module 901 in the virus detection device of the sample shown executes S201, the type identification module 902 executes S202, the record search module 903 executes S203, and the result determination module 904 executes S204.

[0148] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the virus detection method for the sample described above. The steps of the virus detection method for the sample here may be the steps of the virus detection method for the sample described in each of the above embodiments.

[0149] In one embodiment, a computer-readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the processor executes the steps of the virus detection method for the sample described above. The steps of the virus detection method for the sample here may be the steps of the virus detection method for the sample described in each of the above embodiments.

[0150] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0151] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0152] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A method for detecting a virus in a sample, characterized in that: The following steps are involved: Obtain samples to be tested; Obtaining a target type identifier of the sample to be detected; determining whether the sample to be detected is of a recognizable type according to the target type identifier; if so, searching an anti-virus database for a target existing type record corresponding to the target type identifier, and performing a virus detection and killing operation according to the target existing type record; If not, the sample to be detected is compared with the type record table in the anti-virus database, and a type identification result is obtained according to the comparison result. The type record table records type-related information of samples with known virus detection results. The type record table is used to record the type identifier of the newly added identifiable sample. The core control file of the anti-virus engine is used as the anti-virus database, which is a necessary file for the engine to run; If it is determined according to the type identification result that the sample to be detected is of identifiable type, searching for a matching feature record in the antivirus database by using a multi-mode matching algorithm; Determining the virus detection result of the sample to be detected according to the matched feature record; When the type identification result is that the type is unrecognizable, the feature record is not searched, and the virus detection process for the sample to be detected is ended.

2. The method according to claim 1, characterized in that: The step of searching the anti-virus database for matching feature records by using a multi-mode matching algorithm comprises: Obtaining the registry key value of the sample to be detected; If the registry key value is a non-zero value, a matching feature record is searched in the anti-virus database by using a multi-mode matching algorithm; wherein the feature record is stored in the anti-virus database in a json standard format.

3. The method according to claim 2, characterized in that After the step of obtaining the registry key value of the sample to be detected, the method further includes: If the registry key value is zero, stop virus detection on the sample to be detected.

4. The method according to claim 2, characterized in that: The step of determining the virus detection result of the sample to be detected according to the matched feature record includes: Determining feature data in the matched feature record; Determining whether the sample to be detected is a virus sample according to the characteristic data; According to the judgment result, the virus detection result is obtained.

5. The method according to claim 4, characterized in that If the registry key value is a non-zero value, after the step of determining the virus detection result of the sample to be detected according to the matched feature record, the method further includes: If it is determined according to the virus detection result that the sample to be detected is a virus sample, determining a first maximum sample size according to the registry key value; If the sample size of the sample to be detected is less than or equal to the first maximum sample size, the anti-virus engine is controlled to execute a preset virus detection and killing program on the sample to be detected.

6. The method according to any one of claims 1 to 5, characterized in that: The anti-virus database includes a library mark, which is a mark of the current anti-virus database and is used to distinguish it from other anti-virus databases. The anti-virus engine accesses a specific anti-virus database according to the library mark, and different anti-virus databases record information of different samples.

7. The method according to claim 6, characterized in that The step of performing virus detection and killing operation according to the target existing type record includes: Determining the sample size of the sample to be tested; According to the sample size, adjusting the second maximum sample size corresponding to the target sample in the target existing type record; According to the adjusted second maximum sample size, the anti-virus engine is controlled to execute a preset virus detection and killing program on the sample to be detected.

8. A virus detection device for a sample, characterized in that: include: A sample acquisition module, used to acquire a sample to be detected and obtain a target type identifier of the sample to be detected; Determine whether the sample to be detected is of a recognizable type according to the target type identifier; if so, search the anti-virus database for a target type record corresponding to the target type identifier, and perform a virus detection and killing operation according to the target type record; A type identification module, for comparing the sample to be detected with a type record table in an anti-virus database, and obtaining a type identification result according to the comparison result, wherein the type record table records type-related information of samples with known virus detection results, and the type record table is used to record the type identifier of newly added identifiable samples, and the core control file of the anti-virus engine is used as the anti-virus database, and the anti-virus database is a necessary file for the operation of the engine; A record search module, configured to search for a matching feature record in the anti-virus database by a multi-mode matching algorithm if it is determined that the sample to be detected is of identifiable type according to the type identification result; The result determination module is used to determine the virus detection result of the sample to be detected according to the matched feature record. When the type identification result is that the type is unrecognizable, no feature record search is performed and the virus detection process of the sample to be detected is ended.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Cloud antivirus method based on server feedback

    CN102081714A

  • Self-expansion virus blocking method and system

    CN103902896A

  • Terminal system security monitoring method and device

    CN105204825A

  • Script virus detection method and system based on program keyword calling sequence

    CN105488399A

  • Virus protection method, device and equipment and storage medium

    CN109981629A