A malware detection method and system based on large language model heuristic pre-training

By generating and reconstructing sandbox reports within a sandbox and fine-tuning a large language model using security heuristics, the problems of complex sandbox report structure and lack of security knowledge in the model are solved, thereby improving the accuracy and generalization ability of malware detection.

CN123179398APending Publication Date: 2026-11-27SHENZHEN UNIV +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611262661.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-19
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Existing technologies suffer from problems such as complex sandbox report structures, a lack of security domain heuristics in generalized large language models, and difficulty in aligning high-level diagnostics with low-level behavioral evidence, which limit the accuracy of malware detection and its ability to generalize across datasets.

Method used

By acquiring samples of the program to be detected and generating an original report in an isolated sandbox, semantic-driven feature reconstruction is performed to extract multi-dimensional semantic evidence. Based on security heuristics, the large language model is fine-tuned in stages to construct an object detection model, and explicit association between high-level sandbox signatures and low-level API, PE, and import table evidence is performed.

Benefits of technology

It improves the accuracy, generalization ability, and inference efficiency of malware detection, significantly reduces input noise and context consumption, and enhances the interpretability of detection results and practical deployment efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123179398A_ABST
    Figure CN123179398A_ABST
Patent Text Reader

Abstract

The application discloses a malware detection method and system based on a large language model heuristic pre-training, comprising: obtaining a to-be-detected program sample, executing the to-be-detected program sample in an isolated dynamic analysis sandbox, and generating an original sandbox analysis report; performing semantic-driven feature reconstruction on the original sandbox analysis report, extracting and normalizing multi-dimensional semantic evidence, and obtaining behavior analysis corpus; wherein the multi-dimensional semantic evidence comprises a sandbox signature, executable file metadata, an import address table and a time-ordered API calling sequence; constructing knowledge corpus according to preset security heuristic knowledge, fine-tuning a large language model based on the knowledge corpus and the behavior analysis corpus, and obtaining a target detection model; inputting the behavior analysis corpus corresponding to the to-be-detected program into the target detection model, and obtaining a detection result that the to-be-detected program is a malicious program or a benign program; and the application improves the accuracy, generalization ability and reasoning efficiency of malware detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of cybersecurity and artificial intelligence, and in particular to a malware detection method and system based on heuristic pre-training of a large language model. Background Technology

[0002] Malware has long posed a threat to the security of personal terminals, corporate networks, and critical infrastructure. As attackers continue to employ techniques such as obfuscation, packing, polymorphism, environmental awareness evasion, and staged payload delivery, traditional detection methods that rely on known signatures or fixed rules are struggling to identify unknown variants in a timely manner.

[0003] Dynamic analysis techniques typically execute suspicious programs in an isolated sandbox and record their runtime behavior, such as API calls, file read / write operations, registry modifications, network connections, process creation, and memory changes. Sandbox systems like CAPE or Cuckoo can generate relatively complete analysis reports, usually organized in JSON format, which include both low-level behavior logs and high-level sandbox signatures triggered by rules.

[0004] However, existing technologies for malware detection using sandbox reports still have shortcomings. First, raw sandbox JSON reports are deep-layered, contain numerous fields, and are long. Evidence of the same malicious behavior may be scattered across different processes, threads, timestamps, and field branches, making direct input into the model prone to contextual overhead and semantic noise. Second, while general-purpose large language models possess text understanding capabilities, they lack security domain knowledge such as Windows API semantics, sandbox signature meanings, and malicious behavior patterns. This can easily lead to misclassifying common benign behaviors as malicious or ignoring the supporting relationships between low-level behaviors and high-level alerts. Third, existing data processing workflows often model signatures, static attributes, and dynamic API sequences separately, failing to explicitly construct an evidence chain from high-level diagnosis to fine-grained behavior, thus limiting the interpretability and cross-dataset generalization ability of the detection results.

[0005] Therefore, existing technologies still suffer from problems such as complex sandbox report structures, a lack of heuristic knowledge in the security domain in general large language models, and difficulty in aligning high-level diagnostics with low-level behavioral evidence. Summary of the Invention

[0006] The technical problem to be solved by the present invention is to provide a malware detection method and system based on heuristic pre-training of a large language model, in order to address the shortcomings of the existing technology, such as the complex structure of sandbox reports, the lack of security domain heuristics in general large language models, and the difficulty in aligning high-level diagnostics with low-level behavioral evidence.

