Internet of Things malicious code detection method and detection system based on double-representation fusion embedding and readable medium

Through the dual-characterization fusion embedding method, combined with CodeBert and GAT models, semantic features of assembly code segments and function call graph representations are obtained, which solves the problem of missing features in malicious code detection in IoT, and achieves higher detection accuracy and reliability.

CN118898070AActive Publication Date: 2024-11-05ELECTRIC POWER RES INST OF STATE GRID ZHEJIANG ELECTRIC POWER COMAPNY

Patent Information

Application Number
CN202410967932.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-18
Publication Date
2024-11-05
Estimated Expiration
2044-07-18

AI Technical Summary

Technical Problem

The prior art lacks the semantic features of the integrated assembly code and function dependency graph features in the detection of malicious code in the Internet of Things, resulting in insufficient accuracy and reliability of the detection.

Method used

Using a method based on dual-character fusion embedding, the semantic features and function call graph representations of assembly code segments are obtained through dynamic analysis of instrumentation. Combined with CodeBert and GAT models, the data flow direction and attributes and structural features of the function call graph in assembly instructions are learned to form a double Characterize fusion to identify malicious code.

Benefits of technology

It achieves higher accuracy and robustness, significantly improves the recognition accuracy of malicious code in the Internet of Things, ensuring the reliability and accuracy of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118898070A_ABST
    Figure CN118898070A_ABST
Patent Text Reader

Abstract

The invention relates to an Internet of Things malicious code detection method and system based on double-representation fusion embedding and a readable medium, and solves the problem that the accuracy and reliability of Internet of Things malicious code detection are not ideal in the prior art. According to the technical scheme, the method comprises the following steps: 1) obtaining an assembly code of the Internet of Things based on a high-reliability instrumentation dynamic analysis technology; 2) acquiring semantic representation of the assembly code segment based on a CodeBert model; 3) obtaining a function call graph representation based on a transfer neural network model; and 4) fusing, embedding and identifying malicious codes based on double representations (assembly code segment semantic representation and function call graph representation). According to the method, under the condition that the source code is unknown, the assembly code segment semantic representation and the function call graph representation are utilized to construct double representation with high confidence and high reliability, classification detection of malicious codes is achieved through double representation fusion embedding, reliable and accurate detection of the malicious codes of the Internet of Things is achieved, and the malicious codes are detected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of software security, and in particular to an Internet of Things malicious code detection method, a detection system and a readable medium based on dual representation fusion embedding. Background Art

[0002] In order to ensure the availability and security of software, software engineers need to make different decisions during the software life cycle. However, different execution conditions (such as execution environment, compilation environment and optimization strategy) and real-time computing status (such as executable path selection and variable update) may be exploited by attackers to implant malicious code. In order to assist software security assessors in discovering malicious code in binary programs, it is extremely necessary to develop intelligent function type inference tools. Through function type inference, software security assessors can not only perform reverse analysis of binary programs, but also promote the development of fields such as function boundary detection, code similarity analysis and vulnerability mining; moreover, an accurate function type inference model can improve the efficiency of bug search, value set inference and fuzz testing.

[0003] Deep learning has been considered as a cutting-edge key technology for implementing function type inference. It usually requires the following two steps. The first step is to determine the analysis granularity (such as how the data set is organized). For example, natural language processing methods are used to learn the semantics of assembly code in static analysis scenarios; the second step aims to determine the feature representation method based on application requirements. Existing representation methods are mainly divided into two categories: 1) text-based methods, which mainly extract features from assembly code and control flow information retained in binary files, and 2) graph-based methods, where software security testers can build graph representation models at the function, basic block, instruction and other levels to detect software vulnerabilities. However, they do not integrate assembly code semantic features and function dependency graph features, resulting in the lack of global data dependency, which makes the reliability and accuracy of IoT malicious code detection less than ideal. Summary of the invention

