Malware robustness detection method based on data augmentation and byte block level scoring
By combining byte-block-level scoring and multi-instance learning aggregation with data augmentation techniques, the robustness problem of static malware detection models under attacks is solved, enabling efficient detection and interpretive analysis of malware.
Patent Information
- Application Number
- CN202611700934.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-30
- Publication Date
- 2026-11-27
AI Technical Summary
Existing static malware detection models are susceptible to benign byte injection, file end-padding attacks, and adversarial modification attacks, resulting in a decrease in detection rate and a lack of attention to and robustness towards localized malicious regions.
We employ a data augmentation and byte-block-level scoring approach, which improves the model's robustness to attacks by combining byte block partitioning and vectorization, feature extraction, multi-instance learning aggregation, and classification fusion layers with structure-preserving data augmentation.
It effectively mitigates the impact of benign byte injection and attacks on detection, improves the model's detection rate and robustness in attack-avoidance environments, and provides detection explanation information to help locate key risk areas.
Smart Images

Figure CN123179403A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of software security technology, and in particular relates to a robust detection method for malware targeting Windows PE (Portable Executable) files. Background Technology
[0002] Malware poses a significant threat to cybersecurity. Static malware detection methods typically rely on byte sequences, import tables, section information, string statistics, or manually designed features in PE files to determine sample malfunction. With advancements in machine learning and deep learning, methods based on EMBER (Endgame Malware Benchmark for Research) features, byte-level convolutional models, and smooth, robust detection models have achieved higher accuracy rates in detecting common samples.
[0003] However, attackers can perform structure-preserving modifications to PE files without altering the functionality of the malware. These modifications include appending benign bytes to the end of the file, adding new sections and filling them with benign content, modifying header fields, or using automated adversarial modification strategies. These operations change the file's global byte distribution and static statistical characteristics, thereby weakening the ability of traditional detectors to detect truly malicious regions and leading to a decrease in detection rates.
[0004] Therefore, there is a need for a malware detection method that can focus on local malicious regions, reduce interference from irrelevant benign bytes, and actively learn perturbation scenarios during the training phase, in order to improve the robustness of static detection models in attack avoidance environments. Summary of the Invention
[0005] The purpose of this invention is to provide a robust malware detection method based on data augmentation and byte block-level scoring, in order to solve the problem that existing static malware detection models are easily affected by benign byte injection, file end-padding attacks, section injection attacks, and adversarial modification attacks.
[0006] To achieve the above objectives, the specific technical solution of the present invention is as follows:
[0007] A robust malware detection method based on data augmentation and block-level scoring includes the following steps:
[0008] Obtain the raw byte sequence of the PE file;
[0009] The original byte sequence is divided into multiple byte blocks according to a fixed byte block length and then vectorized.
[0010] Feature extraction is performed on each byte block vector to obtain a byte block-level malicious score;
[0011] Based on multi-instance learning, the malicious scoring at the byte block level is aggregated, and the file-level malicious detection results are output.
[0012] During the training phase, structure-preserving data augmentation is introduced, which includes one or more of the following: file front covering, random continuous segment covering, file tail injection, and benign byte injection. The perturbation location and scale are limited to maintain the original function of the sample.
[0013] Furthermore, the byte block partitioning and vectorization includes: padding the input byte sequence with padding markers to an integer multiple of the fixed byte block length, mapping the byte values and padding markers to embedding vectors, and normalizing and aggregating the byte embedding vectors within the same byte block to obtain the vector representation of the corresponding byte block.
[0014] Furthermore, the byte block feature extraction employs a one-dimensional convolutional neural network to model along the byte block sequence direction, in order to capture the local contextual relationships between adjacent byte blocks and the distribution of malicious features across regions.
[0015] Furthermore, the byte-block-level malicious score is used to generate detection explanation information, which includes the number of at least one high-scoring byte block, the byte offset range of the byte block in the PE file, and the corresponding malicious score; the byte-block-level malicious score is calculated by the byte block scoring module for each byte block separately, and is used to locate local byte regions with strong malicious feature responses.
[0016] Furthermore, the multi-instance learning aggregation includes maximum value aggregation, top k mean aggregation, and exponential and logarithmic aggregation, where k is a positive integer. The top k mean aggregation takes the average score of the k highest-scoring valid byte blocks, and if there are fewer than k, it takes the average score of all valid byte blocks.
[0017] The results of maximum value aggregation, top k mean aggregation, and exponential and logarithmic aggregation form an aggregated feature vector. After inputting the aggregated feature vector into the classification fusion layer, a file-level malicious detection score is obtained.
[0018] Furthermore, when aggregating malicious scores at the byte block level, an effective byte block mask is generated based on the effective byte length of the input byte sequence to mask the scores corresponding to all byte blocks composed of padding markers, thereby preventing byte blocks composed of padding markers from affecting the aggregation results.
[0019] This invention provides a robust malware detection system, comprising a data reading module, a byte block segmentation and vectorization module, a byte block feature extraction module, a byte block scoring module, a multi-instance learning aggregation module, a classification fusion layer, and a detection output module.
[0020] It also includes a training enhancement module, which is used during the model training phase to perform one or more of the following on malicious samples according to a preset enhancement configuration: file front covering, random continuous segment covering, file tail injection, and benign byte injection. The module also limits the perturbation scale based on the maximum perturbation ratio and the maximum single perturbation length.
[0021] The system is configured to perform the methods described above in this invention.
[0022] Furthermore, the detection output module includes a threshold determination unit and an interpretation output unit. The threshold determination unit is used to output a malicious or benign detection conclusion based on the comparison result between the file-level malicious detection score and the preset threshold. The interpretation output unit is used to output the number of the high-scoring byte block, the byte offset range in the PE file, and the corresponding malicious score.
[0023] The present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the methods described above.
[0024] The present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in the present invention.
[0025] The present invention has the following advantages: (1) It directly processes the original byte sequence of PE files without the need for manual feature design; (2) It highlights key malicious areas through byte block-level malicious scoring, thereby alleviating feature dilution caused by benign byte injection; (3) It combines maximum value aggregation, top k term mean aggregation, and exponential and logarithmic aggregation to integrate malicious responses of different ranges; (4) It adopts structure-preserving data augmentation to improve the detection stability of file end padding attacks, section injection attacks, and adversarial modification attacks; (5) It outputs high-scoring byte block information to assist in locating key risk areas and improve the interpretability of detection results. Attached Figure Description
[0026] Figure 1 A schematic diagram of the overall structure of the byte block multi-instance detection network;
[0027] Figure 2 This is a schematic diagram of the byte block partitioning and vectorization module of the present invention;
[0028] Figure 3 This is a schematic diagram of the byte block feature extraction module of the present invention;
[0029] Figure 4 This is a schematic diagram of the byte block scoring module of the present invention;
[0030] Figure 5This is a schematic diagram of the multi-instance learning aggregation module of the present invention. Detailed Implementation
[0031] This invention provides a robust malware detection method based on data augmentation and byte block-level scoring: the original byte sequence of a PE file is read, divided into fixed-length byte blocks and quantized, contextual features are extracted and byte block-level malware scores are calculated, and then file-level malware detection results are output through a multi-instance learning aggregation and classification fusion layer; structure-preserving data augmentation is used in the training phase to improve robustness against evasion attacks.
[0032] like Figure 1 As shown, the byte block multi-instance detection network includes a byte block segmentation and vectorization module, a byte block feature extraction module, a byte block scoring module, a multi-instance learning and aggregation module, and a classification fusion layer connected to it. The structure of each module is as follows: Figures 2 to 5 As shown in the diagram, this network treats PE files as instance packets composed of multiple byte blocks, using locally high-scoring byte blocks as the criterion. The MIL (Multiple Instance Learning) aggregation module in the diagram is the multi-instance learning aggregation module. In this paper, fixed-length continuous byte segments are uniformly referred to as byte blocks.
[0033] Step 1: Byte Block Partitioning and Vectorization. Read the original byte sequence of the PE file. The actual byte values are 0 to 255, and a separate padding marker is set as the identifier for the 257th byte class. Samples exceeding the preset input length are truncated to that length, and samples shorter than the preset input length are padded with padding markers at the end. Record the original file byte length and the effective byte length; the effective byte length is the number of actual bytes retained after truncation and before padding, used to generate the effective byte block mask.
[0034] During the byte block partitioning stage, the system groups the byte sequence according to a fixed byte block length P. In one implementation, P is 256 bytes. The preset input length is an integer multiple of P, and the length of the padded byte sequence is denoted as L. Therefore, the number of byte blocks is N = L / P, and each byte block consists of P consecutive bytes. The original PE file is thus converted into a byte block sequence, enabling the model to use local regions as the basic processing unit.
[0035] During the vectorization phase, the byte embedding layer maps real byte values and padding tags to learnable vectors. Padding tags are independently numbered to avoid confusion with real bytes. Subsequently, layer normalization is performed on each byte embedding vector, and the average of the byte embedding vectors within the same byte block is taken to obtain the byte block vector. This process is as follows: Figure 2As shown in the figure, LayerNorm (Layer Normalization) represents the normalization operation, and pad (Padding Token) represents the independent padding token.
[0036] Step 2: Byte Block Feature Extraction. The byte block vector sequence is input into a one-dimensional convolutional neural network. Modeling is performed along the byte block sequence to capture the local contextual relationships between adjacent byte blocks. Malicious code, section boundaries, and injection regions can form combined patterns between adjacent byte blocks. Contextual features can supplement the cross-regional features missing when judging individual byte blocks independently.
[0037] In one implementation, the byte block feature extraction module includes multiple one-dimensional convolutional layers. The initial convolutional layers map the byte block embedding dimension to a higher channel space, extracting basic local patterns; intermediate convolutional layers expand the receptive field along the byte block sequence, learning the distribution of malicious bytes across byte blocks; and the final convolutional layers map to the hidden dimension, forming high-level byte block features. After the convolutional layers, a GELU (Gaussian Error Linear Unit) activation function and a Dropout layer can be connected to enhance non-linear expressive power and reduce the risk of overfitting. Dropout is enabled only during the training phase and disabled during the detection phase.
[0038] Through the feature extraction described above, the model obtains a high-level feature sequence of byte blocks corresponding to the number of byte blocks. Each element is fused with the context information of the corresponding byte block and its neighboring byte blocks, which is then used by the byte block scoring module to determine whether a local region contains malicious features. This process is as follows: Figure 3 As shown in the figure. Conv1d (One-Dimensional Convolution) and... Figure 1 The meaning of 1D (One-Dimensional) convolution is consistent with that in the text; cls_embd_size and cls_hidden represent the byte block embedding dimension and hidden dimension, respectively; kernel_size and k in the convolution box represent the convolution kernel size; padding represents the convolution padding amount, none of which represent k in the aggregation of the first k terms.
[0039] Step 3: Byte Block Scoring. The byte block scoring module receives high-level features of byte blocks and calculates a malicious score for each byte block. The input is a feature sequence arranged by byte block position, and the output is a one-dimensional score sequence corresponding to the number of byte blocks. The byte block-level malicious score represents the intensity of the malicious feature response of the corresponding byte block; the "byte block malicious score," "byte block score," and "malicious score" in the attached figure all refer to this score, which is different from the file-level malicious detection score output by the classification fusion layer.
[0040] In one implementation, the byte block scoring module consists of multiple layers of one-dimensional convolutions: the initial convolutions fuse local discriminative features, the intermediate convolutions compress channels while retaining malicious discrimination information, and the final layer maps the features of each byte block to a single malicious score. The higher the score, the stronger the malicious feature response of that byte block.
[0041] Preserving byte-block-level malicious scores before file-level aggregation helps distinguish critical malicious regions from newly added benign content. When benign bytes at the end of the file or in newly added sections generate low scores, aggregation can still focus on existing high-scoring byte blocks, thereby mitigating feature dilution caused by benign byte injection.
[0042] Byte-block level malware scoring provides output as detection explanation information, including the number of high-scoring byte blocks, their byte offset range, and corresponding malware score. The offset is based on the start position of the PE file, and the range of the last valid byte block does not include padding markers, facilitating analysts' location of critical areas. The byte block scoring module is as follows: Figure 4 As shown.
[0043] Step 4: Multi-instance learning aggregation. The PE file is treated as an instance package composed of multiple byte block instances. The multi-instance learning aggregation module integrates the highest score, multiple high scores, and the smoothed response of all valid scores, and then passes it through a classification fusion layer to obtain the file-level malicious detection result. The process is as follows: Figure 5 As shown.
[0044] In maximum value aggregation (referred to as max pooling in the diagram), the system selects the maximum value of all valid byte block scores and retains the highest malicious response. This method is suitable for situations where malicious features are concentrated in a small number of local areas; when the high scores of critical malicious byte blocks are not affected by disturbances, their maximum responses can be retained.
[0045] In the top-k average pooling (referred to as Top-k average pooling in the diagram), the system selects the k highest-scoring valid byte blocks and calculates the average score. k is a positive integer representing the upper limit of the number of valid byte blocks participating in the aggregation; in one implementation, it is set to 8. If there are fewer than k valid byte blocks, the average score of all valid byte blocks is taken. This method can integrate information from multiple high-scoring byte blocks, reducing the impact of single-point perturbations on the detection results.
[0046] In exponential and logarithmic aggregation, the system performs smooth aggregation of scores for all valid byte blocks based on a temperature parameter. Specifically, it calculates the exponential sum of the scores scaled by the temperature parameter, takes the logarithm, and adjusts the aggregated value according to the temperature parameter. In one implementation, the temperature parameter is set to 5.0. The "logarithmic and exponential pooling" in the diagram refers to exponential and logarithmic aggregation, abbreviated as LSE (Log-Sum-Exp). The system combines the results of maximum value aggregation, top k-term mean aggregation, and exponential and logarithmic aggregation into an aggregated feature vector, inputs it to the classification fusion layer, performs linear mapping and activation processing (random deactivation is enabled during training), obtains a file-level malicious detection score, compares it with a preset threshold, and outputs a malicious or benign detection conclusion. Figure 5 As shown, Linear represents a linear mapping, and the "malicious score" at the end of the classification fusion layer represents the file-level malicious detection score.
[0047] In this invention, the effective byte block mask is generated based on the effective byte length of the input byte sequence; the enhanced sample uses the effective byte length after enhancement and truncation according to the preset input length, before padding. The number of effective byte blocks is the result of dividing the effective byte length by P and rounding up: byte blocks containing at least one real byte are valid, while byte blocks consisting entirely of padding markers are invalid. Invalid byte blocks are masked before aggregation to prevent them from participating in maximum value aggregation, top k-term mean aggregation, or exponential and logarithmic aggregation. This mask is used to exclude fully padded byte blocks, without masking partially padded effective byte blocks entirely.
[0048] In this invention, structure-preserving data augmentation is used to simulate attack evasion. During the training phase, malicious samples are selected according to the proportion of perturbation samples. The number of bytes modified or inserted is limited by the maximum perturbation proportion and the maximum length of a single perturbation, and the perturbation is confined to non-critical areas that do not affect the original functionality. Augmentation methods include one or more of the following: file front overlay, random continuous segment overlay, file tail injection, and benign byte injection.
[0049] File front overlay simulates modification of non-critical front areas or header fields; random continuous segment overlay simulates modification of non-critical continuous areas; file tail injection simulates appending random or irrelevant bytes to the end of the file for padding attacks; benign section byte injection simulates injecting section content from a benign PE file into the tail of a malicious sample or adding new section areas. A section is a segment in the PE file structure, unlike byte blocks divided into fixed lengths. All of the above enhancements should maintain the PE file structure and original functionality.
[0050] The present invention will be further described below with reference to embodiments.
[0051] Example 1
[0052] The implementation process of this invention is illustrated using the Windows PE malware robustness detection task as an example.
[0053] 1. Dataset Construction and Feature Preprocessing. Collect malicious and benign samples, read the original byte sequences of PE files, and truncate or pad them to form a uniform input length. Record the effective byte lengths before and after truncation and padding, which are used to generate an effective byte block mask.
[0054] 2. Model Training. The preprocessed raw byte sequence is input into the byte block multi-instance detection network, which divides the byte into blocks of fixed length and vectorizes them. Then, a one-dimensional convolutional neural network is used to extract byte block features, and a byte block-level malicious score is output through the byte block scoring module. Finally, a multi-instance learning aggregation and classification fusion layer is used to output the file-level malicious detection results.
[0055] 3. Structure-Preserving Data Augmentation. During training, malicious samples are selected according to the proportion of perturbation samples, and operations such as file front-end covering, random continuous segment covering, file tail injection, and benign byte injection are performed. The perturbation is controlled based on non-critical region constraints, the maximum perturbation proportion, and the maximum single perturbation length, so that the augmented samples maintain their original functionality and simulate the byte distribution changes caused by evasion attacks.
[0056] 4. Robustness Evaluation. The byte block multi-instance detection network and baseline detectors were compared under various scenarios, including normal samples, file end-padding attacks, section injection attacks, and adversarial modification attacks. The results are shown in Tables 1 to 5. The baselines included LightGBM (Light Gradient Boosting Machine) and SVC (Support Vector Classification), MalConv2 (the second version of the malware byte convolution model), and DRSM (De-Randomized Smoothed MalConv) models using EMBER features. In the tables, F1 (harmonic mean of precision and recall) is the comprehensive classification metric; "mean" represents the aggregated average scores of all valid byte blocks, and "+" indicates that the aggregated results are jointly input into the classification fusion layer.
[0057] Table 1 Comparison of classification performance for ordinary samples
[0058]
[0059] Table 2 Comparison of detection rate and escape rate under different attack scenarios
[0060]
[0061] Table 3. Classification performance of different multi-instance learning aggregation strategies
[0062]
[0063] Table 4 Escape rates under different multi-instance learning aggregation strategies
[0064]
[0065] Table 5. Results of ablation experiments using data augmentation strategies
[0066]
[0067] Table 1 shows that the F1 score of the byte block multi-instance detection network on ordinary samples is 0.9845. Table 2 shows that under file end-padding attacks, section injection attacks, and adversarial modification attacks, the detection rates of the byte block multi-instance detection network are 99.60%, 96.18%, and 95.00%, respectively, with corresponding escape rates of 0.40%, 3.82%, and 5.00%, which are lower than the baseline models in the table. Tables 3 and 4 show that the combined use of the three aggregations can balance classification performance and robustness; Table 5 shows that after data augmentation, the escape rate decreases in all three attack scenarios.
[0068] Example 2
[0069] In this embodiment, the byte block length is 256 bytes, and the byte block vector is subjected to multi-layer one-dimensional convolution to extract context features. The parameters can be adjusted according to file length, video memory capacity, and detection latency.
[0070] The five one-dimensional convolutional kernels of the byte block feature extraction module can be set to sizes of 7, 7, 5, 5 and 3 respectively, taking into account both a wide context and fine-grained features; Gaussian error linear unit activation function and random deactivation layer can be connected after the convolutional layer.
[0071] Maximum value aggregation, top k-term mean aggregation, and exponential and logarithmic aggregation retain the highest score, the mean of multiple high scores, and the smoothed response of all valid scores, respectively. These three results form an aggregated feature vector, which is then processed by a classification fusion layer to output a file-level malicious detection score. Each aggregation uses only valid byte blocks for scoring. Parameters are shown in Table 6.
[0072] Table 6. Main parameters and functions of the present invention
[0073]
[0074] Example 3
[0075] This embodiment illustrates the execution flow of structure-preserving data augmentation. For a training batch, malicious samples are first filtered by label, and then augmentation targets are selected according to the proportion of perturbation samples. The maximum perturbation proportion uses the effective byte length before augmentation as the denominator to limit the cumulative number of bytes modified or inserted; the maximum single perturbation length limits the number of bytes covered or inserted each time. Combined augmentations are constrained by both the cumulative upper limit and the single upper limit, and the overwrite operation only applies to non-critical areas that do not affect the original functionality.
[0076] In the file front overwrite step, the system only performs limited overwrite on non-critical regions or modifiable non-critical header fields at the beginning of the file, preserving the PE file structure, program control flow, and original functionality. This step simulates local header byte changes, reducing the model's over-reliance on a small number of header statistical differences.
[0077] In the random contiguous fragment overlay step, the system selects one or more contiguous fragments from non-critical regions within the valid byte range and replaces them with random bytes, maintaining the original functionality. This step simulates local byte perturbations, enabling the model to learn a more stable representation of malicious features to non-critical local changes.
[0078] In the file end-injection and benign section byte injection steps, the system appends random bytes, irrelevant bytes, or benign PE file section bytes to the end of the valid bytes. When using the new section method, the PE file structure and original functionality should be maintained. When usable benign section data exists, benign section fragments can be extracted first. After injection, the data is truncated to the preset input length, and the valid byte length is updated according to the number of real bytes retained before generating a valid byte block mask. The enhancement methods and corresponding attack scenarios are shown in Table 7.
[0079] Table 7. Structure-preserving data augmentation methods and corresponding attack scenarios
[0080]
[0081] Example 4
[0082] This embodiment illustrates the deployment method of the present invention in a detection system. The system includes a data reading module, a byte block partitioning and vectorization module, a byte block feature extraction module, a byte block scoring module, a multi-instance learning aggregation module, a classification fusion layer, a detection output module, and a training enhancement module. The detection output module includes a threshold determination unit and an interpretation output unit; the training enhancement module is used during the model training phase. Each module can be deployed on the same server or distributed according to sample size and detection latency requirements.
[0083] For the sample to be detected, the data reading module reads the original bytes of the PE file; the byte block segmentation and vectorization module performs truncation or padding, records the effective byte length and generates byte block vectors; the byte block feature extraction module extracts context features; the byte block scoring module outputs a byte block-level malicious score; the multi-instance learning aggregation module aggregates the effective byte block scores and obtains a file-level malicious detection score through a classification fusion layer; and the threshold determination unit outputs a malicious or benign detection conclusion.
[0084] When interpretation is required, the interpretation output unit returns the numbers of the k highest-scoring valid byte blocks, their byte offset range in the PE file, and their corresponding malicious scores; if there are fewer than k valid byte blocks, it returns information for all valid byte blocks. Security analysts can use this information to locate areas of interest. Detection results and related records are shown in Table 8, where the enhancement strategy records are used for training or evaluation.
[0085] Table 8. Examples of test results and related records
[0086]
[0087] Example 5
[0088] This embodiment illustrates the adaptability of the present invention to different attack scenarios. For file end-padding attacks, the model retains high responses to key malicious byte blocks through byte block-level maliciousness scoring, maximum value aggregation, and top k term mean aggregation, mitigating the interference of newly added benign bytes. For section injection attacks, the model injects benign section bytes during the training phase, enabling the classifier to learn the impact of newly added benign content on byte distribution.
[0089] For adversarial modification attacks, the model combines structure-preserving data augmentation with byte-block-level malicious scoring to extract malicious features from critical byte blocks that have never been corrupted, and uses multiple aggregation results to reduce the risk of misjudgment when a single local score is interfered with.
[0090] Ordinary samples are still processed according to the static detection process, without the need for dynamic execution or reading of sandbox behavior logs. This invention can be used as a standalone static detector or as a robustness enhancement module in a multi-engine detection system, in conjunction with signature detection, rule detection, or manual review processes.
[0091] As can be seen from the above implementation methods and embodiments, the present invention has the following technical advantages:
[0092] (1) Improve robustness. This invention enables the model to focus on key local regions in malicious files by using byte-block-level malicious scoring and multi-instance learning aggregation, thereby reducing the feature dilution effect caused by file end-padding attacks and section injection attacks.
[0093] (2) Maintaining detection performance. This invention directly utilizes the original byte sequence for modeling, without relying on manually designed complex features, and can still maintain high accuracy and F1 value on ordinary samples.
[0094] (3) Enhance interpretability. Byte-block level malicious scoring can reflect the intensity of malicious feature responses in different local areas, providing a basis for subsequent sample analysis, threat localization, and interpretation of detection results.
[0095] (4) Adapt to real attack scenarios. Data augmentation strategies simulate the structure-preserving modification methods commonly used by attackers, enabling the model to learn stable discrimination capabilities against perturbation samples during the training phase.
[0096] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A robust malware detection method based on data augmentation and byte-block-level scoring, characterized in that, Includes the following steps: Obtain the raw byte sequence of a Windows PE file; The original byte sequence is divided into multiple byte blocks according to a fixed byte block length and then vectorized. Feature extraction is performed on each byte block vector to obtain a byte block-level malicious score; Based on multi-instance learning, the malicious scoring at the byte block level is aggregated, and the file-level malicious detection results are output. During the training phase, structure-preserving data augmentation is introduced, which includes one or more of the following: file front covering, random continuous segment covering, file tail injection, and benign byte injection. The perturbation location and perturbation scale are limited to maintain the original function of the sample without being destroyed. The byte-block-level malicious scoring is used to generate detection explanation information, which includes the number of at least one high-scoring byte block, the byte offset range of the byte block in the PE file, and the corresponding malicious score. The byte-block-level malicious score is calculated by the byte block scoring module for each byte block and is used to locate local byte regions with strong malicious feature responses. The multi-instance learning aggregation includes maximum value aggregation, top k mean aggregation, and exponential and logarithmic aggregation, where k is a positive integer. The top k mean aggregation takes the average score of the k highest-scoring valid byte blocks, and if there are fewer than k, it takes the average score of all valid byte blocks. The results of maximum value aggregation, top k mean aggregation, and exponential and logarithmic aggregation form an aggregated feature vector. After inputting the aggregated feature vector into the classification fusion layer, a file-level malicious detection score is obtained.
2. The method according to claim 1, characterized in that, The byte block partitioning and vectorization include: padding the input byte sequence with padding markers to an integer multiple of the fixed byte block length, mapping byte values and padding markers to embedding vectors, and normalizing and aggregating the byte embedding vectors within the same byte block to obtain the vector representation of the corresponding byte block.
3. The method according to claim 1, characterized in that, The byte block feature extraction employs a one-dimensional convolutional neural network to model along the byte block sequence direction, used to capture the local contextual relationships between adjacent byte blocks and the distribution of malicious features across regions.
4. The method according to claim 1, characterized in that, When aggregating malicious scoring at the byte block level, a valid byte block mask is generated based on the valid byte length of the input byte sequence. This mask covers all scores corresponding to byte blocks composed of padding markers, thus preventing byte blocks composed of padding markers from affecting the aggregation results.
5. A robust malware detection system, wherein the system performs the method according to any one of claims 1 to 4, characterized in that, It includes a data reading module, a byte block partitioning and vectorization module, a byte block feature extraction module, a byte block scoring module, a multi-instance learning aggregation module, a classification fusion layer, and a detection output module. It also includes a training enhancement module, which is used to perform one or more of the following on malicious samples during the model training phase: file front covering, random continuous segment covering, file tail injection, and benign byte injection, according to a preset enhancement configuration, and to limit the scale of the perturbation according to the maximum perturbation ratio and the maximum single perturbation length.
6. The system according to claim 5, characterized in that, The detection output module includes a threshold determination unit and an interpretation output unit. The threshold determination unit is used to output a malicious or benign detection conclusion based on the comparison result between the file-level malicious detection score and the preset threshold. The interpretation output unit is used to output the number of the high-scoring byte block, the byte offset range in the PE file, and the corresponding malicious score.
7. A computer device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the method according to any one of claims 1 to 4.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1 to 4.
