Malicious code clustering method and computer device

Through the multi-stage clustering method of identifying and processing malicious codes, the problems of low malicious code recognition rate and low processing efficiency in the existing technology are solved, accurate identification and efficient clustering of malicious codes are achieved, and the monitoring and control of security threats are enhanced. Prevention ability.

CN118332552BActive Publication Date: 2024-08-23CHENXIN LINGCHUANG
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410752356.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-12
Publication Date
2024-08-23
Estimated Expiration
2044-06-12

AI Technical Summary

Technical Problem

The recognition rate of malicious code in the existing technology is low, the processing efficiency is low, the clustering effect is poor, and complex and hidden malware cannot be effectively identified and processed.

Method used

By identifying the type of the original sample set, extracting features, dividing fragments, calculating entropy values, selecting high-entropy value fragments for vectorization processing, and combining with the preset malicious code historical data set for multi-stage clustering, using DBSCAN and hierarchical clustering algorithms for accurate identification.

Benefits of technology

It achieves accurate and rapid identification of malicious code, improves the accuracy and robustness of clustering, and enhances the ability to monitor and prevent malicious code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118332552B
    Figure CN118332552B
Patent Text Reader

Abstract

The present application discloses a malicious code clustering method and a computer device; the method includes: identifying the type of an original sample set; obtaining a first data set based on the type; extracting features from the first data set to obtain a second data set; dividing the second data set into M segments; obtaining M entropy values ​​of the M segments; sorting the M entropy values ​​from large to small, and selecting N segments corresponding to the first N entropy values; calculating the N segments to obtain N vector values; integrating the N vector values ​​with a preset malicious code history data set to obtain an input data set; clustering the input data set using a first clustering algorithm to obtain malicious code clustering information; determining whether there is an unclustered sample set in the malicious code clustering information, and if so, performing secondary clustering using a second clustering algorithm to obtain secondary clustering information. The method can accurately cluster malicious codes, has a high recognition rate and high processing efficiency, and effectively improves the clustering effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a malicious code clustering method and a computer device. Background Art

[0002] In today's digital society, the explosive growth of malicious code every day has become a very challenging reality. With the continuous advancement of technology and the popularization of the Internet, the number of malware variants is increasing day by day, showing an alarming growth trend; these malicious codes are not just simple viruses or worms, but also include more complex and hidden ransomware, spyware, botnets and other forms.

[0003] The method used in the prior art is to analyze samples one by one. However, as the size of malicious code becomes larger and larger, there are more and more ways to write it, some languages ​​with runtimes become more and more popular, and it is more and more common to use loaders or packers to hide real data. These non-technical or technical countermeasures make it impossible for clustering tools in the prior art to accurately identify malicious code, resulting in low recognition rate of malicious code, low processing efficiency, and poor clustering effect. Summary of the invention

[0004] In view of this, the embodiments of the present disclosure provide a malicious code clustering method and a computer device, which can solve the problems of low malicious code recognition rate, low processing efficiency and poor clustering effect existing in the prior art.

[0005] In a first aspect, an embodiment of the present disclosure provides a malicious code clustering method, comprising:

[0006] Identify the type of the original sample set;

[0007] obtaining a first data set based on the type;

[0008] Performing feature extraction on the first data set to obtain a second data set;

[0009] Dividing the second data set into M segments;

[0010] Obtaining M entropy values ​​of the M fragments;

[0011] Sort the M entropy values ​​from large to small, and select N fragments corresponding to the first N entropy values; wherein 0<N≤M;

[0012] Calculate N fragments to obtain N vector values;

[0013] Integrate the N vector values ​​with a preset malicious code history data set to obtain an input data set;

[0014] Clustering the input data set using a first clustering algorithm to obtain malicious code clustering information;

[0015] It is determined whether there is an unclustered sample set in the malicious code clustering information. If so, a second clustering algorithm is used to perform secondary clustering on the unclustered sample set to obtain secondary clustering information.

[0016] Optionally, obtaining a first data set based on the type includes:

[0017] If the type belongs to the first type of database, processing the original sample set based on a first strategy to obtain the first data set;

[0018] If the type belongs to the second type of database, processing the original sample set based on a second strategy to obtain the first data set;

[0019] If the type belongs to the third type of database, the original sample set is processed based on a third strategy to obtain the first data set.

[0020] Optionally, the first type of database is a shell database;

[0021] The second type of database is a loader class database;

[0022] The third type of database is a runtime database.

[0023] Optionally, the processing the original sample set based on a first strategy to obtain the first data set includes:

[0024] Using a reverse engineering tool to perform static analysis on the original sample set to obtain entry points;

[0025] Identify the type of packed program and the type of packer used based on the entry point;

[0026] Unpacking the original sample set based on the packed program type and the shell type to obtain first original data;

[0027] A first preprocessing is performed on the first original data to obtain the first data set.

