Malicious file detection method, device and model, electronic equipment and storage medium

By performing word and char word segmentation processing on Powershell files, combined with the malicious file detection model, it solves the problem that existing technology is difficult to identify malicious Powershell scripts that are encrypted and bypasses processing, and improves the accuracy and efficiency of detection.

CN118606941APending Publication Date: 2024-09-06QI AN XIN TECHNOLOGY GROUP INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410718290.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-04
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

Existing static detection methods used to detect whether Powershell is malicious are difficult to identify Powershell scripts that have been maliciously processed such as encryption, bypassing or inserting useless character interference.

Method used

By performing word segmentation processing and char segmentation processing on the Powershell file to be detected, the corresponding word segmentation set is obtained, and combined with the preset malicious file detection model, threat detection is performed. Word segmentation processing improves the overall feature recognition rate, and char segmentation processing enhances the recognition ability of encryption and bypass processing, reducing the false alarm rate.

Benefits of technology

It improves the detection rate of malicious Powershell scripts, reduces the false positive rate, and can more accurately identify maliciously processed Powershell scripts that have been encrypted, bypassed, or inserted into useless characters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118606941A
    Figure CN118606941A
Patent Text Reader

Abstract

The invention provides a malicious file detection method, device and model, electronic equipment and a storage medium, and relates to the technical field of computers. The malicious file detection method comprises the steps of obtaining a first word segmentation set obtained by performing word segmentation processing on a to-be-detected Powershell file; wherein the word segmentation processing is used for filtering all special symbols in the Powershell file to be detected, and carrying out word segmentation on the Powershell file after filtering all the special symbols; obtaining a second word segmentation set obtained by performing char word segmentation processing on the Powershell file to be detected; based on the first word segmentation set, the second word segmentation set and a preset malicious file detection model, a detection result is obtained, and the detection result represents whether the Powershell file to be detected has threats or not.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of computers, and in particular to a malicious file detection method, device, model, electronic device and storage medium. Background Art

[0002] Powershell is a new generation of command line operating environment developed by Microsoft for Windows platform. Compared with the traditional command line environment, Powershell is more powerful and flexible to use. However, Powershell is often used in various attack scenarios, such as intranet penetration, APT (Advanced Persistent Threat) attacks, ransomware attacks, etc.

[0003] The existing static detection methods for detecting whether a Powershell is malicious are mainly based on regular matching. It is difficult for the static detection method based on regular matching to identify maliciously processed Powershell scripts, such as those that have been encrypted, bypassed, or inserted with useless characters. Summary of the invention

[0004] The present application provides a malicious file detection method, device, model, electronic device and storage medium to solve the problem in the prior art that it is difficult to identify malicious Powershell scripts that have been encrypted, bypassed, inserted with useless characters, etc.

[0005] In a first aspect, the present application provides a malicious file detection method, comprising:

[0006] A first segmentation set is obtained by performing word segmentation processing on the Powershell file to be detected; wherein the word segmentation processing is used to filter all special symbols in the Powershell file to be detected, and the Powershell file after all special symbols are filtered out is segmented; a second segmentation set is obtained by performing char segmentation processing on the Powershell file to be detected; wherein the char segmentation processing is used to filter all symbols except preset character types in the Powershell file to be detected, and the Powershell file after all symbols except preset character types are filtered out is segmented; based on the first segmentation set, the second segmentation set and a preset malicious file detection model, a detection result is obtained, and the detection result indicates whether the Powershell file to be detected has a threat.

[0007] In the embodiment of the present application, the Powershell file to be detected is processed by word segmentation and char segmentation respectively. Since the granularity of word segmentation is larger than that of char segmentation, the result obtained by word segmentation can more accurately reflect the overall characteristics of the Powershell file to be detected, so that the threat detection rate can be improved through word segmentation, thereby reducing the false alarm rate of the model. Since the granularity of char segmentation is smaller, the detection rate of malicious Powershell scripts that have been subjected to malicious processing such as encryption, bypassing, and insertion of useless characters can be increased through char segmentation, thereby achieving an increased probability of identifying Powershell scripts that have been subjected to malicious processing such as encryption, bypassing, and insertion of useless characters.

[0008] In combination with the technical solution provided in the first aspect above, in some possible implementations, the step of obtaining a first segmentation set obtained by performing word segmentation processing on the Powershell file to be detected; and obtaining a second segmentation set obtained by performing char segmentation processing on the Powershell file to be detected includes: obtaining the Powershell file to be detected; performing word segmentation processing on the Powershell file to be detected to obtain the first segmentation set, and performing char segmentation processing on the Powershell file to be detected to obtain the second segmentation set.

[0009] In combination with the technical solution provided in the first aspect above, in some possible implementations, obtaining a Powershell file to be detected includes: obtaining traffic data to be detected; when the traffic data to be detected belongs to a target file, determining whether the traffic data to be detected is a Powershell file; the target file includes a web page file and a picture file; if the traffic data to be detected is a Powershell file, obtaining the traffic data to be detected as the Powershell file to be detected.

