Deformable convolution-based convolutional neural network firmware vulnerability detection method

By introducing deformable convolution and adaptive attention feature computation into CNN, the ability to perceive structural irregularities and discrete local feature regions in firmware vulnerability detection is enhanced, solving the problem of low vulnerability localization accuracy in existing CNNs and achieving more efficient vulnerability detection.

CN121328631APending Publication Date: 2026-01-13安徽明生恒卓科技有限公司
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202511206268.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-27
Publication Date
2026-01-13

AI Technical Summary

Technical Problem

Existing CNNs lack the ability to detect structural irregularities and discrete local feature regions in firmware vulnerability detection, resulting in low vulnerability location accuracy.

Method used

A convolutional neural network method based on deformable convolution is adopted. Through adaptive attention feature calculation and deformable convolution calculation, the ability to perceive structural irregularities and discrete local feature regions is enhanced, thereby improving the accuracy of vulnerability location.

Benefits of technology

It improves the accuracy and generalization of vulnerability detection, and realizes the automated, accurate and universal deployment of firmware vulnerability detection, adapting to the characteristics of different vulnerability types.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121328631A_ABST
    Figure CN121328631A_ABST
Patent Text Reader

Abstract

The invention relates to a convolutional neural network firmware vulnerability detection method based on deformable convolution, which adopts a firmware vulnerability detection model based on a convolutional neural network. Processing the preprocessed firmware binary file of the power side end equipment and then outputting a classification result; and evaluating whether the firmware binary file is normal firmware or vulnerability-containing firmware. And after deformable convolution calculation is carried out on an attention fusion feature graph Z output by adaptive attention feature calculation, an adaptive spatial representation graph Z'is output for pooling. According to the method, deformable convolution calculation is added in a firmware vulnerability detection model, and deformable convolution calculation is carried out on an attention fusion feature map Z output by self-adaptive attention feature calculation; the adaptive spatial representation graph Z'is output for pooling, and the introduced deformable convolution calculation realizes dynamic sampling through offset learning, so that the perceptual ability of structure special-shaped and local feature discrete regions is enhanced, and the vulnerability positioning precision is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a firmware vulnerability detection method, and more particularly to a firmware vulnerability detection method based on deformable convolutional neural networks. Background Technology

[0002] Firmware vulnerability detection plays a crucial role in key areas such as industrial control, smart terminals, the Internet of Things (IoT), automotive electronics, and aerospace. Firmware vulnerabilities can lead to malicious attacks on devices, privilege escalation, and even disruption of normal system operation. Therefore, timely and efficient detection of firmware vulnerabilities is a critical means of ensuring system security. For example, power edge devices (such as smart meters, distribution terminals, and edge computing gateways) are widely deployed in new power systems. Vulnerabilities in their embedded firmware programs can lead to remote control breaches, data tampering, or service interruptions, seriously threatening power grid security. Currently, firmware vulnerability detection methods mainly include analytical model-based methods and data-driven methods.

[0003] The analytical model-based approach relies on reverse engineering, symbolic execution, and static code analysis. It requires accurate firmware modeling and complete code information acquisition. If the firmware architecture changes, it needs to be remodeled, resulting in low applicability.

[0004] Data-driven approaches acquire a large number of firmware samples through data mining and train them using deep learning models to achieve automated vulnerability detection. This method does not rely on precise physical models and can adapt well to different firmware environments. For example, firmware vulnerability detection methods based on convolutional neural networks (CNNs) have powerful local feature extraction capabilities, effectively identifying vulnerability patterns in firmware. However, CNNs still have certain limitations in handling vulnerability detection tasks: insufficient perception of structural irregularities and discrete local feature regions leads to low vulnerability localization accuracy. Summary of the Invention

[0005] (1) Technical problems to be solved

[0006] To address the technical problem that existing CNNs lack the ability to detect structurally irregular and locally discrete regions in firmware vulnerability detection, resulting in low vulnerability location accuracy, this invention provides a firmware vulnerability detection method based on deformable convolutional neural networks.

[0007] (2) Technical solution

[0008] This invention provides a firmware vulnerability detection method based on deformable convolutional neural networks. It employs a firmware vulnerability detection model based on convolutional neural networks, inputting a preprocessed firmware binary file from a power edge device → convolution + batch normalization + ReLU activation → adaptive attention feature calculation → pooling → fully connected layer → classification, and outputting a classification result: evaluating whether the firmware binary file is normal or contains vulnerabilities. Specifically, the attention fusion feature map Z output from the adaptive attention feature calculation is subjected to deformable convolution, and the resulting adaptive spatial representation map Z' is then pooled.

[0009] Z'=W1·y all +b

[0010] In the formula, W1 is the convolution kernel weight;

[0011] b is the bias term of W1;

[0012] y all Let y(p0) represent the complete feature map consisting of all center points P0; p0 is the center point sampled by the convolution of the attention fusion feature map Z in a sliding manner; y(p0) is the output value of the convolution at center point p0. R is a fixed convolutional sampling window for the attention fusion feature map Z, w(p n ) is the convolution kernel at position P n The weights, Z(p0+p n +Δp n ) is the position p0+p in the attention fusion feature map Z. n +Δp n The eigenvalue at Δp n Learnable offsets are added to the corresponding sampling positions.

[0013] As a further improvement to the above scheme, Δp n Designed as follows:

[0014] Δp n =W offset ·Z+b offset

[0015] In the formula, W offset With b offset The convolution kernel and bias are learnable offsets.

[0016] As a further improvement to the above scheme, Z(p0+p n +Δp n )for:

[0017]