[0028] Optionally, the processing the original sample set based on the second strategy to obtain the first data set includes:

[0029] Acquire the features of the loader program of the original sample set through static analysis, wherein the features include a specific encryption algorithm flag or a feature code of a decryption function;

[0030] Decryption code information based on the feature identification;

[0031] Decrypting the original sample set based on the decryption code information to obtain second original data;

[0032] Perform a second preprocessing on the second original data to obtain the first data set.

[0033] Optionally, the processing the original sample set based on a third strategy to obtain the first data set includes:

[0034] Parsing the original sample set to obtain file content;

[0035] Based on the file content, identifying structure start position information and structure end position information;

[0036] Extracting code information of a first preset area based on the structure start position information and the structure end position information;

[0037] Processing the code information using text processing technology to obtain the first data set;

[0038] The first data set includes CIL code and character strings.

[0039] Optionally, extracting features from the first data set to obtain a second data set includes:

[0040] Parsing the first data set to obtain data set content;

[0041] Determining a file category based on the content of the data set;

[0042] Based on the file category, obtaining file structure information;

[0043] Based on the file structure information, extracting text information and code information of a second preset area;

[0044] The text information and the code information are processed using data processing technology to obtain the second data set.

[0045] Optionally, the entropy value is ;

[0046] ;

[0047] in, is a random variable The probability of is the number of values ​​that the random variable can take.

[0048] Optionally, the determining whether there is an unclustered sample set in the malicious code clustering information includes:

[0049] Obtaining all clustering types of the malicious code clustering information;

[0050] Determine whether the number of samples contained in each of the cluster types is greater than a preset value,

[0051] If so, it is determined that there is no unclustered sample set.

[0052] If not, it is determined that there is an unclustered sample set, and the sample set is obtained.

[0053] Optionally, the first clustering algorithm includes a DBSCAN algorithm;

[0054] The second clustering algorithm comprises a hierarchical clustering algorithm.

[0055] In a second aspect, the embodiment of the present disclosure further provides a malicious code clustering system, which adopts the following technical solution:

[0056] an identification module configured to identify the type of the original sample set;

[0057] A first acquisition module, configured to obtain a first data set based on the type;

[0058] a feature extraction module, configured to perform feature extraction on the first data set to obtain a second data set;

[0059] a partitioning module configured to partition the second data set into M segments;

[0060] A second acquisition module is configured to acquire M entropy values ​​of the M segments;

[0061] A selection module is configured to sort the M entropy values ​​from large to small, and select N fragments corresponding to the first N entropy values; wherein 0<N≤M;

[0062] A calculation module, configured to calculate the N fragments to obtain N vector values;

[0063] An integration module, configured to integrate the N vector values ​​with a preset malicious code history data set to obtain an input data set;

[0064] A primary clustering module, configured to cluster the input data set using a first clustering algorithm to obtain malicious code clustering information;

[0065] The secondary clustering module is configured to determine whether there is an unclustered sample set in the malicious code clustering information, and if so, perform secondary clustering on the unclustered sample set using a second clustering algorithm to obtain secondary clustering information.

[0066] In a third aspect, the embodiments of the present disclosure further provide a computer device, which adopts the following technical solution:

[0067] The computer device comprises:

[0068] at least one processor; and,

[0069] a memory communicatively connected to the at least one processor; wherein,

[0070] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any of the malicious code clustering methods described above.

[0071] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable a computer to execute any of the malicious code clustering methods described above.

[0072] In a fifth aspect, an embodiment of the present disclosure further provides a computer program product, including a computer program / instruction, which implements the steps of any of the above methods when executed by a processor.

[0073] The malicious code clustering method disclosed in the present application can classify the sample set into different categories by identifying the type of the original sample set, so as to carry out subsequent processing in a targeted manner; obtain the first data set based on the type of the sample set, and extract features thereof, so as to convert the original data into a more representative and distinguishable form, and provide better input for subsequent clustering; divide the second data set into multiple segments, and calculate the entropy values ​​of these segments, so as to help extract the local features and changes of the data, so as to more accurately describe the characteristics of the data; by sorting the entropy values ​​and selecting the top N high entropy value segments, it is possible to focus on the parts of the data with large changes and rich information , improve the accuracy and effectiveness of clustering; vectorize the selected fragments and convert them into numerical form to facilitate subsequent data processing and clustering; integrate the vector value with the preset malicious code historical data set, which can combine existing knowledge and experience in the clustering process to improve the precision and accuracy of clustering; use the first clustering algorithm to perform preliminary clustering on the input data set, and then determine whether there are unclustered sample sets. If so, perform secondary clustering. This multi-stage clustering method can capture the structure and characteristics of the data more comprehensively, achieve accurate and rapid identification of malicious code, ensure the quality of clustering results, and improve the integrity and robustness of clustering.

[0074] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the following preferred embodiments are specifically cited and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0075] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0076] Figure 1 A flowchart of a malicious code clustering method provided in an embodiment of the present disclosure.

