Android malware detection method based on small sample learning model

By employing a few-shot learning method using Wasserstein generative adversarial gradient penalty networks and stacked convolutional neural networks with multi-head soft self-attention models, the challenges of sample class imbalance and feature extraction in Android malware detection are solved, achieving efficient and accurate malware detection.

CN122113106APending Publication Date: 2026-05-29XIAN UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
XIAN UNIV OF TECH
Filing Date
2026-04-24
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing technologies for detecting Android malware rely on a large amount of sample data, which leads to problems such as imbalanced sample categories, single feature extraction, lack of contextual association for extremely long sequences, and high costs of manual feature engineering, resulting in a high false detection rate.

Method used

We employ a few-shot learning model approach, using a Wasserstein generative adversarial-gradient penalty network for data augmentation. This is combined with stacked convolutional neural networks and a multi-head soft self-attention model to automatically capture local and global feature dependencies, and then construct a dynamic logistic regression model for detection.

Benefits of technology

With limited sample data, we achieved efficient and accurate detection of Android malware, reduced the cost of manual feature engineering, alleviated the problem of sample class imbalance, and improved detection performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122113106A_ABST
    Figure CN122113106A_ABST
Patent Text Reader

Abstract

The application discloses an Android malicious program detection method based on a small sample learning model, and comprises the following steps: step 1, collecting initial sample data and performing preliminary preprocessing to obtain an original Dalvik operation code sequence of the initial sample data; step 2, performing Smali embedding representation on the original Dalvik operation code sequence of the initial sample data obtained in step 1; step 3, obtaining newly generated sample data; step 4, outputting a three-order fusion feature tensor with Android application malicious code semantic information; and step 5, providing a classification result of detecting whether an Android application is a malicious program. According to the method, the sample data enhancement is performed on the initial small sample data, the sample category imbalance problem is alleviated, and the problems of missing long sequence context association, high artificial feature engineering cost and high false detection rate are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer mobile security malicious code detection technology, specifically involving an Android malicious program detection method based on a few-shot learning model. Background Technology

[0002] Currently, mobile smart terminal technology has rapidly become widespread. The diversity of Android applications not only provides users with abundant resources but also makes them vulnerable to malicious attacks. Therefore, the ability to quickly and accurately detect Android malware plays a crucial role in mobile security. Since malware detection largely relies on large sample datasets, and these samples are collected and downloaded from different research teams or institutions, and the amount of labeled data for malicious samples is far less than that for benign samples, this poses a challenge to malware detection that depends on learning from a large number of samples.

[0003] With the significant advantages demonstrated by machine learning and deep learning technologies in areas such as few-shot learning, image recognition, and natural language processing, researchers are continuously exploring the application of machine learning or deep learning theories and techniques to the analysis and detection of malicious behavior in Android applications, particularly in the rapidly evolving field of mobile security detection. Yang W et al., in their paper *AppContext: differentiating malicious and benign mobile app behaviors using context*, directly applied the Support Vector Machine (SVM) algorithm to the control flow graph to train the model. They also considered creating program contexts from sensitive function calls and converting them into features to distinguish between malicious and benign programs. However, this method suffers from a significant drawback: it heavily relies on expert knowledge to design these features, increasing the cost of manual feature engineering. Xu Z et al., in their paper *CDGDroid: android malware detection based on deep learning using CFG and DFG*, proposed a deep learning model based on convolutional neural networks, using a semantic graph representation combining control flow graphs and data flow graphs for Android malware detection. Experimental results show that the aforementioned features improve malware detection accuracy and classification precision. However, the shortcomings of this method are: it is difficult to perform feature mining and learning without relying on a large number of samples, and it cannot rely on a single deep neural network (e.g., convolutional neural network or attention mechanism) to effectively represent the long-term dependencies of ultra-long sequences.

[0004] The Android malware detection process suffers from challenges such as over-reliance on large amounts of initial sample data, imbalanced sample categories, and limited feature extraction. Current research methods, which rely solely on domain knowledge or manually designed related features, may reduce the ability to learn from diverse sample features, failing to capture long-term dependent related features and parallel processing. This impacts the effectiveness of mining ultra-long-term contextual relationships of sequence semantic information and the performance of malicious behavior detection. This leads to problems such as missing contextual relationships in ultra-long sequences, high costs of manual feature engineering, and high false positive rates. Summary of the Invention

[0005] The purpose of this invention is to provide an Android malware detection method based on a few-shot learning model. By performing data augmentation on the initial small sample data, the method alleviates the problem of sample class imbalance and solves the problems of missing contextual associations in ultra-long sequences, high cost of manual feature engineering, and high false detection rate.

[0006] The technical solution adopted in this invention is: an Android malware detection method based on a few-shot learning model, comprising the following steps: Step 1: Collect initial sample data and perform preliminary preprocessing to obtain the original Dalvik opcode sequence of the initial sample data; Step 2: Perform Smali embedding representation on the original Dalvik opcode sequence of the initial sample data obtained in Step 1; Step 3: Obtain newly generated sample data; Step 4: Output a third-order fused feature tensor containing semantic information about malicious code in the Android application; Step 5: Provide the classification results for detecting whether an Android application is malicious.

[0007] The invention is further characterized in that: Step 1 is as follows: Download 500-1000 Android malicious and benign applications with the .apk extension from Androzoo, Drebin, and third-party Android app stores, and generate classification label codes (malicious applications are labeled '1', benign applications are labeled '0'). The Android malicious and benign applications and classification label codes serve as initial sample data. The initial sample data is decompiled using the Apktool tool, generating a series of .smali files for each sample. Each .smali file consists of a Dalvik opcode sequence (e.g., invoke-static, sget-objectaget-object iget). Redundancy is removed from consecutive, repetitive, meaningless .smali files with a similarity exceeding 85%, and common libraries implemented by Dalvik opcode sequences are deleted to remove interference from common libraries in the .smali files. Finally, preliminary preprocessing of the .smali files is performed to obtain the original Dalvik opcode sequence of the initial sample data.

[0008] Step 2 is as follows: Step 2.1: Learn dense embedding vectors from the original Dalvik opcode sequence of the initial sample data obtained in Step 1, using each .smali file after preliminary preprocessing as a word granularity, thereby capturing the semantic information of the Dalvik opcode sequence; Step 2.2: Perform Smali embedding representation using the hierarchical pooling method to obtain the initial Smali embedding vectors for highlighting important local Dalvik opcode sequences in the .smali file; In step 2, for the hierarchical pooling method, it is necessary to define an initial size of... sliding window The sliding window Apply the initial preset step size to the vector matrix to be reduced. (=2) Sliding; During each sliding operation, the values ​​within the current window are reduced by the mean, and finally, all the results of the mean reduction operation are reduced by the maximum. The sliding window allows the results of hierarchical pooling to retain more local spatial information. The hierarchical pooling size used in Smali embedding representation is expressed as: (1) In the formula, Indicates the size of the hierarchical pooling; Indicates in the domain The Middle A sequence of .smali files; Indicates the area Quantity; This indicates the selection parameter, which can take the value 0 or 1; Recording during forward propagation The value is then used to perform backpropagation based on the records; finally, the output is the initial sample data after Smali embedding representation, denoted as . Specifically, it is represented as the initial Smali embedding vector of the Dalvik opcode sequence highlighting important localities. ,here ; In step 3, the input layer includes the input to the generator network layer and the input to the discriminator network layer. The input to the generator network layer is Gaussian random noise, and the input to the discriminator network layer is the result calculated by weighted summation of the initial sample data after Smali embedding representation obtained in step 2 and the initial newly generated sample data output by the generator network layer. The generator network layer is the constructed generator network; the discriminator network layer is the constructed discriminator network; and the output layer outputs the newly generated sample data mapped from the trained generator network. After Gaussian random noise enters the generator network layer from the input layer, the generator network layer outputs the initial newly generated sample data. The initial newly generated sample data and the initial sample data after Smali embedding representation obtained in step 2 are weighted and summed to calculate the result value. This result value enters the discriminator network layer and outputs the gradient value of the intermediate interpolated sample data between the initial sample data after Smali embedding representation and the initial newly generated sample data. Then, the final objective functions of the generator network built in the generator network layer and the discriminator network built in the discriminator network layer are alternately optimized, and the network parameters of the two networks are updated to obtain the trained generator network. Finally, the output layer outputs the newly generated sample data mapped from the trained generator network.