[0007] The technical solution adopted by this invention to solve the technical problem is as follows: In a first aspect, the present invention provides a malware detection method based on heuristic pre-training of a large language model, comprising: Obtain a sample of the program to be tested, and execute the sample of the program to be tested in an isolated dynamic analysis sandbox to generate an original sandbox analysis report containing dynamic behavior information and static attribute information; The original sandbox analysis report is subjected to semantic-driven feature reconstruction to extract and normalize multidimensional semantic evidence, thereby obtaining behavioral analysis corpus; wherein, the multidimensional semantic evidence includes one or more combinations of sandbox signatures, executable file metadata, import address tables, and time-ordered API call sequences; A knowledge corpus is constructed based on preset security heuristics, and the large language model is fine-tuned in stages based on the knowledge corpus and the behavior analysis corpus to obtain the target detection model. The behavioral analysis corpus corresponding to the program to be detected is input into the target detection model to obtain the detection result of whether the program to be detected is a malicious program or a benign program.

[0008] In one implementation, executing the sample program to be tested in an isolated dynamic analysis sandbox to generate an original sandbox analysis report containing dynamic behavior information and static attribute information includes: The program sample to be tested is scheduled to be executed in one or more Windows analysis virtual machines via a sandbox host; During execution, behavioral information generated by the program sample to be tested and its subprocesses is collected; wherein, the behavioral information includes one or more combinations of Win32 API calls, file system operations, registry operations, network communication, memory dumps, and screenshots; The behavioral information is matched based on preset sandbox rules to generate a sandbox signature to characterize suspicious behavior, and the behavioral information, the sandbox signature, and executable file attributes are aggregated into the original sandbox analysis report.

[0009] In one implementation, performing semantic-driven feature reconstruction on the original sandbox analysis report includes: Sandbox signatures are extracted from the original sandbox analysis report, and signatures with different naming formats are normalized; wherein, the signatures are those with the same or similar semantics; Extract executable file metadata from the original sandbox analysis report; wherein, the executable file metadata includes one or more combinations of: file hash, file type, section layout, entry point information, and digital signature status; The import address table entries are extracted from the original sandbox analysis report to obtain the functional capability information exposed by the program sample to be tested; API call names are extracted from the call logs of different processes and threads and merged into a single API call sequence according to global time order.

[0010] In one implementation, the behavior analysis corpus includes: an instruction field, an input field, and an output field; The instruction field is used to instruct the large language model to analyze the original sandbox analysis report and determine whether it is a malicious or benign program; the input fields include: the sandbox signature obtained after semantic-driven feature reconstruction, executable file metadata, import address table, and time-ordered API call sequence; the output fields include: malicious label or benign label.

[0011] In one implementation, the preset security heuristic knowledge includes: API semantic knowledge and sandbox signature semantic knowledge; wherein, the API semantic knowledge includes: API functions, parameter meanings, return value meanings, and potential uses in malware scenarios; the sandbox signature semantic knowledge includes: signature triggering conditions, risk meanings, and corresponding underlying behavioral evidence.

[0012] In one implementation, the step of fine-tuning the large language model in stages based on the knowledge corpus and the behavior analysis corpus to obtain the object detection model includes: In the first stage, the knowledge corpus is used to learn knowledge from the large language model, enabling the large language model to learn prior knowledge in the security domain. In the second stage, the behavior analysis corpus is used to perform behavior learning on the large language model that has completed knowledge learning, so that the large language model learns the evidence association relationship between sandbox signatures, executable file metadata, import address table, and time-ordered API call sequence; wherein, the number of training rounds for behavior learning is less than the number of training rounds for knowledge learning. The target detection model is obtained by updating the model parameters based on the low-rank adaptation method.

[0013] In one implementation, the step of inputting the behavior analysis corpus corresponding to the program to be detected into the target detection model to obtain the detection result of whether the program to be detected is malicious or benign includes: Input the behavior analysis corpus corresponding to the program to be detected into the target detection model according to the preset prompt template; Obtain the category text or category probability output by the target detection model; Based on the category text or the category probability, the detection result of whether the program to be detected is a malicious program or a benign program is obtained.

[0014] Secondly, the present invention provides a malware detection system based on heuristic pre-training of a large language model, comprising: The report generation module is used to acquire a sample of the program to be tested, execute the sample of the program to be tested in an isolated dynamic analysis sandbox, and generate an original sandbox analysis report containing dynamic behavior information and static attribute information. The semantic reconstruction module is used to perform semantic-driven feature reconstruction on the original sandbox analysis report, extract and standardize multidimensional semantic evidence, and obtain behavioral analysis corpus; wherein, the multidimensional semantic evidence includes one or more combinations of sandbox signatures, executable file metadata, import address tables, and time-ordered API call sequences; The heuristic training module is used to construct a knowledge corpus based on preset security heuristics, and to fine-tune the large language model in stages based on the knowledge corpus and the behavior analysis corpus to obtain the target detection model. The detection inference module is used to input the behavior analysis corpus corresponding to the program to be detected into the target detection model to obtain the detection result of whether the program to be detected is a malicious program or a benign program.