[0018] In the formula, Υ(p+Δp) represents the four nearest integer points of the sampling point position p+Δp, and G(q,p0+p) represents the four nearest integer points of the sampling point position p+Δp. n +Δp n ) represents the position p0+p of integer point q relative to non-integer sampling points. n +Δp n The contribution, q is the distance from the sampling point p0+p n +Δp n One of the four nearest integer points, Z(q) is the position p0+p in the attention fusion feature map Z at the distance from the sampling point. n +Δp n The eigenvalues ​​of the four most recent integer points.

[0019] Furthermore, G(q,p0+p) n +Δp n )for:

[0020] G(q,p0+p n +Δp n )=(1-|p x +Δp x -q x |)(1-|p y +Δp y -q y |)

[0021] In the formula, P x P is the x-coordinate of the reference point p. y The ordinate of the reference point p, Δp x It is the component of the offset Δp on the horizontal axis, q x Δp is the x-coordinate of the integer point q. y It is the component of the offset Δp on the horizontal and vertical axes, q y It is the ordinate of the integer point q.

[0022] As a further improvement to the above scheme, the adaptive attention feature is calculated as follows: based on the convolutional feature map X of the ReLU activation output, the channel attention feature A is calculated. channel Spatial attention feature A spatial The attention fusion feature map Z is obtained based on the fusion weight fusion.

[0023] Furthermore, through the calibrated global feature F global The dynamic fusion weight α is calculated using a fully connected layer. dyn Adaptive fusion of A channel and A spatial Obtain weighted attention fusion feature A adaptive Then, perform element-wise multiplication with X to obtain the enhanced attention fusion feature map Z;

[0024]

[0025] α dyn =σ(W α ·F global +b α )

[0026] A adaptive =α dyn ·A channel +(1-α dyn )·A spatial

[0027] Z = X⊙A adaptive

[0028] Where H and W are the total length and total width in pixels of X, respectively; i1 and j represent the index values ​​from 1 to H and from 1 to W, respectively; X(i,j,c,n) is the feature of sample n in X at pixel position (i1,j) within channel c; σ(·) is the Sigmoid activation function; W α It is a fully connected weight matrix, b α It is W α The bias term.

[0029] Preferably, two fully connected layers are used to compress and expand the channel information of the convolutional feature map X to obtain the channel attention feature A. channel :

[0030] The convolutional feature map X is reshaped to flatten its spatial dimensions, forming a tensor of shape [L,C,N], where L represents the total spatial length, C is the number of channels, and N is the batch dimension.

[0031] Perform channel-wise 1D convolution on the tensor and use TD-Conv1D to compute the global features of each channel;

[0032] The channel attention feature A is obtained by computing the global features through two fully connected layers. channel .

[0033] More preferably, tensor X reshape for:

[0034] X reshape =reshape(X,[L,C,N]) (1)

[0035] Where X is the convolutional feature map;

[0036] The global feature of the c-th channel is:

[0037]

[0038] Among them, X reshape (i,c) represents the feature at the c-th channel and the i-th spatial length of the tensor, K(i,c) represents the TD-Conv1D convolution kernel at the c-th channel and the i-th spatial length of the tensor, and B(c) is the bias term of K(i,c).

[0039] Channel attention feature A channel for:

[0040]

[0041] Where σ(·) is the Sigmoid activation function, and It is the weight matrix for channel compression and expansion. and It corresponds and The bias term, PReLU, is used as an activation function to introduce nonlinear features, F TD For channel_feature(c).

[0042] Preferably, spatial features of the convolutional feature map X are extracted through 3×3 convolution, and spatial attention weights are calculated by combining the bias term to obtain spatial attention features A. spatial :

[0043] Calculate global pooling features on the convolutional feature map X, and perform channel average pooling to obtain channel average features;

[0044] Calculate the maximum value of each pixel in the channel dimension of the convolutional feature map, and perform channel max pooling to obtain the channel maximum feature.

[0045] The final spatial attention feature A is obtained by concatenating channel average pooling and channel max pooling. spatial .

[0046] More preferably, the channel average characteristic is:

[0047]

[0048] Where C is the number of channels, spatial_avg(i,j,n) is the average channel feature of sample n at position (i,j) in all channels, and X(i,j,c,n) is the feature of sample n at position (i,j) in channel c in the convolutional feature map.

[0049] The most prominent feature of a channel is:

[0050]

[0051] Where spatial_max(i,j,n) is the maximum channel feature of sample n at position (i,j) in all channels;

[0052] Spatial attention feature A spatial for:

[0053] A spatial =σ(Conv2D(conact(F) avg, F max )),W s ,b s (6)

[0054] Where σ(·) is the Sigmoid activation function, contact(·) is the concatenation function, Conv2D(·) is the convolution function, and F avg It is spatial_avg(i,j,n), F max It is spatial_max(i,j,n), W s It is a 3×3 convolution kernel; b s It is W s The bias.

[0055] (3) Beneficial effects

[0056] Compared with the prior art, the present invention has the following advantages:

[0057] This invention adds deformable convolution calculation between "adaptive attention feature calculation" and "pooling" in the firmware vulnerability detection model. After performing deformable convolution calculation on the attention fusion feature map Z output by adaptive attention feature calculation, the output adaptive spatial representation map Z' is pooled. The introduced deformable convolution calculation achieves dynamic sampling through offset learning, thereby enhancing the perception ability of structural irregularities and discrete local feature regions, and improving the vulnerability location accuracy.