[0009] Step 3 specifically involves: Step 3.1: Construct the generator network of the generator network layer and its final objective function. A gradient penalty term is introduced. In step 3.1, the generator network structure of the generator network layer is as follows: including a first input layer, a first fully connected layer, a first deflattened layer, a first deconvolutional layer, a first upsampling layer, a first normalization layer, a second deconvolutional layer, a second upsampling layer, a second normalization layer, a third deconvolutional layer, a third upsampling layer, a third normalization layer, a fourth deconvolutional layer, a fourth upsampling layer, a fourth normalization layer, and a first output layer; The parameters for each layer are as follows: the first fully connected layer takes 100 vectors as input and outputs 112,800 vectors; the feature map dimensions after reconstruction by the first deflating layer are (8, 47, 375, 64); the first deconvolutional layer has 64 input channels and 64 output channels; the second deconvolutional layer has 64 input channels and 32 output channels; the third deconvolutional layer has 32 input channels and 16 output channels; the kernel size of the first, second, and third deconvolutional layers is set to 4×4, and the stride is set to 2; the fourth... The deconvolutional layer has 16 input channels and 1 output channel; the kernel size of the fourth deconvolutional layer is set to 3×3 and the stride is set to 1; the first output layer has a single channel; the first, second, third, and fourth normalization layers all use the BN normalization function; the activation functions of the first fully connected layer, first deflattening layer, first deconvolutional layer, second deconvolutional layer, third deconvolutional layer, and fourth deconvolutional layer are LeakyReLU; the activation function of the first output layer is Tanh, and the output value is stabilized in the range of [-1, 1]; the first, second, third, and fourth upsampling layers all perform a 2x upsampling operation on their input feature layers; The generator network's first input layer takes Gaussian random noise as input, and its first output layer outputs a two-dimensional matrix representing the initial newly generated sample data, denoted as . ; The final objective function of the generator network Represented as: (2) In the formula, This represents the final objective function of the generator network; This represents the expected distribution of the initial newly generated sample data; This represents the expected distribution of the initial sample data after Smali embedding representation; The weight hyperparameters representing the gradient penalty term; Represents the gradient penalty term; Since it is difficult to directly compute the numerical space of the critical gradient in high dimensions, it is necessary to derive intermediate interpolated sample data from the initial sample data space to the newly generated sample data space. The intermediate interpolated sample data is represented as follows: (3) In the formula, This represents intermediate interpolated sample data; Represents a random parameter between [0, 1]; This represents the initial sample data after Smali embedding representation; This represents the initial newly generated sample data; Subsequently, a gradient penalty term is introduced to indirectly calculate the gradient value, thus establishing a correlation between the gradient and the cutoff threshold. The gradient penalty term is expressed as: (4) In the formula, Represents the gradient penalty term; Represented as The norm; Indicates the type of gradient norm; Indicates intermediate interpolated sample data The expected distribution; Indicates intermediate interpolated sample data The gradient operator; Step 3.2: Construct the discriminator network and its final objective function for the discriminator network layer. ; In step 3.2, the discriminator network structure of the discriminator network layer is as follows: including a first input layer, a first convolutional layer, a first downsampling layer, a first activation function layer, a second convolutional layer, a second downsampling layer, a second activation function layer, a third convolutional layer, a third downsampling layer, a third activation function layer, a first flattening layer, a first fully connected layer, and a first output layer; The parameters for each layer are as follows: the first convolutional layer has 1 input channel and 32 output channels; the second convolutional layer has 32 input channels and 64 output channels; the third convolutional layer has 64 input channels and 128 output channels; all convolutional layers use LeakyReLU as the activation function; the first flattening layer flattens the convolutional features, and the first fully connected layer outputs a Wasserstein score to measure the realism of the convolutional features, which is calculated to be 2,256,000; the first fully connected layer takes 2,256,000 vectors as input and outputs 1 vector; the first output layer has a single channel; all three downsampling layers (from the first to the third) perform a 2x downsampling operation on the spatial features extracted from their inputs. The first input layer of the discriminator network takes the weighted sum of the initial sample data after Smali embedding representation obtained in step 2 and the initial newly generated sample data obtained in step 3.1 as input. The first output layer outputs the gradient value of the intermediate interpolated sample data between the initial sample data after Smali embedding representation and the initial newly generated sample data. The final objective function of the discriminator network is expressed as: (5) In the formula, This represents the final objective function of the discriminator network; Step 3.3: Alternately optimize the final objective functions of the generator network built in the generator network layer and the discriminator network built in the discriminator network layer, update the network parameters of the two networks, and obtain the trained generator network; Step 3.4: By inputting Gaussian random noise into the generator network layer, and after training the constructed Wasserstein-based generative adversarial network with gradient penalty, a new generated sample data with a similar structure and form to the initial sample data represented by the Smali embedding is finally mapped from the generator network layer. Specifically, this is represented as the data-augmented Smali embedding vector. ,here ; Step 3.3 specifically involves: Step 3.3.1: Fix the generator network and update the discriminator network parameters k (=5) times; Specifically, in each round of training, the generator network parameters are kept unchanged, and the output of the discriminator network is calculated using the initial sample data after Smali embedding representation and the initial newly generated sample data respectively; the final objective function of the discriminator network is optimized by minimizing the Wasserstein distance and adding a gradient penalty term, and the parameters of each layer of the generator network are updated k (=5) times through backpropagation. Step 3.3.2: Fix the discriminator network and update the generator network parameters once; Specifically, after the discriminator network is updated, the discriminator network parameters are kept unchanged, and the final objective function of the generator network is optimized. The parameters of each layer of the generator network are updated once through backpropagation. Step 3.3.3: Determine whether the number of times the discriminator network parameters are updated has reached the set maximum number of iterations of 200,000, and whether the number of times the generator network parameters are updated has reached the calculated number of iterations of 40,000; if yes, the trained generator network is obtained; otherwise, return to step 3.3.1.

[0010] Step 4 is as follows: Step 4.1: Construct a stacked convolutional neural network; Stacked convolutional neural networks include: low-level convolutional neural networks and high-level convolutional neural networks; Step 4.1.1: The low-level convolutional neural network structure is as follows: input layer a, convolutional layer a, normalization layer a, average pooling layer a, dropout layer a, and output layer a.

[0011] The parameters for each layer are as follows: the number of input channels in the a-th convolutional layer is 1, the number of output channels is 64, the kernel size is set to 3×3, and the stride is set to 1; the activation function of the a-th convolutional layer is ReLU; the normalization layer uses BN normalization function; the pooling size of the a-th average pooling layer is 2×2; and the Dropout of the a-th Dropout layer is set to 0.3. The input of the a-th input layer of the low-level convolutional neural network is a sample data consisting of the newly generated sample data obtained in step 3 and the initial sample data after Smali embedding representation obtained in step 2, in a data volume ratio of 2:1. The sample data is used to generate a low-level embedding input matrix. A low-level sampling matrix is ​​obtained from the low-level embedding input matrix through random sampling. The low-level sampling matrix is ​​then used to obtain local features through K-means clustering. The local features and the low-level embedding input matrix are then fed into the a-th convolutional layer for convolution. The generated convolutional features are then fed into the a-th normalization layer and the a-th average pooling layer to obtain a low-level feature vector. The low-level feature vector is then fed into the a-th Dropout layer to obtain the processed low-level feature map matrix. The output of the a-th output layer of the low-level convolutional neural network is a low-level embedding output matrix with high-dimensional feature representation. Step 4.1.2: Input the low-level embedding output matrix from 4.1.1 into the high-level convolutional neural network. The high-level convolutional neural network structure is as follows: b-th input layer, b-th convolutional layer, b-th normalization layer, b-th max pooling layer, b-th dropout layer, and b-th output layer. The parameters for each layer are as follows: the b-th convolutional layer has 1 input channel, 64 output channels, a kernel size of 3×3, and a stride of 1; the b-th convolutional layer uses ReLU as its activation function; the b-th normalization layer uses BN as its normalization function; the b-th max pooling layer has a pooling size of 2×2; and the b-th Dropout layer has a Dropout value of 0.3. The input of the b-th input layer of the high-level convolutional neural network is the low-level embedding output matrix, which is the high-dimensional feature representation output in step 4.1.1. A high-level sampling matrix is ​​obtained from the low-level embedding output matrix through random sampling. The high-level sampling matrix is ​​then used to obtain local features through K-means clustering. These local features are then convolved with the high-level embedding input matrix in the b-th convolutional layer. The generated convolutional features are then fed into the b-th normalization layer and the b-th max pooling layer to obtain a high-level feature vector. The high-level feature vector is then fed into the b-th Dropout layer to obtain a dimensionality-reduced high-level feature map matrix. The output of the b-th output layer of the high-level convolutional neural network is the high-level embedding output matrix, which is the dimensionality-reduced local feature representation. Step 4.2: Fusing local and global feature representations in a stacked convolutional neural network towards a multi-head soft self-attention mechanism; Step 4.2 specifically involves: representing the high-level embedding output matrix from step 4.1 as a three-dimensional feature vector, and then combining the three-dimensional feature vector with the data-augmented Smali embedding vector. By performing pointwise vector addition, a new third-order feature sequence tensor is obtained. Third-order feature sequence tensor As input to the multi-head soft self-attention mechanism constructed in step 4.3, it provides a model for the global feature representation dependencies of the multi-head soft self-attention mechanism; Step 4.3: Construct a multi-head soft self-attention mechanism; In step 4.3: The third-order feature sequence tensor obtained in step 4.2 Entering a multi-headed soft self-attention mechanism; Step 4.3 specifically involves: Step 4.3.1: Construct a single-head soft self-attention mechanism; The multi-head soft self-attention mechanism is a custom-defined one. indivual( Values ,in Positive integers are preferred. The values ​​are 4~16) concatenated using a single-head soft self-attention mechanism. The third-order feature sequence tensor output from step 4.2 is then used. As input, through A set of independent linear transformation parameter matrices , and ,in( ), the third-order feature sequence tensor Mapped to different feature representation subspaces, generating the first... The first head corresponds to the query vectors , No. Key vectors and the Value vectors Then, the global features are softly and smoothly weighted using the softmax function to achieve direct association of nodes in ultra-long sequences by a single-head soft self-attention mechanism. The calculated result of the single-head soft self-attention mechanism is expressed as follows: (6) In the formula, This represents the calculated value for a single-head soft self-attention mechanism; each head The corresponding soft weight parameters are , , ; Indicates matrix transpose; Represents the dimension of the key vector; Among them, the The expression for the size is as follows: (7) In the formula, Indicates the first Size; parameter matrix , , ,here ; Parallel execution Sub-single-head soft self-attention computation. In each computation, a randomly initialized differential parameter matrix is ​​used. This makes different single heads It can simultaneously capture malicious code semantic information from different dimensions in the feature sequence.