[0015] Thirdly, the present invention provides a terminal, comprising: a processor and a memory, wherein the memory stores a malware detection program based on a large language model heuristic pre-training, and the malware detection program based on a large language model heuristic pre-training, when executed by the processor, is used to implement the operation of the malware detection method based on a large language model heuristic pre-training as described in the first aspect.

[0016] Fourthly, the present invention also provides a computer-readable storage medium storing a malware detection program based on a large language model heuristic pre-training, wherein the malware detection program based on a large language model heuristic pre-training, when executed by a processor, is used to implement the operation of the malware detection method based on a large language model heuristic pre-training as described in the first aspect.

[0017] The present invention, by employing the above technical solution, has the following effects: 1) This invention compresses lengthy and nested sandbox JSON reports into well-structured multidimensional semantic evidence through semantic-driven feature reconstruction, significantly reducing input noise and context consumption.

[0018] 2) This invention enables large language models to understand malicious behavior based on security priors through heuristic knowledge learning and behavior learning, thereby improving their generalization ability for unknown samples and few sample scenarios.

[0019] 3) This invention improves the interpretability of detection results and practical deployment efficiency by explicitly associating high-level sandbox signatures with low-level API, PE, and import table evidence. Attached Figure Description

[0020] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the structures shown in these drawings without creative effort.

[0021] Figure 1 This is a flowchart of the malware detection method based on heuristic pre-training of a large language model in this invention.

[0022] Figure 2 This is a schematic diagram comparing the present invention with the general large language model in the malware analysis workflow.

[0023] Figure 3 This is a schematic diagram of the overall detection framework in the malware detection method based on heuristic pre-training of a large language model in this invention; Figure 4 This is a schematic diagram of the architecture of the CAPEv2 dynamic analysis sandbox in this invention.

[0024] Figure 5 This is a schematic diagram comparing the learning capabilities of the present invention in scenarios with few samples.

[0025] Figure 6 This is a functional schematic diagram of the terminal in one implementation of the present invention.

[0026] The objectives, features, and advantages of this invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0027] To make the objectives, technical solutions, and advantages of this invention clearer and more explicit, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0028] Exemplary methods Current technologies for malware detection using sandbox reports still have shortcomings. First, raw sandbox JSON reports are deep-layered, contain numerous fields, and are long. Evidence of the same malicious behavior may be scattered across different processes, threads, timestamps, and field branches, making direct input into the model prone to contextual overhead and semantic noise. Second, while general-purpose large language models possess text understanding capabilities, they lack security domain knowledge such as Windows API semantics, sandbox signature meanings, and malicious behavior patterns. This can easily lead to misclassifying common benign behaviors as malicious or ignoring the supporting relationships between low-level behaviors and high-level alerts. Third, existing data processing workflows often model signatures, static attributes, and dynamic API sequences separately, failing to explicitly construct an evidence chain from high-level diagnosis to fine-grained behavior, thus limiting the interpretability and cross-dataset generalization ability of the detection results.

[0029] Therefore, existing technologies still suffer from problems such as complex sandbox report structures, a lack of heuristic knowledge in the security domain in general large language models, and difficulty in aligning high-level diagnostics with low-level behavioral evidence.

[0030] To address the above technical problems, this invention provides a malware detection method based on heuristic pre-training of a large language model. The method includes: acquiring a sample of a program to be detected and executing the sample in an isolated dynamic analysis sandbox to generate an original sandbox analysis report; performing semantic-driven feature reconstruction on the original sandbox analysis report, extracting and standardizing multi-dimensional semantic evidence to obtain behavioral analysis corpus; wherein the multi-dimensional semantic evidence includes: sandbox signature, executable file metadata, import address table, and time-ordered API call sequence; constructing a knowledge corpus based on preset security heuristics, and fine-tuning the large language model based on the knowledge corpus and behavioral analysis corpus to obtain a target detection model; inputting the behavioral analysis corpus corresponding to the program to be detected into the target detection model to obtain a detection result indicating whether the program to be detected is malicious or benign; this invention can reconstruct lengthy, nested, and noisy sandbox JSON reports into semantic representations with clear evidence chains, and through heuristic knowledge learning and behavioral learning, enables the large language model to acquire diagnostic reasoning capabilities similar to those of security analysts, thereby improving the accuracy, generalization ability, and reasoning efficiency of malware detection.