[0077] Figure 2 for Figure 1 A schematic diagram of a flow chart of a method for obtaining a first data set.

[0078] Figure 3 for Figure 2 A flowchart of a method for processing an original sample set based on a first strategy is shown in FIG.

[0079] Figure 4 for Figure 2 A flowchart of a method for processing an original sample set based on a second strategy is shown in FIG.

[0080] Figure 5 for Figure 2 Schematic diagram of the flow of the method for processing the original sample set based on the third strategy.

[0081] Figure 6 for Figure 1 A schematic flow chart of a method for obtaining a second data set.

[0082] Figure 7 for Figure 1 Flow chart of the method for determining the unclustered sample set in .

[0083] Figure 8 A functional block diagram of a malicious code clustering system provided in an embodiment of the present disclosure.

[0084] Fig. 9 A schematic diagram of the structure of a computer device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0085] The embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.

[0086] It should be clear that the following embodiments of the present disclosure are described by specific specific examples, and those skilled in the art can easily understand other advantages and effects of the present disclosure from the contents disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all of the embodiments. The present disclosure can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present disclosure. It should be noted that the following embodiments and features in the embodiments can be combined with each other in the absence of conflict. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present disclosure.

[0087] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein may be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on the present disclosure, it should be understood by those skilled in the art that an aspect described herein may be implemented independently of any other aspect, and two or more of these aspects may be combined in various ways. For example, any number of aspects described herein may be used to implement the device and / or practice the method. In addition, other structures and / or functionalities other than one or more of the aspects described herein may be used to implement this device and / or practice this method.

[0088] It should also be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present disclosure. The drawings only show components related to the present disclosure rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.

[0089] Additionally, in the following description, specific details are provided to facilitate a thorough understanding of the examples. However, it will be understood by those skilled in the art that the aspects described may be practiced without these specific details.

[0090] Reference Figure 1 The first aspect of the present application discloses a malicious code clustering method, the method comprising the following steps:

[0091] S100, identifying the type of the original sample set.

[0092] In this step, the original sample set is the input malicious code sample set. By identifying the type, it can provide guidance for subsequent data processing. Different types of malicious codes may have different characteristics and behaviors. Therefore, first identifying the type of the sample set helps to accurately and quickly trigger subsequent operations.

[0093] S200, obtaining a first data set based on the type.

[0094] The purpose of this step is to adopt corresponding operations according to the specific type, so as to quickly obtain the first data set.

[0095] S300, extracting features from the first data set to obtain a second data set.

[0096] Through feature extraction, the raw data can be converted into representative feature vectors, which can better describe each sample, help reduce the dimension of the data, and extract the most important information, providing better input for subsequent analysis and clustering.

[0097] S400: Divide the second data set into M segments.

[0098] Dividing the second data set into multiple segments can improve processing efficiency and help better capture local features of the data, making subsequent analysis more flexible and accurate.

[0099] S500: Obtain M entropy values ​​of M segments.

[0100] In this step, entropy is used to measure the uncertainty and confusion of the data. By calculating the entropy, we can quantify the complexity and amount of information of each fragment, understand the structure and characteristics of the data, and provide a basis for subsequent fragment selection.

[0101] S600, sorting the M entropy values ​​from large to small, and selecting N segments corresponding to the first N entropy values; wherein 0<N≤M.

[0102] In this step, selecting fragments with larger entropy values ​​means selecting the most representative and important parts of the data, which helps to improve the efficiency and accuracy of the analysis and avoids unnecessary processing of the entire data set.

[0103] It should be noted that if the number of divided segments is small, all of them can be selected in this step.

[0104] S700, calculating the N fragments to obtain N vector values.

[0105] In this embodiment, hash calculation is preferably performed on the N fragments.

[0106] S800, integrating the N vector values ​​with a preset malicious code history data set to obtain an input data set.

[0107] In this step, integrating current data with historical data can enrich the information of the data and improve the accuracy and robustness of clustering. The knowledge and patterns in historical data can help us better understand the current data set and classify and cluster more accurately.

[0108] S900: clustering the input data set using a first clustering algorithm to obtain malicious code clustering information.

[0109] The first clustering algorithm can classify samples with similar characteristics in the data set into one category, quickly obtain the structure and distribution of the data, discover potential malicious code groups, and provide guidance for subsequent analysis and defense.

[0110] S1000, determining whether there is an unclustered sample set in the malicious code clustering information, and if so, performing secondary clustering on the unclustered sample set using a second clustering algorithm to obtain secondary clustering information.

[0111] For the unclustered sample set, using the second clustering algorithm for secondary clustering can further refine the classification results, improve the recognition rate of malicious code, achieve comprehensive clustering analysis, obtain accurate clustering analysis results, and improve the accuracy and completeness of classification.

[0112] Among them, M>0.