[0058] B. This invention, on the one hand, utilizes dynamic fusion of channel attention features A channel Spatial attention feature A spatial This effectively improves the generalization ability of firmware vulnerability detection models based on convolutional neural networks. On the other hand, the weighted attention fusion feature A adaptive Element-wise multiplication with the convolutional feature map X yields an enhanced attention fusion feature map Z. TD-Conv1D is used to improve the expressive power of channel features and avoid information loss. Thirdly, the channel attention feature A... channel Spatial attention feature A spatialDerived from convolutional feature map X, and dynamically fused with it, it works synergistically with convolutional feature map X to effectively characterize key vulnerability features, achieving a lightweight spatial attention mechanism, improving detection efficiency, and adapting to edge devices. Therefore, this invention solves the technical problems of existing CNNs in firmware vulnerability detection, such as difficulty in simultaneously considering local and global features, inability to adapt to different vulnerability types, and inability to effectively characterize key vulnerability features.

[0059] This invention combines "deformable convolution computation" with "adaptive attention feature computation" to achieve adaptive attention and dynamic weighting, enabling a complete end-to-end network training process and achieving automated, accurate, and universal deployment of firmware vulnerability detection tasks.

[0060] D. This invention can combine firmware image conversion methods with deep neural networks to model and identify vulnerability patterns in grayscale images. Attached Figure Description

[0061] Figure 1 This is a flowchart of the convolutional neural network firmware vulnerability detection method provided in Embodiment 1 of the present invention.

[0062] Figure 2 This is a flowchart of the convolutional neural network firmware vulnerability detection method provided in Embodiment 2 of the present invention.

[0063] Figure 3 yes Figure 2 A flowchart of the adaptive attention feature calculation method used in the firmware vulnerability detection method.

[0064] Figure 4 yes Figure 3 The adaptive attention feature calculation method uses channel attention feature A. channel The calculation method flowchart.

[0065] Figure 5 yes Figure 3 The spatial attention feature A used in the adaptive attention feature calculation method spatial The calculation method flowchart. Detailed Implementation

[0066] The technical solutions in the embodiments of the present invention will be clearly and completely described below. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0067] It should be noted that when a component is said to be "installed on" another component, it can be directly on the other component or it may be in a component that is centered on it. When a component is said to be "set on" another component, it can be directly set on the other component or it may also be in a component that is centered on it. When a component is said to be "fixed to" another component, it can be directly fixed to the other component or it may also be in a component that is centered on it.

[0068] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the specification of this invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. The term "or / and" as used herein includes any and all combinations of one or more of the associated listed items.

[0069] Example 1

[0070] The firmware vulnerability detection method based on deformable convolution of convolutional neural networks of the present invention adopts a firmware vulnerability detection model based on convolutional neural networks. The method inputs the preprocessed firmware binary file of the power edge device → convolution + batch normalization + ReLU activation → adaptive attention feature calculation → deformable convolution calculation → pooling → fully connected → classification and outputs the classification result: to evaluate whether the firmware binary file is normal firmware or firmware containing vulnerabilities.

[0071] Please see Figure 1 , Figure 1 This is a flowchart of a firmware vulnerability detection method based on deformable convolutional neural networks provided in Embodiment 1 of the present invention.

[0072] Step 1: Convert the firmware binary file of the power edge device into a firmware image dataset in a format that can be accepted by the convolutional neural network. Specifically, this can be done by: byte padding the binary file → converting it into a two-dimensional matrix → normalizing it to a grayscale image (e.g., 1500×1500).

[0073] Preprocessing of firmware binary files can employ traditional binary file conversion methods to process firmware data. For example, the conversion method for firmware image data may include the following steps: reading firmware data in bin format from the firmware binary file and parsing it in binary mode, requiring byte padding during the parsing process; subsequently, converting the parsed one-dimensional binary data into a two-dimensional matrix format; simultaneously, converting all firmware data in the two-dimensional matrix format into standardized grayscale images and uniformly adjusting them to a size of 1500×1500 pixels (other sizes are also possible, such as 2000×2000 pixels); finally, outputting a firmware image dataset of uniform specifications.

[0074] Before use, the firmware vulnerability detection model of this invention needs to be trained with training set data until the model is stable, and then the accuracy of the model is verified with test set data. For example, firmware files in bin format can be read from the "normal" firmware folder and the "vulnerable" firmware folder containing firmware binary files, respectively, and parsed in binary mode. The read firmware data is preprocessed, including byte padding to ensure data integrity, and the one-dimensional binary data is converted into a two-dimensional matrix format to meet the input requirements of the subsequent deep learning model. At the same time, to ensure the consistency of input data, all firmware data is converted into standardized grayscale images and adjusted to a uniform size of 1500×1500 pixels as model input samples. A portion of the model input samples is used as training set data, and the other portion is used as test set data.

[0075] Step 2: Input the "uniform format firmware image dataset" output from Step 1 into the CNN network for data processing: Input → Convolution + Batch Normalization + ReLU Activation → Adaptive Attention Feature Calculation → Deformable Convolution Calculation → Pooling → Fully Connected → Classification. The final output is the classification result: evaluating whether the firmware binary file is normal firmware or firmware containing vulnerabilities.

[0076] Steps 3, 4, and 5 are refinements of step 2. Step 3 calculates the channel attention feature A from the convolutional feature map X output by ReLU activation. channel Spatial attention feature A spatial Step 4 involves performing deformable convolution on the attention fusion feature map Z based on the fusion weights, and then outputting an adaptive spatial representation map Z'. Step 5 involves performing pooling, fully connected layers, and classification on the adaptive spatial representation map Z' in sequence.

[0077] Z'=W1·y all +b

[0078] In the formula, W1 is the convolution kernel weight;

[0079] b is the bias term of W1;

[0080] y all Let y(p0) represent the complete feature map consisting of all center points P0; p0 is the center point sampled by the convolution of the attention fusion feature map Z in a sliding manner; y(p0) is the output value of the convolution at center point p0. R is a fixed convolutional sampling window for the attention fusion feature map Z, w(p n ) is the convolution kernel at position P n The weights, Z(p0+p n +Δp n ) is the position p0+p in the attention fusion feature map Z. n+Δp n The eigenvalue at Δp n Learnable offsets are added to the corresponding sampling positions.