[0031] like Figure 1 As shown, this embodiment of the invention provides a malware detection method based on heuristic pre-training of a large language model, comprising the following steps: Step S100: Obtain the program sample to be tested, and execute the program sample to be tested in an isolated dynamic analysis sandbox to generate an original sandbox analysis report containing dynamic behavior information and static attribute information.

[0032] In this embodiment, to implement the method, a malware detection framework based on heuristic pre-training of a large language model is provided; the malware detection framework can be called LHPD, which stands for Heuristic Pre-trained Detection Framework Based on a Large Language Model. This framework combines sandbox execution, semantic-driven feature reconstruction, and heuristic fine-tuning, enabling the large language model to diagnose malware based on a structured chain of evidence, rather than directly relying on shallow patterns in lengthy raw JSON reports.

[0033] like Figure 3 As shown, this embodiment is based on the aforementioned malware detection framework, and the overall process includes: generating the original sandbox analysis report, semantic-driven feature reconstruction, and phased fine-tuning based on security heuristics; among which, the process of generating the original sandbox analysis report uses CAPEv2 to dynamically analyze the sandbox architecture (such as...). Figure 4 As shown in the figure.

[0034] Specifically, in one implementation of this embodiment, step S100 includes the following steps: Step S101: The sample program to be tested is scheduled to be executed in one or more Windows analysis virtual machines via a sandbox host; Step S102: During execution, collect behavioral information generated by the program sample to be detected and its subprocesses; wherein, the behavioral information includes one or more combinations of Win32 API calls, file system operations, registry operations, network communication, memory dumps, and screenshots. Step S103: Match the behavioral information based on preset sandbox rules to generate a sandbox signature for characterizing suspicious behavior, and aggregate the behavioral information, the sandbox signature, and executable file attributes into the original sandbox analysis report.

[0035] As an example, in this embodiment, analysis tasks can be created using the CAPE sandbox host, and Windows executable files can be scheduled to run in an isolated Windows analysis virtual machine. The sandbox host and the analysis virtual machine are connected via an isolated virtual network to prevent samples from damaging the real environment.

[0036] During the execution phase, the sandbox system records the system-level behaviors of the program sample to be tested and its derived processes. These system-level behaviors may include Win32 API call traces, file creation or deletion records, registry access, network communication, process memory dumps, system-wide memory dumps, and desktop screenshots. The sandbox can also trigger higher-level signatures based on preset rules, such as packing behavior, anti-virtual machine behavior, suspicious network connections, YARA hits, abnormal mutexes, or suspicious file deliveries.

[0037] Upon timeout or completion of the task, the sandbox system aggregates the aforementioned behavioral information, signature information, and static file attributes into a raw sandbox analysis report. This raw sandbox analysis report is typically in JSON format and contains multiple levels and nested fields.

[0038] like Figure 1 As shown, this embodiment of the invention provides a malware detection method based on heuristic pre-training of a large language model, comprising the following steps: Step S200: Perform semantic-driven feature reconstruction on the original sandbox analysis report, extract and standardize multidimensional semantic evidence to obtain behavioral analysis corpus; wherein, the multidimensional semantic evidence includes one or more combinations of sandbox signature, executable file metadata, import address table and time-ordered API call sequence.

[0039] In this embodiment, during the semantic-driven feature reconstruction process, the sandbox signature is first normalized; then, executable file metadata such as executable file hash, file type, section layout, entry point and digital signature status are extracted, as well as import address table entries are extracted to represent the functional capabilities exposed by the sample; finally, cross-process and cross-thread API call logs are merged into a single API call sequence in global time order.

[0040] Specifically, in one implementation of this embodiment, step S200 includes the following steps: Step S201: Extract sandbox signatures from the original sandbox analysis report and normalize signatures with different naming formats; wherein, the signatures are signatures with the same or similar semantics; Step S202: Extract executable file metadata from the original sandbox analysis report; wherein, the executable file metadata includes one or more combinations of: file hash, file type, section layout, entry point information, and digital signature status; Step S203: Extract the import address table entries from the original sandbox analysis report to obtain the functional capability information exposed by the program sample to be tested; Step S204: Extract API call names from the call logs of different processes and threads, and merge them into a single API call sequence according to the global time order.

[0041] It should be noted that, in this embodiment, although the original sandbox analysis report contains a large amount of information, it suffers from redundant fields, log noise, and scattered evidence across branches. If directly input into a large language model, the model needs to implicitly reconstruct behavioral relationships within a long context, making it susceptible to interference from irrelevant fields. Therefore, this embodiment sets up a semantically driven feature reconstruction module to perform feature selection and semantic formatting on the original report.