[0010] In the embodiment of the present application, since the amount of calculation required to determine whether the traffic data to be detected is a Powershell file is large, the traffic data to be detected is screened and the traffic data to be detected that are non-target files are filtered out, thereby reducing the amount of traffic data to be detected that needs to be determined whether it is a Powershell file to be detected, thereby achieving the effect of reducing the amount of calculation.

[0011] In combination with the technical solution provided in the first aspect above, in some possible implementations, when the traffic data to be detected belongs to the target file, if the traffic data to be detected belongs to the web page file, the method further includes: determining whether the web page file is a binary file; and when the web page file is not a binary file, proceeding to execute the step of determining whether the traffic data to be detected is a Powershell file.

[0012] In an embodiment of the present application, when the traffic data to be detected is a web page file, it is further determined whether the traffic data to be detected is a binary file, so that web page files that are binary files can be filtered out, further reducing the amount of traffic data to be detected that needs to be determined whether it is a Powershell file to be detected, thereby reducing the amount of calculation.

[0013] In combination with the technical solution provided in the first aspect above, in some possible implementations, the malicious file detection model includes an input layer, a first convolutional layer, a first pooling layer, a second convolutional layer, a second pooling layer, a splicing layer, a first bidirectional long short-term memory network layer, a second bidirectional long short-term memory network layer, and a fully connected layer; wherein the input layer is used to obtain a first word set and a second word set, and input the first word set into the first convolutional layer, and the first convolutional layer inputs the processed data into the first pooling layer; the input layer is also used to input the second word set into the second convolutional layer, and the second convolutional layer inputs the processed data into the second pooling layer; the splicing layer aligns and splices the result output by the first pooling layer with the result output by the second pooling layer, and inputs the aligned and spliced ​​data into the first bidirectional long short-term memory network layer, the first bidirectional long short-term memory network layer outputs the processed result to the second bidirectional long short-term memory network layer, the second bidirectional long short-term memory network layer outputs the processed data to the fully connected layer, and the fully connected layer outputs the detection result.

[0014] In the embodiment of the present application, the first word segmentation set is processed by the first convolution layer and the first pooling layer, and the second word segmentation set is processed by the second convolution layer and the second pooling layer, and then the output result of the first pooling layer is aligned and spliced ​​with the output result of the second pooling layer, so that the spliced ​​data reflects the characteristics of two dimensions at the same time. Since the first word segmentation set can improve the detection rate and reduce the probability of false alarms; and the second word segmentation set can increase the detection rate of malicious Powershell scripts that apply malicious processing such as encryption, bypassing, and inserting useless characters to interfere. Therefore, the detection results obtained based on the spliced ​​data can realize the detection of known Powershell files and unknown Powershell files.

[0015] In combination with the technical solution provided in the first aspect above, in some possible implementations, obtaining the Powershell file to be detected includes: obtaining an initial Powershell file; converting the initial Powershell file into a file in a preset encoding format to obtain the Powershell file to be detected.

[0016] In the embodiment of the present application, the initial Powershell file is converted into a file in a preset encoding format, thereby ensuring that the Powershell file to be detected is correct and preventing deviations in the detection results caused by different encoding formats.

[0017] In combination with the technical solution provided in the first aspect above, in some possible implementations, a detection result is obtained based on the first word segmentation set, the second word segmentation set and a preset malicious file detection model, including: calculating the word vector of each word in the first word segmentation set to obtain a first word vector set; calculating the word vector of each word in the second word segmentation set to obtain a second word vector set; inputting the first word vector set and the second word vector set into the preset malicious file detection model to obtain the detection result.

[0018] In combination with the technical solution provided in the first aspect above, in some possible implementations, the method further includes: obtaining a false alarm Powershell file; the false alarm Powershell file is: among the Powershell files to be detected input into the malicious file detection model, the detection result output by the malicious file detection model is judged to be an erroneous detection result of the Powershell file to be detected; using the first word set and the second word set corresponding to the false alarm Powershell file to update and train the malicious file detection model to obtain a new malicious file detection model.

[0019] In an embodiment of the present application, the malicious file detection model is updated and trained by falsely reporting Powershell files, so that the detection result of the malicious file detection model can be made more accurate.

[0020] In the second aspect, the present application provides a malicious file detection model, including: an input layer, a first convolutional layer, a first pooling layer, a second convolutional layer, a second pooling layer, a splicing layer, a first bidirectional long short-term memory network layer, a second bidirectional long short-term memory network layer, and a fully connected layer; wherein the input layer is used to obtain a first segmentation set and a second segmentation set, and input the first segmentation set into the first convolutional layer, and the first convolutional layer inputs the processed data into the first pooling layer; the first segmentation set is obtained by performing word segmentation processing on the Powershell file to be detected, and the second segmentation set is obtained by performing char segmentation processing on the Powershell file to be detected; wherein the word segmentation processing is used to filter all special symbols in the Powershell file to be detected, and to filter the Powers after filtering all special symbols. hell file is segmented; the char segmentation process is used to filter all symbols except the preset character type in the Powershell file to be detected, and the Powershell file after filtering all symbols except the preset character type is segmented; the input layer is also used to input the second segmentation set into the second convolution layer, and the second convolution layer inputs the processed data into the second pooling layer; the splicing layer aligns and splices the result output by the first pooling layer with the result output by the second pooling layer, and inputs the aligned and spliced ​​data into the first bidirectional long short-term memory network layer, the first bidirectional long short-term memory network layer outputs the processed result to the second bidirectional long short-term memory network layer, the second bidirectional long short-term memory network layer outputs the processed data to the fully connected layer, and the fully connected layer outputs the detection result.