[0113] The malicious code clustering method disclosed in the present application can realize accurate identification and precise clustering of large quantities of samples; by identifying the type of the original sample set, the sample set can be divided into different categories, so as to carry out subsequent processing in a targeted manner; based on the type of the sample set, a first data set is obtained and feature extraction is performed on it, which can convert the original data into a more representative and distinguishable form, providing better input for subsequent clustering; dividing the second data set into multiple segments and calculating the entropy values ​​of these segments is helpful to extract the local features and changes of the data, so as to more accurately describe the characteristics of the data; by sorting the entropy values ​​and selecting the top N high entropy value segments, it is possible to focus on the changes in the data. The large and information-rich parts are vectorized to improve the accuracy and effectiveness of clustering; the selected fragments are vectorized and converted into numerical form to facilitate subsequent data processing and clustering; the vector values ​​are integrated with the preset malicious code historical data set, which can combine existing knowledge and experience in the clustering process to improve the precision and accuracy of clustering; the first clustering algorithm is used to perform preliminary clustering on the input data set, and then it is determined whether there are unclustered sample sets. If so, secondary clustering is performed. This multi-stage clustering method can capture the structure and characteristics of the data more comprehensively, realize accurate and rapid identification of malicious code, ensure the quality of clustering results, and improve the integrity and robustness of clustering.

[0114] In summary, the malicious code clustering method disclosed in the present application can classify and cluster malicious codes more accurately through processing and optimization of multiple steps, which can help researchers to more easily identify and analyze new malicious code variants, greatly reduce the number of detection rules, and help antivirus products improve detection efficiency, that is, effectively improve the detection and analysis efficiency of malicious codes, help to timely discover and respond to various security threats, and provide reliable support for further research and defense.

[0115] Reference Figure 2 , the method for obtaining the first data set specifically includes the following steps:

[0116] Determine whether the type belongs to the first type of database, and if so, process the original sample set based on the first strategy to obtain a first data set;

[0117] If not, determine whether the type belongs to the second type of database, and if so, process the original sample set based on the second strategy to obtain the first data set;

[0118] If not, it indicates that the type belongs to the third type of database, and the original sample set is processed based on the third strategy to obtain the first data set.

[0119] In this embodiment, the first type of database is preferably a shell database; the second type of database is preferably a loader database (ie, a Loader database); and the third type of database is preferably a runtime database, wherein the runtime database mainly includes .Net / Vb.

[0120] Specifically, in this step, if the type belongs to the first type of database, the original sample set is processed based on the first strategy to obtain the first data set; if the type belongs to the second type of database, the original sample set is processed based on the second strategy to obtain the first data set; if the type belongs to the third type of database, the original sample set is processed based on the third strategy to obtain the first data set.

[0121] Through the method for obtaining the first data set disclosed in this embodiment, different processing strategies can be adopted according to different types to extract relevant information to the greatest extent; this hierarchical, multi-strategy method can more comprehensively cover various types of databases, thereby improving the success rate and efficiency of obtaining the first data set; at the same time, by adopting different strategies for different types, it is possible to better cope with complex situations that may exist in the data set and improve the quality and accuracy of data acquisition.

[0122] Reference Figure 3 The method for processing the original sample set based on the first strategy specifically includes:

[0123] A100,uses reverse engineering tools to perform static analysis on the original sample set to obtain,entry points.

[0124] By using reverse engineering tools to perform static analysis, we can gain in-depth understanding of the structure and function of the sample set, accurately identify the entry point of the program, and help subsequent analysis steps be more targeted and effective, thereby improving processing efficiency.

[0125] Specifically, the reverse engineering tool may be IDA Pro, Ghidra, or the like.

[0126] A200,identifies the type of packed program and the type of packer used based on the entry point.

[0127] Packed programs may hide the original code. Analyzing the type of packed programs and the type of shell used can help to perform targeted decompression operations and recover the original data. Identifying and analyzing packed programs can provide more available data for subsequent analysis, avoid interference from packed programs, and improve the depth and accuracy of sample analysis.

[0128] A300, unpacking the original sample set based on the packed program type and the shell type to obtain first original data.

[0129] The unpacking operation can remove the influence of the packing program, making the original data in the sample set available and ensuring that subsequent analysis and processing are based on the real original data. After obtaining the original data, subsequent analysis and processing can be performed more accurately, avoiding data distortion and analysis bias caused by the packing program.

[0130] A400: Perform first preprocessing on the first original data to obtain a first data set.

[0131] The first preprocessing makes the first raw data more suitable for subsequent analysis and modeling, which helps to reduce noise and extract more meaningful features; by preprocessing the first raw data, a clearer and easier to understand data set can be obtained, providing a better foundation for subsequent analysis and modeling.