[0042] In one implementation, the semantic-driven feature reconstruction module extracts four complementary semantic dimensions from the original sandbox analysis report: The first category is sandbox signatures, which are used to summarize high-level suspicious behavior triggered by security expert rules.

[0043] The second category is executable file metadata, which describes static attributes such as file identity, hash, file type, section layout, entry point, digital signature status, and compilation characteristics.

[0044] The third category is the import address table, which is used to describe the functional capabilities exposed by a program at the static level, such as file operations, process operations, network communication, memory management, or keyboard status acquisition capabilities.

[0045] The fourth category is time-ordered API call sequences, which are used to represent the underlying behavioral trajectories that occur during the actual execution of the program.

[0046] For time-ordered API call sequences, if the original report records call logs separately by process and thread, this embodiment merges API calls from different processes and threads according to global timestamps or execution order, retains API names, and removes low-value log noise to obtain a single linear sequence. This processing allows the model to more easily learn long-term dependencies and causal execution paths.

[0047] The reconstructed behavioral analysis corpus can be organized using an instruction fine-tuning format, which explicitly expresses the correspondence from high-level alerts to low-level evidence, including: instruction fields, input fields, and output fields. Among them, the instruction field is used to instruct the large language model to analyze the original sandbox analysis report and determine whether it is a malicious or benign program. The input fields include: the sandbox signature obtained after semantically driven feature reconstruction, executable file metadata, import address table, and time-ordered API call sequence. The output fields include: malicious labels or benign labels.

[0048] like Figure 1 As shown, this embodiment of the invention provides a malware detection method based on heuristic pre-training of a large language model, comprising the following steps: Step S300: Construct a knowledge corpus based on preset security heuristics, and fine-tune the large language model in stages based on the knowledge corpus and the behavior analysis corpus to obtain the target detection model.

[0049] Specifically, in one implementation of this embodiment, step S300 includes the following steps: Step S301: In the first stage, the knowledge corpus is used to perform knowledge learning on the large language model, so that the large language model learns prior knowledge in the security domain. Step S302: In the second stage, the behavior analysis corpus is used to perform behavior learning on the large language model that has completed knowledge learning, so that the large language model learns the evidence association relationship between sandbox signatures, executable file metadata, import address table, and time-ordered API call sequence; wherein, the number of training rounds for behavior learning is less than the number of training rounds for knowledge learning, so as to reduce the risk of overfitting the target detection model to the training samples and maintain the learned security domain prior knowledge; Step S303: Update the model parameters based on the low-rank adaptation method to obtain the target detection model.

[0050] In this embodiment, the general-purpose large language model may possess some security-related knowledge during large-scale pre-training, but it typically lacks a systematic understanding of Windows API semantics, sandbox signature meaning, and malware attack techniques. Therefore, this embodiment constructs a security heuristic knowledge corpus for malware analysis and employs a heuristic fine-tuning strategy to gradually enable the model to acquire security analysis capabilities.

[0051] The preset security heuristic knowledge includes at least: API semantic knowledge and sandbox signature semantic knowledge. The API semantic knowledge includes: API functionality, parameter meanings, return value meanings, and potential uses in malware scenarios. In other words, API semantic knowledge describes the API's functional specifications, parameter requirements, return value meanings, typical usage methods, and possible abuse scenarios for malware. For example, for an API used to obtain keyboard status, the knowledge corpus can explain its normal function and potential malicious uses in keylogging or user behavior monitoring. The sandbox signature semantic knowledge includes: signature triggering conditions, risk meanings, and corresponding underlying behavioral evidence. In other words, sandbox signature semantic knowledge describes signature triggering conditions and the risk meanings they represent, such as process memory YARA hits, anti-virtual machine detection, or command and control communication indications.

[0052] In this embodiment, the phased fine-tuning includes a knowledge learning phase and a behavior learning phase. In the knowledge learning phase, the basic large language model is fine-tuned using the security heuristic knowledge, enabling the model to learn security domain priors and heuristic judgment rules. In the behavior learning phase, the large language model that has completed knowledge learning is fine-tuned a second time using the behavior analysis corpus, enabling the model to learn the evidence chain relationship between signatures, static attributes, import capabilities, and API execution trajectories.

[0053] In one alternative implementation, low-rank adaptation (LoRA) can be used for fine-tuning to reduce training memory and parameter update overhead. The number of training epochs in the behavior learning phase can be set to be fewer than that in the knowledge learning phase. For example, after training for several epochs in the knowledge learning phase, the behavior learning phase can be trained for only a few epochs to reduce the risk of overfitting and maintain the domain reasoning ability already acquired by the model.