[0012] Step 4.3.2: Concatenate multiple single-head soft self-attention mechanisms; right The results of each single-head soft self-attention calculation are linearly transformed to obtain the query vectors. Key vector Sum value vector Then Each independently computed single head By concatenating the feature dimensions, the resulting high-dimensional vector encompasses... Each feature represents the contextual information of the subspace. Subsequently, a global weight matrix is ​​introduced. Apply a linear aggregation mapping to the spliced ​​result. The linear aggregation mapping uses a dot product to... and Multiplication is performed to obtain the dependencies between the input opcodes. Scaling transformation and masking are then used to compress and restore the features of the dispersed feature representation subspace back to the original dimensional space, eliminating redundant information, resulting in the multi-head soft self-attention matrix, expressed as: (8) In the formula, This represents the values ​​of the multi-head soft self-attention matrix. Indicates the first Height to the The individual components are concatenated; parameter matrix ; Step 4.3.3: Construct residual connections; Repeat steps 4.1 and 4.2 to compute the multi-head soft self-attention matrix in parallel. Each time a single-head soft self-attention matrix is ​​calculated... , , Linear transformation parameters The results were all different. Then, the results of the parallel computation of the multi-head soft self-attention matrix were compared with the third-order feature sequence tensor. Performing residual connections yields a third-order fused feature tensor, denoted as: (9) In the formula, This represents the third-order fused feature tensor obtained after residual connection. This indicates normalization processing. Represents a third-order feature sequence tensor. Represents a residual join that represents element-wise addition; By constructing residual connections, the local spatial features extracted by stacked convolutional neural networks and the global logical features extracted by multi-head soft self-attention mechanisms are fused to establish semantic associations of ultra-long sequence contexts, obtain ultra-long sequence node representations, and output a third-order fused feature tensor with semantic information of Android application malicious code.

[0013] Step 5 specifically involves: Step 5.1: Construct a feedforward neural network; In step 5.1: The feedforward neural network structure includes an input layer, a dropout layer, a flattening layer, a fully connected layer, a fully connected layer, a fully connected layer, a fully connected layer, and an output layer.

[0014] The parameters for each layer are as follows: In the first Dropout layer, Dropout is set to 0.25, with L2 regularization; the first flattening layer takes a 3D tensor as input and outputs a 2D tensor; the first fully connected layer takes 64 vectors as input and outputs 64 vectors; the activation function of the first fully connected layer is Softsign; the second fully connected layer takes 64 vectors as input and outputs 8 vectors; the activation function of the second fully connected layer is ReLU; the third fully connected layer takes 8 vectors as input and outputs 1 vector; the activation function of the third fully connected layer is Sigmoid. The input of the first input layer of the feedforward neural network is the third-order fusion feature tensor with semantic information of malicious code of Android application output in step 4. It combines the third-order fusion feature tensor output in step 4 and the convolutional feature output in the b-th convolutional layer in step 4.1.2 to enter the first flattening layer to output a 2D tensor, and then enters the first fully connected layer, the second fully connected layer, and the third fully connected layer in sequence. The output of the first output layer of the feedforward neural network is the probability value of predicting the current classification label encoding as '1'. Step 5.2: Form a dynamic logistic regression model and its cost function; The dynamic logistic regression model uses the feedforward neural network constructed in step 5.1 as its basic architecture. Based on the weights and biases of the feedforward neural network constructed in step 5.1, it is dynamically optimized through backpropagation and gradient descent, continuously adjusting the parameters of each layer in the feedforward neural network. This enables the dynamic logistic regression model to adaptively learn patterns and relationships in the sample data, thus achieving dynamic logistic regression. The structure of the dynamic logistic regression model is as follows: it includes an A-th input layer, an A-th hidden layer, and an A-th output layer. The parameters for each layer are as follows: the number of layers in the A-th hidden layer is expanded to 2; the activation function of the A-th hidden layer is Softsign; the activation function of the A-th output layer is Sigmoid. Wherein, the input of the Ath input layer is the input of the feedforward neural network constructed in step 5.1, and the output of the Ath output layer is the probability value of predicting the current classification label as '1'; The probability values ​​output by the dynamic logistic regression model are expressed as follows: (10) In the formula, This represents the probability value output by the dynamic logistic regression model; Represented by natural constant An exponential function with base 0; This is represented as the hidden layer state, i.e., the dynamic logistic regression model as the input to the binary classifier; and These represent the weights and biases of the dynamic logistic regression model, respectively. in, (11) In the formula, Indicates the hidden layer state output; This represents the activation function of the hidden layer, with an output range of (-1, 1); Indicates the first Layer weight matrix; This represents the output of the multi-head soft self-attention mechanism; Indicates the first Layer bias vector; Then the value vector The data is fed into the constructed feedforward neural network to obtain a confidence label for whether the classification result is malicious. The confidence label is represented as follows: (12) In the formula, A confidence label indicating whether an Android application is malicious; Indicates the category label of the sample data; This indicates the confidence level of whether an Android application is malicious. This represents the value of the independent variable that makes the predicted probability distribution function reach its maximum value; This represents the probability value output by the dynamic logistic regression model; The cost function of the dynamic logistic regression model is expressed as: (13) In the formula, This represents the cost function value of the dynamic logistic regression model; Represents the parameter vector of the dynamic logistic regression model; Indicates the number of categories; Indicates the L2 regularization parameter; This represents the square of the Frobenius norm of the parameter matrix; Step 5.3: Input the third-order fusion feature tensor containing semantic information of malicious code in Android applications into the trained dynamic logistic regression model. Through backpropagation calculation and gradient descent optimization of the dynamic logistic regression model, output the classification label encoding result of whether the Android application to be detected is a malicious program.

[0015] The beneficial effects of this invention are: (1) The method of this invention enhances sample data by using a Wasserstein generative adversarial-gradient penalty network without relying on any temporal information and only relying on a small amount of initial sample data. The constructed Wasserstein generative adversarial-gradient penalty network solves the problems of training oscillation and mode collapse in traditional GAN ​​networks, and generates high-quality new sample data that is similar in form to the initial sample data and is grammatically compliant and semantically realistic. The new sample data not only ensures the global rich and important Smali embedding representation and the sequence dependency association between upper-layer models, but also enhances the stability of network training and the quality of generated samples.

[0016] (2) The method of this invention automatically captures the local feature dependencies between adjacent Smali embedding sequences and the global feature dependencies between ultra-long Smali embedding sequences by fusing stacked convolutional neural networks and multi-head soft self-attention models, thus achieving parallel computation of sequences. The method of this invention requires no manual feature engineering throughout the process, saving labor costs. Comparison with the Android malware detection model with the same sample size without data augmentation verifies that the method of this invention has strong feature extraction capabilities, global semantic understanding, and computational efficiency, providing a more efficient and accurate learning model for Android malware detection.

[0017] (3) To address the shortcomings of existing Android malicious application detection methods, the method of this invention is based on a Wasserstein generative adversarial-gradient penalty network and a fusion of stacked convolutional neural networks and a multi-head soft self-attention model for few-shot learning of Android malicious applications. By reducing redundant assembly sequences and performing word-granular embedding encoding on the original .smali files, it extracts complex and diverse features without relying on a large amount of initial sample data, obtaining rich and important Smali embedding representations of subsequences. Data augmentation is performed on the initial small amount of sample data to alleviate the problem of sample class imbalance, and to solve the problems of missing contextual associations in ultra-long sequences, high cost of manual feature engineering, and high false detection rate. The Android malicious application detection method proposed in this invention can effectively classify and detect the Android applications to be detected. Attached Figure Description

[0018] Figure 1 This is a flowchart of the Android malware detection method based on a few-shot learning model according to the present invention; Figure 2 This is the hierarchical pooling process of Smali embedding representation in the method of this invention; Figure 3 The method of this invention is based on Wasserstein to generate an adversarial-gradient penalty network structure; Figure 4 yes Figure 3 Gaussian random noise is used as input; Figure 5 This is the generator network structure in the method of this invention; Figure 6 This is the discriminator network structure in the method of this invention; Figure 7 This refers to the low-level convolutional neural network structure in the method of this invention; Figure 8 This refers to the high-level convolutional neural network structure in the method of this invention; Figure 9 This is the feedforward neural network structure in the method of this invention. Detailed Implementation

[0019] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments.

[0020] This invention provides an Android malware detection method based on a few-shot learning model, referring to... Figure 1Specifically, the process involves: First, using the Smali embedding representations of .smali files (after filtering public libraries) as input to a few-shot learning model. Then, data augmentation is performed by constructing a Wasserstein-based generative adversarial network with gradient penalty to generate new sample data. Next, a long sequence of nodes containing semantic information about malicious code in Android applications is obtained by constructing a fusion of stacked convolutional neural networks and a multi-head soft self-attention model, forming a dynamic logistic regression model. Finally, the Android application classification and detection results are generated. The specific implementation includes the following steps: Step 1: Collect initial sample data and perform preliminary preprocessing to obtain the original Dalvik opcode sequence of the initial sample data; Step 1 is as follows: Download 500-1000 Android malicious and benign applications with the .apk extension from Androzoo, Drebin, and third-party Android app stores, and generate classification label codes (malicious applications are labeled '1', benign applications are labeled '0'). The Android malicious and benign applications and classification label codes serve as initial sample data. The initial sample data is decompiled using the Apktool tool, generating a series of .smali files for each sample. Each .smali file consists of a Dalvik opcode sequence (e.g., invoke-static, sget-objectaget-object iget). Redundancy is removed from consecutive, repetitive, meaningless .smali files with a similarity exceeding 85%, and common libraries implemented by Dalvik opcode sequences are deleted to remove interference from common libraries in the .smali files. Finally, preliminary preprocessing of the .smali files is performed to obtain the original Dalvik opcode sequence of the initial sample data.