[0021] In a third aspect, the present application provides a malicious file detection device, including: an acquisition module and a processing module, the acquisition module is used to acquire a first segmentation set obtained by performing word segmentation processing on a Powershell file to be detected; wherein the word segmentation processing is used to filter all special symbols in the Powershell file to be detected, and perform segmentation on the Powershell file after filtering all special symbols; the acquisition module is also used to acquire a second segmentation set obtained by performing char segmentation processing on the Powershell file to be detected; wherein the char segmentation processing is used to filter all symbols except preset character types in the Powershell file to be detected, and perform segmentation on the Powershell file after filtering all symbols except preset character types; the processing module is used to obtain a detection result based on the first segmentation set, the second segmentation set and a preset malicious file detection model, and the detection result represents whether the Powershell file to be detected has a threat.

[0022] In a fourth aspect, the present application provides an electronic device, comprising: a memory and a processor, the memory and the processor being connected; the memory being used to store programs; and the processor being used to call the programs stored in the memory to execute the method described in the first aspect above and / or in combination with any possible implementation of the first aspect above.

[0023] In a fifth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a computer, the computer program executes the method described in the first aspect above and / or in combination with any possible implementation of the first aspect above. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0025] Figure 1 A schematic diagram of the process of the first malicious file detection method shown in an embodiment of the present application;

[0026] Figure 2 A structural block diagram of a malicious file detection model shown in an embodiment of the present application;

[0027] Figure 3 A schematic diagram of a second malicious file detection method shown in an embodiment of the present application;

[0028] Figure 4 A structural block diagram of a malicious file detection device shown in an embodiment of the present application;

[0029] Figure 5 A structural block diagram of an electronic device shown in an embodiment of the present application. DETAILED DESCRIPTION

[0030] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0031] It should be noted that similar numbers and letters represent similar items in the following figures, so once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. At the same time, in the description of this application, relational terms such as "first", "second", etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.

[0032] The technical solution of the present application will be described in detail below with reference to the accompanying drawings.

[0033] See also Figure 1 , Figure 1 A flowchart of a malicious file detection method shown in an embodiment of the present application is shown below in combination with Figure 1 Describe the steps it involves.

[0034] S100: Obtain a first word segmentation set obtained by performing word segmentation processing on the Powershell file to be detected.

[0035] The Powershell file to be detected can be pre-acquired and stored in a storage medium, and can be directly called when needed. Alternatively, the Powershell file to be detected can also be acquired in real time when needed.

[0036] Among them, word segmentation is used to filter all special symbols in the Powershell file to be detected, and to perform word segmentation on the Powershell file after all special symbols are filtered out. After all special symbols are filtered out, only letters and numbers are retained in the Powershell file.

[0037] The specific method of word segmentation processing is well known to those skilled in the art and will not be described here for the sake of brevity.

[0038] In one implementation manner, a specific method of obtaining a first segmented word set obtained by performing word segmentation processing on a Powershell file to be detected may be: obtaining a Powershell file to be detected; performing word segmentation processing on the Powershell file to be detected to obtain a first segmented word set.

[0039] In one implementation, the specific method of obtaining the Powershell file to be detected can be: first obtain the traffic data to be detected. Then, if the traffic data to be detected belongs to the target file, determine whether the traffic data to be detected is a Powershell file; the target file includes a web page file (Web file) and an image file. If the traffic data to be detected is a Powershell file, determine that the traffic data to be detected is a Powershell file to be detected.

[0040] If the traffic data to be detected does not belong to the target file, that is, the traffic data to be detected is not a web page file or a picture file, it is determined that the traffic data to be detected is not a Powershell file.

[0041] Since the amount of calculation required to determine whether the traffic data to be detected is a Powershell file is large, the traffic data to be detected is screened and the traffic data of non-target files is filtered out, thereby reducing the amount of traffic data to be detected that needs to be determined to be a Powershell file to be detected, thereby achieving the effect of reducing the amount of calculation.

[0042] Optionally, a method of determining whether the traffic data to be detected belongs to the target file may be: judging the file type by the hexadecimal of the file header bytes of the traffic data to be detected.

[0043] For example, the hexadecimal number of the header byte of a jpeg (Joint Photographic Experts Group) file is FFD8FF, and the hexadecimal number of the header byte of an exe (executable file) file is 4D5A9000. Therefore, the hexadecimal number of the header byte of the file can be used to confirm whether the traffic data to be detected belongs to the target file.