[0054] like Figure 1 As shown, this embodiment of the invention provides a malware detection method based on heuristic pre-training of a large language model, comprising the following steps: Step S400: Input the behavior analysis corpus corresponding to the program to be detected into the target detection model to obtain the detection result of whether the program to be detected is a malicious program or a benign program.

[0055] Specifically, in one implementation of this embodiment, step S400 includes the following steps: Step S401: Input the behavior analysis corpus corresponding to the program to be detected into the target detection model according to the preset prompt template; Step S402: Obtain the category text or category probability output by the target detection model; Step S403: Based on the category text or the category probability, parse the detection result to determine whether the program to be detected is a malicious program or a benign program.

[0056] In this embodiment, during the inference phase, for a new program sample to be detected, steps S100 and S200 are first executed to obtain the corresponding behavioral analysis corpus. Subsequently, this behavioral analysis corpus is input into the target detection model according to a preset prompt template. The target detection model performs diagnostic inference based on the correlation between sandbox signatures, PE metadata, import capabilities, and API execution trajectories, outputting category text or category probability.

[0057] If the object detection model outputs a category text, it can be directly parsed as Malware or Benign, and mapped to malicious or benign programs. If the object detection model outputs a category probability, the detection result can be determined based on the relationship between the malicious category probability and a preset threshold.

[0058] Compared to directly inputting the raw JSON report into a large language model, this embodiment significantly reduces the average input length, inference time, and GPU memory usage through semantic-driven feature reconstruction. At the same time, it improves the model's semantic understanding of malware behavior through fine-tuning with heuristic knowledge and behavioral evidence chains.

[0059] Experimental results show that, on a dataset containing 13,623 CAPE analysis reports, the model fine-tuned based on the framework provided in this embodiment outperforms general large language models and traditional dynamic analysis baselines in terms of accuracy, F1 score, cross-dataset generalization, and few-shot detection.

[0060] like Figure 2 As shown, Figure 2This is a comparative diagram of the present invention and a general large language model in the malware analysis workflow. The present invention can diagnose malware based on a structured chain of evidence, rather than relying directly on shallow patterns in lengthy raw JSON reports; for example... Figure 5 As shown, Figure 5 This is a schematic diagram comparing the learning ability of the present invention in a few-sample scenario. The detection performance of the present invention under different configurations is better than that of the general large language model and the traditional dynamic analysis baseline.

[0061] Experimental data verification: To further illustrate the technical effects of the embodiments of the present invention, the semantic-driven feature reconstruction and heuristic fine-tuning strategies are described below with reference to experimental data. The relevant data are used to demonstrate the improvements of the present invention in semantic understanding, detection accuracy, generalization ability, few-shot learning ability, and system efficiency.

[0062] Table 1: Examples of HBFS pre-trained knowledge corpora:

[0063] Table 2: Comparison of perplexity of four large language models before and after applying LHPD:

[0064] Table 3: Comparison with current advanced general-purpose large language models in malware detection tasks:

[0065] Table 4: Performance comparison with other malware detection methods:

[0066] Table 5: Ablation experimental results of SDFR and HBFS components in the LHPD framework:

[0067] In Table 5, Qwen corresponds to Qwen-3-32B, and Llama corresponds to Llama-3.1-8B-instruct.

[0068] Table 6: Evaluation of generalization ability across datasets:

[0069] Table 7: System overhead, efficiency, and detection performance under different configurations:

[0070] Table 2 shows that LHPD significantly reduces perplexity across different model backbones, indicating an enhanced ability to understand the semantic chains of malware behavior. Tables 3 and 4 show that the model fine-tuned using the framework of this invention achieves higher detection performance compared to general large language models and traditional dynamic analysis methods. Table 5 shows that SDFR and HBFS can independently improve performance, with the best results achieved when combined. Tables 6 and 7 show that this invention also demonstrates good stability and deployment value in terms of cross-dataset distribution variations and actual inference overhead.

[0071] This embodiment achieves the following technical effects through the above technical solution: 1) This embodiment compresses the lengthy and nested sandbox JSON report into a well-structured multidimensional semantic evidence through semantic-driven feature reconstruction, significantly reducing input noise and context consumption.

[0072] 2) This embodiment uses heuristic knowledge learning and behavior learning to enable the large language model to understand malicious behavior from the perspective of security domain priors, thereby improving its generalization ability to unknown samples and few sample scenarios.

[0073] 3) This embodiment improves the interpretability of detection results and practical deployment efficiency by explicitly associating high-level sandbox signatures with low-level API, PE, and import table evidence.