[0021] Step 2: Perform Smali embedding representation on the original Dalvik opcode sequence of the initial sample data obtained in Step 1; Step 2 is as follows: Step 2.1: Learn dense embedding vectors from the original Dalvik opcode sequence of the initial sample data obtained in Step 1, using each .smali file after preliminary preprocessing as a word granularity, thereby capturing the semantic information of the Dalvik opcode sequence; Step 2.2: Perform Smali embedding representation using the hierarchical pooling method to obtain the initial Smali embedding vectors for highlighting important local Dalvik opcode sequences in the .smali file; In step 2, for the hierarchical pooling method (refer to...) Figure 2 It is necessary to define an initial size of ), sliding window The sliding window Apply the initial preset step size to the vector matrix to be reduced. (=2) Sliding; During each sliding operation, the values ​​within the current window are reduced by the mean, and finally, all the results of the mean reduction operation are reduced by the maximum. The sliding window allows the results of hierarchical pooling to retain more local spatial information. The hierarchical pooling size used in Smali embedding representation is expressed as: (1) In the formula, Indicates the size of the hierarchical pooling; Indicates in the domain The Middle A sequence of .smali files; Indicates the area Quantity; This indicates the selection parameter, which can take the value 0 or 1; Recording during forward propagation The value is then used to perform backpropagation based on the records; finally, the output is the initial sample data after Smali embedding representation, denoted as . Specifically, it is represented as the initial Smali embedding vector of the Dalvik opcode sequence highlighting important localities. ,here ; Step 3: Input the initial sample data after Smali embedding representation obtained in Step 2 into the constructed Wasserstein-based generative adversarial-gradient penalty network for training to obtain newly generated sample data; Reference Figures 3-4 As shown, a Wasserstein generative adversarial network with gradient penalty is constructed, which includes an input layer, a generator network layer, a discriminator network layer, and an output layer.

[0022] In step 3, the input layer includes the input to the generator network layer and the input to the discriminator network layer. The input to the generator network layer is Gaussian random noise, and the input to the discriminator network layer is the result calculated by weighted summation of the initial sample data after Smali embedding representation obtained in step 2 and the initial newly generated sample data output by the generator network layer. The generator network layer is the constructed generator network; the discriminator network layer is the constructed discriminator network; and the output layer outputs the newly generated sample data mapped from the trained generator network. After Gaussian random noise enters the generator network layer from the input layer, the generator network layer outputs the initial newly generated sample data. The initial newly generated sample data and the initial sample data after Smali embedding representation obtained in step 2 are weighted and summed to calculate the result value. This result value enters the discriminator network layer and outputs the gradient value of the intermediate interpolated sample data between the initial sample data after Smali embedding representation and the initial newly generated sample data. Then, the final objective functions of the generator network built in the generator network layer and the discriminator network built in the discriminator network layer are alternately optimized, and the network parameters of the two networks are updated to obtain the trained generator network. Finally, the output layer outputs the newly generated sample data mapped from the trained generator network. Step 3 specifically involves: Step 3.1: Construct the generator network of the generator network layer and its final objective function. A gradient penalty term is introduced. In step 3.1, the generator network structure of the generator network layer is as follows: Figure 5 As shown, its specific structure includes: a first input layer, a first fully connected layer, a first deflattening layer, a first deconvolution layer, a first upsampling layer, a first normalization layer, a second deconvolution layer, a second upsampling layer, a second normalization layer, a third deconvolution layer, a third upsampling layer, a third normalization layer, a fourth deconvolution layer, a fourth upsampling layer, a fourth normalization layer, and a first output layer; The parameters for each layer are as follows: the first fully connected layer takes 100 vectors as input and outputs 112,800 vectors; the feature map dimensions after reconstruction by the first deflating layer are (8, 47, 375, 64); the first deconvolutional layer has 64 input channels and 64 output channels; the second deconvolutional layer has 64 input channels and 32 output channels; the third deconvolutional layer has 32 input channels and 16 output channels; the kernel size of the first, second, and third deconvolutional layers is set to 4×4, and the stride is set to 2; the fourth... The deconvolutional layer has 16 input channels and 1 output channel; the kernel size of the fourth deconvolutional layer is set to 3×3 and the stride is set to 1; the first output layer has a single channel; the first, second, third, and fourth normalization layers all use the BN normalization function; the activation functions of the first fully connected layer, first deflattening layer, first deconvolutional layer, second deconvolutional layer, third deconvolutional layer, and fourth deconvolutional layer are LeakyReLU; the activation function of the first output layer is Tanh, and the output value is stabilized in the range of [-1, 1]; the first, second, third, and fourth upsampling layers all perform a 2x upsampling operation on their input feature layers; The generator network's first input layer takes Gaussian random noise as input, and its first output layer outputs a two-dimensional matrix representing the initial newly generated sample data, denoted as . ; The final objective function of the generator network Represented as: (2) In the formula, This represents the final objective function of the generator network; This represents the expected distribution of the initial newly generated sample data; This represents the expected distribution of the initial sample data after Smali embedding representation; The weight hyperparameters representing the gradient penalty term; Represents the gradient penalty term; Since it is difficult to directly compute the numerical space of the critical gradient in high dimensions, it is necessary to derive intermediate interpolated sample data from the initial sample data space to the newly generated sample data space. The intermediate interpolated sample data is represented as follows: (3) In the formula, This represents intermediate interpolated sample data; Represents a random parameter between [0, 1]; This represents the initial sample data after Smali embedding representation; This represents the initial newly generated sample data; Subsequently, a gradient penalty term is introduced to indirectly calculate the gradient value, thus establishing a correlation between the gradient and the cutoff threshold. The gradient penalty term is expressed as: (4) In the formula, Represents the gradient penalty term; Represented as The norm; Indicates the type of gradient norm; Indicates intermediate interpolated sample data The expected distribution; Indicates intermediate interpolated sample data The gradient operator; Step 3.2: Construct the discriminator network and its final objective function for the discriminator network layer. ; In step 3.2, the discriminator network structure of the discriminator network layer is as follows: Figure 6 As shown, its specific structure includes: a first input layer, a first convolutional layer, a first downsampling layer, a first activation function layer, a second convolutional layer, a second downsampling layer, a second activation function layer, a third convolutional layer, a third downsampling layer, a third activation function layer, a first flattening layer, a first fully connected layer, and a first output layer. The parameters for each layer are as follows: the first convolutional layer has 1 input channel and 32 output channels; the second convolutional layer has 32 input channels and 64 output channels; the third convolutional layer has 64 input channels and 128 output channels; all convolutional layers use LeakyReLU as the activation function; the first flattening layer flattens the convolutional features, and the first fully connected layer outputs a Wasserstein score to measure the realism of the convolutional features, which is calculated to be 2,256,000; the first fully connected layer takes 2,256,000 vectors as input and outputs 1 vector; the first output layer has a single channel; the first downsampling layer to the third downsampling layer all perform a 2x downsampling operation on the spatial features extracted from their inputs; The first input layer of the discriminator network takes the weighted sum of the initial sample data after Smali embedding representation obtained in step 2 and the initial newly generated sample data obtained in step 3.1 as input. The first output layer outputs the gradient value of the intermediate interpolated sample data between the initial sample data after Smali embedding representation and the initial newly generated sample data. The final objective function of the discriminator network is expressed as: (5) In the formula, This represents the final objective function of the discriminator network; Step 3.3: Alternately optimize the final objective functions of the generator network built in the generator network layer and the discriminator network built in the discriminator network layer, update the network parameters of the two networks, and obtain the trained generator network; Step 3.3 specifically involves: Step 3.3.1: Fix the generator network and update the discriminator network parameters k (=5) times; Specifically, in each round of training, the generator network parameters are kept unchanged, and the output of the discriminator network is calculated using the initial sample data after Smali embedding representation and the initial newly generated sample data respectively; the final objective function of the discriminator network is optimized by minimizing the Wasserstein distance and adding a gradient penalty term, and the parameters of each layer of the generator network are updated k (=5) times through backpropagation. Step 3.3.2: Fix the discriminator network and update the generator network parameters once; Specifically, after the discriminator network is updated, the discriminator network parameters are kept unchanged, and the final objective function of the generator network is optimized. The parameters of each layer of the generator network are updated once through backpropagation. Step 3.3.3: Determine whether the number of times the discriminator network parameters are updated has reached the set maximum number of iterations of 200,000, and whether the number of times the generator network parameters are updated has reached the calculated number of iterations of 40,000; if yes, the trained generator network is obtained; otherwise, return to step 3.3.1.

[0023] Step 3.4: By inputting Gaussian random noise into the generator network layer, and after training the constructed Wasserstein-based generative adversarial network with gradient penalty, a new generated sample data with a similar structure and form to the initial sample data represented by the Smali embedding is finally mapped from the generator network layer. Specifically, this is represented as the data-augmented Smali embedding vector. ,here ; Step 4: Input the newly generated sample data obtained in Step 3 and the initial sample data after Smali embedding representation obtained in Step 2 into the constructed fusion stacked convolutional neural network and multi-head soft self-attention model with a data volume ratio of 2:1 to obtain the ultra-long sequence node representation with semantic information of Android application malicious code, and output the third-order fusion feature tensor with semantic information of Android application malicious code. Step 4 specifically involves: Step 4.1: Construct a stacked convolutional neural network; Stacked convolutional neural networks include: low-level convolutional neural networks and high-level convolutional neural networks; Step 4.1.1: Refer to Figure 7 The low-level convolutional neural network structure is as follows: input layer a, convolutional layer a, normalization layer a, average pooling layer a, dropout layer a, and output layer a.