[0004] The purpose of the present invention is to solve the above-mentioned problems existing in the prior art and provide an Internet of Things malicious code detection method, detection system and readable medium based on dual representation fusion embedding. First, a layered instrumentation strategy is used to dynamically analyze the binary program to achieve a single execution to obtain the semantic features of the assembly code segment and the function call graph representation, while ensuring that the dynamic analysis strategy is not affected by the execution environment, compilation optimization, etc.; then, based on the CodeBert model, the data flow characteristics within the assembly instruction and the data dependency characteristics between the assembly instructions are learned to obtain a short-span, independent and unique assembly code segment semantic feature vector; at the same time, based on the GAT model, the attributes and structural characteristics of the function call graph nodes are learned to obtain a long-span data dependency feature vector; finally, the assembly code segment semantic representation and the function call graph representation are used to achieve reliable and accurate Internet of Things malicious code detection.

[0005] The above technical purpose of the present invention is mainly solved by the following technical solution: a method for detecting malicious code in the Internet of Things based on dual representation fusion embedding, characterized in that the steps are:

[0006] Based on the dynamic analysis technology of instrumentation, the binary program is dynamically analyzed to obtain the assembly code of the Internet of Things. In this step, the interference of the execution environment and the compilation environment on dynamic tracking is shielded without affecting the execution efficiency of the detected software, ensuring that the dynamic analysis strategy is not affected by the execution environment, compilation optimization, etc.

[0007] The assembly code is embedded in the bidirectional encoder Bert model, and the bidirectional encoder CodeBert model adapted to the assembly instructions is constructed. The semantic features of the assembly code segments in the functions in the assembly code are obtained through the CodeBert model. The semantic features of the assembly code segments are short-span data dependency features. The semantic features of the assembly code segments (short-span data dependency features) are short-span, independent and unique semantic feature vectors of the assembly code segments.

[0008] Extracting function call graph structure and node attributes through message passing neural network model GAT to obtain function call graph representation, wherein the function call graph representation is a long-span data dependency feature;

[0009] The semantic features of the assembly code segment and the function call graph representation are fused to form a dual representation fusion, and malicious code is identified based on the dual representation fusion embedding, which is used to learn malicious code features to detect IoT malicious code.

[0010] In summary, a method for detecting IoT malicious code based on dual representation fusion embedding is to use the above-mentioned assembly code segment semantic features and function call graph representation to achieve reliable and accurate IoT malicious code detection.

[0011] As a further improvement and supplement to the above technical solution, the present invention adopts the following technical measures: inserting callback functions at function calls and function returns using the plugging dynamic analysis technology, obtaining the instructions at the plugging position and the instruction information before and after the plugging position, obtaining the boundary of each function, making the boundary of each function clear through function calls and function returns, and preventing dynamic tracking loss during function calls and jump pointers. The plugging dynamic analysis technology (or dynamic plugging strategy) has high reliability. When tracking the execution process of the target software, the plugging dynamic analysis technology can clearly find the boundary of each function, thereby solving the problem of dynamic tracking loss caused by hidden function calls and jump pointers.

[0012] Fine-tune the Token type in the bidirectional encoder model Bert to build the CodeBert model, which is used to learn the data flow characteristics within the instruction and the data dependency characteristics between instructions in the function, where the data flow within the instruction describes the memory data processing flow in a fine-grained manner, and the data dependency between instructions describes the key function logic in the form of local code (i.e. function). The CodeBert model obtained after fine-tuning will be able to learn the data flow characteristics within the instruction and the data dependency characteristics between instructions.

[0013] The type model is used to divide the operands of instructions into data type operands and address type operands, and the token type is added to the operands. In the data type operands, the constant token is marked as "[constant]", and in the address type operands, the immediate token is marked as "[immediate]", the absolute address token is marked as "[ab_addr]", and the relative address token is marked as "[re_addr]", so as to identify the constraints within the instruction and improve the accuracy of the short-span data dependency features. Among them, the Bert model can adapt to assembly instructions in the instruction formats of X86, ARM, and MIPS.