[0132] The method for processing the original sample set based on the first strategy disclosed in this embodiment 1) effectively improves the depth and accuracy of analysis: by identifying and parsing the shell program and preprocessing the original data, the depth and accuracy of analysis can be improved, making the understanding of the sample set more comprehensive and in-depth; 2) effectively improves the processing efficiency: through targeted analysis and processing steps, the efficiency of processing the sample set can be improved, avoiding unnecessary work and time waste; 3) effectively ensures the reliability of the analysis: by removing the influence of the shell program and preprocessing the data, the reliability of subsequent analysis and modeling can be ensured, reducing analysis deviations and errors caused by data quality issues.

[0133] In this embodiment, by unpacking and preprocessing, a cleaner data set that is easier to analyze and process can be prepared, laying the foundation for subsequent analysis work; unpacking and preprocessing of raw data can improve data quality and availability, and help improve the accuracy and effectiveness of subsequent analysis and modeling; processing of the packed program allows researchers to better understand the internal mechanisms and characteristics of the program, thereby providing a deeper understanding for further research and analysis, and further, can make subsequent data mining, analysis and modeling work smoother and more targeted.

[0134] Specifically, the first preprocessing preferably includes at least one of data format conversion and data cleaning.

[0135] Reference Figure 4 The method for processing the original sample set based on the second strategy specifically includes:

[0136] B100, obtains the features of the loader program of the original sample set through static analysis, the features including specific encryption algorithm flags or feature codes of decryption functions.

[0137] Obtaining the characteristics of the loader program helps in the subsequent decryption steps and data processing, making the entire process more efficient.

[0138] B200, decrypts code information based on feature recognition.

[0139] B300, decrypt the original sample set based on the decryption code information to obtain second original data.

[0140] B400, performing second preprocessing on the second original data to obtain a first data set.

[0141] The method disclosed in this embodiment makes full use of the characteristics of the loader program and the decryption code information, extracts useful information from the original sample set and decrypts the data, and finally obtains a processed first data set. Such a processing flow can improve the availability and value of the data and provide a better foundation for subsequent data analysis and application.

[0142] In this embodiment, the second preprocessing preferably includes at least one of data format conversion and data cleaning.

[0143] In addition, the method for processing the original sample set based on the second strategy can also adopt the virtual execution of the virtual machine to obtain the first data set; specifically, use virtual software to execute the sample, dump the process memory when the execution time reaches 3s or the exit function is executed as an interrupt opportunity, and replace the dumped data with a new input sample.

[0144] Reference Figure 5The method for processing the original sample set based on the third strategy specifically includes:

[0145] C100, parses the original sample set and obtains the file content.

[0146] This step allows subsequent processing to be based on real data, ensuring the accuracy and effectiveness of the processing.

[0147] C200, based on the file content, identifies the structure start position information and the structure end position information.

[0148] This step can help locate the required code segments, avoid processing irrelevant content, and improve processing efficiency.

[0149] C300: Extract code information of a first preset area based on the structure start position information and the structure end position information.

[0150] The code information of the first preset area is extracted, focusing on the portion of interest and avoiding processing irrelevant data, thereby simplifying the subsequent processing flow.

[0151] C400 processes the code information using text processing technology to obtain a first data set; the first data set includes CIL codes and character strings.

[0152] The method disclosed in this embodiment can accurately locate and extract the required code information by gradually processing the original sample set, avoid processing irrelevant content, and improve the accuracy of the data; adopt structure recognition and text processing technology, can quickly locate and extract target information, improve processing efficiency, save time and resources; the method can be adjusted and expanded according to specific needs, for example, customized processing can be performed according to different file types and data structures, and has certain flexibility and versatility; through sophisticated processing steps, the quality of extracted data can be guaranteed, noise and errors can be reduced, and the reliability and effectiveness of subsequent analysis can be improved.

[0153] Reference Figure 6 , the method for obtaining the second data set specifically includes the following steps:

[0154] S310, parsing the first data set to obtain data set content.

[0155] Specifically, an appropriate file reading method (such as the `open()` function in Python) can be used to read the content in the first data set and load it into memory for subsequent processing. Then, the content is parsed, and text extraction can be performed for text files, and code parsing can be performed for code files to obtain the data set content.

[0156] S320, determining a file category based on the data set content.

[0157] Specifically, the file category can be determined by analyzing the characteristics of the data set content (such as file extension, file header information, etc.); further, this can be achieved through a file type recognition algorithm or a rule-based method.

[0158] S330, obtaining file structure information based on the file category.

[0159] Specifically, for text files, structures such as paragraphs and sentences can be identified; for code files, structural information such as functions and variable definitions can be identified. This step can be achieved with the help of syntax analyzers or regular expressions.

[0160] S340, extracting text information and code information of a second preset area based on the file structure information.

[0161] According to the set or selected preset area, the required text information and code information are extracted from the file structure information; specifically, the file structure can be traversed or searched, and the corresponding content can be extracted according to the mark of the preset area.

[0162] In addition, regular expressions, natural language processing techniques (such as word segmentation, part-of-speech tagging), etc. can also be used for text extraction technology.