[0024] The parameters for each layer are as follows: the number of input channels in the a-th convolutional layer is 1, the number of output channels is 64, the kernel size is set to 3×3, and the stride is set to 1; the activation function of the a-th convolutional layer is ReLU; the normalization layer uses BN normalization function; the pooling size of the a-th average pooling layer is 2×2; and the Dropout of the a-th Dropout layer is set to 0.3. The input of the a-th input layer of the low-level convolutional neural network is a sample data consisting of the newly generated sample data obtained in step 3 and the initial sample data after Smali embedding representation obtained in step 2, in a data volume ratio of 2:1. The sample data is used to generate a low-level embedding input matrix. A low-level sampling matrix is ​​obtained from the low-level embedding input matrix through random sampling. The low-level sampling matrix is ​​then used to obtain local features through K-means clustering. The local features and the low-level embedding input matrix are then fed into the a-th convolutional layer for convolution. The generated convolutional features are then fed into the a-th normalization layer and the a-th average pooling layer to obtain a low-level feature vector. The low-level feature vector is then fed into the a-th Dropout layer to obtain the processed low-level feature map matrix. The output of the a-th output layer of the low-level convolutional neural network is a low-level embedding output matrix with high-dimensional feature representation. Step 4.1.2: Input the low-level embedding output matrix from 4.1.1 into the high-level convolutional neural network, referring to... Figure 8 The high-level convolutional neural network structure is as follows: b-th input layer, b-th convolutional layer, b-th normalization layer, b-th max pooling layer, b-th dropout layer, and b-th output layer. The parameters for each layer are as follows: the b-th convolutional layer has 1 input channel, 64 output channels, a kernel size of 3×3, and a stride of 1; the b-th convolutional layer uses ReLU as its activation function; the b-th normalization layer uses BN as its normalization function; the b-th max pooling layer has a pooling size of 2×2; and the b-th Dropout layer has a Dropout value of 0.3. The input of the b-th input layer of the high-level convolutional neural network is the low-level embedding output matrix, which is the high-dimensional feature representation output in step 4.1.1. A high-level sampling matrix is ​​obtained from the low-level embedding output matrix through random sampling. The high-level sampling matrix is ​​then used to obtain local features through K-means clustering. These local features are then convolved with the high-level embedding input matrix in the b-th convolutional layer. The generated convolutional features are then fed into the b-th normalization layer and the b-th max pooling layer to obtain a high-level feature vector. The high-level feature vector is then fed into the b-th Dropout layer to obtain a dimensionality-reduced high-level feature map matrix. The output of the b-th output layer of the high-level convolutional neural network is the high-level embedding output matrix, which is the dimensionality-reduced local feature representation. Step 4.2: Fusing local and global feature representations in a stacked convolutional neural network towards a multi-head soft self-attention mechanism; Step 4.2 specifically involves: representing the high-level embedding output matrix from step 4.1 as a three-dimensional feature vector, and combining the three-dimensional feature vector with the data-augmented Smali embedding vector. By performing pointwise vector addition, a new third-order feature sequence tensor is obtained. Third-order feature sequence tensor As input to the multi-head soft self-attention mechanism constructed in step 4.3, it provides a model for the global feature representation dependencies of the multi-head soft self-attention mechanism; Step 4.3: Construct a multi-head soft self-attention mechanism; In step 4.3: The third-order feature sequence tensor obtained in step 4.2 Entering a multi-headed soft self-attention mechanism; Step 4.3 specifically involves: Step 4.3.1: Construct a single-head soft self-attention mechanism; The multi-head soft self-attention mechanism is a custom-defined one. indivual( Values ,in Positive integers are preferred. The values ​​are 4~16) concatenated using a single-head soft self-attention mechanism. The third-order feature sequence tensor output from step 4.2 is then used. As input, through A set of independent linear transformation parameter matrices , and ,in( ), the third-order feature sequence tensor Mapped to different feature representation subspaces, generating the first... The first head corresponds to the query vectors , No. Key vectors and the Value vectors Then, the Softmax function is used to perform soft-smooth weighted calculation on the global features, realizing the direct association of nodes in the ultra-long sequence by the single-head soft self-attention mechanism. The calculated result of the single-head soft self-attention mechanism is expressed as follows: (6) In the formula, This represents the calculated value for a single-head soft self-attention mechanism; each head The corresponding soft weight parameters are , , ; Indicates matrix transpose; Represents the dimension of the key vector; Among them, the The expression for the size is as follows: (7) In the formula, Indicates the first Size; parameter matrix , , ,here ; Parallel execution Sub-single-head soft self-attention computation. In each computation, a randomly initialized differential parameter matrix is ​​used. This makes different single heads It can simultaneously capture malicious code semantic information from different dimensions in the feature sequence.

[0025] Step 4.3.2: Concatenate multiple single-head soft self-attention mechanisms; right The results of each single-head soft self-attention calculation are linearly transformed to obtain the query vectors. Key vector Sum value vector Then Each independently computed single head By concatenating the feature dimensions, the resulting high-dimensional vector encompasses... Each feature represents the contextual information of the subspace. Subsequently, a global weight matrix is ​​introduced. Apply a linear aggregation mapping to the spliced ​​result. The linear aggregation mapping uses a dot product to... and Multiplication is performed to obtain the dependencies between the input opcodes. Scaling transformation and masking are then used to compress and restore the features of the dispersed feature representation subspace back to the original dimensional space, eliminating redundant information, resulting in the multi-head soft self-attention matrix, expressed as: (8) in, This represents the values ​​of the multi-head soft self-attention matrix. Indicates the first Height to the The individual components are concatenated; parameter matrix ; Step 4.3.3: Construct residual connections; Repeat steps 4.1 and 4.2 to compute the multi-head soft self-attention matrix in parallel. Each time a single-head soft self-attention matrix is ​​calculated... , , Linear transformation parameters The results were all different. Then, the results of the parallel computation of the multi-head soft self-attention matrix were compared with the third-order feature sequence tensor. Performing residual connections yields a third-order fused feature tensor, denoted as: (9) In the formula, This represents the third-order fused feature tensor obtained after residual connection. This indicates normalization processing. Represents a third-order feature sequence tensor. Represents a residual join that represents element-wise addition; By constructing residual connections, the local spatial features extracted by stacked convolutional neural networks and the global logical features extracted by multi-head soft self-attention mechanisms are fused to establish semantic associations of ultra-long sequence contexts, obtain ultra-long sequence node representations, and output a third-order fused feature tensor with semantic information of Android application malicious code.

[0026] Step 5: Input the third-order fusion feature tensor with semantic information of malicious code in Android application output from Step 4 into the feedforward neural network to form a dynamic logistic regression model. The dynamic logistic regression model serves as a binary classifier to provide classification results for detecting whether an Android application is malicious. Step 5.1: Construct a feedforward neural network; In step 5.1: refer to Figure 9 The feedforward neural network structure includes an input layer, a dropout layer, a flattening layer, a fully connected layer, a fully connected layer, a fully connected layer, a fully connected layer, and an output layer.

[0027] The parameters for each layer are as follows: In the first Dropout layer, Dropout is set to 0.25, with L2 regularization; the first flattening layer takes a 3D tensor as input and outputs a 2D tensor; the first fully connected layer takes 64 vectors as input and outputs 64 vectors; the activation function of the first fully connected layer is Softsign; the second fully connected layer takes 64 vectors as input and outputs 8 vectors; the activation function of the second fully connected layer is ReLU; the third fully connected layer takes 8 vectors as input and outputs 1 vector; the activation function of the third fully connected layer is Sigmoid. The input of the first input layer of the feedforward neural network is the third-order fusion feature tensor with semantic information of malicious code of Android application output in step 4. It combines the third-order fusion feature tensor output in step 4 and the convolutional feature output in the b-th convolutional layer in step 4.1.2 to enter the first flattening layer to output a 2D tensor, and then enters the first fully connected layer, the second fully connected layer, and the third fully connected layer in sequence. The output of the first output layer of the feedforward neural network is the probability value of predicting the current classification label encoding as '1'. Step 5.2: Form a dynamic logistic regression model and its cost function; The dynamic logistic regression model uses the feedforward neural network constructed in step 5.1 as its basic architecture. Based on the weights and biases of the feedforward neural network constructed in step 5.1, it is dynamically optimized through backpropagation and gradient descent, continuously adjusting the parameters of each layer in the feedforward neural network. This enables the dynamic logistic regression model to adaptively learn patterns and relationships in the sample data, thus achieving dynamic logistic regression. The structure of the dynamic logistic regression model is as follows: it includes an A-th input layer, an A-th hidden layer, and an A-th output layer. The parameters for each layer are as follows: the number of layers in the A-th hidden layer is expanded to 2; the activation function of the A-th hidden layer is Softsign; the activation function of the A-th output layer is Sigmoid. Wherein, the input of the Ath input layer is the input of the feedforward neural network constructed in step 5.1, and the output of the Ath output layer is the probability value of predicting the current classification label as '1'; The probability values ​​output by the dynamic logistic regression model are expressed as follows: (10) In the formula, This represents the probability value output by the dynamic logistic regression model; Represented by natural constant An exponential function with base 0; This is represented as the hidden layer state, i.e., the dynamic logistic regression model as the input to the binary classifier; and These represent the weights and biases of the dynamic logistic regression model, respectively. in, (11) In the formula, Indicates the hidden layer state output; This represents the activation function of the hidden layer, with an output range of (-1, 1); Indicates the first Layer weight matrix; This represents the output of the multi-head soft self-attention mechanism; Indicates the first Layer bias vector; Then the value vector The data is fed into the constructed feedforward neural network to obtain a confidence label for whether the classification result is malicious. The confidence label is represented as follows: (12) In the formula, A confidence label indicating whether an Android application is malicious; Indicates the category label of the sample data; This indicates the confidence level of whether an Android application is malicious. This represents the value of the independent variable that makes the predicted probability distribution function reach its maximum value; This represents the probability value output by the dynamic logistic regression model; The cost function of the dynamic logistic regression model is expressed as: (13) In the formula, This represents the cost function value of the dynamic logistic regression model; Represents the parameter vector of the dynamic logistic regression model; Indicates the number of categories; Indicates the L2 regularization parameter; This represents the square of the Frobenius norm of the parameter matrix; Step 5.3: Input the third-order fusion feature tensor containing semantic information of malicious code in Android applications into the trained dynamic logistic regression model. Through backpropagation calculation and gradient descent optimization of the dynamic logistic regression model, output the classification label encoding result of whether the Android application to be detected is a malicious program.