[0014] When obtaining the function call graph representation, the graph structure information is fused by modifying the attributes of the graph nodes to extract the function call relationship features, wherein the function call relationship features include single node features and relationship features between a single node and neighboring nodes. The relationship features between a single node and neighboring nodes are formed into a graph self-attention layer and an attention coefficient is generated through a plurality of stacked blocks to realize node joint learning between nodes. The calculation formula of the attention coefficient is:

[0015]

[0016] Since the graph structure composed of a single node and its neighboring nodes cannot fully reflect the function call graph representation, node association is an important way to improve feature reliability. Combining the obtained single node features and the attention coefficient, the neural network model traverses each node feature and node joint learning to obtain the final node feature, that is, the long-span data-dependent feature. The formula for node joint learning is:

[0017]

[0018] Among them, θ is the weight matrix, α is the attention coefficient vector, i is the target node index, j is the adjacent node index, and finally the attention coefficient X′ of the target node is obtained i .

[0019] When assembling the semantic representation of the code, the function node attributes are constructed. The function node attributes include the node number node_id, the node feature node_feature, the head node head_node, the tail node tail_node and the edge feature edge_feature, among which node_feature is the main attribute of node, and the other attributes are auxiliary attributes.

[0020] The message passing neural network model GAT (a graph neural network model based on attention mechanism) constructs a graph attention layer by building block layers and stacking block layers, and generates each node according to the graph structure matrix and neighbor node attributes in the graph attention layer. In order to improve the generalization ability of learning graph models, the multi-head attention mechanism of the GAT model is used to combine independent node features, randomly sample node features from the graph attention layer, and jointly obtain target node features as long-span data-dependent features of the objective function.

[0021] After obtaining the short-span semantic features and long-span data dependency features, a data structure containing the global features of the code is constructed by splicing; then the network model LSTM that can learn temporal features is used to realize dual representation fusion and result prediction. The first-layer LSTM network in the LSTM model combines the semantic features of the assembly code segment with the long-span data dependency features to obtain the high-dimensional feature vector of the target function; the second-layer LSTM network in the LSTM model combines the high-dimensional features of the target function according to the function execution order to obtain the results that can predict malicious software behavior.

[0022] In order to fuse the assembly code semantic representation and the function dependency graph representation, the assembly code semantic representation and the function call graph representation are fused and connected into a feature vector through splicing, and the LSTM model is used to cyclically learn the connected feature vector; in the LSTM model, the first layer of LSTM network reconstructs the connected feature vector into a hidden variable containing complete data dependency; the second layer of LSTM network cyclically updates the hidden variable according to the labeled function call sequence to obtain the malicious code detection result.

[0023] The technical solution of the second technical theme of the present invention: an Internet of Things malicious code detection system based on dual representation fusion embedding, characterized in that it executes the above-mentioned Internet of Things malicious code detection method based on dual representation fusion embedding, and the Internet of Things malicious code detection system based on dual representation fusion embedding includes: a dynamic analysis module, a module for obtaining semantic features of assembly code segments, a module for obtaining function call graph representations, a dual representation fusion module, and a module for learning malicious code features;

[0024] Dynamic analysis module: Dynamic analysis based on high-reliability instrumentation shields the interference of execution environment and compilation environment on dynamic tracking without affecting the execution efficiency of the detected software;

[0025] Obtaining assembly code segment semantic feature module: Embed assembly code in the bidirectional encoder Bert model, build a bidirectional encoder CodeBert model that adapts to assembly instructions, and obtain the semantic features of assembly code segments in functions in the assembly code through the CodeBert model. The semantic features of assembly code segments are short-span data dependency features.

[0026] Obtaining function call graph representation module: extracting function call graph structure and node attributes through message passing neural network model to obtain function call graph representation, wherein the function call graph representation is a long-span data dependency feature;

[0027] Dual representation fusion module: fusing the semantic features of the assembly code segment with the function call graph representation to form a dual representation fusion;

[0028] Learning malicious code feature module: Malicious code is identified based on dual representation fusion embedding, which is used to learn malicious code features to detect malicious code in the Internet of Things.

[0029] The technical solution of the third technical subject of the present invention is: a readable medium having a computer program stored thereon, characterized in that when the computer program is executed by a processor, the above-mentioned IoT malicious code detection method based on dual representation fusion embedding is implemented.

