Malicious program detection method and device, storage medium, and electronic device
By simulating running program files in a sandbox, building a detection model, and extracting instruction sequence features, the problem of low efficiency in existing malware detection is solved, achieving efficient identification of malicious programs and improving accuracy.
Patent Information
- Application Number
- CN202011509623.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-18
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2040-12-18
Smart Images

Figure CN112528284B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence, and in particular to a method and device for detecting malicious programs, a storage medium, and an electronic device. Background Art
[0002] In the relevant technology, malware is a software designed to damage the target computer or occupy the target computer resources. Traditional malware includes worms, Trojans, etc. These malware seriously infringe the legitimate rights and interests of users and may even cause huge economic or other forms of loss of interests to users and others. In recent years, as virtual currency has entered the public eye, malicious mining programs have also begun to emerge in large numbers, and hackers have gained huge profits by invading malicious mining programs. The current malware detection technologies mainly include feature code detection, behavior detection, and heuristic detection. The use of machine learning can improve the generalization ability to a certain extent and improve the recognition rate of malicious samples.
[0003] In the related technology, malware identification is performed by combining content with signature codes. The combination of content and signature codes is the principle of traditional virus engines. Based on the static analysis method of content, the virus sample does not need to be actually executed. Security personnel directly open the file to view the binary code or disassemble and analyze the source code later. This method depends on the security personnel to provide accurate matching signature codes, and the matching is fast. However, just like the common antivirus engines, the virus database needs to be updated regularly, which requires high time and labor costs.
[0004] With respect to the above-mentioned problems existing in the related technologies, no effective solutions have been found so far. Summary of the invention
[0005] The embodiments of the present invention provide a method and device for detecting malicious programs, a storage medium, and an electronic device.
[0006] According to one aspect of an embodiment of the present application, a method for detecting malicious programs is provided, comprising: simulating the running of a program file to be detected in a sandbox; extracting instruction sequence features after the program file is simulated and run; and detecting the maliciousness of the program file in a detection model based on the instruction sequence features, wherein the maliciousness is used to characterize the probability value that the program file is a malicious program.
[0007] Furthermore, before detecting the program type of the program file in the detection model according to the instruction sequence characteristics, the method includes: performing a frequency inverse file frequency (TF IDF) transformation on the sample data to obtain the TFIDF characteristics of the sample data, and obtaining the statistical characteristics of the sample data; using a naive Bayesian logistic regression (NBLR) model and a mild gradient boosting machine (LightGBM) model to construct an initial model, wherein the initial model includes a NBLR initial model and a LightGBM initial model; training the initial model based on the TFIDF characteristics and the statistical characteristics to obtain the detection model.
[0008] Further, training the initial model based on the TFIDF features and the statistical features includes: using the TFIDF features to train the NBLR initial model to obtain a NBLR model and NBLR probability features, wherein the NBLR probability features are used to characterize the predicted values output by the NBLR model during the training process; and using the TFIDF features, the statistical features and the NBLR probability features to train the LightGBM initial model to obtain a LightGBM model.
[0009] Further, the TF IDF feature is used to train the NBLR initial model to obtain the NBLR model and the NBLR probability feature, including: dividing the sample data into N parts, wherein N is an integer greater than 1; using N training cycles to train the NBLR initial model to obtain the NBLR model and the NBLR probability feature, wherein in each training cycle, the i-th sample data is selected from the N sample data as the prediction data, and the remaining sample data is the model result of the previous training cycle of the iterative training of the training data, and i is an integer from 1 to N.
[0010] Furthermore, before training the initial model based on the TFIDF features and the statistical features, the method further includes: sorting the plurality of TFIDF features according to the verification result of the chi-square test; and selecting the first several TFIDF features in the sequence of the plurality of TFIDF features.
[0011] Further, detecting the maliciousness of the program file in the detection model according to the instruction sequence characteristics includes: outputting multiple program probability values in the detection model according to the instruction sequence characteristics, wherein each program probability value corresponds to a malicious program type; and selecting the highest designated program probability value among the multiple program probability values as the maliciousness of the program file.
[0012] Further, extracting the instruction sequence features after the program file is simulated and run includes: extracting the application program interface API instruction sequence after the program file is simulated and run; transforming the API instruction sequence into a word frequency inverse file frequency TFIDF model to obtain the instruction sequence features, wherein the instruction sequence features include: identification information of the API called by the program file, the thread number of the machine calling the API, and the sequential number of the API call in the thread.
[0013] According to another aspect of an embodiment of the present application, a malicious program detection device is also provided, including: an operation module, used to simulate the operation of a program file to be detected in a sandbox; an extraction module, used to extract instruction sequence characteristics after the program file is simulated and run; a detection module, used to detect the maliciousness of the program file in a detection model based on the instruction sequence characteristics, wherein the maliciousness is used to characterize the probability value that the program file is a malicious program.
[0014] Furthermore, the device includes: a transformation module, which is used to perform a frequency inverse file frequency (TF IDF) transformation on the sample data before the detection module detects the program type of the program file in the detection model according to the instruction sequence characteristics, so as to obtain the TFIDF characteristics of the sample data and obtain the statistical characteristics of the sample data; a construction module, which is used to construct an initial model using a naive Bayesian logistic regression (NBLR) model and a light gradient boosting machine (LightGBM) model, wherein the initial model includes a NBLR initial model and a LightGBM initial model; and a training module, which is used to train the initial model based on the TFIDF characteristics and the statistical characteristics to obtain the detection model.
[0015] Furthermore, the training module includes: a first training unit, used to train the NBLR initial model using the TFIDF feature to obtain a NBLR model and a NBLR probability feature, wherein the NBLR probability feature is used to characterize the predicted value output by the NBLR model during the training process; a second training unit, used to train the LightGBM initial model using the TFIDF feature, the statistical feature and the NBLR probability feature to obtain a LightGBM model.
[0016] Furthermore, the first training unit includes: a splitting subunit, used to divide the sample data into N parts, wherein N is an integer greater than 1; a training subunit, used to train the NBLR initial model using N training cycles to obtain the NBLR model and NBLR probability features, wherein in each training cycle, the i-th sample data is selected from the N parts of sample data as prediction data, and the remaining sample data are model results of the previous training cycle of iterative training of the training data, and i is an integer from 1 to N.
[0017] Furthermore, the device also includes: a sorting module, which is used to sort multiple TFIDF features according to the verification result of the chi-square test before the training module trains the initial model based on the TFIDF features and the statistical features; and a screening module, which is used to screen the first several TFIDF features in the sequence of the multiple TFIDF features.
[0018] Furthermore, the detection module includes: an output unit, used to output multiple program probability values in the detection model according to the instruction sequence characteristics, wherein each program probability value corresponds to a malicious program type; and a selection unit, used to select the highest specified program probability value among the multiple program probability values as the maliciousness of the program file.
[0019] Furthermore, the extraction module includes: an extraction unit, which is used to extract the application program interface API instruction sequence after the program file is simulated and run; a transformation unit, which is used to transform the API instruction sequence into a word frequency inverse file frequency TFIDF model to obtain the instruction sequence features, wherein the instruction sequence features include: identification information of the API called by the program file, the thread number of the machine calling the API, and the sequential number of the API call in the thread.
[0020] According to another aspect of an embodiment of the present application, a storage medium is further provided, which includes a stored program, and the above steps are executed when the program is run.
[0021] According to another aspect of an embodiment of the present application, there is also provided an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; wherein: the memory is used to store computer programs; and the processor is used to execute the steps in the above method by running the program stored in the memory.
[0022] The embodiment of the present application also provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute the steps in the above method.
[0023] Through the present invention, the program file to be detected is simulated and run in a sandbox, the instruction sequence characteristics of the program file after the simulated running are extracted, and the maliciousness of the program file is detected in a detection model according to the instruction sequence characteristics. By adopting the instruction sequence characteristics of the program file to detect the maliciousness of the program file, a dynamic identification method for malicious programs is provided, without extracting the source code or binary code of the program file, thereby solving the technical problem of low malicious program identification efficiency in related technologies and improving the recognition rate and accuracy of malicious programs. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0025] Figure 1 is a hardware structure block diagram of a server according to an embodiment of the present invention;
[0026] Figure 2 is a flow chart of a method for detecting malicious programs according to an embodiment of the present invention;
[0027] Figure 3 is a schematic diagram of extracting sample features from sample data according to an embodiment of the present invention;
[0028] Figure 4 is a schematic diagram of a detection model in an embodiment of the present invention;
[0029] Figure 5 is a schematic diagram of training an NBLR model according to an embodiment of the present invention;
[0030] Figure 6 Schematic diagram of fusing the NBLR model result and the LightGBM model according to an embodiment of the present invention;
[0031] Figure 7 is a structural block diagram of a malicious program detection device according to an embodiment of the present invention;
[0032] Figure 8 It is a structural block diagram of an electronic device implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0033] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only embodiments of a part of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work should fall within the scope of protection of the present application. It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict.
[0034] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0035] Example 1
[0036] The method embodiment provided in the first embodiment of the present application can be executed in a server, a computer, or a similar computing device. Taking running on a server as an example, Figure 1 FIG. 1 is a hardware structure diagram of a server according to an embodiment of the present invention. Figure 1 As shown, the server 10 may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. Optionally, the server may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above server. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0037] The memory 104 can be used to store server programs, for example, software programs and modules of application software, such as a server program corresponding to a method for detecting a malicious program in an embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the server program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the server 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0038] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the server 10. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0039] In this embodiment, a method for detecting malicious programs is provided. Figure 2 is a flow chart of a method for detecting malicious programs according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:
[0040] Step S202, simulating the running of the program file to be detected in the sandbox;
[0041] In this embodiment, the program file can be an APK (Android application package) file, a text file, a plug-in, or any other file in any format including an executable script. In addition to using the sandbox to extract features, sample features can also be extracted by monitoring dynamic operation behaviors such as program file access behaviors when the program file is executed normally.
[0042] Step S204, extracting instruction sequence features after the program file is simulated and run;
[0043] The instruction sequence feature of this embodiment is used to characterize the API instructions of the program file when it is running, including the API interface identifier called by the program file, the called thread, the index information of the thread, etc.
[0044] Step S206, detecting the maliciousness of the program file in the detection model according to the instruction sequence characteristics, wherein the maliciousness is used to represent the probability value of the program file being a malicious program;
[0045] Optionally, the detection model can be a binary classification model or a multi-classification model. When the detection model is a binary classification model, two probability values are output, corresponding to normal files and malicious programs respectively. Malicious programs are a general term for abnormal files. When the detection model is a multi-classification model, multiple probability values are output, corresponding to multiple types of malicious programs respectively. The type of malicious program with the highest probability value can be selected from them, and its probability value is determined as the degree of maliciousness.
[0046] Through the above steps, the program file to be detected is simulated and run in the sandbox, the instruction sequence characteristics of the program file after the simulated running are extracted, and the maliciousness of the program file is detected in the detection model according to the instruction sequence characteristics. By using the instruction sequence characteristics of the program file to detect the maliciousness of the program file, a dynamic identification method for malicious programs is provided, without extracting the source code or binary code of the program file, which solves the technical problem of low efficiency in identifying malicious programs in related technologies and improves the recognition rate and accuracy of malicious programs.
[0047] In this embodiment, before detecting the program type of the program file in the detection model according to the instruction sequence feature, the following steps are included:
[0048] S11, performing term frequency–inverse document frequency (TFIDF) transformation on the sample data to obtain TFIDF features of the sample data and obtain statistical features of the sample data;
[0049] In an example of this embodiment, the sample features of each sample data include multiple data fields, among which, file_id: file number; label: file label, 0-normal, 1-ransomware, 2-mining program, 3-DDoS Trojan, 4-worm virus, 5-infectious virus, 6-backdoor program, 7-Trojan program; api: API name called by the file; tid: thread number calling API; index: sequential number of API calls in the thread.
[0050] According to the API instruction sequence after the sandbox program simulates the operation of the file, a sequence of APIs can be obtained. This sequence can be regarded as a sentence and TFIDF transformation can be performed on it according to the common ideas of text processing (ngram 1 to 4 are used here). Figure 3 As shown, Figure 3 It is a schematic diagram of an embodiment of the present invention for extracting sample features from sample data, and obtaining TFIDF features and statistical features, wherein the statistical features include: how many different APIs are executed by the file, how many APIs are executed in total by the file, how many threads are called by the file, statistical distribution features of the APIs in each tid in the file, the maximum index value of the API called by the file, the index of each API when it is first called in the file, the relative position of each API when it is first called in the file, the number of times and proportion of each API execution in the file, etc.
[0051] S12, using the naive Bayesian logistic regression NBLR model and the light gradient boosting machine LightGBM model to build the initial model, where the initial model includes the NBLR initial model and the LightGBM initial model;
[0052] In one implementation of this embodiment, before training the initial model based on the TFIDF features and the statistical features, the method further includes: sorting the multiple TFIDF features according to the verification result of the chi-square test; and selecting the first several TFIDF features in the sequence of the multiple TFIDF features.
[0053] In this embodiment, Naive Bayers Logistic Regression (NBLR) includes a Naive Bayes part and a Logistic Regression part. Overall, NBLR combines the two most common basic classification models well by training a weight coefficient r to form a basic model with strong versatility and better effect.
[0054] In the Naive Bayers section: (i) ∈{0,1,2,3..}, is the label of the i-th sample;
[0055] f (i) is the sample feature of the i-th eye, that is, TFIDF feature
[0056]
[0057] Among them, a is the smoothing parameter, which is an adjustable hyperparameter.
[0058] In the Logistic Regression section:
[0059]
[0060] in,
[0061] Figure 4is a schematic diagram of the detection model in an embodiment of the present invention. The TF IDF feature is used as input to train NBLR. Whether a sample is a malicious file is predicted by out-of-fold prediction, and its probability is used as a new feature. Further, in the training process of the binary classification model based on NBLR, n binary classification models are trained based on OneVsRest as new features, which are provided to the subsequent LightGBM model fusion training. Finally, the three types of features of TF IDF feature + statistical feature + NBLR probability are used as input to train LightGBM. In order to increase the effect and robustness of the model, the TF IDF used by LightGBM is the first N TFIDF features screened out according to the chi-square test.
[0062] S13, training an initial model based on TF IDF features and statistical features to obtain a detection model.
[0063] In one implementation of this embodiment, training the initial model based on TFIDF features and statistical features includes: using TFIDF features to train the NBLR initial model to obtain the NBLR model and NBLR probability features, wherein the NBLR probability features are used to characterize the predicted values output by the NBLR model during the training process; using TFIDF features, statistical features and NBLR probability features to train the LightGBM initial model to obtain the LightGBM model.
[0064] In an example based on the above implementation, the TF IDF feature is used to train the NBLR initial model to obtain the NBLR model and the NBLR probability feature, including: dividing the sample data into N parts, where N is an integer greater than 1; using N training cycles to train the NBLR initial model to obtain the NBLR model and the NBLR probability feature, where in each training cycle, the i-th sample data is selected from the N sample data as the prediction data, and the remaining sample data is the model result of the previous training cycle of the iterative training of the training data, and i is an integer from 1 to N.
[0065] Model training and model fusion are divided into two steps. The first step is the training of the NBLR model, and the second step is the fusion of the NBLR model results and the LightGBM model. The specific operations are as follows: Figure 5 As shown, Figure 5 is a schematic diagram of training an NBLR model according to an embodiment of the present invention, Figure 6 is a schematic diagram of fusing the NBLR model result and the LightGBM model according to an embodiment of the present invention. In one example, N=5. During the training of the NBLR model, the process includes:
[0066] First, divide the data into 5 parts (similar to 5-fold cross validation);
[0067] Perform prediction verification on the i-th fold and perform model training on the remaining folds, with i taking values from 1 to 5;
[0068] After doing this five times, it is equivalent to predicting on all the training data, and obtaining the out-of-fold prediction value of the complete training data;
[0069] Use the above five models to predict the test set respectively, and then take the average of the five predictions to get the predicted value on the test set.
[0070] exist Figure 6 In the figure, the process of fusing the NBLR model results and the LightGBM model is similar to the training process of the NBLR model. The difference is that the input feature part is increased by the prediction value obtained in the training process of the NBLR model.
[0071] Optionally, detecting the maliciousness of a program file in a detection model according to the instruction sequence characteristics includes: outputting multiple program probability values in the detection model according to the instruction sequence characteristics, wherein each program probability value corresponds to a type of malicious program; and selecting the highest specified program probability value among the multiple program probability values as the maliciousness of the program file. Optionally, the types of malicious programs include: infectious viruses, Trojan programs, mining programs, DDOS Trojans, and ransomware viruses.
[0072] In one implementation of the present embodiment, extracting instruction sequence features after a program file is simulated and run includes: extracting an application program interface API instruction sequence after the program file is simulated and run; transforming the API instruction sequence using a word frequency inverse file frequency (TF IDF) model to obtain instruction sequence features, wherein the instruction sequence features include: identification information of the API called by the program file, the thread number of the machine calling the API, and the sequential number of the API calls in the thread.
[0073] Using the solution of this embodiment, the existing data is the API instruction sequence of files (such as Windows executable programs) after being simulated and run by sandbox programs. All of them are Windows binary executable programs, including normal files, infectious viruses, Trojan programs, mining programs, DDOS Trojans, ransomware viruses, etc., and a fusion machine learning model of NBLR and LightGBM is established to detect malicious programs.
[0074] LR models are suitable for processing sparse features, GBDT models are suitable for processing dense features. NBLR is used to process TFIDF features (very sparse), and LightGBM is used to process dense statistical features, giving full play to the advantages of each model and improving model efficiency and prediction accuracy. When fusing NBLR and LightGBM, the out-of-fold prediction (OOF) method is used to avoid overfitting. The model used has low complexity and strong interpretability. In terms of implementation capabilities, the TF-IDF model, NBLR model and LightGBM model are pre-trained offline, the model can be replaced arbitrarily, the algorithm is simple, and the cost of model update is low. In the production environment, when new samples arrive, TF-IDF and statistical features can be extracted in parallel, and then passed through the NBLR and LightGBM models in turn to obtain the prediction results.
[0075] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0076] Example 2
[0077] In this embodiment, a malicious program detection device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0078] Figure 7 is a structural block diagram of a malicious program detection device according to an embodiment of the present invention, such as Figure 7 As shown, the device includes: an operation module 70, an extraction module 72, and a detection module 74, wherein:
[0079] An operation module 70 is used to simulate and run the program file to be detected in the sandbox;
[0080] An extraction module 72 is used to extract instruction sequence features after the program file is simulated and run;
[0081] The detection module 74 is used to detect the maliciousness of the program file in the detection model according to the instruction sequence characteristics, wherein the maliciousness is used to represent the probability value of the program file being a malicious program.
[0082] Optionally, the device includes: a transformation module, used to perform a frequency inverse file frequency (TF IDF) transformation on the sample data before the detection module detects the program type of the program file in the detection model according to the instruction sequence characteristics, so as to obtain the TFIDF characteristics of the sample data and obtain the statistical characteristics of the sample data; a construction module, used to construct an initial model using a naive Bayesian logistic regression (NBLR) model and a light gradient boosting machine (LightGBM) model, wherein the initial model includes a NBLR initial model and a LightGBM initial model; and a training module, used to train the initial model based on the TFIDF characteristics and the statistical characteristics to obtain the detection model.
[0083] Optionally, the training module includes: a first training unit, used to train the NBLR initial model using the TFIDF features to obtain a NBLR model and NBLR probability features, wherein the NBLR probability features are used to characterize the predicted values output by the NBLR model during the training process; a second training unit, used to train the LightGBM initial model using the TFIDF features, the statistical features and the NBLR probability features to obtain a LightGBM model.
[0084] Optionally, the first training unit includes: a splitting subunit, used to divide the sample data into N parts, wherein N is an integer greater than 1; a training subunit, used to train the NBLR initial model using N training cycles to obtain the NBLR model and NBLR probability features, wherein in each training cycle, the i-th sample data is selected from the N parts of sample data as prediction data, and the remaining sample data are model results of the previous training cycle of iterative training of the training data, and i is an integer from 1 to N.
[0085] Optionally, the device also includes: a sorting module, used to sort multiple TFIDF features according to the verification result of the chi-square test before the training module trains the initial model based on the TFIDF features and the statistical features; and a screening module, used to screen the first several TFIDF features in the sequence of the multiple TFIDF features.
[0086] Optionally, the detection module includes: an output unit, used to output multiple program probability values in the detection model according to the instruction sequence characteristics, wherein each program probability value corresponds to a malicious program type; and a selection unit, used to select the highest specified program probability value among the multiple program probability values as the maliciousness of the program file.
[0087] Optionally, the extraction module includes: an extraction unit, used to extract an application program interface API instruction sequence after the program file is simulated and run; a transformation unit, used to transform the API instruction sequence into a word frequency inverse file frequency TFIDF model to obtain the instruction sequence features, wherein the instruction sequence features include: identification information of the API called by the program file, the thread number of the machine calling the API, and the sequential number of the API calls in the thread.
[0088] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0089] Example 3
[0090] An embodiment of the present invention further provides a storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0091] Optionally, in this embodiment, the storage medium may be configured to store a computer program for performing the following steps:
[0092] S1, simulate running the program file to be tested in the sandbox;
[0093] S2, extracting the instruction sequence features after the program file is simulated and run;
[0094] S3, detecting the maliciousness of the program file in a detection model according to the instruction sequence feature, wherein the maliciousness is used to represent the probability value of the program file being a malicious program.
[0095] Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store computer programs.
[0096] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0097] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0098] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0099] S1, simulate running the program file to be tested in the sandbox;
[0100] S2, extracting the instruction sequence features after the program file is simulated and run;
[0101] S3, detecting the maliciousness of the program file in a detection model according to the instruction sequence feature, wherein the maliciousness is used to represent the probability value of the program file being a malicious program.
[0102] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.
[0103] Figure 8 is a structural diagram of an electronic device according to an embodiment of the present invention, such as Figure 8 As shown, it includes a processor 81, a communication interface 82, a memory 83 and a communication bus 84, wherein the processor 81, the communication interface 82, and the memory 83 communicate with each other through the communication bus 84, the memory 83 is used to store computer programs; the processor 81 is used to execute the programs stored in the memory 83.
[0104] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0105] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0106] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0107] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0108] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0109] If the integrated 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 technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or CD-ROM and other media that can store program codes.
[0110] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for detecting malicious programs, characterized in that: include: Simulate and run the program file to be tested in the sandbox; Extracting the instruction sequence features after the program file is simulated and run, wherein the instruction sequence features include: identification information of the API called by the program file, the thread number of the machine calling the API, and the sequence number of the API call in the thread; Detecting the maliciousness of the program file in a detection model according to the instruction sequence feature, wherein the maliciousness is used to characterize the probability value of the program file being a malicious program; Before detecting the maliciousness of the program file in the detection model according to the instruction sequence characteristics, the method further includes: performing a word frequency inverse file frequency TFIDF transformation on the sample data to obtain the TFIDF characteristics of the sample data and obtain the statistical characteristics of the sample data; using a naive Bayesian logistic regression NBLR model and a light gradient boosting machine LightGBM model to construct an initial model, wherein the initial model includes an NBLR initial model and a LightGBM initial model; training the initial model based on the TFIDF characteristics and the statistical characteristics to obtain the detection model, wherein the statistical characteristics include at least one of the following: the number of types of file execution APIs; , the total number of APIs executed by the file, the number of threads called by the file, the statistical distribution characteristics of the APIs in each tid in the file, the maximum index value of the API called by the file, the index of each API when it is called for the first time in the file, the relative position of each API when it is called for the first time in the file, the number and proportion of executions of each API in the file, wherein the NBLR model includes a naive Bayes model and a logistic regression model, which is obtained by combining the naive Bayes model and the logistic regression model by training a weight coefficient r, wherein the NBLR initial model in the initial model is used to process TFIDF features, and the LightGBM initial model in the initial model is used to process statistical features.
2. The method according to claim 1, characterized in that Training the initial model based on the TFIDF feature and the statistical feature includes: The NBLR initial model is trained using the TFIDF feature to obtain a NBLR model and a NBLR probability feature, wherein the NBLR probability feature is used to characterize a predicted value output by the NBLR model during the training process; The LightGBM initial model is trained using the TFIDF feature, the statistical feature and the NBLR probability feature to obtain a LightGBM model.
3. The method according to claim 2, characterized in that The NBLR initial model is trained using the TFIDF feature to obtain the NBLR model and the NBLR probability feature including: Divide the sample data into N parts, where N is an integer greater than 1; The NBLR initial model is trained for N training cycles to obtain the NBLR model and NBLR probability features, wherein in each training cycle, the i-th sample data is selected from the N sample data as prediction data, and the remaining sample data is used as training data to continue iteratively training the model result obtained in the previous training cycle, where i is an integer from 1 to N.
4. The method according to claim 1, characterized in that: Before training the initial model based on the TFIDF feature and the statistical feature, the method further includes: Sort multiple TFIDF features according to the verification results of the chi-square test; The first several TFIDF features are selected from the sequence of the plurality of TFIDF features.
5. The method according to claim 1, characterized in that Detecting the maliciousness of the program file in the detection model according to the instruction sequence feature includes: Outputting a plurality of program probability values in the detection model according to the instruction sequence characteristics, wherein each program probability value corresponds to a malicious program type; The highest designated program probability value is selected from the plurality of program probability values as the maliciousness of the program file.
6. The method according to claim 1, characterized in that Extracting the instruction sequence features of the program file after being simulated and run includes: Extracting an application program interface API instruction sequence after the program file is simulated and run; The API instruction sequence is transformed into a term frequency inverse document frequency (TFIDF) model to obtain the instruction sequence features.
7. A malicious program detection device, characterized in that: include: A running module is used to simulate and run the program file to be detected in the sandbox; An extraction module is used to extract the instruction sequence features of the program file after being simulated and run, wherein the instruction sequence features include: identification information of the API called by the program file, the thread number of the machine calling the API, and the sequence number of the API call in the thread; A detection module, used for detecting the maliciousness of the program file in a detection model according to the instruction sequence characteristics, wherein the maliciousness is used to represent the probability value of the program file being a malicious program; The device includes: a transformation module, which is used to perform a word frequency inverse file frequency TFIDF transformation on the sample data before the detection module detects the maliciousness of the program file in the detection model according to the instruction sequence characteristics, obtain the TFIDF characteristics of the sample data, and obtain the statistical characteristics of the sample data; a construction module, which is used to construct an initial model using a naive Bayesian logistic regression NBLR model and a light gradient boosting machine LightGBM model, wherein the initial model includes a NBLR initial model and a LightGBM initial model; a training module, which is used to train the initial model based on the TFIDF characteristics and the statistical characteristics to obtain the detection model, wherein the statistical characteristics include at least one of the following : The number of types of file execution APIs, the total number of file execution APIs, the number of threads called by the file, the statistical distribution characteristics of the APIs in each tid in the file, the maximum index value of the API called by the file, the index of each API when it is called for the first time in the file, the relative position of each API when it is called for the first time in the file, the number and proportion of executions of each API in the file, wherein the NBLR model includes a naive Bayes model and a logistic regression model, which is obtained by combining the naive Bayes model and the logistic regression model by training a weight coefficient r, wherein the NBLR initial model in the initial model is used to process TFIDF features, and the LightGBM initial model in the initial model is used to process statistical features.
8. A storage medium, characterized in that: The storage medium includes a stored program, wherein the program executes the method steps of any one of claims 1 to 6 when running.
9. An electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein: The processor, the communication interface, and the memory communicate with each other via a communication bus; wherein: Memory, used to store computer programs; A processor, configured to execute the method steps of any one of claims 1 to 6 by running a program stored in a memory.