[0028] Example 1 The experimental effects of the present invention will be further explained below in conjunction with evaluation experiments.

[0029] 1. Evaluate the experimental environment: The hardware environment for the evaluation experiment was: an Intel Core i7-9700 CPU, an NVIDIA GTX1660Ti GPU, and 64GB of RAM.

[0030] The software environment for the evaluation experiment was: Anaconda3 2019.03, CUDA 10.1, cuDNN V7.6, Python 3.7.3, and the deep learning framework Tensorflow 2.2.

[0031] Evaluation of the experimental sample dataset: The initial sample dataset size was 600 samples, and the sizes after data augmentation were 5560 and 25670 samples, respectively. 80% of the sample dataset was selected as the training set, and the remaining 20% ​​was selected as the test set. Validation was performed using a 10-fold cross-validation method.

[0032] The model metrics are: accuracy, classification precision, recall, F1 score, and false positive rate.

[0033] 1) Accuracy: This measures the overall classification accuracy. The higher the value, the better the classification effect. It is expressed as: (14) in, Indicates accuracy; The true class represents the number of Android malicious applications that have been classified as malicious. This represents the true negative class, which is the number of Android benign applications that are classified as benign. This indicates the number of pseudo-positive Android applications that were classified as malicious. This represents the number of pseudo-negative classes, which is the number of Android malicious applications that are classified as benign.

[0034] 2) Classification accuracy: The proportion of all samples marked as Android malicious applications that are actually Android malicious applications, expressed as: (15) in, Indicates the classification accuracy.

[0035] 3) Recall rate: The proportion of identified malicious Android applications out of the actual number of malicious Android applications, expressed as: (16) in, This indicates the recall rate.

[0036] 4) F1 score: the harmonic mean of classification precision and recall. The score ranges from 0 to 1, with values ​​closer to 1 indicating better model performance, expressed as: (17) Where F1 represents the F1 score.

[0037] 5) False Detection Rate: The proportion of identified benign Android applications out of actual malicious Android applications, expressed as: (18) in, This indicates the false positive rate.

[0038] 2. Evaluation of experimental content and result analysis: Evaluation Experiment 1: The test set was tested using existing pre-trained data augmentation strategies, data preprocessing methods, standard stacked convolutional neural networks (DCNNs) with the same initial and augmented sample data sizes, and the method of this invention. The accuracy, recall, classification precision, F1 score, and false positive rate were calculated respectively.

[0039] Table 1. Experimental comparison results between standard stacked convolutional neural networks and the present invention.

[0040] As can be seen from Table 1, the accuracy, recall, classification precision, and F1 score of the present invention are all higher, and the false detection rate is reduced by 3.85% compared with the standard stacked convolutional neural network (DCNN) model, indicating that the model learning effect can be improved by incorporating the multi-head soft self-attention mechanism.

[0041] Evaluation Experiment 2: The test set was tested using existing pre-trained convolutional neural networks (1-D CNN) with no data augmentation, different data preprocessing methods, artificial feature engineering, and equal total sample data, and the method of this invention was used to calculate the accuracy.

[0042] Table 2. Experimental comparison results between Convolutional Neural Network (1D-CNN) and the present invention.

[0043] The existing convolutional neural network (1-D CNN) method mentioned above is derived from the article "One-dimensional convolutional neural networks for android malware detection" (International Colloquium on Signal Processing & Its Applications).

[0044] As can be seen from Table 2, the accuracy of the present invention is higher, indicating that the present invention has a better Android malware detection effect even without relying on any timing information and with a small initial sample data volume.

[0045] According to the verification experiment, after small-sample learning with 600 initial sample data, the final Android malware detection model can achieve an accuracy of 98.12%, which is higher than the 94.65% accuracy of the standard stacked convolutional neural network (DCNN) model with the same data augmentation and sample data volume, and higher than the 97.04% accuracy of the convolutional neural network (1-D CNN) model without data augmentation and with the same sample data volume.

[0046] Example 2 The Android malware detection method based on a few-shot learning model includes the following steps: Step 1: Collect initial sample data and perform preliminary preprocessing to obtain the original Dalvik opcode sequence of the initial sample data; Step 2: Perform Smali embedding representation on the original Dalvik opcode sequence of the initial sample data obtained in Step 1; Step 3: Obtain the newly generated sample data; Step 4: Output a third-order fused feature tensor containing semantic information about malicious code in the Android application; Step 5: Provide the classification results for detecting whether an Android application is malicious.

[0047] Example 3 The Android malware detection method based on a few-shot learning model includes the following steps: Step 1: Collect initial sample data and perform preliminary preprocessing to obtain the original Dalvik opcode sequence of the initial sample data; Step 1 is as follows: 700 malicious and benign Android applications with the .apk extension were downloaded from Androzoo, Drebin, and third-party Android app stores, along with classification tag codes. These malicious and benign applications and classification tag codes served as initial sample data. The initial sample data was decompiled using the Apktool tool, generating a series of .smali files for each sample. Each .smali file consisted of a Dalvik opcode sequence. Redundancy was removed from consecutive, repetitive, meaningless .smali files with a similarity exceeding 85%, and common libraries implemented using Dalvik opcode sequences were deleted to remove interference from these common libraries. Finally, preliminary preprocessing of the .smali files yielded the original Dalvik opcode sequences of the initial sample data.

[0048] Step 2: Perform Smali embedding representation on the original Dalvik opcode sequence of the initial sample data obtained in Step 1; Step 3: Obtain the newly generated sample data; Step 4: Output a third-order fused feature tensor containing semantic information about malicious code in the Android application; Step 5: Provide the classification results for detecting whether an Android application is malicious.

[0049] Example 4 The Android malware detection method based on a few-shot learning model includes the following steps: Step 1: Collect initial sample data and perform preliminary preprocessing to obtain the original Dalvik opcode sequence of the initial sample data; Step 1 is as follows: Eighty hundred Android malicious and benign applications with the .apk extension were downloaded from Androzoo, Drebin, and third-party Android app stores, along with classification tag codes. These applications and the classification tag codes served as initial sample data. The initial sample data was decompiled using the Apktool tool, generating a series of .smali files for each sample. Each .smali file consisted of a Dalvik opcode sequence. Redundancy was removed from consecutive, repetitive, meaningless .smali files with a similarity exceeding 85%, and common libraries implemented using Dalvik opcode sequences were deleted to remove interference from these libraries. Finally, preliminary preprocessing of the .smali files yielded the original Dalvik opcode sequence of the initial sample data.

[0050] Step 2: Perform Smali embedding representation on the original Dalvik opcode sequence of the initial sample data obtained in Step 1; Step 3: Obtain the newly generated sample data; Step 4: Output a third-order fused feature tensor containing semantic information about malicious code in the Android application; Step 5: Provide the classification results for detecting whether an Android application is malicious.

[0051] Example 5 The Android malware detection method based on a few-shot learning model includes the following steps: Step 1: Collect initial sample data and perform preliminary preprocessing to obtain the original Dalvik opcode sequence of the initial sample data; Step 1 is as follows: 1000 malicious and benign Android applications with the .apk extension were downloaded from Androzoo, Drebin, and third-party Android app stores, along with classification tag codes. These malicious and benign applications and classification tag codes served as initial sample data. The initial sample data was decompiled using the Apktool tool, generating a series of .smali files for each sample. Each .smali file consisted of a Dalvik opcode sequence. Redundancy was removed from consecutive, repetitive, meaningless .smali files with a similarity exceeding 85%, and common libraries implemented using Dalvik opcode sequences were deleted to remove interference from these common libraries. Finally, preliminary preprocessing of the .smali files yielded the original Dalvik opcode sequence of the initial sample data.

[0052] Step 2: Perform Smali embedding representation on the original Dalvik opcode sequence of the initial sample data obtained in Step 1; Step 3: Obtain the newly generated sample data; Step 4: Output a third-order fused feature tensor containing semantic information about malicious code in the Android application; Step 5: Provide the classification results for detecting whether an Android application is malicious.

[0053] Example 6 The Android malware detection method based on a few-shot learning model includes the following steps: Step 1: Collect initial sample data and perform preliminary preprocessing to obtain the original Dalvik opcode sequence of the initial sample data; Step 1 is as follows: Download 500 Android malicious and benign applications with the .apk extension from Androzoo, Drebin, and third-party Android app stores, and generate classification label codes. These Android malicious and benign applications, along with the classification label codes, serve as initial sample data. The initial sample data is decompiled using the Apktool tool, generating a series of .smali files for each sample. Each .smali file consists of a Dalvik opcode sequence. Redundancy is removed from consecutive, repetitive, meaningless .smali files with a similarity exceeding 85%, and common libraries implemented using Dalvik opcode sequences are deleted to remove interference from these common libraries. Finally, preliminary preprocessing of the .smali files yields the original Dalvik opcode sequence of the initial sample data.

[0054] Step 2: Perform Smali embedding representation on the original Dalvik opcode sequence of the initial sample data obtained in Step 1; Step 3: Obtain the newly generated sample data; Step 4: Output a third-order fused feature tensor containing semantic information about malicious code in the Android application; Step 5: Provide the classification results for detecting whether an Android application is malicious.

Claims

1. An Android malware detection method based on a few-shot learning model, characterized in that, Includes the following steps: Step 1: Collect initial sample data and perform preliminary preprocessing to obtain the original Dalvik opcode sequence of the initial sample data; Step 2: Perform Smali embedding representation on the original Dalvik opcode sequence of the initial sample data obtained in Step 1; Step 3: Obtain the newly generated sample data; Step 4: Output a third-order fused feature tensor containing semantic information about malicious code in the Android application; Step 5: Provide the classification results for detecting whether an Android application is malicious.