[0030] The present invention has the following beneficial effects: 1. The IoT malicious code detection method formed by the fusion embedding of the assembly code segment semantic representation and the function call graph representation has higher accuracy and robustness, and the recognition accuracy of IoT malicious code is significantly improved, thereby achieving reliable and accurate IoT malicious code detection. 2. The binary program is dynamically analyzed using a layered instrumentation strategy to achieve a single execution to obtain the above two representations, while ensuring that the dynamic analysis strategy is not affected by the execution environment, compilation optimization, etc. / 3. Based on the CodeBert model, the data flow characteristics within the assembly instruction and the data dependency characteristics between assembly instructions are learned to obtain a short-span, independent and unique semantic feature vector of the assembly code segment; at the same time, the attributes and structural characteristics of the function call graph nodes are learned based on the GAT model to obtain a long-span data dependency feature vector. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 The present invention relates to a flow chart of a method for detecting malicious code in the Internet of Things based on dual representation fusion embedding.

[0032] Figure 2 The present invention relates to a comparative experimental curve diagram of an Internet of Things malicious code detection method based on dual representation fusion embedding using high compilation optimization.

[0033] Figure 3 The present invention relates to a comparative experimental curve diagram of an Internet of Things malicious code detection method based on dual representation fusion embedding using no compilation optimization.

[0034] Figure 1 In the figure: a is the node feature; T is the single-layer neural network node input; A is the single-layer neural network node; H is the output result; Fn represents a function (each node represents a function). DETAILED DESCRIPTION

[0035] The technical solution of the present invention is further specifically described below through embodiments and in conjunction with the accompanying drawings.

[0036] Example 1: Reference Figure 1 ,This example shows the specific implementation process of a method for detecting malicious code in IoT based on dual representation fusion and embedding, which includes the following four steps:

[0037] S1: Based on the dynamic analysis technology of instrumentation, the interference of the execution environment and the compilation environment on dynamic tracking is shielded without affecting the execution efficiency of the detected software, and the assembly code of the Internet of Things is obtained.

[0038] In order to reduce the risk of losing the pointer to the currently executed instruction, the present invention uses a stack and queue data structure to record the program stack, thereby filtering out hidden call functions in dynamic tracking and solving the problem of tracking loss. The queue stores function attributes and a complete function call sequence with addresses as keys. The stack simulates the program stack execution process, records the _ebp, _esp register values ​​and target addresses of the call instructions, so as to closely track the target binary execution process. When the %ret instruction is called, the tracker compares the most recently recorded _ebp, _esp register values ​​in the stack with the address to which the return value jumps. If the two values ​​are equal or the difference between the two values ​​is within 15 bytes (maximum instruction length), the value is recorded. Otherwise, the jump target address is recorded in the program stack. Similarly, when the %call instruction is called, the tracker compares the most recent _ebp, _esp register values ​​with the address to which the %call instruction jumps, and follows the same rules as above. Through the above rules, all adopted values ​​are recorded in the dictionary.

[0039] S2: Embed assembly code in the bidirectional encoder Bert model, build a bidirectional encoder CodeBert model that adapts to assembly instructions, and obtain the semantic features of assembly code segments within functions in the assembly code through the CodeBert model. The semantic features of assembly code segments are short-span data dependency features.

[0040] In order to achieve effective embedding of semantic representation of assembly code, the present invention constructs an improved PalmTree model based on the bidirectional encoder Bert model to predict the true label of random mask tokens and cyclically learn the contextual semantic relationship of assembly code. The improved PalmTree model has the characteristics of bidirectional connection and is structured into a multi-layer structure (such as encoder, decoder) within the Transformer unit. Among them, the encoder is trained to predict mask tokens. The entire training task consists of two subtasks. The first subtask is to obtain a masked language model MLM, which understands the internal structure and data flow of assembly instructions. The second subtask aims to jointly adjust the embedding model and the instruction sequence prediction model to learn the data dependencies between instructions.