[0081] Where, Δp n Designed as: Δp n =W offset ·Z+b offset

[0082] In the formula, W offset With b offset The convolution kernel and bias are learnable offsets.

[0083] And Z(p0+p n +Δp n )for:

[0084]

[0085] In the formula, Υ(p+Δp) represents the four nearest integer points of the sampling point position p+Δp, and G(q,p0+p) represents the four nearest integer points of the sampling point position p+Δp. n +Δp n ) represents the position p0+p of integer point q relative to non-integer sampling points. n +Δp n The contribution, q is the distance from the sampling point p0+p n +Δp n One of the four nearest integer points, Z(q) is the position p0+p in the attention fusion feature map Z at the distance from the sampling point. n +Δp n The eigenvalues ​​of the four most recent integer points.

[0086] And G(q,p0+p) n +Δp n )for:

[0087] G(q,p0+p n +Δp n )=(1-|p x +Δp x -q x |)(1-|p y +Δp y -q y |)

[0088] In the formula, P x P is the x-coordinate of the reference point p. y The ordinate of the reference point p, Δp x It is the component of the offset Δp on the horizontal axis, q x Δp is the x-coordinate of the integer point q. y It is the component of the offset Δp on the horizontal and vertical axes, q yIt is the ordinate of the integer point q.