[0163] S350, using data processing technology to process the text information and the code information to obtain a second data set.

[0164] Specifically, data processing is performed on the extracted text information and code information, including but not limited to text cleaning, word segmentation, encoding conversion, etc., which can be achieved using various data processing technologies and tools, such as string processing functions in Python, NLTK (Natural Language Toolkit), etc.

[0165] In this step, the second data set obtained is a data set consisting of processed text information and processed code information.

[0166] Furthermore, after extracting the data segments and code segments, they can also be cleaned and processed to ensure the quality and integrity of the data; for example, useless characters or marks can be removed, missing values ​​can be processed, duplicates can be removed, etc.

[0167] In this embodiment, the entropy value is ;

[0168] ;

[0169] in, is a random variable The probability of is the number of values ​​that the random variable can take.

[0170] Reference Figure 7 , judging whether there is an unclustered sample set in the malicious code clustering information, that is, the judging method of the unclustered sample set specifically includes:

[0171] Get all cluster types of malicious code cluster information;

[0172] Determine whether the number of samples contained in each cluster type is greater than the preset value.

[0173] If so, it is determined that there is no unclustered sample set.

[0174] If not, it is determined that there is an unclustered sample set, and the sample set is obtained.

[0175] The method disclosed in this step ensures the reliability of the judgment result by comprehensively analyzing the clustering information, avoiding the omission of possible unclustered sample sets; by setting preset values, it can more accurately judge whether there are unclustered sample sets, reducing the possibility of misjudgment and improving the accuracy of judgment; the method is simple and direct, easy to implement and operate, and is suitable for checking and evaluating malicious code clustering information in actual application scenarios; it can timely discover and obtain unclustered sample sets, which helps to strengthen the monitoring and prevention of malicious codes and improve the security of the system.

[0176] In this embodiment, the preset value may preferably be 1.

[0177] In this embodiment, the second clustering algorithm is different from the first clustering algorithm, and the second clustering algorithm and the first clustering algorithm can cover all clustering analyses, which can effectively ensure the comprehensiveness of clustering.

[0178] Specifically, the first clustering algorithm preferably includes a DBSCAN algorithm, and the second clustering algorithm preferably includes a hierarchical clustering algorithm.

[0179] Through multiple clustering analyses, this application can automatically identify and cluster malicious code, reducing the need for manual intervention and enabling faster detection and response to malicious code threats. By using different clustering algorithms, the accuracy of malicious code clustering can be improved, effectively reducing the false alarm rate and ensuring that the malicious code clustering results obtained are comprehensive and accurate, which helps to accurately locate and handle security threats.

[0180] Furthermore, the method disclosed in the present application has a certain degree of adaptability, and can automatically select a clustering algorithm as needed, and perform secondary clustering on unclustered sample sets. This flexibility enables the system to cope with ever-changing malicious code threats and continuously optimize and improve over time, effectively enhancing the security and reliability of the system.

[0181] In this embodiment, a hash algorithm may be used to calculate the N fragments. Specifically, the hash algorithm includes any one of MD5, SHA-1, and SHA-256.

[0182] Specifically, the hash calculation method is: H=0;

[0183] ;in, To shift left, is XOR.

[0184] In this embodiment, the division method adopted for dividing the second data set into M segments can be to use a sliding window, starting from the beginning of the second data set, moving the window with a fixed size or according to a certain rule (such as a specific delimiter), and treating the data in each window as a segment.

[0185] In the actual test, we used the DBSCAN algorithm. For general samples, since the N fragments with the highest entropy values ​​were selected as features, such features are more representative of the sample and help the accuracy of the clustering results. For samples with shells and samples executed by Loader, we used methods such as unpacking and decryption to recover the original data, which is helpful for identifying variants. The special analysis of .Net can eliminate the interference caused by using the runtime library code as clustering data.

[0186] The scheme performs secondary clustering on the sample sets that DBSCAN fails to classify, which can improve the coverage of clustering results and improve efficiency.

[0187] In this embodiment, the preset malicious code historical data set can be sporadic or specific malicious code files (samples) collected during work, referred to as historical data. In the process of extracting features from historical data, samples are labeled one by one, and the label is unique to a certain sample, and there is a corresponding relationship between the sample and the label.

[0188] In the actual collection process, historical data may not be very much, but it may have a greater impact on the use of projects or engineering, and the actual effect is relatively clear. If the features are extracted separately, it is not friendly to general killing, so we integrate such data into large batches of data and classify them in a targeted manner, which is more friendly to the general killing of features.

[0189] The preset malicious code historical data set can also be a collection of malware samples that have been analyzed, classified, and labeled; the main function of this data set is to provide a reference standard or benchmark so that newly discovered malicious code can be compared and associated with known malicious code when executing the clustering algorithm; in this way, it is possible to more effectively identify, classify, and understand how new malicious code matches or differentiates from existing threat models.