[0041] S3: The function call graph structure and node attributes are extracted through the message passing neural network model GAT to obtain the function call graph representation, where the function call graph representation is a long-span data dependency feature.

[0042] The graph learning process combines the calling relationship between functions with the execution state of the target binary file, improving the long-span data dependency between functions. The learning process of the GAT model constructs a graph attention layer by stacking block layers, and generates each node and feature vector according to the graph structure matrix and adjacent node attributes. Then, in order to improve the generalization ability of the learning graph model, the present invention combines the independent node features through a multi-head attention mechanism, which uses the graph attention layer to randomly sample node features and connect them to obtain the target node features as the long-span data dependency of the objective function.

[0043] S4: The semantic features of the assembly code segment are integrated with the function call graph representation to form a dual representation fusion, and malicious code is identified based on the dual representation fusion embedding, which is used to learn malicious code features to detect IoT malicious code.

[0044] The assembly code semantic feature vector (i.e., assembly code semantic feature) is generated by the semantic learning model, and the function dependency graph feature vector (i.e., function dependency graph feature) is generated by the graph learning model. Using these two representations, short-span and long-span data dependencies can be extracted, which is crucial to improving the accuracy and robustness of malicious code detection. Figure 1 As shown in step (g) in , in order to fuse the above two features, the present invention connects them into the same vector instead of solving the problem of feature loss through mathematical operations. Then, in order to obtain the complete data dependency and reliable prediction results of each function, we use a cascaded LSTM model to cyclically learn the connected feature vectors. In this model, the first LSTM network reconstructs the connected feature vectors into implicit variables containing complete data dependencies. The second LSTM network cyclically updates the implicit variables according to the well-labeled function call sequence. Through the above design, high-confidence malicious code detection results can be obtained.

[0045] Compared with the prior art, this technical solution has the following effective effects:

[0046] (1) The IoT malicious code detection method based on dual representation fusion embedding has higher accuracy and robustness. In order to prove the effectiveness of the present invention, the present invention also uses a dataset generated by dynamic analysis of four tool libraries with a compilation optimization level of O2 for testing. Figure 2 ) and without compilation optimization (as shown Figure 3 The impact of these two execution paths on the present invention is shown in Figure 2. It can be seen that the execution path that retains more information has higher recognition robustness. At the same time, the present invention has higher accuracy and stronger stability when using the same test set as input to detect different software or tool libraries. Compared with existing work, the recognition accuracy has been significantly improved.

[0047] (2) The present invention designs an experiment to compare the experimental results of the present invention with those of other recent excellent studies, so as to evaluate the actual effect of the present invention in different scenarios. The present invention uses compiler optimization levels (including O2 and O3) that have a significant impact on assembly code to compile the target software. Since O0 and O1 are general optimization levels, O1 and O0 are baselines. Then, the robustness and operating efficiency of the present invention are tested when encountering data dependencies of different strengths. The evaluation results are shown in Table 1. First, the present invention is slower than other binary similarity reasoning strategies (such as Asm2vec, EKLAVYA). In order to meet higher code coverage, the data set of the present invention is larger than that of other static analysis strategies, which is expected. However, when the data dependency becomes sparse, the recognition accuracy does not drop significantly, which proves that the present invention is still an excellent strategy under the condition of known limited data dependencies.

[0048] Table 1:

[0049]

[0050] Next, the above technical solution is expressed in another way:

[0051] Use the instrumentation dynamic analysis technology to insert callback functions at function calls and function returns, obtain the instructions at the instrumentation location and the instruction information before and after the instrumentation location, obtain the boundaries of each function, and make the boundaries of each function clear through function calls and function returns to prevent dynamic tracking loss during function calls and jump pointers. Instrumentation dynamic analysis technology (or dynamic instrumentation strategy) has high reliability. When tracing the execution process of the target software, instrumentation dynamic analysis technology can clearly find the boundaries of each function, thereby solving the problem of dynamic tracking loss caused by hidden function calls and jump pointers.

[0052] Fine-tune the Token type in the bidirectional encoder model Bert to build the CodeBert model, which is used to learn the data flow characteristics within the instruction and the data dependency characteristics between instructions in the function, where the data flow within the instruction describes the memory data processing flow in a fine-grained manner, and the data dependency between instructions describes the key function logic in the form of local code (i.e. function). The CodeBert model obtained after fine-tuning will be able to learn the data flow characteristics within the instruction and the data dependency characteristics between instructions.

[0053] The type model is used to divide the operands of instructions into data type operands and address type operands, and the token type is added to the operands. In the data type operands, the constant token is marked as "[constant]", and in the address type operands, the immediate token is marked as "[immediate]", the absolute address token is marked as "[ab_addr]", and the relative address token is marked as "[re_addr]", so as to identify the constraints within the instruction and improve the accuracy of the short-span data dependency features. Among them, the Bert model can adapt to assembly instructions in the instruction formats of X86, ARM, and MIPS.

[0054] When obtaining the function call graph representation, the graph structure information is fused by modifying the attributes of the graph nodes to extract the function call relationship features, wherein the function call relationship features include single node features and relationship features between a single node and neighboring nodes. The relationship features between a single node and neighboring nodes are formed into a graph self-attention layer and an attention coefficient is generated through a plurality of stacked blocks to realize node joint learning between nodes. The calculation formula of the attention coefficient is:

[0055]

[0056] Since the graph structure composed of a single node and its neighboring nodes cannot fully reflect the function call graph representation, node association is an important way to improve feature reliability. Combining the obtained single node features and the attention coefficient, the neural network model traverses each node feature and node joint learning to obtain the final node feature, that is, the long-span data-dependent feature. The formula for node joint learning is:

[0057]

[0058] Among them, θ is the weight matrix, α is the attention coefficient vector, i is the target node index, j is the adjacent node index, and finally the attention coefficient X′ of the target node is obtained i .

[0059] When assembling the semantic representation of the code, the function node attributes are constructed. The function node attributes include the node number node_id, the node feature node_feature, the head node head_node, the tail node tail_node and the edge feature edge_feature, among which node_feature is the main attribute of node, and the other attributes are auxiliary attributes.

[0060] The message passing neural network model GAT (a graph neural network model based on attention mechanism) constructs a graph attention layer by building block layers and stacking block layers, and generates each node according to the graph structure matrix and neighbor node attributes in the graph attention layer. In order to improve the generalization ability of learning graph models, the multi-head attention mechanism of the GAT model is used to combine independent node features, randomly sample node features from the graph attention layer, and jointly obtain target node features as long-span data-dependent features of the objective function.

[0061] After obtaining the short-span semantic features and long-span data dependency features, a data structure containing the global features of the code is constructed by splicing; then the network model LSTM that can learn temporal features is used to realize dual representation fusion and result prediction. The first-layer LSTM network in the LSTM model combines the semantic features of the assembly code segment with the long-span data dependency features to obtain the high-dimensional feature vector of the target function; the second-layer LSTM network in the LSTM model combines the high-dimensional features of the target function according to the function execution order to obtain the results that can predict malicious software behavior.

[0062] In order to fuse the assembly code semantic representation and the function dependency graph representation, the assembly code semantic representation and the function call graph representation are fused and connected into a feature vector through splicing, and the LSTM model is used to cyclically learn the connected feature vector; in the LSTM model, the first layer of LSTM network reconstructs the connected feature vector into a hidden variable containing complete data dependency; the second layer of LSTM network cyclically updates the hidden variable according to the labeled function call sequence to obtain the malicious code detection result.

[0063] Embodiment 2: The technical solution of the second technical theme of the present invention: an Internet of Things malicious code detection system based on dual representation fusion embedding, characterized in that it executes the above-mentioned Internet of Things malicious code detection method based on dual representation fusion embedding, and the Internet of Things malicious code detection system based on dual representation fusion embedding includes: a dynamic analysis module, a module for obtaining semantic features of assembly code segments, a module for obtaining function call graph representations, a dual representation fusion module, and a module for learning malicious code features;

[0064] Dynamic analysis module: Dynamic analysis based on high-reliability instrumentation shields the interference of execution environment and compilation environment on dynamic tracking without affecting the execution efficiency of the detected software;

[0065] Obtaining assembly code segment semantic feature module: Embed assembly code in the bidirectional encoder Bert model, build a bidirectional encoder CodeBert model that adapts to assembly instructions, and obtain the semantic features of assembly code segments in functions in the assembly code through the CodeBert model. The semantic features of assembly code segments are short-span data dependency features.

[0066] Obtaining function call graph representation module: extracting function call graph structure and node attributes through message passing neural network model to obtain function call graph representation, wherein the function call graph representation is a long-span data dependency feature;

[0067] Dual representation fusion module: fusing the semantic features of the assembly code segment with the function call graph representation to form a dual representation fusion;

[0068] Learning malicious code feature module: Malicious code is identified based on dual representation fusion embedding, which is used to learn malicious code features to detect malicious code in the Internet of Things.

[0069] Embodiment 3: The technical solution of the third technical subject involved in the present invention: a readable medium having a computer program stored thereon, characterized in that when the computer program is executed by a processor, the above-mentioned IoT malicious code detection method based on dual representation fusion embedding is implemented.

[0070] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. In the above embodiments, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for detecting malicious code in the Internet of Things based on dual representation fusion embedding, characterized in that: The steps are: Based on the dynamic analysis technology of plug-in, the assembly code of the Internet of Things is obtained; The assembly code is embedded in the bidirectional encoder Bert model, and the bidirectional encoder CodeBert model adapted to the assembly instructions is constructed. The semantic features of the assembly code segments in the functions in the assembly code are obtained through the CodeBert model. The semantic features of the assembly code segments are short-span data dependency features. Extracting function call graph structure and node attributes through message passing neural network model GAT to obtain function call graph representation, wherein the function call graph representation is a long-span data dependency feature; The semantic features of the assembly code segment and the function call graph representation are fused to form a dual representation fusion, and malicious code is identified based on the dual representation fusion embedding, which is used to learn malicious code features to detect IoT malicious code.

2. The method for detecting malicious code in the Internet of Things based on dual representation fusion embedding according to claim 1 is characterized in that: Use the instrumentation dynamic analysis technology to insert callback functions at function calls and function returns, obtain the instructions at the instrumentation location and the instruction information before and after the instrumentation location, obtain the boundaries of each function, and make the boundaries of each function clear through function calls and function returns to prevent dynamic tracking loss during function calls and jump pointers.

3. The method for detecting malicious code in the Internet of Things based on dual representation fusion embedding according to claim 1 is characterized in that: The Token type in the bidirectional encoder model Bert is fine-tuned to construct a CodeBert model. The CodeBert model is used to learn the intra-instruction data flow characteristics and inter-instruction data dependency characteristics in a function. The intra-instruction data flow describes the memory data processing flow in a fine-grained manner, and the inter-instruction data dependency describes the key function logic in the form of local code.

4. The method for detecting malicious code in the Internet of Things based on dual representation fusion embedding according to claim 3 is characterized in that: The type model is used to divide the operands of instructions into data type operands and address type operands, and a token type is added to the operands. In the data type operands, the constant token is marked as "[constant]", and in the address type operands, the immediate token is marked as "[immediate]", the absolute address token is marked as "[ab_addr]", and the relative address token is marked as "[re_addr]", so as to identify the constraints within the instruction and improve the accuracy of the short-span data dependency features.

5. The method for detecting malicious code in the Internet of Things based on dual representation fusion embedding according to any one of claims 1 to 4, characterized in that: When obtaining the function call graph representation, the graph structure information is fused by modifying the attributes of the graph nodes to extract the function call relationship features, wherein the function call relationship features include single node features and relationship features between a single node and neighboring nodes. The relationship features between a single node and neighboring nodes are formed into a graph self-attention layer and an attention coefficient is generated through a plurality of stacked blocks to realize node joint learning between nodes. The calculation formula of the attention coefficient is: X′ i =a i,i i xi +S j∈N(t) a i,i i xj (1); Combining the obtained single node feature and the attention coefficient, the neural network model traverses each node feature and node joint learning to obtain the final node feature, that is, the long-span data-dependent feature. The formula for the node joint learning is: Among them, θ is the weight matrix, α is the attention coefficient vector, i is the target node index, j is the adjacent node index, and finally the attention coefficient X′ of the target node is obtained i .

6. The method for detecting malicious code in the Internet of Things based on dual representation fusion embedding according to claim 5 is characterized in that: Construct function node attributes, which include node number node_id, node feature node_feature, head node head_node, tail node tail_node and edge feature edge_feature; the message passing neural network model GAT constructs a graph attention layer by constructing a block layer and a stacked block layer, generates each node according to the graph structure matrix and neighbor node attributes in the graph attention layer, combines independent node features through the multi-head attention mechanism of the GAT model, randomly samples node features from the graph attention layer and combines them to obtain target node features as long-span data-dependent features of the objective function.

7. The method for detecting malicious code in the Internet of Things based on dual representation fusion embedding according to any one of claims 1 to 4, characterized in that: After obtaining the short-span semantic features and long-span data dependency features, a data structure containing the global features of the code is constructed by splicing; then the network model LSTM that can learn temporal features is used to realize dual representation fusion and result prediction. The first-layer LSTM network in the LSTM model combines the semantic features of the assembly code segment with the long-span data dependency features to obtain the high-dimensional feature vector of the target function; the second-layer LSTM network in the LSTM model combines the high-dimensional features of the target function according to the function execution order to obtain the results that can predict malicious software behavior.

8. The method for detecting malicious code in the Internet of Things based on dual representation fusion embedding according to claim 7 is characterized in that: The assembly code semantic representation and function call graph representation are fused and connected into a feature vector through splicing, and the connected feature vector is cyclically learned using the LSTM model. In the LSTM model, the first layer of the LSTM network reconstructs the connected feature vector into a latent variable containing complete data dependencies. The second layer of the LSTM network cyclically updates the latent variables according to the labeled function call sequence to obtain the malicious code detection results.

9. An IoT malicious code detection system based on dual representation fusion embedding, characterized in that: It implements the IoT malicious code detection method based on dual representation fusion embedding according to any one of claims 1 to 8, and the IoT malicious code detection system based on dual representation fusion embedding comprises: a dynamic analysis module, a module for obtaining semantic features of assembly code segments, a module for obtaining function call graph representations, a dual representation fusion module, and a module for learning malicious code features; Dynamic analysis module: Dynamic analysis based on high-reliability instrumentation shields the interference of execution environment and compilation environment on dynamic tracking without affecting the execution efficiency of the detected software; Obtaining assembly code segment semantic feature module: Embed assembly code in the bidirectional encoder Bert model, build a bidirectional encoder CodeBert model that adapts to assembly instructions, and obtain the semantic features of assembly code segments in functions in the assembly code through the CodeBert model. The semantic features of assembly code segments are short-span data dependency features. Obtaining function call graph representation module: extracting function call graph structure and node attributes through message passing neural network model to obtain function call graph representation, wherein the function call graph representation is a long-span data dependency feature; Dual representation fusion module: fusing the semantic features of the assembly code segment with the function call graph representation to form a dual representation fusion; Learning malicious code feature module: Malicious code is identified based on dual representation fusion embedding, which is used to learn malicious code features to detect malicious code in the Internet of Things.

10. A readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for detecting malicious code in the Internet of Things based on dual representation fusion embedding according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Malicious software detection method and device, equipment and storage medium

    CN113360912A

  • Malicious software detection method using dynamic graph attention network

    CN115525896A

  • Similar vulnerability detection method based on tree attention and weighted graph matching

    CN115859307A

  • ATTCK technology mapping method based on multi-label classification

    CN117851870A

  • Generic feature extraction for identifying malicious packages

    US20230401320A1

Cited By

  • Meta-learning-based method for mining implicit association of malicious code gene information

    WO2026123828A1