[0089] The deformable convolution calculation for the attention fusion feature map Z is not a typical convolution approach. The key idea in this invention is that the convolution sampling position starts from the static position (p0+p). n ) is expanded to a learnable location (p0+p n +Δp n This allows the sampling location to be optimized end-to-end during training, dynamically adapting to key information regions in the input image.

[0090] Z∈R H×W×C The size of the convolution kernel is K h ×K w The basic convolution operation is defined as follows:

[0091]

[0092] P0 is the convolution sampling center point that traverses Z in a sliding manner, P n It is the offset relative to the fixed sampling position P0, Δp n Here, y(·) is the learnable offset, y(·) is the output function of the convolution function, y(P0) is the output value of the convolution at the center point P0, and w(·) is the weight function of the convolution kernel. n (This is about P) n The convolution kernel at position P n The weights, Z(·) are functions of the value function, Z(p0+p n ) is P0+P in Z n The feature value at position Z. R is a fixed convolution sampling window for Z (for example, for a 3×3 convolution, |R| = 9).

[0093] In this invention, a learnable offset Δp is added to the sampling position. n The convolution process is then updated as follows:

[0094]

[0095] Where the offset Δp n It is not predefined, but automatically learned through the offset prediction subnetwork, and its structure is as follows:

[0096] Δp n =W offset ·Z+b offset

[0097] Among them, W offset With b offset For learnable offset convolution kernels and biases.

[0098] Due to Δp nZ(p0+p) is usually a non-integer, therefore in actual sampling... n +Δp n The sampled values ​​need to be calculated using bilinear interpolation. The specific formula for dynamic sampling based on bilinear interpolation is as follows:

[0099]

[0100] Where Υ(p+Δp) represents the four nearest integer neighbors of the sampling point p+Δp, G(·) is the bilinear interpolation weight function, Z(·) is the value function, and Z(q) is the distance from the sampling point p0+p in Z. n +Δp n The specific formulas for the values ​​of the four most recent integer points s are as follows:

[0101] G(q,p0+p n +Δp n )=(1-|p x +Δp x -q x |)(1-|p y +Δp y -q y |)

[0102] In practice, this interpolation operation is performed on each channel one by one, ensuring that the value at each position is a weighted average of the surrounding four points. Δp is a learnable sampling offset, G(q,p0+p n +Δp n ) represents integer point q for non-integer sampling points p0+p n +Δp n The contribution size, q is the distance from sampling point p0+p n +Δp n One of the four most recent integer points, P x P is the x-coordinate of the reference point p. y The ordinate of the reference point p, Δp x It is the component of the offset Δp on the horizontal axis, q x Δp is the x-coordinate of the integer point q. y It is the component of the offset Δp on the horizontal and vertical axes, q y It is the ordinate of the integer point q.

[0103] The complete feature map y is formed by sliding through all the convolutional sampling center points P0 of Z and corresponding to y(P0). all The final convolution operation is performed using a regular convolution kernel W and a bias b: Z' = W·y all +b

[0104] The resulting Z' is the adaptive spatial representation map. W is the convolution kernel weight, b is the convolution kernel bias, and y allThis represents the complete feature map consisting of y(P0) corresponding to all center points P0.

[0105] Therefore, the invention adds deformable convolution calculation between "adaptive attention feature calculation" and "pooling" in the firmware vulnerability detection model. After performing deformable convolution calculation on the attention fusion feature map Z output by adaptive attention feature calculation, the adaptive spatial representation map Z' is output and then pooled. The introduced deformable convolution calculation achieves dynamic sampling through offset learning, thereby enhancing the perception ability of structural irregularities and discrete local feature regions and improving the vulnerability location accuracy.

[0106] Example 2

[0107] Please see Figure 2 , Figure 2 This is a flowchart of the convolutional neural network firmware vulnerability detection method provided in Embodiment 2 of the present invention. Embodiment 2 improves upon Embodiment 1 by refining the adaptive attention feature calculation and proposing a channel-spatial attention fusion mechanism to achieve adaptive attention and dynamic weighting. Therefore, Embodiment 2 can achieve a complete end-to-end network training process, enabling automated, accurate, and universal deployment of firmware vulnerability detection tasks. This invention combines firmware image conversion methods with deep neural networks to model and identify vulnerability morphologies in grayscale images. Therefore, the convolutional neural network firmware vulnerability detection method in Embodiment 2 is not only based on deformable convolution but also on two key features: adaptive fusion attention feature enhancement.

[0108] The convolutional neural network (CNN) firmware vulnerability detection method in this embodiment 2 includes the following steps:

[0109] Convert the firmware binary files of power edge devices into firmware image datasets in a format that can be accepted by convolutional neural networks.

[0110] A firmware vulnerability detection model based on convolutional neural networks is adopted. The firmware image dataset is processed sequentially as follows: convolution + batch normalization + ReLU activation → adaptive attention feature calculation → deformable convolution calculation → pooling → fully connected → classification. The classification result is output to evaluate whether the firmware binary file is normal firmware or firmware containing vulnerabilities.

[0111] The firmware vulnerability detection method of this invention employs a firmware vulnerability detection model based on convolutional neural networks to identify the channel attention feature A of the convolutional feature map X obtained from the firmware binary file of the power edge device. channel Spatial attention feature A spatial By using a fully connected layer to compute dynamic fusion weights based on the calibrated global features, adaptive fusion of A is achieved. channel and A spatialThe weighted attention fusion features are obtained, and then multiplied element-wise with X to obtain enhanced attention fusion features before the classification results are processed.

[0112] Preprocessing of firmware binary files can employ traditional binary file conversion methods to process firmware data. For example, the conversion method for firmware image data may include the following steps: reading firmware data in bin format from the firmware binary file and parsing it in binary mode, requiring byte padding during the parsing process; subsequently, converting the parsed one-dimensional binary data into a two-dimensional matrix format; simultaneously, converting all firmware data in the two-dimensional matrix format into standardized grayscale images and uniformly adjusting them to a size of 1500×1500 pixels; finally, outputting a firmware image dataset of uniform specifications.

[0113] Before use, the firmware vulnerability detection model of this invention needs to be trained with training set data until the model is stable, and then the accuracy of the model is verified with test set data. For example, firmware files in bin format can be read from the "normal" firmware folder and the "vulnerable" firmware folder containing firmware binary files, respectively, and parsed in binary mode. The read firmware data is preprocessed, including byte padding to ensure data integrity, and the one-dimensional binary data is converted into a two-dimensional matrix format to meet the input requirements of the subsequent deep learning model. At the same time, to ensure the consistency of input data, all firmware data is converted into standardized grayscale images and adjusted to a uniform size of 1500×1500 pixels as model input samples. A portion of the model input samples is used as training set data, and the other portion is used as test set data.

[0114] The firmware vulnerability detection model may include an input layer, convolutional layers, batch normalization layers, ReLU activation layers, an attention mechanism module, pooling layers, fully connected layers, and a softmax layer (i.e., a classification layer). The input layer takes firmware images from a firmware image dataset as input. The attention mechanism module enhances the network's focus on features within the firmware images. The pooling layer uses 2x2 max pooling with a stride of 2. The fully connected layer maps the network's output to the classification result, and the classification layer is used for final classification. This invention employs an improved attention mechanism module to optimize the firmware vulnerability detection model, enabling the convolutional neural network to pay more attention to features in important regions during feature learning, resulting in an optimized firmware vulnerability detection model.

[0115] For adaptive attention feature calculation of the attention mechanism module in the firmware vulnerability detection model, please refer to [link / reference]. Figure 3 , Figure 2 This is a flowchart of the adaptive attention feature calculation method of the present invention. The adaptive attention feature calculation method includes the following steps:

[0116] Calculate channel attention features: Compress and expand the channel information of the convolutional feature map output by ReLU activation using two fully connected layers to obtain channel attention features;

[0117] Calculate spatial attention features: Extract spatial features from the convolutional feature map through 3×3 convolution, and calculate spatial attention weights by combining the bias term to obtain spatial attention features;

[0118] Calculate dynamic fusion weights: Calculate dynamic fusion weights using a fully connected layer on the labeled global features;

[0119] Based on the dynamic fusion weights, channel attention features and spatial attention features are fused to obtain weighted attention feature fusion feature A. adaptive The enhanced attention fusion feature map Z is obtained by multiplying the convolution feature map element by element and then using it for subsequent deformable convolution (the calculation of deformable convolution is as shown in Example 1, and will not be repeated in Example 2).

[0120] Therefore, this invention also improves the firmware vulnerability detection model based on convolutional neural networks. The improvement lies in adaptive attention feature calculation. The input to adaptive attention feature calculation is the convolutional feature map X, and the output is an enhanced attention fusion feature map Z. That is, the enhanced attention fusion feature map Z is obtained based on the convolutional feature map X output by ReLU activation. Please refer to [link to relevant documentation]. Figure 2 The improvement of the firmware vulnerability detection model based on convolutional neural networks lies specifically in: using the calibrated global features F global Dynamic fusion weights αdyn are computed using a single fully connected layer to adaptively fuse A. channel and A spatial Obtain weighted attention fusion feature A adaptive Then, the enhanced attention fusion feature map Z is obtained by multiplying it element-wise with X, and then the classification result is processed.

[0121]

[0122] α dyn =σ(W α ·F global +b α )

[0123] A adaptive =α dyn ·A channel +(1-α dyn )·A spatial

[0124] Z = X⊙A adaptive

[0125] Where H and W are the total length and total width in pixels of X, respectively; i1 and j represent the index values ​​from 1 to H and from 1 to W, respectively; X(i,j,c,n) is the feature of sample n in X at pixel position (i1,j) within channel c; σ(·) is the Sigmoid activation function; W α It is a fully connected weight matrix, b α It is W α The bias term.

[0126] Therefore, this invention sets parameters for an adaptive attention mechanism. The hyperparameters of the adaptive attention mechanism are initialized, including channel attention, spatial attention, PReLU activation layers, dynamic fusion weight calculation, and TD-Conv1D parameters. The channel attention part uses a two-layer fully connected structure for channel information compression and expansion, where Wc1 and bc1 are responsible for channel feature compression, and Wc2 and bc2 are responsible for channel feature expansion. The spatial attention part extracts spatial features through a 3×3 convolution (Ws) and calculates spatial attention weights by combining a bias term (bs). The PReLU activation function (alpha) further enhances the nonlinear expressive power of the model. Furthermore, a dynamic fusion mechanism is introduced, learning the optimal fusion method between channel attention and spatial attention through alpha_fc and beta_fc. To optimize the computational efficiency of channel attention, a TD-Conv1D structure is designed, where TDConvKernel serves as a one-dimensional convolution kernel for compressing channel information, while TDConvBias serves as a bias term to further adjust the channel feature representation.

[0127] Compared to traditional techniques (which employ a firmware vulnerability detection model based on convolutional neural networks to identify channel attention features A of the convolutional feature map X from the firmware binary file of power edge devices), this method utilizes a different approach. channel Spatial attention feature A spatial Compared to the previous method (which outputs a classification result after processing the attention fusion features obtained by fusion weight fusion), this invention, on the one hand, dynamically fuses channel attention features A channel Spatial attention feature A spatial This effectively improves the generalization ability of firmware vulnerability detection models based on convolutional neural networks. On the other hand, the weighted attention fusion feature A adaptive Element-wise multiplication with the convolutional feature map X yields an enhanced attention fusion feature map Z. TD-Conv1D is used to improve the expressive power of channel features and avoid information loss. Thirdly, the channel attention feature A... channel Spatial attention feature A spatialDerived from convolutional feature map X, and dynamically fused with it, it works synergistically with convolutional feature map X to effectively characterize key vulnerability features, achieving a lightweight spatial attention mechanism, improving detection efficiency, and adapting to edge devices. Therefore, this invention solves the technical problems of existing CNNs in firmware vulnerability detection, such as difficulty in simultaneously considering local and global features, inability to adapt to different vulnerability types, and inability to effectively characterize key vulnerability features.

[0128] Please see Figure 4 It is the channel attention feature A channel Flowchart of the calculation method, channel attention feature A channel The calculation method includes the following steps:

[0129] The convolutional feature map X is reshaped to flatten its spatial dimensions, forming a tensor of shape [L,C,N], where L represents the total spatial length, C is the number of channels, and N is the batch dimension.

[0130] Perform channel-wise 1D convolution on the tensor and use TD-Conv1D to compute the global features of each channel;

[0131] The channel attention feature A is obtained by computing the global features through two fully connected layers. channel .

[0132] In this embodiment, to enhance information interaction between channels, TD-Conv1D (temporal convolution) is introduced to replace the global average pooling (GAP) of the traditional attention mechanism, thus extracting channel features more accurately. First, the input is reshaped to flatten the spatial dimensions, forming a tensor X of shape [L,C,N]. reshape The specific formula is as follows:

[0133] X reshape =reshape(X,[L,C,N]) (1)

[0134] Where L represents the total spatial length, C is the number of channels, N is the batch dimension, and X is the convolutional feature map.

[0135] Subsequently, a channel-wise 1D convolution is performed, and TD-Conv1D is used to calculate the global features of each channel. The specific formula is as follows:

[0136]

[0137] Among them, X reshape (i,c) represents the feature at the c-th channel and the i-th spatial length of the tensor, K(i,c) represents the TD-Conv1D convolution kernel at the c-th channel and the i-th spatial length of the tensor, and B(c) is the bias term of K(i,c).

[0138] After obtaining the channel feature (channel_feature(c)), the channel attention A is calculated through two fully connected layers. channel The calculation formula is as follows:

[0139]

[0140] in and These are the weight matrices for channel compression and expansion, respectively; and is the corresponding bias term; PReLU is used as the activation function to introduce nonlinear features; σ(·) is the Sigmoid activation function.

[0141] Please see Figure 5 It is a spatial attention feature A spatial Flowchart of the computational method, spatial attention feature A spatial The calculation method includes the following steps:

[0142] Calculate global pooling features on the convolutional feature map, and perform channel average pooling to obtain channel average features;

[0143] Calculate the maximum value of each pixel in the channel dimension of the convolutional feature map, and perform channel max pooling to obtain the channel maximum feature.

[0144] The final spatial attention features are obtained by concatenating the channels using average pooling and maximum pooling.

[0145] In this embodiment, spatial attention is calculated as follows. To further enhance the model's ability to capture local spatial features, the spatial attention weights are calculated using the following method. First, the global pooling features are calculated, where the formula for calculating the channel average feature is as follows:

[0146]

[0147] Where C is the number of channels, spatial_avg(i,j,n) is the average channel feature of sample n at position (i,j) in all channels, and X(i,j,c,n) is the feature of sample n at position (i,j) in channel c in the convolutional feature map.

[0148] Channel max pooling calculates the maximum channel feature of each pixel along the channel dimension, and its calculation formula is as follows:

[0149]

[0150] Where spatial_max(i,j,n) is the maximum channel feature of sample n at position (i,j) across all channels.

[0151] After completing the calculations for channel average pooling and channel max pooling, in order to fully utilize the global statistical information of average pooling and the salient feature information of max pooling, the two are concatenated, and the final spatial attention input feature A is calculated according to the following formula. spatial The calculation formula is as follows:

[0152] A spatial =(σConv2D(conact(F)) avg, F max ),W s ,b s (6)

[0153] Where σ(·) is the Sigmoid activation function, contact(·) is the concatenation function, Conv2D(·) is the convolution function, and F avg It is spatial_avg(i,j,n), F max It is spatial_max(i,j,n), W s It is a 3×3 convolution kernel; b s It is W s The bias.

[0154] This invention uses the calibrated global feature F global The dynamic fusion weight α is calculated using a fully connected layer. dyn Adaptive fusion of A channel and A spatial Obtain weighted attention fusion feature A adaptive To enable the model to dynamically adjust the ratio of channel attention to spatial attention based on global features, this design employs global average pooling (GAP) to extract global features F. global The dynamic fusion weights are calculated through a learnable linear transformation. Global features F global It is the mean of the input feature X in the spatial dimension, defined as follows:

[0155]

[0156] Where H is the length of the convolutional feature map, W is the width of the convolutional feature map, i1 and j represent the index values ​​from 1 to H and from 1 to W respectively, and X(i,j,c,n) is the feature of sample n in the convolutional feature map at position (i,j) within channel c.

[0157] After obtaining the global feature F global Then, a fully connected layer is used to compute the dynamic fusion weight α using a single fully connected layer. dyn The calculation formula is as follows:

[0158] α dyn =σ(Wα ·F global +b α (8)

[0159] Where σ(·) is the Sigmoid activation function, α dyn W represents the dynamic fusion weights. α It is the fully connected weight matrix used in the dynamic fusion process, b α It is W α The bias term.

[0160] Complete the fusion weight α dyn After calculation, channel attention feature A is used. channel Spatial attention feature A spatial To calculate the final weighted attention fusion feature A adaptive The calculation formula is as follows:

[0161] A adaptive =α dyn ·A channel +(1-α dyn )·A spatial (9)

[0162] Among them, A channel For channel attention features, A spatial It is a spatial attention feature, α dyn This indicates the dynamic fusion weights.

[0163] The final weighted attention fusion feature A is obtained. adaptive Then, it is multiplied element-wise with the input feature X to obtain the enhanced attention fusion feature map Z, calculated as follows:

[0164] Z = X⊙A adaptive (10)

[0165] Example 3

[0166] This embodiment discloses a firmware vulnerability detection device based on convolutional neural networks, which includes a conversion module and a firmware vulnerability detection module. The conversion module is used to convert the firmware binary file of the power edge device into a firmware image dataset in a format that can be accepted by the convolutional neural network. The firmware vulnerability detection module is used to evaluate whether the firmware binary file of the power edge device is normal firmware or firmware containing vulnerabilities using a firmware vulnerability detection model based on convolutional neural networks.

[0167] The firmware vulnerability detection model includes: input layer → "convolution + batch normalization + ReLU activation" layer → adaptive attention calculation layer → deformable convolution layer → pooling layer → fully connected layer → classification layer. In this embodiment, the adaptive attention calculation layer is used to calculate the enhanced attention fusion feature map Z (as described in Embodiment 2) from the convolution feature map X output by the "convolution + batch normalization + ReLU activation" layer. The deformable convolution layer is used to perform deformable convolution on the enhanced attention fusion feature map Z to obtain the adaptive spatial representation map Z' (as described in Embodiment 1) and then perform pooling. The introduced deformable convolution calculation achieves dynamic sampling through offset learning, thereby enhancing the perception ability of structural irregularities and discrete local feature regions, and improving the vulnerability location accuracy.

[0168] The firmware vulnerability detection device based on convolutional neural networks in this embodiment has the following advantages:

[0169] 1. Introduce deformable convolutional structures to achieve dynamic sampling through offset learning;

[0170] 2. A channel-space attention fusion mechanism is proposed to achieve adaptive attention and dynamic weighting;

[0171] 3. Combining firmware image conversion methods with deep neural networks, we model and identify vulnerability patterns in grayscale images;

[0172] 4. A complete end-to-end network training process, which can realize the automation, accuracy and universality of firmware vulnerability detection tasks;

[0173] 5. An adaptive attention mechanism structure that integrates channel attention and spatial attention;

[0174] 6. The TD-Conv1D convolutional structure replaces the traditional GAP channel attention calculation method;

[0175] 7. A spatial attention mechanism combining channel average pooling and channel max pooling;

[0176] 8. Adaptively adjust the ratio of the two types of attention by dynamically fusing weights;

[0177] 9. Using the firmware binary-to-grayscale image as input, construct a CNN for classification and detection.

[0178] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0179] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these all fall within the protection scope of the present invention. Therefore, the protection scope of this invention patent should be determined by the appended claims.

Claims

1. A firmware vulnerability detection method based on deformable convolutional neural networks, which employs a firmware vulnerability detection model based on convolutional neural networks, inputting a preprocessed firmware binary file of a power edge device → convolution + batch normalization + ReLU activation → adaptive attention feature calculation → pooling → fully connected → classification and outputting the classification result: evaluating whether the firmware binary file is normal firmware or firmware containing vulnerabilities; characterized in that, After performing deformable convolution on the attention fusion feature map Z output by adaptive attention feature computation, the output adaptive spatial representation map Z' is pooled. Z'=W1·y all +b In the formula, W1 is the convolution kernel weight; b is the bias term of W1; y all Let y(p0) represent the complete feature map consisting of y(p0) corresponding to all center points P0; p0 is the center point sampled by the convolution of the attention fusion feature map Z in a sliding manner; y(p0) is the output value of the convolution at center point p0. R is a fixed convolutional sampling window for the attention fusion feature map Z, w(p n ) is the convolution kernel at position P n The weights, Z(p0+p n +Δp n ) is the position p0+p in the attention fusion feature map Z. n +Δp n The eigenvalue at Δp n Learnable offsets are added to the corresponding sampling positions.

2. The firmware vulnerability detection method based on deformable convolutional neural networks according to claim 1, characterized in that, Δp n Designed as follows: Δp n =W offset ·Z+b offset In the formula, W offset With b offset The convolution kernel and bias are learnable offsets.

3. The firmware vulnerability detection method based on deformable convolutional neural networks according to claim 1, characterized in that, Z(p0+p n +Δp n )for: In the formula, Υ(p+Δp) represents the four nearest integer points of the sampling point position p+Δp, and G(q,p0+p) represents the four nearest integer points of the sampling point position p. n +Δp n ) is the position p0+p of integer point q for non-integer sampling points. n +Δp n The contribution, q is the distance from the sampling point p0+p n +Δp n One of the four nearest integer points, Z(q) is the position p0+p in the attention fusion feature map Z at the distance from the sampling point. n +Δp n The eigenvalues ​​of the four most recent integer points.