[0074] Exemplary device Based on the above embodiments, the present invention also provides a malware detection system based on heuristic pre-training of a large language model, comprising: The report generation module is used to acquire a sample of the program to be tested, execute the sample of the program to be tested in an isolated dynamic analysis sandbox, and generate an original sandbox analysis report containing dynamic behavior information and static attribute information. The semantic reconstruction module is used to perform semantic-driven feature reconstruction on the original sandbox analysis report, extract and standardize multidimensional semantic evidence, and obtain behavioral analysis corpus; wherein, the multidimensional semantic evidence includes one or more combinations of sandbox signatures, executable file metadata, import address tables, and time-ordered API call sequences; The heuristic training module is used to construct a knowledge corpus based on preset security heuristics, and to fine-tune the large language model in stages based on the knowledge corpus and the behavior analysis corpus to obtain the target detection model. The detection inference module is used to input the behavior analysis corpus corresponding to the program to be detected into the target detection model to obtain the detection result of whether the program to be detected is a malicious program or a benign program.

[0075] Based on the above embodiments, the present invention also provides a terminal, the principle block diagram of which can be as follows: Figure 6 As shown.

[0076] The terminal includes: a processor, a memory, an interface, a display screen, and a communication module connected via a system bus; wherein, the processor of the terminal provides computing and control capabilities; the memory of the terminal includes a computer-readable storage medium and internal memory; the computer-readable storage medium stores an operating system and computer programs; the internal memory provides an environment for the operation of the operating system and computer programs in the computer-readable storage medium; the interface is used to connect to external devices; the display screen is used to display relevant information; and the communication module is used to communicate with a cloud server or other devices.

[0077] When executed by the processor, this computer program is used to implement a malware detection method based on heuristic pre-training of a large language model.

[0078] It will be understood by those skilled in the art that Figure 6 The schematic diagram shown is merely a partial structural diagram related to the present invention and does not constitute a limitation on the terminal to which the present invention is applied. A specific terminal may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0079] In one embodiment, a terminal is provided, comprising: a processor and a memory, the memory storing a malware detection program pre-trained based on a large language model heuristic, the malware detection program being executed by the processor to implement the operations of the malware detection method pre-trained based on a large language model as described above.

[0080] In one embodiment, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a malware detection program based on a large language model heuristic pre-training, which, when executed by a processor, is used to implement the operations of the malware detection method based on a large language model heuristic pre-training as described above.

[0081] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, database, or other media used in the embodiments provided by this invention can include both non-volatile and volatile memory.

[0082] In summary, this invention provides a malware detection method and system based on heuristic pre-training of a large language model, comprising: acquiring a sample of a program to be detected, executing the sample in an isolated dynamic analysis sandbox, and generating an original sandbox analysis report; performing semantic-driven feature reconstruction on the original sandbox analysis report, extracting and standardizing multi-dimensional semantic evidence to obtain behavioral analysis corpus; wherein, the multi-dimensional semantic evidence includes: sandbox signature, executable file metadata, import address table, and time-ordered API call sequence; constructing a knowledge corpus based on preset security heuristics, and fine-tuning the large language model based on the knowledge corpus and behavioral analysis corpus to obtain a target detection model; inputting the behavioral analysis corpus corresponding to the program to be detected into the target detection model to obtain the detection result that the program to be detected is a malicious program or a benign program; this invention improves the accuracy, generalization ability, and inference efficiency of malware detection.

[0083] It should be understood that the application of the present invention is not limited to the examples above. Those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.

Claims

1. A malware detection method based on heuristic pre-training of a large language model, characterized in that, include: Obtain a sample of the program to be tested, and execute the sample of the program to be tested in an isolated dynamic analysis sandbox to generate an original sandbox analysis report containing dynamic behavior information and static attribute information; The original sandbox analysis report is subjected to semantic-driven feature reconstruction to extract and normalize multidimensional semantic evidence, thereby obtaining behavioral analysis corpus; wherein, the multidimensional semantic evidence includes one or more combinations of sandbox signatures, executable file metadata, import address tables, and time-ordered API call sequences; A knowledge corpus is constructed based on preset security heuristics, and the large language model is fine-tuned in stages based on the knowledge corpus and the behavior analysis corpus to obtain the target detection model. The behavioral analysis corpus corresponding to the program to be detected is input into the target detection model to obtain the detection result of whether the program to be detected is a malicious program or a benign program.