2. The Android malware detection method based on a few-shot learning model according to claim 1, characterized in that, Step 1 is as follows: Download 500-1000 Android malicious and benign applications with the .apk extension from Androzoo, Drebin, and third-party Android app stores, and generate classification tag codes; the Android malicious and benign applications and classification tag codes together serve as initial sample data; decompile the initial sample data using the Apktool tool, and each sample data will generate a series of files with the .smali extension; Each .smali file is composed of a Dalvik opcode sequence. Redundancy removal is performed on .smali files that are consecutive, repetitive, meaningless, and have a similarity exceeding 85%. Common libraries in .smali files implemented by Dalvik opcode sequences are deleted to remove interference from common libraries in .smali files. Finally, preliminary preprocessing of .smali files is achieved to obtain the original Dalvik opcode sequence of the initial sample data.

3. The Android malware detection method based on a few-shot learning model according to claim 1, characterized in that, Step 2 is as follows: Step 2.1: Learn dense embedding vectors from the original Dalvik opcode sequence of the initial sample data obtained in Step 1, using each .smali file after preliminary preprocessing as a word granularity, thereby capturing the semantic information of the Dalvik opcode sequence; Step 2.2: Perform Smali embedding representation using the hierarchical pooling method to obtain the initial Smali embedding vectors for highlighting important local Dalvik opcode sequences in the .smali file; In step 2, for the hierarchical pooling method, it is necessary to define an initial size of... sliding window The sliding window Apply the initial preset step size to the vector matrix to be reduced. Sliding; During each slide, the values ​​within the current window are averaged, and finally, all the averaged values ​​are maximized; the hierarchical pooling size used in the Smali embedding representation is represented as: (1) In the formula, Indicates the size of the hierarchical pooling; Indicates in the domain The Middle A sequence of .smali files; Indicates the region Quantity; This indicates the selection parameter, which can take the value 0 or 1; Recording during forward propagation The value is then used to perform backpropagation based on the records; finally, the output is the initial sample data after Smali embedding representation, denoted as . Specifically, it is represented as the initial Smali embedding vector of the Dalvik opcode sequence highlighting important localities. ,here .

4. The Android malware detection method based on a few-shot learning model according to claim 3, characterized in that, In step 3, the input layer includes the input of the generator network layer and the input of the discriminator network layer. The input of the generator network layer is Gaussian random noise, and the input of the discriminator network layer is the result calculated by weighted summation of the initial sample data after Smali embedding representation obtained in step 2 and the initial newly generated sample data output by the generator network layer. The generator network layer is the constructed generator network; The discriminator network layer is the constructed discriminator network; the output layer outputs newly generated sample data mapped from the trained generator network. After Gaussian random noise enters the generator network layer from the input layer, the generator network layer outputs the initial newly generated sample data. The initial newly generated sample data and the initial sample data after Smali embedding representation obtained in step 2 are weighted and summed to calculate the result value. This result value enters the discriminator network layer and outputs the gradient value of the intermediate interpolated sample data between the initial sample data after Smali embedding representation and the initial newly generated sample data. Then, the final objective functions of the generator network built in the generator network layer and the discriminator network built in the discriminator network layer are alternately optimized, and the network parameters of the two networks are updated to obtain the trained generator network. Finally, the output layer outputs the newly generated sample data mapped from the trained generator network.

5. The Android malware detection method based on a few-shot learning model according to claim 4, characterized in that, Step 3 specifically involves: Step 3.1: Construct the generator network of the generator network layer and its final objective function. A gradient penalty term is introduced. In step 3.1, the generator network structure of the generator network layer is as follows: including a first input layer, a first fully connected layer, a first deflattened layer, a first deconvolutional layer, a first upsampling layer, a first normalization layer, a second deconvolutional layer, a second upsampling layer, a second normalization layer, a third deconvolutional layer, a third upsampling layer, a third normalization layer, a fourth deconvolutional layer, a fourth upsampling layer, a fourth normalization layer, and a first output layer; The parameters for each layer are as follows: the first fully connected layer takes 100 vectors as input and outputs 112,800 vectors; the feature map dimensions after reconstruction by the first deflating layer are (8, 47, 375, 64); the first deconvolutional layer has 64 input channels and 64 output channels; the second deconvolutional layer has 64 input channels and 32 output channels. The third deconvolutional layer has 32 input channels and 16 output channels; the kernel size of the first, second, and third deconvolutional layers is set to 4×4, and the stride is set to 2; the fourth deconvolutional layer has 16 input channels and 1 output channel; the kernel size of the fourth deconvolutional layer is set to 3×3, and the stride is set to 1; the first output layer has a single channel; the first, second, third, and fourth normalization layers all use the BN normalization function; the activation functions of the first fully connected layer, first deflattening layer, first deconvolutional layer, second deconvolutional layer, third deconvolutional layer, and fourth deconvolutional layer are LeakyReLU; the activation function of the first output layer is Tanh, and the output value is stabilized in the range [-1, 1]; the first, second, third, and fourth upsampling layers all perform a 2x upsampling operation on their input feature layers; The generator network's first input layer takes Gaussian random noise as input, and its first output layer outputs a two-dimensional matrix representing the initial newly generated sample data, denoted as . ; The final objective function of the generator network Represented as: (2) In the formula, This represents the final objective function of the generator network; This represents the expected distribution of the initial newly generated sample data; This represents the expected distribution of the initial sample data after Smali embedding representation; The weight hyperparameters representing the gradient penalty term; Represents the gradient penalty term; The intermediate interpolated sample data is derived from the initial sample data space to create a new sample data space. The intermediate interpolated sample data is represented as follows: (3) In the formula, This represents intermediate interpolated sample data; Represents a random parameter between [0, 1]; This represents the initial sample data after Smali embedding representation; This represents the initial newly generated sample data; Subsequently, a gradient penalty term is introduced to indirectly calculate the gradient value, thus establishing a correlation between the gradient and the cutoff threshold. The gradient penalty term is expressed as: (4) In the formula, Represents the gradient penalty term; Represented as The norm; Indicates the type of gradient norm; Indicates intermediate interpolated sample data The expected distribution; Indicates intermediate interpolated sample data The gradient operator; Step 3.2: Construct the discriminator network and its final objective function for the discriminator network layer. ; In step 3.2, the discriminator network structure of the discriminator network layer is as follows: including a first input layer, a first convolutional layer, a first downsampling layer, a first activation function layer, a second convolutional layer, a second downsampling layer, a second activation function layer, a third convolutional layer, a third downsampling layer, a third activation function layer, a first flattening layer, a first fully connected layer, and a first output layer; The parameters for each layer are as follows: the first convolutional layer has 1 input channel and 32 output channels; the second convolutional layer has 32 input channels and 64 output channels; the third convolutional layer has 64 input channels and 128 output channels; all convolutional layers use LeakyReLU as the activation function; the first flattening layer flattens the convolutional features, and the first fully connected layer outputs a Wasserstein score to measure the realism of the convolutional features, which is calculated to be 2,256,000; the first fully connected layer takes 2,256,000 vectors as input and outputs 1 vector; the first output layer has a single channel; all three downsampling layers (from the first to the third) perform a 2x downsampling operation on the spatial features extracted from their inputs. The first input layer of the discriminator network takes the weighted sum of the initial sample data after Smali embedding representation obtained in step 2 and the initial newly generated sample data obtained in step 3.1 as input. The first output layer outputs the gradient value of the intermediate interpolated sample data between the initial sample data after Smali embedding representation and the initial newly generated sample data. The final objective function of the discriminator network is expressed as: (5) In the formula, This represents the final objective function of the discriminator network; Step 3.3: Alternately optimize the final objective functions of the generator network built in the generator network layer and the discriminator network built in the discriminator network layer, update the network parameters of the two networks, and obtain the trained generator network; Step 3.4: By inputting Gaussian random noise into the generator network layer, and after training the constructed Wasserstein-based generative adversarial network with gradient penalty, a new generated sample data with a similar structure and form to the initial sample data represented by the Smali embedding is finally mapped from the generator network layer. Specifically, this is represented as the data-augmented Smali embedding vector. ,here .

6. The Android malware detection method based on a few-shot learning model according to claim 5, characterized in that, Step 3.3 specifically involves: Step 3.3.1: Fix the generator network and update the discriminator network parameters k times; Specifically, in each training round, the generator network parameters are kept constant, and the output of the discriminator network is calculated using the initial sample data after Smali embedding representation and the initial newly generated sample data respectively; the final objective function of the discriminator network is optimized by minimizing the Wasserstein distance and adding a gradient penalty term, and the parameters of each layer of the generator network are updated k times through backpropagation. Step 3.3.2: Fix the discriminator network and update the generator network parameters once; Specifically, after the discriminator network is updated, the discriminator network parameters are kept unchanged, and the final objective function of the generator network is optimized. The parameters of each layer of the generator network are updated once through backpropagation. Step 3.3.3: Determine whether the number of times the discriminator network parameters have been updated has reached the set maximum number of iterations of 200,000, and whether the number of times the generator network parameters have been updated has reached the calculated number of iterations of 40,000; if so, the trained generator network is obtained. Otherwise, return to step 3.3.

1.

7. The Android malware detection method based on a few-shot learning model according to claim 6, characterized in that, Step 4 specifically involves: Step 4.1: Construct a stacked convolutional neural network; Stacked convolutional neural networks include: low-level convolutional neural networks and high-level convolutional neural networks; Step 4.1.1: The low-level convolutional neural network structure is as follows: input layer a, convolutional layer a, normalization layer a, average pooling layer a, dropout layer a, and output layer a. The parameters for each layer are as follows: the number of input channels in the a-th convolutional layer is 1, the number of output channels is 64, the kernel size is set to 3×3, and the stride is set to 1; the activation function of the a-th convolutional layer is ReLU; the normalization layer uses BN normalization function; the pooling size of the a-th average pooling layer is 2×2; and the Dropout of the a-th Dropout layer is set to 0.