4. The firmware vulnerability detection method based on deformable convolutional neural networks according to claim 3, characterized in that, G(q,p0+p n +Δp n )for: G(q,p0+p n +Δp n )=(1-|p x +Δp x -q x |)(1-|p y +Δp y -q y |) In the formula, P x P is the x-coordinate of the reference point p. y The ordinate of the reference point p, Δp x It is the component of the offset Δp on the horizontal axis, q x Δp is the x-coordinate of the integer point q. y It is the component of the offset Δp on the horizontal and vertical axes, q y It is the ordinate of the integer point q.

5. The firmware vulnerability detection method based on deformable convolutional neural networks according to claim 1, characterized in that, The adaptive attention feature is calculated as follows: based on the convolutional feature map X output by ReLU activation, the channel attention feature A is calculated. channel Spatial attention feature A spatial The attention fusion feature map Z is obtained based on the fusion weight fusion.

6. The firmware vulnerability detection method based on deformable convolutional neural networks according to claim 5, characterized in that, By calibrating the global feature F global The dynamic fusion weight α is calculated using a fully connected layer. dyn Adaptive fusion of A channel and A spatial Obtain weighted attention fusion feature A adaptive Then, perform element-wise multiplication with X to obtain the enhanced attention fusion feature map Z; a dyn =σ(W α ·F global +b α ) A adaptive =a dyn ·A channel +(1-a dyn )·A spatial Z=X⊙A adaptive Where H and W are the total length and total width in pixels of X, respectively; i1 and j represent the index values ​​from 1 to H and from 1 to W, respectively; X(i,j,c,n) is the feature of sample n in X at pixel position (i1,j) within channel c; σ(·) is the Sigmoid activation function; W α It is a fully connected weight matrix, b α It is W α The bias term.