[0044] Optionally, the method of determining whether the traffic data to be detected is a Powershell file may be: judging whether the traffic data to be detected contains a Powershell statement by using a grammar rule. If the traffic data to be detected contains a Powershell statement, then the traffic data to be detected is confirmed to be a Powershell file to be detected. If the traffic data to be detected does not contain a Powershell statement, then the traffic data to be detected is confirmed not to be a Powershell file to be detected.

[0045] Optionally, when the traffic data to be detected belongs to the target file, if the traffic data to be detected belongs to a web page file, it is also possible to: first determine whether the traffic data to be detected is a binary file. If the traffic data to be detected is not a binary file, proceed to the step of determining whether the traffic data to be detected is a Powershell file. If the traffic data to be detected is a binary file, confirm that the traffic data to be detected is not a Powershell file.

[0046] In the case where the traffic data to be detected is a web page file, it is further determined whether the traffic data to be detected is a binary file, so that web page files that are binary files can be filtered out, further reducing the amount of traffic data to be detected that needs to be determined whether it is a Powershell file to be detected, thereby reducing the amount of calculation.

[0047] The method for determining whether the traffic data to be detected is a binary file may be: determining whether the file is a binary file based on the encoding method of the traffic data to be detected and the proportion of binary in the traffic data to be detected.

[0048] Since different Powershell files may have different encoding formats, in one implementation, the specific method of obtaining the Powershell file to be detected may be: obtaining an initial Powershell file; converting the initial Powershell file into a file of a preset encoding format to obtain the Powershell file to be detected. By converting the initial Powershell file into a file of a preset encoding format, the Powershell file to be detected is ensured, and deviations in the detection results caused by different encoding formats are prevented.