3. The input of the a-th input layer of the low-level convolutional neural network is a sample data consisting of the newly generated sample data obtained in step 3 and the initial sample data after Smali embedding representation obtained in step 2, in a data volume ratio of 2:

1. The sample data is used to generate a low-level embedding input matrix. A low-level sampling matrix is ​​obtained from the low-level embedding input matrix through random sampling. The low-level sampling matrix is ​​then used to obtain local features through K-means clustering. The local features and the low-level embedding input matrix are then fed into the a-th convolutional layer for convolution. The generated convolutional features are then fed into the a-th normalization layer and the a-th average pooling layer to obtain a low-level feature vector. The low-level feature vector is then fed into the a-th Dropout layer to obtain the processed low-level feature map matrix. The output of the a-th output layer of the low-level convolutional neural network is a low-level embedding output matrix with high-dimensional feature representation. Step 4.1.2: Input the low-level embedding output matrix from 4.1.1 into the high-level convolutional neural network. The high-level convolutional neural network structure is as follows: b-th input layer, b-th convolutional layer, b-th normalization layer, b-th max pooling layer, b-th dropout layer, and b-th output layer. The parameters for each layer are as follows: the b-th convolutional layer has 1 input channel, 64 output channels, a kernel size of 3×3, and a stride of 1; the b-th convolutional layer uses ReLU as its activation function; the b-th normalization layer uses BN as its normalization function; the b-th max pooling layer has a pooling size of 2×2; and the b-th Dropout layer has a Dropout value of 0.

3. The input of the b-th input layer of the high-level convolutional neural network is the low-level embedding output matrix, which is the high-dimensional feature representation output in step 4.1.

1. A high-level sampling matrix is ​​obtained from the low-level embedding output matrix through random sampling. The high-level sampling matrix is ​​then used to obtain local features through K-means clustering. These local features are then convolved with the high-level embedding input matrix in the b-th convolutional layer. The generated convolutional features are then fed into the b-th normalization layer and the b-th max pooling layer to obtain a high-level feature vector. The high-level feature vector is then fed into the b-th Dropout layer to obtain a dimensionality-reduced high-level feature map matrix. The output of the b-th output layer of the high-level convolutional neural network is the high-level embedding output matrix, which is the dimensionality-reduced local feature representation. Step 4.2: Fusing local and global feature representations in a stacked convolutional neural network towards a multi-head soft self-attention mechanism; Step 4.2 specifically involves: representing the high-level embedding output matrix from step 4.1 as a three-dimensional feature vector, and combining the three-dimensional feature vector with the data-augmented Smali embedding vector. By performing pointwise vector addition, a new third-order feature sequence tensor is obtained. Third-order feature sequence tensor As input to the multi-head soft self-attention mechanism constructed in step 4.3, it provides a model for the global feature representation dependencies of the multi-head soft self-attention mechanism; Step 4.3: Construct a multi-head soft self-attention mechanism; In step 4.3: The third-order feature sequence tensor obtained in step 4.2 Entering a multi-headed soft self-attention mechanism; Step 4.3 specifically involves: Step 4.3.1: Construct a single-head soft self-attention mechanism; The multi-head soft self-attention mechanism is a custom-defined one. A series of single-head soft self-attention mechanisms are concatenated to form the third-order feature sequence tensor output in step 4.

2. As input, through A set of independent linear transformation parameter matrices , and ,in The third-order feature sequence tensor Mapped to different feature representation subspaces, generating the first... The first head corresponds to the query vectors , No. Key vectors and the Value vectors Then, the global features are softly and smoothly weighted using the softmax function. The result of the single-head soft self-attention mechanism is expressed as follows: (6) In the formula, This represents the calculated value for a single-head soft self-attention mechanism; each head The corresponding soft weight parameters are , , ; Indicates matrix transpose; Represents the dimension of the key vector; Among them, the The expression for the size is as follows: (7) In the formula, Indicates the first Size; parameter matrix , , ,here ; Parallel execution In each single-head soft self-attention computation, a randomly initialized differential parameter matrix is ​​used. This makes different single heads It can simultaneously capture malicious code semantic information from different dimensions in a feature sequence; Step 4.3.2: Concatenate multiple single-head soft self-attention mechanisms; right The results of each single-head soft self-attention calculation are linearly transformed to obtain the query vectors. Key vector Sum value vector Then Each independently computed single head By concatenating the feature dimensions, the resulting high-dimensional vector encompasses... Each feature represents the contextual information of the subspace; subsequently, a global weight matrix is ​​introduced. Perform linear aggregation mapping on the spliced ​​results; the linear aggregation mapping uses a dot product to... and Multiplication is performed to obtain the dependencies between the input opcodes. Scaling transformation and masking are then used to compress and restore the features of the dispersed feature representation subspace back to the original dimensional space, eliminating redundant information, resulting in the multi-head soft self-attention matrix, expressed as: (8) In the formula, This represents the values ​​of the multi-head soft self-attention matrix. Indicates the first Height to the The individual components are concatenated; parameter matrix ; Step 4.3.3: Construct residual connections; Repeat steps 4.1 and 4.2 to compute the multi-head soft self-attention matrix in parallel. Each time a single-head soft self-attention matrix is ​​calculated... , , Linear transformation parameters The results were all different; then the results of the parallel computation of the multi-head soft self-attention matrix were compared with the third-order feature sequence tensor. Performing residual connections yields a third-order fused feature tensor, denoted as: (9) In the formula, This represents the third-order fused feature tensor obtained after residual connection. This indicates normalization processing. Represents a third-order feature sequence tensor. Represents a residual join that represents element-wise addition; By constructing residual connections, the local spatial features extracted by stacked convolutional neural networks and the global logical features extracted by multi-head soft self-attention mechanisms are fused to establish semantic associations of ultra-long sequence contexts, obtain ultra-long sequence node representations, and output a third-order fused feature tensor with semantic information of Android application malicious code.

8. The Android malware detection method based on a few-shot learning model according to claim 7, characterized in that, Step 5 specifically involves: Step 5.1: Construct a feedforward neural network; In step 5.1: the feedforward neural network structure includes an input layer, a dropout layer, a flattening layer, a fully connected layer, a fully connected layer, a fully connected layer, a fully connected layer, and an output layer. The parameters for each layer are as follows: In the first Dropout layer, Dropout is set to 0.25, with L2 regularization; the first flattening layer takes a 3D tensor as input and outputs a 2D tensor; the first fully connected layer takes 64 vectors as input and outputs 64 vectors; the activation function of the first fully connected layer is Softsign; the second fully connected layer takes 64 vectors as input and outputs 8 vectors; the activation function of the second fully connected layer is ReLU; the third fully connected layer takes 8 vectors as input and outputs 1 vector; the activation function of the third fully connected layer is Sigmoid. The input of the first input layer of the feedforward neural network is the third-order fusion feature tensor with semantic information of malicious code of Android application output in step 4. It combines the third-order fusion feature tensor output in step 4 and the convolutional feature output in the b-th convolutional layer in step 4.1.2 to enter the first flattening layer to output a 2D tensor, and then enters the first fully connected layer, the second fully connected layer, and the third fully connected layer in sequence. The output of the first output layer of the feedforward neural network is the probability value of predicting the current classification label encoding as '1'. Step 5.2: Form a dynamic logistic regression model and its cost function; The dynamic logistic regression model uses the feedforward neural network constructed in step 5.1 as its basic architecture, based on the weights and biases of the feedforward neural network constructed in step 5.

1. The dynamic logistic regression model structure includes an A-th input layer, an A-th hidden layer, and an A-th output layer. The parameters for each layer are as follows: the number of layers in the A-th hidden layer is expanded to 2; the activation function of the A-th hidden layer is Softsign; the activation function of the A-th output layer is Sigmoid. Wherein, the input of the Ath input layer is the input of the feedforward neural network constructed in step 5.1, and the output of the Ath output layer is the probability value of predicting the current classification label as '1'; The probability values ​​output by the dynamic logistic regression model are expressed as follows: (10) In the formula, This represents the probability value output by the dynamic logistic regression model; Represented by natural constant An exponential function with base 0; This is represented as the hidden layer state, i.e., the dynamic logistic regression model as the input to the binary classifier; and These represent the weights and biases of the dynamic logistic regression model, respectively. in, (11) In the formula, Indicates the hidden layer state output; This represents the activation function of the hidden layer, with an output range of (-1, 1); Indicates the first Layer weight matrix; This represents the output of the multi-head soft self-attention mechanism; Indicates the first Layer bias vector; Then the value vector The data is fed into the constructed feedforward neural network to obtain a confidence label for whether the classification result is malicious. The confidence label is represented as follows: (12) In the formula, A confidence label indicating whether an Android application is malicious; Indicates the category label of the sample data; This indicates the confidence level of whether an Android application is malicious. This represents the value of the independent variable that makes the predicted probability distribution function reach its maximum value; This represents the probability value output by the dynamic logistic regression model; The cost function of the dynamic logistic regression model is expressed as: (13) In the formula, This represents the cost function value of the dynamic logistic regression model; Represents the parameter vector of the dynamic logistic regression model; Indicates the number of categories; Indicates the L2 regularization parameter; This represents the square of the Frobenius norm of the parameter matrix; Step 5.3: Input the third-order fusion feature tensor containing semantic information of malicious code in Android applications into the trained dynamic logistic regression model, and output the classification label encoding result of whether the Android application to be detected is a malicious program.