7. The firmware vulnerability detection method based on deformable convolutional neural networks according to claim 5, characterized in that, Two fully connected layers are used to compress and expand the channel information of the convolutional feature map X to obtain the channel attention feature A. channel : The convolutional feature map X is reshaped to flatten its spatial dimensions, forming a tensor of shape [L,C,N], where L represents the total spatial length, C is the number of channels, and N is the batch dimension. Perform channel-wise 1D convolution on the tensor and use TD-Conv1D to compute the global features of each channel; The channel attention feature A is obtained by computing the global features through two fully connected layers. channel .

8. The firmware vulnerability detection method based on deformable convolutional neural networks according to claim 7, characterized in that, Tensor X reshape for: X reshape =reshape(X,[L,C,N]) (1) Where X is the convolutional feature map; The global feature of the c-th channel is: Among them, X reshape (i,c) represents the feature at the c-th channel and the i-th spatial length of the tensor, K(i,c) represents the TD-Conv1D convolution kernel at the c-th channel and the i-th spatial length of the tensor, and B(c) is the bias term of K(i,c). Channel attention feature A channel for: Where σ(·) is the Sigmoid activation function, and It is the weight matrix for channel compression and expansion. and It corresponds and The bias term, PReLU, is used as an activation function to introduce nonlinear features, F TD For channel_feature(c).