2. The malware detection method based on heuristic pre-training of a large language model according to claim 1, characterized in that, The process of executing the sample program to be tested in an isolated dynamic analysis sandbox generates an original sandbox analysis report containing dynamic behavior information and static attribute information, including: The program sample to be tested is scheduled to be executed in one or more Windows analysis virtual machines via a sandbox host; During execution, behavioral information generated by the program sample to be tested and its subprocesses is collected; wherein, the behavioral information includes one or more combinations of Win32 API calls, file system operations, registry operations, network communication, memory dumps, and screenshots; The behavioral information is matched based on preset sandbox rules to generate a sandbox signature to characterize suspicious behavior, and the behavioral information, the sandbox signature, and executable file attributes are aggregated into the original sandbox analysis report.

3. The malware detection method based on heuristic pre-training of a large language model according to claim 1, characterized in that, The semantic-driven feature reconstruction of the original sandbox analysis report includes: Sandbox signatures are extracted from the original sandbox analysis report, and signatures with different naming formats are normalized; wherein, the signatures are those with the same or similar semantics. Extract executable file metadata from the original sandbox analysis report; wherein, the executable file metadata includes one or more combinations of: file hash, file type, section layout, entry point information, and digital signature status; The import address table entries are extracted from the original sandbox analysis report to obtain the functional capability information exposed by the program sample to be tested; API call names are extracted from the call logs of different processes and threads and merged into a single API call sequence according to global time order.

4. The malware detection method based on heuristic pre-training of a large language model according to claim 1, characterized in that, The behavior analysis corpus includes: instruction fields, input fields, and output fields; The instruction field is used to instruct the large language model to analyze the original sandbox analysis report and determine whether it is a malicious or benign program; the input fields include: the sandbox signature obtained after semantic-driven feature reconstruction, executable file metadata, import address table, and time-ordered API call sequence; the output fields include: malicious label or benign label.

5. The malware detection method based on heuristic pre-training of a large language model according to claim 1, characterized in that, The preset security heuristic knowledge includes: API semantic knowledge and sandbox signature semantic knowledge; wherein, the API semantic knowledge includes: API functions, parameter meanings, return value meanings, and potential uses in malware scenarios; the sandbox signature semantic knowledge includes: signature triggering conditions, risk meanings, and corresponding underlying behavioral evidence.

6. The malware detection method based on heuristic pre-training of a large language model according to claim 1, characterized in that, The step of fine-tuning the large language model in stages based on the knowledge corpus and the behavior analysis corpus to obtain the object detection model includes: In the first stage, the knowledge corpus is used to learn knowledge from the large language model, enabling the large language model to learn prior knowledge in the security domain. In the second stage, the behavior analysis corpus is used to perform behavior learning on the large language model that has completed knowledge learning, so that the large language model learns the evidence association relationship between sandbox signatures, executable file metadata, import address table, and time-ordered API call sequence; wherein, the number of training rounds for behavior learning is less than the number of training rounds for knowledge learning. The target detection model is obtained by updating the model parameters based on the low-rank adaptation method.

7. The malware detection method based on heuristic pre-training of a large language model according to claim 1, characterized in that, The step of inputting the behavior analysis corpus corresponding to the program to be detected into the target detection model to obtain the detection result of whether the program to be detected is a malicious program or a benign program includes: Input the behavior analysis corpus corresponding to the program to be detected into the target detection model according to the preset prompt template; Obtain the category text or category probability output by the target detection model; Based on the category text or the category probability, the detection result of whether the program to be detected is a malicious program or a benign program is obtained.

8. A malware detection system based on heuristic pre-training of a large language model, characterized in that, include: The report generation module is used to acquire a sample of the program to be tested, execute the sample of the program to be tested in an isolated dynamic analysis sandbox, and generate an original sandbox analysis report containing dynamic behavior information and static attribute information. The semantic reconstruction module is used to perform semantic-driven feature reconstruction on the original sandbox analysis report, extract and standardize multidimensional semantic evidence, and obtain behavioral analysis corpus; wherein, the multidimensional semantic evidence includes one or more combinations of sandbox signatures, executable file metadata, import address tables, and time-ordered API call sequences; The heuristic training module is used to construct a knowledge corpus based on preset security heuristics, and to fine-tune the large language model in stages based on the knowledge corpus and the behavior analysis corpus to obtain the target detection model. The detection inference module is used to input the behavior analysis corpus corresponding to the program to be detected into the target detection model to obtain the detection result of whether the program to be detected is a malicious program or a benign program.

9. A terminal, characterized in that, include: The processor and memory, wherein the memory stores a malware detection program based on a large language model heuristic pre-training, the malware detection program based on a large language model heuristic pre-training, when executed by the processor, is used to implement the operation of the malware detection method based on a large language model heuristic pre-training as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a malware detection program based on a large language model heuristic pre-training, which, when executed by a processor, is used to implement the malware detection method based on a large language model heuristic pre-training as described in any one of claims 1-7.