[0190] Reference Figure 8 In the second aspect, the embodiment of the present disclosure also provides a malicious code clustering system, which adopts the following technical solutions:

[0191] an identification module configured to identify the type of the original sample set;

[0192] A first acquisition module, configured to obtain a first data set based on the type;

[0193] A feature extraction module, configured to extract features from the first data set to obtain a second data set;

[0194] a partitioning module configured to partition the second data set into M segments;

[0195] A second acquisition module is configured to acquire M entropy values ​​of the M segments;

[0196] A selection module is configured to sort the M entropy values ​​from large to small, and select N fragments corresponding to the first N entropy values; wherein 0<N≤M;

[0197] A calculation module, configured to calculate the N fragments to obtain N vector values;

[0198] An integration module, configured to integrate the N vector values ​​with a preset malicious code history data set to obtain an input data set;

[0199] A primary clustering module is configured to cluster the input data set using a first clustering algorithm to obtain malicious code clustering information;

[0200] The secondary clustering module is configured to determine whether there is an unclustered sample set in the malicious code clustering information, and if so, perform secondary clustering on the unclustered sample set using a second clustering algorithm to obtain secondary clustering information.

[0201] The computer device according to the embodiment of the present disclosure includes a memory and a processor. The memory is used to store non-temporary computer-readable instructions. Specifically, the memory may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, a random access memory (RAM) and / or a cache memory (cache), etc. The non-volatile memory may include, for example, a read-only memory (ROM), a hard disk, a flash memory, etc.

[0202] The processor may be a central processing unit (CPU) or other forms of processing units with data processing capabilities and / or instruction execution capabilities, and may control other components in the computer device to perform desired functions. In one embodiment of the present disclosure, the processor is used to run the computer-readable instructions stored in the memory, so that the computer device performs all or part of the steps of the malicious code clustering method of each embodiment of the present disclosure.

[0203] Those skilled in the art should be able to understand that in order to solve the technical problem of how to obtain a good user experience, the present embodiment may also include well-known structures such as a communication bus and an interface, and these well-known structures should also be included in the protection scope of the present disclosure.

[0204] like Fig. 9 A schematic diagram of the structure of a computer device provided in an embodiment of the present disclosure is shown, which is a schematic diagram of the structure of a computer device suitable for implementing the embodiment of the present disclosure. Fig. 9 The computer device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0205] like Fig. 9 As shown, the computer device may include a processor (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) or a program loaded from a storage device into a random access memory (RAM). In the RAM, various programs and data required for the operation of the computer device are also stored. The processor, ROM, and RAM are connected to each other via a bus. An input / output (I / O) interface is also connected to the bus.

[0206] Typically, the following devices can be connected to the I / O interface: input devices such as sensors or visual information acquisition devices; output devices such as display screens; storage devices such as tapes, hard disks, etc.; and communication devices. The communication device can allow the computer device to communicate with other devices (such as edge computing devices) wirelessly or by wire to exchange data. Fig. 9 A computer device having various devices is shown, but it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed instead.

[0207] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device, or installed from a ROM. When the computer program is executed by a processor, all or part of the steps of the malicious code clustering method of the embodiment of the present disclosure are executed.

[0208] For detailed description of this embodiment, reference may be made to the corresponding descriptions in the aforementioned embodiments, which will not be repeated here.

[0209] According to the computer-readable storage medium of the embodiment of the present disclosure, non-transitory computer-readable instructions are stored thereon. When the non-transitory computer-readable instructions are executed by a processor, all or part of the steps of the malicious code clustering method of each embodiment of the present disclosure are executed.

[0210] The above-mentioned computer-readable storage media include, but are not limited to: optical storage media (e.g., CD-ROM and DVD), magneto-optical storage media (e.g., MO), magnetic storage media (e.g., magnetic tape or mobile hard disk), media with built-in rewritable non-volatile memory (e.g., memory card) and media with built-in ROM (e.g., ROM box).

[0211] For detailed description of this embodiment, reference may be made to the corresponding descriptions in the aforementioned embodiments, which will not be repeated here.

[0212] The basic principles of the present disclosure are described above in conjunction with specific embodiments. However, it should be noted that the advantages, strengths, effects, etc. mentioned in the present disclosure are only examples and not limitations, and it cannot be considered that these advantages, strengths, effects, etc. are required by each embodiment of the present disclosure. In addition, the specific details disclosed above are only for the purpose of illustration and ease of understanding, and are not limitations. The above details do not limit the present disclosure to the necessity of adopting the above specific details to be implemented.

[0213] In the present disclosure, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. The block diagrams of the devices, devices, equipment, and systems involved in the present disclosure are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagram. As will be appreciated by those skilled in the art, these devices, devices, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including", "comprising", "having", etc. are open words, referring to "including but not limited to", and can be used interchangeably with them. The words "or" and "and" used here refer to the words "and / or" and can be used interchangeably with them, unless the context clearly indicates otherwise. The words "such as" used here refer to the phrase "such as but not limited to", and can be used interchangeably with them.