[0049] In order to facilitate understanding of the above-mentioned word segmentation processing of the Powershell file to be detected, the specific method of obtaining the first word segmentation set is as follows: sv('Tn'+'0E8')([CHaR[]]"))43]rahc[]gNIrTs[,)78]rahc[+67]rahc[+87]rahc[((EcAlpEr.)421]rahc[]gNIrTs[,)47]rahc[+78]ra hc[+97]rahc[((EcAlpEr.)'`','VOT'(EcAlpEr.)'\',)18]rahc[+77]rahc[+601]rahc[((EcAlpEr.)63]rahc[]gNIrTs[,)96]rahc[+48]rahc[+911]rahc[((EcAlpEr.)93]rahc[]gNIrTs[,'cN1'(EcAlpEr.)' is used as an example for explanation.

[0050] Special characters in the Powershell file to be detected, such as symbols such as "(", "'", "[", etc.", are filtered out, and then word segmentation is performed, and the first word segmentation set obtained is: sv tn*e*char 43rahc gnirts 78rahc 67rahc 87rahcecalper*rahc gnirts 47rahc 78rahc 97rahc ecalper vot ec alper 18rahc 77rahc*rahc ecalper 63rahc gnirts 96rahc 48rahc*rahc ecalper 93rahc gnirts cn*ecalper.

[0051] The examples given here are only for ease of understanding and should not be regarded as limitations on this application.

[0052] S200: Obtain a second segmentation set obtained by performing char segmentation processing on the Powershell file to be detected.

[0053] Among them, the char word segmentation process is used to filter all symbols except the preset character type in the Powershell file to be detected, and to perform word segmentation on the Powershell file after filtering all symbols except the preset character type.

[0054] In one implementation manner, the specific process of obtaining the second segmented word set obtained by performing char segmentation processing on the Powershell file to be detected may be: obtaining the Powershell file to be detected; performing char segmentation processing on the Powershell file to be detected to obtain the second segmented word set.

[0055] In one embodiment, the preset character types may include at least one of letters, numbers, spaces, "-", "'", "!", "%", "&", "()", "*", ",", ".", " / ", ":", ";", "?", "@", """, "[", "\\", "]", "`", "_", "{", "|", "}", "+", "<", "=", ">", "^", "#", "$", and "~".

[0056] The specific method of word segmentation processing is well known to those skilled in the art and will not be described here for the sake of brevity.

[0057] In order to facilitate the understanding of the above char word segmentation processing, the preset character types may include letters, numbers, spaces, "-", "'", "!", "%", "&", "()", "*", ",", ".", " / ", ":", ";", "?", "@", """, "[", "\\", "]", "`", "_", "{", "|", "}", "+", "<", "=", ">", "^", "#", "$", "~", and the Powershell file to be detected is: sv('Tn'+'0E8')([CHaR[]]"))43]rahc[]gNIrTs[,)78]rahc[+67]rahc[+87]rahc[((EcAlpEr.)421]rahc[]gNIrTs[,)47]rahc[+78]rahc[+97]rahc[((EcAlpEr.)'`','VOT'(EcAlpE r.)'\',)18]rahc[+77]rahc[+601]rahc[((EcAlpEr.)63]rahc[]gNIrTs[,)96]rahc[+48]ra hc[+911]rahc[((EcAlpEr.)93]rahc[]gNIrTs[,'cN1'(EcAlpEr.)' is used as an example for explanation.

[0058] The second segmentation set of the above-mentioned Powershell file to be detected after char segmentation is: sv

[0059] ('Tn'+'E')([CHaR[]]"))]rahc[]gNIrTs[,)]rahc[+]rahc[+]rahc[((EcAlpEr.)]rahc[]gN IrTs[,)]rahc[+]rahc[+]rahc[((EcAlpEr.)''','VOT'(EcAlpEr.)'\',)]rahc[+]rahc[+]ra hc[((EcAlpEr.)]rahc[]gNIrTs[,)]rahc[+]rahc[+]rahc[((EcAlpEr.)]rahc[]gNIrTs[,'cN'(EcAlpEr.)'.

[0060] The examples given here are only for ease of understanding and should not be regarded as limitations on this application.

[0061] S300: Obtain a detection result based on the first word segmentation set, the second word segmentation set and a preset malicious file detection model.

[0062] The detection result indicates whether the Powershell file to be detected contains threats.

[0063] The detection result may be a character indicating that the Powershell file to be detected has a threat, or a character indicating that the Powershell file to be detected has no threat.

[0064] For example, when the detection result is 1, it indicates that there is a threat in the Powershell file to be detected; when the detection result is 0, there is no threat in the Powershell file to be detected.

[0065] Alternatively, the detection result may also indicate the probability that the Powershell file to be detected contains a threat, or the probability that the Powershell file does not contain a threat.

[0066] For example, when the result output by the malicious file detection model represents the probability that the to-be-detected Powershell file has a threat, if the detection result is 30%, it can be determined that the probability that the to-be-detected Powershell file has a threat is 30%.

[0067] Alternatively, the detection result may also be a character outputting a character representing the probability that the to-be-detected Powershell file contains a threat.

[0068] For example, if the detection result is 1, it is considered that the probability that the Powershell file to be detected has a threat is less than the first preset threshold. If the detection result is 2, it is considered that the probability that the Powershell file to be detected has a threat is greater than or equal to the first preset threshold and less than the second preset threshold. If the detection result is 3, it is considered that the probability that the Powershell file to be detected has a threat is greater than or equal to the third preset threshold.

[0069] The specific implementation method of the detection result can be set according to actual needs, and its specific form is not limited here.

[0070] In one implementation, based on the first word segmentation set, the second word segmentation set and the preset malicious file detection model, the specific process of obtaining the detection result representing the probability that the to-be-detected Powershell file has a threat can be: firstly, the word vector of each word in the first word segmentation set is calculated to obtain the first word vector set; and the word vector of each word in the second word segmentation set is calculated to obtain the second word vector set. Then, the first word vector set and the second word vector set are input into the preset malicious file detection model to obtain the detection result.

[0071] Optionally, the method of calculating the word vector of each word in the first word segmentation set and the method of calculating the word vector of each word in the second word segmentation set can be any method that can calculate the word vector, for example, the word vector can be calculated using the word2vec (CBOW) model. The method of calculating the word vector is not limited to the method exemplified here.

[0072] Optionally, the first word set and the second word set may be directly used as input data of the malicious file detection model.

[0073] In one implementation, the malicious file detection model may include an input layer, a first convolutional layer, a first pooling layer, a second convolutional layer, a second pooling layer, a concatenation layer, a first bidirectional long short-term memory network layer, a second bidirectional long short-term memory network layer, and a fully connected layer. For ease of understanding, please refer to Figure 2 .

[0074] The input layer is used to obtain the first word segmentation set and the second word segmentation set, and input the first word segmentation set into the first convolutional layer, and the first convolutional layer inputs the processed data into the first pooling layer.

[0075] The input layer is also used to input the second word set into the second convolutional layer, and the second convolutional layer inputs the processed data into the second pooling layer.

[0076] The splicing layer aligns and splices the results output by the first pooling layer with the results output by the second pooling layer, and inputs the aligned and spliced ​​data into the first bidirectional long short-term memory network layer. The first bidirectional long short-term memory network layer outputs the processed results to the second bidirectional long short-term memory network layer. The second bidirectional long short-term memory network layer outputs the processed data to the fully connected layer, and the fully connected layer outputs the detection results.

[0077] Optionally, the fully connected layer may include a first fully connected layer and a second fully connected layer. The first fully connected layer receives data output by the second bidirectional long short-term memory network layer, and transmits the processed data to the second fully connected layer, and the second fully connected layer outputs the detection result.

[0078] The specific working principles of the input layer, convolution layer, pooling layer, bidirectional long short-term memory network layer, and fully connected layer are well known to those skilled in the art and will not be repeated here for the sake of brief description.

[0079] In one implementation, the training process of the malicious file detection model may be: first, a training data set is obtained, and the training data set includes multiple sets of training data. Each set of training data includes a first training word set and a second training word set, and each set of training data is marked with a label representing whether there is a threat. The initial malicious file detection model is trained based on the training data set to obtain a trained malicious file detection model.

[0080] Among them, the specific process of training the malicious file detection model is well known to those skilled in the art and will not be repeated here for the sake of brief description.

[0081] Optionally, each set of training data in the training data set can be obtained by processing a sample Powershell file. The method of obtaining the first training word set and the second training word set based on the sample Powershell file is the same as the method of obtaining the first word set and the second word set based on the Powershell file to be detected, which will not be repeated here for the sake of simplicity.

[0082] In one implementation, a false positive Powershell file can also be obtained; the false positive Powershell file is: among the Powershell files to be detected that are input into the malicious file detection model, the detection result output by the malicious file detection model is determined to be an erroneous detection result. Then, the malicious file detection model is updated and trained using the first word set and the second word set corresponding to the false positive Powershell file to obtain a new malicious file detection model. The malicious file detection model is updated and trained by using the false positive Powershell file, so that the detection result of the malicious file detection model can be made more accurate.

[0083] To understand the above malicious file detection method, please refer to Figure 3 , Figure 3 A specific implementation of a malicious file detection method shown in an embodiment of the present application.

[0084] like Figure 3 As shown, firstly, the flow data to be detected is obtained. It is determined whether the flow data to be detected belongs to the target file. If the flow data to be detected does not belong to the target file, the detection is exited.

[0085] In the case where the flow data to be detected belongs to a web page file, it is determined whether the flow data to be detected is a binary file. If the flow data to be detected is a binary file, the detection is exited.

[0086] When the traffic data to be detected is not a binary file, it is determined whether the traffic data to be detected is a Powershell file.

[0087] In the case where the traffic data to be detected is an image file, it is determined whether the traffic data to be detected is a Powershell file. If the traffic data to be detected is not a Powershell file, the detection is exited.

[0088] If the traffic data to be detected is a Powershell file, the traffic data to be detected is converted into a file in a preset encoding format to obtain the Powershell file to be detected.

[0089] The Powershell file to be detected is processed by word segmentation to obtain a first segmentation set. The Powershell file to be detected is processed by char segmentation to obtain a second segmentation set.

[0090] Based on the first word segmentation set, the second word segmentation set and a preset malicious file detection model, a detection result is obtained.

[0091] Figure 3 The specific implementation methods of each step shown have been clearly described in the previous text and will not be repeated here for the sake of brevity.

[0092] Based on the same technical concept, the present application also provides a malicious file detection device, such as Figure 4 As shown, the malicious file detection device 100 includes an acquisition module 110 and a processing module 120 .

[0093] The acquisition module 110 is used to obtain a first word segmentation set obtained by performing word segmentation processing on the Powershell file to be detected; wherein the word segmentation processing is used to filter all special symbols in the Powershell file to be detected, and perform word segmentation on the Powershell file after filtering all special symbols.

[0094] The acquisition module 110 is also used to obtain a second word segmentation set obtained by performing char word segmentation processing on the Powershell file to be detected; wherein the char word segmentation processing is used to filter all symbols except preset character types in the Powershell file to be detected, and to perform word segmentation on the Powershell file after filtering all symbols except preset character types.

[0095] The processing module 120 is further configured to obtain a detection result based on the first word segmentation set, the second word segmentation set and a preset malicious file detection model, wherein the detection result indicates whether the Powershell file to be detected has a threat.

[0096] The acquisition module 110 is specifically used to acquire the Powershell file to be detected; perform word segmentation processing on the Powershell file to be detected to obtain a first segmentation set; perform char segmentation processing on the Powershell file to be detected to obtain a second segmentation set.

[0097] The acquisition module 110 is specifically used to obtain the flow data to be detected; when the flow data to be detected belongs to the target file, determine whether the flow data to be detected is a Powershell file; the target file includes a web page file and a picture file; if the flow data to be detected is a Powershell file, determine that the flow data to be detected is the Powershell file to be detected.

[0098] In the case where the traffic data to be detected belongs to the target file, if the traffic data to be detected belongs to the web page file, the acquisition module 110 is specifically used to determine whether the web page file is a binary file; in the case where the web page file is not a binary file, the step of determining whether the traffic data to be detected is a Powershell file is executed.

[0099] In one implementation, the malicious file detection model includes an input layer, a first convolutional layer, a first pooling layer, a second convolutional layer, a second pooling layer, a splicing layer, a first bidirectional long short-term memory network layer, a second bidirectional long short-term memory network layer, and a fully connected layer; wherein the input layer is used to obtain a first word segmentation set and a second word segmentation set, and input the first word segmentation set into the first convolutional layer, and the first convolutional layer inputs the processed data into the first pooling layer; the input layer is also used to input the second word segmentation set into the second convolutional layer, and the second convolutional layer inputs the processed data into the second pooling layer; the splicing layer aligns and splices the result output by the first pooling layer with the result output by the second pooling layer, and inputs the aligned and spliced ​​data into the first bidirectional long short-term memory network layer, the first bidirectional long short-term memory network layer outputs the processed result to the second bidirectional long short-term memory network layer, the second bidirectional long short-term memory network layer outputs the processed data to the fully connected layer, and the fully connected layer outputs the detection result.

[0100] The acquisition module 110 is specifically used to acquire an initial Powershell file; convert the initial Powershell file into a file in a preset encoding format to obtain the Powershell file to be detected.

[0101] The processing module 120 is specifically used to calculate the word vector of each word in the first word set to obtain a first word vector set; calculate the word vector of each word in the second word set to obtain a second word vector set; input the first word vector set and the second word vector set into the preset malicious file detection model to obtain the detection result.

[0102] The acquisition module 110 is also used to acquire a false positive Powershell file; the false positive Powershell file is: among the Powershell files to be detected input into the malicious file detection model, the detection result output by the malicious file detection model is determined to be an erroneous detection result. The processing module 120 is also used to update and train the malicious file detection model using the first word set and the second word set corresponding to the false positive Powershell file to obtain a new malicious file detection model.

[0103] The malicious file detection device 100 provided in the embodiment of the present application has the same implementation principle and technical effects as those of the aforementioned malicious file detection method embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding contents in the aforementioned malicious file detection method embodiment.

[0104] See also Figure 5 , which is an electronic device 200 provided in an embodiment of the present application. The electronic device 200 includes: a processor 210 and a memory 220.

[0105] The memory 220 and the processor 210 are electrically connected to each other directly or indirectly to achieve data transmission or interaction. For example, these components can be electrically connected to each other via one or more communication buses or signal lines. The memory 220 is used to store computer programs, such as storing Figure 3The software function module shown in the figure is the malicious file detection device 100. The malicious file detection device 100 includes at least one software function module that can be stored in the memory 220 in the form of software or firmware or fixed in the operating system (OS) of the electronic device 200. The processor 210 is used to execute the executable module stored in the memory 220, such as the software function module or computer program included in the malicious file detection device 100. At this time, the processor 210 is used to obtain a first word segmentation set obtained by performing word segmentation processing on the Powershell file to be detected; wherein the word segmentation processing is used to filter all special symbols in the Powershell file to be detected, and to perform word segmentation on the Powershell file after all special symbols are filtered out; obtain a second word segmentation set obtained by performing char segmentation processing on the Powershell file to be detected; wherein the char segmentation processing is used to filter all symbols except preset character types in the Powershell file to be detected, and to perform word segmentation on the Powershell file after all symbols except preset character types are filtered out; based on the first word segmentation set, the second word segmentation set and a preset malicious file detection model, a detection result is obtained, and the detection result represents whether there is a threat in the Powershell file to be detected.

[0106] Among them, the memory 220 can be, but is not limited to, RAM (Random Access Memory), ROM (Read Only Memory), PROM (Programmable Read-Only Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electric Erasable Programmable Read-Only Memory), etc.

[0107] The processor 210 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a CPU (Central Processing Unit), an NP (Network Processor), etc.; it may also be a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The various methods, steps and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. A general-purpose processor may be a microprocessor or the processor 210 may also be any conventional processor, etc.

[0108] The electronic device 200 mentioned above includes but is not limited to a personal computer, a server, etc.

[0109] The embodiment of the present application also provides a computer-readable storage medium (hereinafter referred to as storage medium), on which a computer program is stored, and when the computer program is run by a computer such as the above-mentioned electronic device 200, the above-mentioned malicious file detection method is executed. The computer-readable storage medium includes: a U disk, a mobile hard disk, a read-only memory, a random access memory, a magnetic disk or an optical disk, and other media that can store program codes.

[0110] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A malicious file detection method, characterized in that: include: Obtaining a first segmentation set obtained by performing word segmentation processing on the Powershell file to be detected; wherein the word segmentation processing is used to filter all special symbols in the Powershell file to be detected, and perform segmentation on the Powershell file after filtering all special symbols; Obtain a second segmentation set obtained by performing char segmentation processing on the Powershell file to be detected; wherein the char segmentation processing is used to filter all symbols except preset character types in the Powershell file to be detected, and perform segmentation on the Powershell file after filtering all symbols except the preset character types; Based on the first word segmentation set, the second word segmentation set and a preset malicious file detection model, a detection result is obtained, and the detection result indicates whether the Powershell file to be detected poses a threat.

2. The method according to claim 1, characterized in that: The method of obtaining a first segmented word set obtained by performing word segmentation processing on the Powershell file to be detected and obtaining a second segmented word set obtained by performing char segmentation processing on the Powershell file to be detected comprises: Obtain the Powershell file to be detected; Perform word segmentation processing on the Powershell file to be detected to obtain a first word segmentation set; Perform char word segmentation processing on the Powershell file to be detected to obtain a second word segmentation set.

3. The method according to claim 2, characterized in that Get the Powershell file to be detected, including: Obtain the traffic data to be detected; In the case where the traffic data to be detected belongs to a target file, determining whether the traffic data to be detected is a Powershell file; the target file includes a web page file and a picture file; If the traffic data to be detected is a Powershell file, the traffic data to be detected is obtained as the Powershell file to be detected.

4. The method according to claim 3, characterized in that In the case where the traffic data to be detected belongs to the target file, if the traffic data to be detected belongs to the web page file, the method further includes: Determine whether the webpage file is a binary file; In the case that the web page file is not a binary file, the process proceeds to the step of determining whether the traffic data to be detected is a Powershell file.

5. The method according to claim 1, characterized in that The malicious file detection model includes an input layer, a first convolutional layer, a first pooling layer, a second convolutional layer, a second pooling layer, a concatenation layer, a first bidirectional long short-term memory network layer, a second bidirectional long short-term memory network layer, and a fully connected layer; The input layer is used to obtain a first word segmentation set and a second word segmentation set, and input the first word segmentation set into the first convolution layer, and the first convolution layer inputs the processed data into the first pooling layer; The input layer is further used to input the second word set into the second convolutional layer, and the second convolutional layer inputs the processed data into the second pooling layer; The splicing layer aligns and splices the results output by the first pooling layer with the results output by the second pooling layer, and inputs the aligned and spliced ​​data into the first bidirectional long short-term memory network layer. The first bidirectional long short-term memory network layer outputs the processed results to the second bidirectional long short-term memory network layer. The second bidirectional long short-term memory network layer outputs the processed data to the fully connected layer, and the fully connected layer outputs the detection results.

6. The method according to claim 2, characterized in that Get the Powershell file to be detected, including: Get the initial Powershell file; The initial Powershell file is converted into a file in a preset encoding format to obtain the Powershell file to be detected.

7. The method according to claim 1, characterized in that Based on the first word segmentation set, the second word segmentation set and a preset malicious file detection model, a detection result is obtained, including: Calculate the word vector of each word in the first word set to obtain a first word vector set; Calculate the word vector of each word in the second word set to obtain a second word vector set; The first word vector set and the second word vector set are input into the preset malicious file detection model to obtain the detection result.

8. The method according to any one of claims 1 to 7, characterized in that: The method further comprises: Acquire a false positive Powershell file; the false positive Powershell file is: among the Powershell files to be detected input into the malicious file detection model, the Powershell file to be detected whose detection result output by the malicious file detection model is determined to be an erroneous detection result; The malicious file detection model is updated and trained using the first word set and the second word set corresponding to the false positive Powershell file to obtain a new malicious file detection model.

9. A malicious file detection model, characterized in that: include: Input layer, first convolutional layer, first pooling layer, second convolutional layer, second pooling layer, concatenation layer, first bidirectional long short-term memory network layer, second bidirectional long short-term memory network layer, fully connected layer; The input layer is used to obtain a first word segmentation set and a second word segmentation set, and input the first word segmentation set into the first convolution layer, and the first convolution layer inputs the processed data into the first pooling layer; the first word segmentation set is obtained by performing word segmentation processing on the Powershell file to be detected, and the second word segmentation set is obtained by performing char segmentation processing on the Powershell file to be detected; wherein the word segmentation processing is used to filter all special symbols in the Powershell file to be detected, and perform word segmentation on the Powershell file after filtering all special symbols; the char segmentation processing is used to filter all symbols except preset character types in the Powershell file to be detected, and perform word segmentation on the Powershell file after filtering all symbols except preset character types; The input layer is further used to input the second word set into the second convolutional layer, and the second convolutional layer inputs the processed data into the second pooling layer; The splicing layer aligns and splices the results output by the first pooling layer with the results output by the second pooling layer, and inputs the aligned and spliced ​​data into the first bidirectional long short-term memory network layer. The first bidirectional long short-term memory network layer outputs the processed results to the second bidirectional long short-term memory network layer. The second bidirectional long short-term memory network layer outputs the processed data to the fully connected layer, and the fully connected layer outputs the detection results.

10. A malicious file detection device, characterized in that: include: An acquisition module is used to acquire a first segmentation set obtained by performing word segmentation processing on the Powershell file to be detected; wherein the word segmentation processing is used to filter all special symbols in the Powershell file to be detected, and perform segmentation on the Powershell file after filtering all special symbols; The acquisition module is further used to obtain a second word segmentation set obtained by performing char word segmentation processing on the Powershell file to be detected; wherein the char word segmentation processing is used to filter all symbols except preset character types in the Powershell file to be detected, and to perform word segmentation on the Powershell file after filtering all symbols except the preset character types; The processing module is used to obtain a detection result based on the first word segmentation set, the second word segmentation set and a preset malicious file detection model, wherein the detection result indicates whether the Powershell file to be detected has a threat.

11. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are connected; The memory is used to store programs; The processor is used to call the program stored in the memory to execute the method according to any one of claims 1-8.

12. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a computer, the method according to any one of claims 1 to 8 is executed.