9. The firmware vulnerability detection method based on deformable convolutional neural networks according to claim 5, characterized in that, Spatial features of the convolutional feature map X are extracted using 3×3 convolution, and spatial attention weights are calculated by combining the bias term to obtain spatial attention features A. spatial : Calculate global pooling features on the convolutional feature map X, and perform channel average pooling to obtain channel average features; Calculate the maximum value of each pixel in the channel dimension of the convolutional feature map, and perform channel max pooling to obtain the channel maximum feature. The final spatial attention feature A is obtained by concatenating channel average pooling and channel max pooling. spatial .

10. The firmware vulnerability detection method based on deformable convolutional neural networks according to claim 9, characterized in that, The channel average characteristic is: Where C is the number of channels, spatial_avg(i,j,n) is the average channel feature of sample n at position (i,j) in all channels, and X(i,j,c,n) is the feature of sample n at position (i,j) in channel c in the convolutional feature map. The most prominent feature of a channel is: Where spatial_max(i,j,n) is the maximum channel feature of sample n at position (i,j) in all channels; Spatial attention feature A spatial for: A spatial =σ(Conv2D(conact(F avg, F max )),W s ,b s ) (6) Where σ(·) is the Sigmoid activation function, contact(·) is the concatenation function, Conv2D(·) is the convolution function, and F avg It is spatial_avg(i,j,n), F max It is spatial_max(i,j,n), W s It is a 3×3 convolution kernel; b s It is W s The bias.

Citation Information

Patent Citations

  • Target detection method based on deep learning

    CN110569782A

  • Road scene target detection method based on optimized network structure and mixed confidence

    CN114663847A

  • Metal plate surface defect detection method

    CN115587998A

  • Extra-high voltage converter transformer state monitoring method and system

    CN116680623A

  • Motor imagery electroencephalogram signal classification method

    CN117195049A