[0214] Additionally, as used herein, "or" used in a list of items beginning with "at least one" indicates a separate list, so that, for example, a list of "at least one of A, B, or C" means A or B or C, or AB or AC or BC, or ABC (i.e., A and B and C). Furthermore, the word "exemplary" does not mean that the example described is preferred or better than other examples.

[0215] It should also be noted that in the system and method of the present disclosure, each component or each step can be decomposed and / or recombined. Such decomposition and / or recombination should be regarded as equivalent solutions of the present disclosure.

[0216] Various changes, substitutions, and modifications of the techniques described herein may be made without departing from the teachings defined by the appended claims. Furthermore, the scope of the claims of the present disclosure is not limited to the specific aspects of the processes, machines, manufactures, compositions of events, means, methods, and actions described above. Currently existing or later to be developed processes, machines, manufactures, compositions of events, means, methods, or actions that perform substantially the same functions or achieve substantially the same results as the corresponding aspects described herein may be utilized. Thus, the appended claims include such processes, machines, manufactures, compositions of events, means, methods, or actions within their scope.

[0217] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the aspects shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

[0218] The above description has been given for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present disclosure to the forms disclosed herein. Although multiple example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions and sub-combinations thereof.

Claims

1. A malicious code clustering method, characterized in that: include: Identify the type of the original sample set; obtaining a first data set based on the type; Performing feature extraction on the first data set to obtain a second data set; Dividing the second data set into M segments; Obtaining M entropy values ​​of the M fragments; Sort the M entropy values ​​from large to small, and select N fragments corresponding to the first N entropy values; wherein 0<N≤M; Calculate N fragments to obtain N vector values; Integrate the N vector values ​​with a preset malicious code history data set to obtain an input data set; Using a first clustering algorithm to cluster the input data set to obtain malicious code clustering information; Determine whether there is an unclustered sample set in the malicious code clustering information, and if so, perform secondary clustering on the unclustered sample set using a second clustering algorithm to obtain secondary clustering information; The obtaining of a first data set based on the type includes: If the type belongs to the first type of database, processing the original sample set based on a first strategy to obtain the first data set; If the type belongs to the second type of database, processing the original sample set based on a second strategy to obtain the first data set; If the type belongs to the third type of database, processing the original sample set based on a third strategy to obtain the first data set; The first type of database is a shell database; The second type of database is a loader class database; The third type of database is a runtime database.

2. The malicious code clustering method according to claim 1, characterized in that: The step of processing the original sample set based on the first strategy to obtain the first data set includes: Using a reverse engineering tool to perform static analysis on the original sample set to obtain entry points; Identify the type of packed program and the type of packer used based on the entry point; Unpacking the original sample set based on the packed program type and the shell type to obtain first original data; The first original data is subjected to a first preprocessing to obtain the first data set.

3. The malicious code clustering method according to claim 1, characterized in that: The processing of the original sample set based on the second strategy to obtain the first data set includes: Acquire the features of the loader program of the original sample set through static analysis, wherein the features include a specific encryption algorithm flag or a feature code of a decryption function; Decryption code information based on the feature identification; Decrypting the original sample set based on the decryption code information to obtain second original data; Perform a second preprocessing on the second original data to obtain the first data set.

4. The malicious code clustering method according to claim 1, characterized in that: The step of processing the original sample set based on the third strategy to obtain the first data set includes: Parsing the original sample set to obtain file content; Based on the file content, identifying structure start position information and structure end position information; Extracting code information of a first preset area based on the structure start position information and the structure end position information; Processing the code information using text processing technology to obtain the first data set; The first data set includes CIL code and character strings.

5. The malicious code clustering method according to claim 1, characterized in that: The step of extracting features from the first data set to obtain a second data set includes: Parsing the first data set to obtain data set content; Determining a file category based on the content of the data set; Based on the file category, obtaining file structure information; Based on the file structure information, extracting text information and code information of a second preset area; The text information and the code information are processed using data processing technology to obtain the second data set.

6. The malicious code clustering method according to claim 1, characterized in that: The entropy value is ; ; in, is a random variable The probability of is the number of values ​​that the random variable can take.

7. The malicious code clustering method according to claim 1, characterized in that: The determining whether there is an unclustered sample set in the malicious code clustering information includes: Obtaining all clustering types of the malicious code clustering information; Determine whether the number of samples contained in each of the cluster types is greater than a preset value, If so, it is determined that there is no unclustered sample set. If not, it is determined that there is an unclustered sample set, and the sample set is obtained.

8. The malicious code clustering method according to claim 1, characterized in that: The first clustering algorithm includes a DBSCAN algorithm; The second clustering algorithm comprises a hierarchical clustering algorithm.

9. A computer device, characterized in that: The computer device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the malicious code clustering method described in any one of claims 1-8.