Ransomware detection method based on large graph model
By employing a ransomware detection method based on a large graph model, combining graph neural networks and large language models, global and local behavioral features of ransomware samples are extracted. This solves the problem of insufficient generalization performance in the detection of novel ransomware in existing technologies, and achieves efficient ransomware identification and detection.
Patent Information
- Application Number
- CN202511015798.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-23
- Publication Date
- 2025-11-07
AI Technical Summary
Existing ransomware detection methods lack generalization performance and robustness when facing new ransomware, making it difficult to achieve efficient detection and identification.
A ransomware detection method based on a graph big model is adopted. By extracting API call behavior features, learning global call patterns, learning local call patterns, and fusing multi-scale information, combined with graph neural networks and a large language model, the global and local behavioral features of ransomware samples are captured and information is fused to achieve detection.
It significantly improves the generalization detection capability for novel ransomware, accurately identifies ransomware and effectively distinguishes between benign and malicious samples, and maintains high detection accuracy while possessing excellent generalization performance.
Smart Images

Figure CN120910856A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of malware detection, in particular to a ransomware detection method based on a graph large model. BACKGROUND
[0002] Ransomware has become a major threat in the field of network security, with its family evolving rapidly and new variants emerging constantly. Ransomware usually invades victim systems through phishing, vulnerability exploitation, and other methods, then collects system information and exchanges keys for file encryption with the command and control (C&C) server, and finally demands ransom from victims to restore file access. In recent years, ransomware attack methods have evolved from single encryption ransom to double ransom and even triple ransom. Attackers not only encrypt files, but also steal and leak data, and even launch distributed denial of service (DDoS) attacks to increase the amount of ransom. The attack targets of ransomware also show new trends, gradually shifting from a large number of low-cost targets to a small number of high-value targets, such as critical infrastructure, large enterprises, and government agencies. Once these high-value targets are attacked, they will cause huge economic losses, social impacts, and even national security risks. Therefore, it is of high theoretical value and practical significance to study how to detect ransomware quickly and effectively.
[0003] Although there are currently various methods for detecting ransomware, they generally lack generalization. Traditional rule-based or signature-based detection methods can effectively identify known threats, but they cannot cope with new variants. In recent years, machine learning and deep learning-based detection methods have gradually emerged, but these methods are essentially still extracting and learning the behavior of known ransomware variants, and their detection capabilities depend on the coverage of the training data. For example, Chinese patent CN119740136A proposes a ransomware classification scheme based on a large model, which introduces large model technology to automatically extract features from ransomware samples using its powerful feature learning ability. Through learning from a large amount of historical ransomware data, the large model can generate highly abstract feature representations, which can be used to distinguish different types of ransomware. However, when faced with completely new ransomware families, these methods lack generalization performance and robustness.
[0004] Given the rapid iteration of ransomware, there is an urgent need for a highly generalizable detection model that can learn the essential properties of known ransomware behavior and effectively detect new ransomware families. SUMMARY
[0005] The present application aims to overcome the defects of the prior art and provide a ransomware detection method based on a graph large model, which can accurately identify ransomware and significantly improve the generalization detection capability of new ransomware.
[0006] The present application can be achieved by the following technical solutions: a ransomware detection method based on a graph large model, comprising an API (Application Programming Interface) call behavior feature extraction stage, a global call pattern learning stage, a local call pattern learning stage, and a multi-scale information fusion stage, the API call behavior feature extraction stage is used to construct an API call graph, extract frequent sequences, and generate API function descriptions;
[0007] The global call pattern learning stage is used to learn the global structure information of the API call graph through a graph neural network, capture the overall behavior characteristics of the ransomware sample, and obtain the global call pattern of the ransomware sample;
[0008] The local call pattern learning stage is used to learn the frequent call sequences through a large language model, understand the most critical local frequent behavior of the ransomware sample, and obtain the local call pattern of the ransomware sample;
[0009] The multi-scale information fusion stage is used to splice the vector representations of the global call pattern and the local call pattern of the ransomware sample, and input them into a multi-layer perceptron for classification, and output the ransomware detection result.
[0010] Further, the specific process of constructing the API call graph in the API call behavior feature extraction stage is:
[0011] According to the API call sequence of the ransomware sample, an API call graph is constructed, wherein the node attribute is the API name, the edge attribute is the call parameter, and the graph covers all API call information of the sample to describe the global API call behavior of the sample;
[0012] That is, each API call is regarded as a node in the graph, a directed edge is added between adjacent API nodes according to the API call sequence, and the direction of the edge is pointed by the API calling first to the API calling later; the parameters at the time of API call are taken as the attributes of the edge, the API nodes appearing in the graph represent the API set called by the sample, and the more edges pointing to a certain API node, the more times the API is called, and the greater the impact of the API on the behavior of the ransomware sample.
[0013] Further, the specific process of extracting frequent sequences in the API call behavior feature extraction stage is:
[0014] Extract the most frequently occurring call sub-sequence in the API call sequence to obtain the most critical local behavior in the sample running process.
[0015] Further, the specific process of generating API function description in the API call behavior feature extraction stage is:
[0016] The prompt engineering method is adopted to design the prompt words, and the large language model is combined to generate function description for each API, that is, the large language model is prompted to explain the function of each API, and the corresponding natural language function description of each API is output.
[0017] Further, the specific process of the global call pattern learning stage includes:
[0018] The node is encoded by using the large language model, and the edge is encoded by using the large language model to obtain the encoded graph.
[0019] The encoded graph is input into the graph neural network for learning.
[0020] Further, the process of encoding the node by using the large language model includes: replacing the node attribute API name with the API function description, and encoding the API function description by using the large language model.
[0021] Further, the process of encoding the edge by using the large language model includes: the original attribute of the edge is the call parameter, and for multiple specific attributes in the call parameter, the large language model is used for encoding respectively, and the encoding results are spliced to be the encoding of the edge.
[0022] Further, the specific attributes include file path, registry key, dynamic link library name and uniform resource locator.
[0023] Further, the specific process of the local call pattern learning stage includes: replacing each API name in the frequent call sequence with the function description text and splicing, and passing the spliced function description text to the large language model for semantic understanding.
[0024] Further, the specific process of the multi-scale information fusion stage includes: splicing the encoding of the API call graph in the global call pattern learning and the encoding of the frequent call sequence in the local call pattern learning by using the graph neural network, and passing the splicing result to the multi-layer perceptron for prediction, and outputting the detection result of the ransomware.
[0025] Compared with the prior art, the present application has the following advantages:
[0026] The present application designs four method stages of API calling behavior feature extraction, global calling mode learning, local calling mode learning and multi-scale information fusion. In the API calling behavior feature extraction stage, the API calling graph is constructed, the frequent calling sequence is extracted and the API function description is generated. In the global calling mode learning stage, the nodes and edges of the API calling graph are encoded by the large language model, and the API calling graph is learned by using the graph neural network. In the local calling mode learning stage, the frequent calling sequence is learned by the large language model. In the multi-scale information fusion stage, the learning results of the global and local calling modes are combined, and the final classification detection is performed. Thus, the graph neural network and the large language model are combined creatively, and the advantages of both in graph structure learning and semantic understanding are fully utilized. The global calling mode of the ransomware sample is learned by using the graph neural network, and the local calling mode is understood by using the large language model. Through effective fusion of the information learned in the two scales, the ransomware can be accurately identified, and the generalization detection ability of the new ransomware can be significantly improved.
[0027] In the present application, the API calling behavior feature extraction stage includes three parts of constructing API calling graph, extracting frequent sequence and generating API function description. These features will be used as input data for learning global and local calling modes. In constructing the API calling graph, the API calling graph is constructed according to the API calling sequence of the sample, the node attribute is the API name, the edge attribute is the calling parameter, and the graph covers all API calling information of the sample to describe the global API calling behavior of the sample. This graph structure can comprehensively show the API calling situation of the sample and reflect the dependency relationship between APIs, which is beneficial to accurately learning the global structure information of the API calling graph in the subsequent global calling mode learning stage, so as to capture the overall behavior characteristics of the ransomware sample.
[0028] In extracting the frequent sequence, considering that the information contained in the API calling sequence is often not only the simple superposition of the semantics of a single API compared with a single API calling, the adjacent calling actions reflect deeper behavior intention and context association, so the most frequent calling subsequence in the API calling sequence is extracted. The frequent calling sequence can indicate the repeated behavior in the sample running process, and thus is beneficial to identifying the most critical local behavior in the program execution process.
[0029] When generating API function descriptions, a prompting engineering approach is employed. Prompt words are designed to standardize the model's output format and improve output quality. These prompts allow the LLM (Layered Modeling Language) to interpret the functionality of each API, resulting in a natural language function description for each API. In subsequent encoding, API names containing numerous abbreviations are replaced with natural language function descriptions as input. This maximizes the preservation and even expands upon the semantic information contained in the API names, thereby improving encoding quality. Attached Figure Description
[0030] Figure 1 This is a schematic diagram of the method flow of the present invention;
[0031] Figure 2 This is a schematic diagram illustrating the application process of the embodiment;
[0032] Figure 3 This is a schematic diagram of the confusion matrix detected in a known ransomware family test set in the example;
[0033] Figure 4a This is a feature space distribution diagram of benign samples and known ransomware family samples before model learning in the embodiment.
[0034] Figure 4b This is a feature space distribution diagram of benign samples and known ransomware family samples after model learning in the embodiment.
[0035] Figure 5 This is a feature space distribution diagram of benign samples and novel ransomware family samples after model learning in the embodiment. Detailed Implementation
[0036] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments.
[0037] Example
[0038] like Figure 1 As shown, a ransomware detection method based on a graph-based model includes an API call behavior feature extraction stage, a global call pattern learning stage, a local call pattern learning stage, and a multi-scale information fusion stage. Specifically:
[0039] a) API call behavior feature extraction, which includes three parts: constructing an API call graph, extracting frequent sequences, and generating API function descriptions. These features will serve as input data for learning global and local call patterns.
[0040] b) Global call pattern learning: By learning the global structure information of the API call graph through graph neural network, the overall behavioral characteristics of ransomware samples can be captured and the global call pattern of the samples can be obtained.
[0041] c) Local invocation pattern learning, learning frequent invocation sequences through large language models, understanding the most critical local frequent behaviors of samples, and obtaining the local invocation patterns of samples;
[0042] d) Multi-scale information fusion, by concatenating the vector representations of global and local invocation patterns learned by graph neural networks and large language models respectively, and inputting them into a multi-layer perceptron for classification, to realize the detection of ransomware.
[0043] In the API call behavior feature extraction stage, an API call graph is constructed according to the API call sequence of the sample, the node attribute is the API name, the edge attribute is the call parameter, and the graph covers all API call information of the sample to describe the global API call behavior of the sample. The most frequent invocation subsequence in the API call sequence is extracted to obtain the most critical local behavior in the sample running process. A prompt engineering method is used to generate a function description for each API with the help of a large language model, so that the semantic information contained in the API name can be maximized during the encoding process to improve the encoding quality.
[0044] In the global invocation pattern learning stage, the node attribute API name is replaced with API function description, and the API function description is encoded by a large language model to maximize the preservation of API function semantics in the encoding result. The original attribute of the edge is the call parameter, and the four most common attribute values in the call parameter are file path, registry key, dynamic link library name and uniform resource locator. The four attributes are encoded by a large language model, and the encoding results are concatenated as the edge encoding. After the encoding of nodes and edges is completed, the graph is input into a graph neural network for learning.
[0045] In the local invocation pattern learning stage, each API name in the frequent invocation sequence is replaced with a function description text and concatenated, and then the concatenated function description text is passed to a large language model for semantic understanding.
[0046] In the multi-scale information fusion stage, the encoding of the API call graph by the graph neural network in the global invocation pattern learning and the encoding of the frequent invocation sequence by the large language model in the local invocation pattern learning are concatenated and passed to a multi-layer perceptron for prediction to realize the detection of ransomware.
[0047] The present embodiment applies the above scheme, for example, Figure 2As shown, the API call sequence is taken as raw data, an API call graph is constructed according to the API call sequence, frequent sequences are extracted, and API function descriptions are generated with the help of an LLM (Large Language Model), the API call graph is learned by a GNN (Graph Neural Network) to capture the global behavior characteristics of the sample, and the frequent call sequences are learned by an LLM to understand the frequent local behavior of the sample, and finally the global and local behavior information is integrated and prediction is performed. Specifically, the entire ransomware detection method process includes the following four steps:
[0048] I. API call behavior feature extraction. This step will extract the features of the API call sequence, including three parts of constructing an API call graph, extracting frequent sequences, and generating API function descriptions. These features will be used as input data when learning global and local call patterns.
[0049] Construction of the API call graph. The specific construction method is as follows:
[0050] 1) Each API call is regarded as a node in the graph;
[0051] 2) According to the API call sequence, a directed edge is added between adjacent API nodes, and the direction of the edge is from the API calling first to the API calling later;
[0052] 3) The parameters at the time of API call are taken as the attributes of the edge.
[0053] The API nodes appearing in the graph represent the API set called by the sample. The more edges pointing to a certain API node, the more times the API is called, and the greater its impact on the sample behavior. This graph structure can comprehensively demonstrate the API calling situation of the sample and reflect the dependency relationship between APIs.
[0054] Frequent call sequence extraction. The frequent call sequence is the most frequently occurring call subsequence in the API call sequence. Compared with a single API call, the information contained in the API call sequence is often not just a simple superposition of single API semantics, and adjacent call actions reflect deeper behavior intentions and context associations. Frequent call sequences can indicate repeated behavior during sample execution, and thus identify the most critical local behavior during program execution.
[0055] API function description generation. This scheme adopts the prompting engineering method to design prompt words to standardize the model output format and improve the output quality. By prompting, the LLM explains the function of each API to obtain the natural language function description corresponding to each API. In the subsequent coding process, this scheme replaces the API name in the form of a large number of abbreviations with the function description in the form of natural language as the coding input, which can maximize the retention and even expand the semantic information contained in the API name, thereby improving the coding quality.
[0056] II. Global call pattern learning. This step aims to learn the global structure information of the API call graph through GNN, so as to capture the overall behavior characteristics of the ransomware sample. The node attribute value in the API call graph is the API name, which is replaced by its corresponding function description, and then the function description is input to the LLM for coding to obtain the feature vector representation of the node. Since the function description is closer to natural language, the model can effectively retain the real intention of API call when learning API semantics. The attribute value of the edge is the parameter in the API call, and this method selects the four most common types of parameter values, including file path, registry key, dynamic link library name and uniform resource locator as the attribute of the edge. Use LLM to encode the four types of parameters respectively, and concatenate the encoding results as the feature vector representation of the edge.
[0057] The coded graph is input to the GNN for learning. The learning of GNN includes two steps, and the information propagation mode of each step is as follows:
[0058]
[0059] where, i i represents the feature vector of node i, e j,i represents the feature of the edge from node j to node i, ∈ represents the learnable residual parameter, K is the maximum order, which controls the range of information propagation, W k is the trainable weight matrix corresponding to the k-th order, A is the adjacency matrix, and D is the degree matrix corresponding to A.
[0060] III. Local call pattern learning. This step aims to learn the frequent call sequence through LLM to understand the most critical frequent behavior of the sample, so as to extract the local frequent behavior of the sample. Replace each API name in the frequent call sequence with the function description text and concatenate it, and then pass the concatenated description text to the LLM for semantic understanding to realize the feature vector representation of the frequent sequence.
[0061] IV. Multi-scale information fusion. This step aims to fuse the global call information and the local call information, so as to comprehensively utilize the information of two scales for ransomware detection. By splicing the encoding of the API call graph by the GNN in the global call pattern learning and the encoding of the frequent call sequence by the LLM in the local call pattern learning, it is delivered to the multi-layer perception for prediction, so as to realize the detection of the ransomware.
[0062] Figure 3 The confusion matrix of the model in the detection of the known ransomware family test set is shown. In the test set containing 90 benign samples and 122 ransomware samples, only one benign sample is wrongly determined as a ransomware, and the accuracy rate reaches 99.53%.
[0063] Figure 4a and 4b The feature space distribution of benign samples and known ransomware family samples before and after the model learning is shown respectively. In the original feature space, the distribution of benign samples and malicious samples overlaps, the intra-class distance is large, and the inter-class discrimination is low. After model learning, the two kinds of samples in the embedding space show a clear separation trend, and the aggregation degree of intra-class samples is significantly improved, indicating that the model can effectively learn the discriminative features to distinguish benign samples and malicious samples.
[0064] Figure 5 The feature space distribution of benign samples and new ransomware family samples after the model learning is shown. The results show that the model can effectively distinguish most of the benign samples and the new ransomware family samples, and only a few samples are predicted incorrectly. This shows that the model has successfully learned the essential difference between benign samples and ransomware samples, and has high generalization, and can provide reliable detection results for the ransomware family not contained in the training set.
[0065] In summary, this scheme combines GNN and LLM, GNN is good at learning in complex graph structure data, and can effectively extract the feature representation of nodes, edges and the whole graph, and LLM has strong semantic understanding and text generation ability. This scheme combines the two, and the graph large model can further understand the semantic behavior based on the learning of the graph structure presented by the malicious software, so as to improve the detection performance. This scheme comprehensively utilizes the information of two scales for ransomware detection, and can effectively distinguish benign samples and ransomware samples, and realize effective detection of new ransomware family samples. The experimental results show that this scheme maintains high detection accuracy for known ransomware family samples, and also shows excellent generalization performance for new ransomware family samples.
Claims
1. A ransomware detection method based on a graph big model, characterized in that, The API calling behavior feature extraction stage is used to construct an API calling graph, extract frequent sequences, and generate API function descriptions. The global calling pattern learning stage is used to learn the global structure information of the API calling graph through a graph neural network, capture the overall behavior characteristics of the ransomware sample, and obtain the global calling pattern of the ransomware sample. The local calling pattern learning stage is used to learn the frequent calling sequences through a large language model, understand the most critical local frequent behavior of the ransomware sample, and obtain the local calling pattern of the ransomware sample. The multi-scale information fusion stage is used to splice the vector representations of the global calling pattern and the local calling pattern of the ransomware sample, and input them into a multi-layer perceptron for classification to output the ransomware detection result.
2. The ransomware detection method based on a graph model according to claim 1, characterized in that, The specific process of constructing the API calling graph in the API calling behavior feature extraction stage is as follows: According to the API calling sequence of the ransomware sample, an API calling graph is constructed, wherein the node attribute is the API name, the edge attribute is the calling parameter, and the graph covers all API calling information of the sample to describe the global API calling behavior of the sample. That is, each API call is regarded as a node in the graph, a directed edge is added between adjacent API nodes according to the API calling sequence, the direction of the edge is from the API calling first to the API calling later, the parameters at the time of API calling are taken as the attributes of the edge, the API nodes appearing in the graph represent the API set called by the sample, and the more edges pointing to a certain API node, the more times the API is called, and the greater the impact of the API on the behavior of the ransomware sample.
3. The ransomware detection method based on a graph model according to claim 2, characterized in that, The specific process of extracting frequent sequences in the API calling behavior feature extraction stage is as follows: The most frequently occurring calling subsequence in the API calling sequence is extracted to obtain the most critical local behavior in the sample running process.
4. The ransomware detection method based on a graph model according to claim 3, characterized in that, The specific process of generating API function descriptions in the API calling behavior feature extraction stage is as follows: A prompt word is designed by using a prompt engineering method, and a large language model is used to generate a function description for each API, that is, the large language model is used to explain the function of each API through the prompt word, and a natural language function description corresponding to each API is output.
5. The ransomware detection method based on a graph model according to claim 4, characterized in that, The specific process of the global calling pattern learning stage includes: The node is encoded by using a large language model, the edge is encoded by using a large language model, and the encoded graph is obtained. The encoded graph is input into a graph neural network for learning.
6. The ransomware detection method based on a graph model according to claim 5, characterized in that, The process of encoding the node by using a large language model includes: replacing the node attribute API name with the API function description, and encoding the API function description by using a large language model.
7. The ransomware detection method based on a graph model according to claim 6, characterized in that, The process of encoding the edge by using a large language model includes: the original attribute of the edge is the calling parameter, a large language model is used to encode a plurality of specific attributes in the calling parameter, and the encoding results are spliced to obtain the encoding of the edge.
8. The ransomware detection method based on a graph model according to claim 7, characterized in that, The specific attributes include file path, registry key, dynamic link library name, and uniform resource locator.
9. The ransomware detection method based on a graph model according to claim 5, characterized in that, The specific process of the local call mode learning stage includes: replacing each API name pair in the frequently called sequence with a function description text and splicing, and delivering the spliced function description text to a large language model for semantic understanding.
10. The ransomware detection method based on a graph model according to claim 9, characterized in that, The specific process of the multi-scale information fusion stage includes: splicing the encoding of the API call graph by the graph neural network in the global call mode learning and the encoding of the frequently called sequence by the large language model in the local call mode learning, delivering the spliced result to a multi-layer perception for prediction, and outputting the detection result of the ransomware.
Citation Information
Patent Citations
Ransomware classification method and system based on large model
CN119740136A
