Graph neural network-based peeling binary function signature recovery method and device
By constructing a data flow graph (DFG) based on a graph neural network and utilizing graph convolutional networks (GCN) and multilayer perceptrons (MLP), this method solves the problem of function signature recovery in compiler optimization and cross-architecture scenarios, achieving higher accuracy and stability, and is applicable to function signature recovery in the field of network security.
Patent Information
- Application Number
- CN202611635463.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-22
- Publication Date
- 2026-11-20
AI Technical Summary
Existing technologies have poor accuracy and reliability in recovering binary function signatures in the face of compiler optimizations, cross-architecture and cross-compiler scenarios. Commercial tools perform poorly when dealing with complex optimized code and are difficult to adapt to changes in different optimization levels and architectures.
We employ a graph neural network-based approach, constructing a data flow graph (DFG) and utilizing a graph convolutional network (GCN) to extract function-level semantic features. We then combine this with a multilayer perceptron (MLP) for parameter count identification and type recovery. The training dataset covers various architectures and optimization levels, and we use an adaptive optimizer for model training to enhance the model's generalization ability and robustness.
It improves the accuracy and stability of function signature recovery, can adapt to different compiler optimization levels and architectures, enhances the performance and reliability of the model in complex scenarios, and is suitable for function signature recovery in the field of network security.
Smart Images

Figure CN123137663A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the technical field of binary program analysis / software reverse engineering, and in particular to a method and apparatus for recovering extracted binary function signatures based on graph neural networks. Background Technology
[0002] Existing techniques for recovering binary function signatures have the following main drawbacks: Sensitivity to compiler optimizations. Compiler optimizations (such as inlining, loop unrolling, and dead code elimination) drastically alter the surface structure of binary code, leading to significant differences in the recovery performance of existing methods at different optimization levels. For example, some heuristic-based tools experience a significant decrease in accuracy and reliability when faced with highly optimized code.
[0003] Insufficient cross-architecture and cross-compiler support. Optimization strategies differ significantly across architectures (e.g., x86, x64, ARM) and compilers (e.g., GCC, Clang). Existing methods largely rely on the characteristics of specific architectures or compilers, making it difficult to maintain consistent performance across cross-architecture and cross-compiler scenarios. For example, some tools are inadequate in recognizing variadic functions, potentially misinterpreting floating-point registers as parameters, resulting in excessive function signature parameters.
[0004] Limitations of Commercial Tools. While commercial tools (such as IDA Pro and Binary Ninja) and open-source frameworks (such as Ghidra and angr) offer powerful decompilation and analysis capabilities, their accuracy and reliability are limited when faced with highly obfuscated or complexly optimized code. For example, Ghidra has shortcomings in recognizing variadic functions, sometimes incorrectly identifying all floating-point registers as parameters, resulting in function signatures with excessive parameters. Summary of the Invention
[0005] The purpose of this invention is to at least address one of the shortcomings of the prior art by providing a method for recovering extracted binary function signatures based on graph neural networks.
[0006] To achieve the above objectives, the present invention adopts the following technical solution: Specifically, a binary function signature stripping recovery method based on graph neural networks is proposed, including the following: Obtain the target binary file; The target binary file is converted into a Vex IR representation, and a data flow graph (DFG) is constructed, where nodes in the DFG represent variables or operations, and edges represent dependencies between variables. The data flow graph (DFG) is input into a pre-built and trained signature recovery model based on a graph neural network, and the signature recovery model outputs the signature recovery result.
[0007] Furthermore, specifically, the process of constructing a Data Flow Graph (DFG) includes: First, the binary file is loaded using Angr.Project, and loading options are set. Next, the binary code of the binary file is converted into an architecture-independent Vex intermediate representation (IR) using Angr's Block.vex interface, thus achieving a unified intermediate layer representation. Then, function and basic block information is extracted using the CGFast analysis function. During the data flow analysis phase, symbolic execution is performed based on the Vex IR to extract variables and their data dependencies along the paths, generating a path-level data flow graph (path-DFG). Then, the path-DFGs from different paths are aggregated into a function-level data flow graph (func-DFG), achieving data flow graph aggregation. After the function-level data flow graph (func-DFG) is generated, it is normalized by defining operator mappings and optimizing edge labels to obtain the final data flow graph (DFG). Finally, the final data flow graph (DFG) and its related information are encapsulated into an Input object and saved as a .pkl file for subsequent loading and use.
[0008] Furthermore, specifically, the signature recovery model includes, Shared encoder: The input is a function-level data flow graph func-DFG, where nodes represent variables or operations and edges represent data dependencies. It uses a graph convolutional network (GCN) as its basic architecture to extract semantic features of nodes through multiple convolutions. The output is an encoded node feature vector that captures global data dependencies within the function. Task-specific decoders are used for parameter quantity identification, parameter type recovery, and return type inference, respectively. The inputs are all node features output by the shared encoder, and the network structure is a multilayer perceptron (MLP). They all output signature recovery results.
[0009] Furthermore, specifically, the process of creating the training dataset for the signature recovery model includes, We collect C language code from open-source software libraries to obtain multiple binary files, extend the compilation toolchain to support compilation of various architectures at different optimization levels, preprocess the generated binary files, extract the assembly instruction sequences of functions, and retain debugging information to obtain the original signatures of the functions to obtain the dataset, and perform deduplication on the dataset to obtain the training dataset.
[0010] Furthermore, specifically, during the training process of the signature recovery model, the compiler optimization level is used as a conditional signal input, and an adaptive optimizer is used for training.
[0011] Furthermore, the method also includes systematic evaluation and generalization capability verification: after completing the training of the signature recovery model, the performance indicators of the model are quantified, including the accuracy of parameter number recovery, the precision of parameter type and return type recovery, recall rate and F1 score, until the performance indicators meet the standards and the training of the signature recovery model is completed.
[0012] Furthermore, specifically, converting the target binary file into a Vex IR representation includes, First, the target binary file is converted into a raw Vex IR sequence; where Vex IR is an architecture-independent intermediate representation under the angr binary analysis framework. If the raw Vex IR sequence is denoted as... ; For any data in V ,Will An expression tree that can be parsed into a binary or multi-way expression tree The temporary variable Tmp of VexIR is then processed in SSA form, which is a static single assignment form, meaning that each temporary variable Tmp is assigned a value only once. A mapping DU is then constructed. ,in For the statement index of this Tmp, This is the set of indexes for statements that reference this Tmp; for Record its That is, the set of registers read by this statement and That is, the set of registers written to by this statement; get The middle representation ; for The intermediate representation is determined by checking if it hits any of the following garbage instruction patterns: self-assignment register transfer, explicit no-operation instruction, dead assignment without side effects, or register write with unused result. If it does, the corresponding flag number Flag[i] is set to 1; otherwise, Flag[i] is set to 0, thus obtaining the intermediate representation of M1. , An array containing all Flag[i]; For statements in M2 where Flag[i]=0, their expression trees are generated using a pre-established algebraic identity rule base R. Perform pattern matching and replace successfully matched nodes with the target expression tree corresponding to the rule in R. After replacement, continue pattern matching on the newly generated nodes until no match can be found. If statement expression tree If the value degenerates into a single leaf node after pattern matching and is a temporary variable, then the statement can directly reference and update it. The expression tree is replaced, and the references of related temporary variables in DU are updated. The intermediate Tmp, which is about to be eliminated, is removed from its use set to obtain the intermediate representation. ,in The sequence of statements after pattern matching; Iterate through each temporary variable in M3 If its The corresponding expression tree If there are no Iex_Get or Iex_Load nodes, calculate their constant values. , Eval is the expression tree evaluation function, w is the bit width of Tmp, and mod is the modulo operation; All references Replace Iex_Binder(Tmp_t) in the statement with Iex_Const(val_t); from Remove from And mark its definition statement as removable; Scan all Ist_WrTmp statements; if the Tmp defined by that statement is in... If the `use` collection is empty, then the statement is marked as deletable; Delete all statements that have been marked as removable, and remove the current statement from the use set of all Tmp referenced in its source operands; If the use set of a certain Tmp becomes empty as a result, then its definition statement also becomes deletable; Removing the statement with Flag[i]=1 from the sequence yields the final Vex IR representation.
[0013] The present invention also proposes a binary function signature stripping recovery device based on graph neural networks, characterized by comprising the following: The data acquisition module is used to acquire the target binary file; The Data Flow Graph (DFG) building module is used to convert the target binary file into a Vex IR representation and construct a Data Flow Graph (DFG). The nodes of the DFG represent variables or operations, and the edges represent the dependencies between variables. The signature recovery module is used to input the data flow graph (DFG) into a pre-built and trained signature recovery model based on a graph neural network, and output the signature recovery result through the signature recovery model.
[0014] The beneficial effects of this invention are as follows: This invention proposes a method and apparatus for recovering extracted binary function signatures based on graph neural networks. By constructing a generalized dataset across optimization levels and employing a multi-task graph neural network architecture, it can better address the challenges posed by compiler optimizations. It enhances the model's generalization ability; the architecture-independent data flow graph (DFG) construction enables the model to work across different processor architectures and adapt to various hardware platforms. It improves the model's robustness; in complex real-world scenarios, through conditional training strategies, the model can robustly cope with code variants at different optimization levels. It provides a more reliable function signature recovery method for related research in the field of network security, contributing to improved efficiency and effectiveness in system defense, vulnerability discovery, and software protection. Attached Figure Description
[0015] The above and other features of this disclosure will become more apparent from the detailed description of the embodiments illustrated in conjunction with the accompanying drawings. In the accompanying drawings, the same reference numerals denote the same or similar elements. Obviously, the drawings described below are merely some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained from these drawings without any creative effort. In the drawings: Figure 1 The diagram shows the principle of the binary function signature recovery method based on graph neural network of the present invention. Detailed Implementation
[0016] The following will provide a clear and complete description of the concept, specific structure, and technical effects of the present invention in conjunction with embodiments and accompanying drawings, so as to fully understand the purpose, solution, and effects of the present invention. It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. The same reference numerals used throughout the accompanying drawings indicate the same or similar parts.
[0017] Example 1, referring to Figure 1 This invention proposes a binary function signature recovery method based on graph neural networks, comprising the following: Obtain the target binary file; The target binary file is converted into a Vex IR representation, and a data flow graph (DFG) is constructed, where nodes in the DFG represent variables or operations, and edges represent dependencies between variables. The data flow graph (DFG) is input into a pre-built and trained signature recovery model based on a graph neural network, and the signature recovery model outputs the signature recovery result.
[0018] In a preferred embodiment of the present invention, the process of constructing a Data Flow Graph (DFG) specifically includes: First, the binary file is loaded using Angr.Project, and loading options are set. Next, the binary code of the binary file is converted into an architecture-independent Vex intermediate representation (IR) using Angr's Block.vex interface, thus achieving a unified intermediate layer representation. Then, function and basic block information is extracted using the CGFast analysis function. During the data flow analysis phase, symbolic execution is performed based on the Vex IR to extract variables and their data dependencies along the paths, generating a path-level data flow graph (path-DFG). Then, the path-DFGs from different paths are aggregated into a function-level data flow graph (func-DFG), achieving data flow graph aggregation. After the function-level data flow graph (func-DFG) is generated, it is normalized by defining operator mappings and optimizing edge labels to obtain the final data flow graph (DFG). Finally, the final data flow graph (DFG) and its related information are encapsulated into an Input object and saved as a .pkl file for subsequent loading and use.
[0019] In this preferred embodiment, symbolic execution based on Vex IR can accurately track the definition-use chain of variables on each execution path, including address dependencies, operand dependencies, and value dependencies. This provides direct evidence for determining the number and type of parameters. Each path-level DFG is aggregated into a function-level DFG, preserving data dependency information for all possible execution paths of the function. This avoids missing parameter usage in conditional branches during single-path analysis. The DFG is encapsulated as an Input object and saved as a .pkl file, supporting batch pre-computation and reuse of DFGs. This avoids repeated symbolic execution and improves the processing efficiency of large-scale analysis scenarios.
[0020] The binary representations of each training sample are converted into function-level data flow graphs (func-DFG) using the same process. The training dataset is constructed using the function-level data flow graphs (func-DFG) as model inputs and the corresponding original function signatures as labels.
[0021] In a preferred embodiment of the present invention, specifically, the signature recovery model includes: Shared encoder: The input is a function-level data flow graph func-DFG, where nodes represent variables or operations and edges represent data dependencies. It uses a graph convolutional network (GCN) as its basic architecture to extract semantic features of nodes through multiple convolutions. The output is an encoded node feature vector that captures global data dependencies within the function. Task-specific decoders are used for parameter quantity identification, parameter type recovery, and return type inference, respectively. The inputs are all node features output by the shared encoder, and the network structure is a multilayer perceptron (MLP). They all output signature recovery results.
[0022] In this preferred embodiment, the common data dependency features of the GCN encoder learning function are shared, and the three decoders share the underlying representation, which reduces the number of parameters and allows the gradients of each subtask to jointly optimize the encoder, learning more robust features. The three subtasks of parameter number, parameter type, and return type are trained together, and the semantic correlation between subtasks (such as the return type affecting the use of the return register and the parameter number constraining the range of the parameter register) provide mutual supervision signals to improve the accuracy of each subtask. Graph convolutional networks are naturally adapted to the non-Euclidean structure of data flow graphs (DFGs), and can aggregate neighbor node information through message passing mechanism, which can capture long-distance data dependencies between variables, which cannot be effectively modeled by sequence models. Each task-specific decoder adopts an MLP to map graph-level / node-level features to specific signature dimensions, which is concise and highly targeted.
[0023] The shared encoder extracts node features through multi-layer graph convolution, then obtains a fixed-dimensional graph-level feature vector through global average pooling, which is then input into the task-specific decoder.
[0024] As a preferred embodiment of the present invention, specifically, the process of creating the training dataset for the signature recovery model includes, We collect C language code from open-source software libraries to obtain multiple binary files, extend the compilation toolchain to support compilation of various architectures at different optimization levels, preprocess the generated binary files, extract the assembly instruction sequences of functions, and retain debugging information to obtain the original signatures of the functions to obtain the dataset, and perform deduplication on the dataset to obtain the training dataset.
[0025] In this preferred embodiment, training data is generated by compiling at all optimization levels from O0 to O3, enabling the model to learn the changing patterns of code structure under different optimization levels, extract essential features of function signatures that are independent of optimization level, and significantly reduce sensitivity to compiler optimizations. The extended compilation toolchain supports multiple architectures (x86, x64, AArch64, Arm32, Mips), ensuring that training data covers mainstream processor architectures and that the model has cross-architecture generalization capabilities. Debugging information (DWARF, etc.) is used to automatically obtain the original function signatures as ground truth, eliminating the need for manual annotation and ensuring the accuracy and scale of annotation. The dataset is deduplicated to prevent identical or highly similar functions from appearing simultaneously in the training and test sets, ensuring that model performance evaluation reflects true generalization ability rather than memory ability.
[0026] The compiler optimization level is encoded as a one-dimensional conditional vector, which is then concatenated with the graph-level features output by the shared encoder and input into the task-specific decoder. This enables the model to be aware of the optimization level and adaptively adjust the recovery strategy.
[0027] In a preferred embodiment of the present invention, specifically, during the training process of the signature recovery model, the compiler optimization level is used as a conditional signal input, and an adaptive optimizer is used for training.
[0028] In this preferred embodiment, the compiler optimization level is encoded as a conditional signal input to the model, enabling the model to perceive the current input optimization level and adaptively adjust the feature extraction and recovery strategies according to the characteristics of the code structure under different optimization levels. This avoids the performance trade-off caused by a single model "applying equal effort" across all optimization levels. The adaptive optimizer (such as Adam or AdamW) combined with dynamic learning rate scheduling can adaptively adjust the learning rate of each parameter in multi-task joint training, alleviate gradient conflicts, accelerate convergence, and improve the final performance. Combined with gradient pruning techniques, gradient explosion is prevented in deep message passing of GCN, ensuring the stability of the training process.
[0029] As a preferred embodiment of the present invention, the method further includes systematic evaluation and generalization capability verification: after completing the training of the signature recovery model, quantify various performance indicators of the model, including the accuracy of parameter number recovery, the precision of parameter type and return type recovery, recall rate and F1 score, until the performance indicators meet the standards and the training of the signature recovery model is completed.
[0030] In this preferred embodiment, the accuracy, precision, recall, and F1 score are quantified in three dimensions: the number of parameters, parameter types, and return types, to comprehensively evaluate the model's performance on each subtask. This avoids the single overall metric masking local defects. The training completion condition is that each performance metric meets the target, rather than a fixed number of training rounds. This ensures that the model is delivered only after it reaches the preset quality threshold in each dimension, guaranteeing the reliability of the output results. The model is evaluated on an independent test set to verify its generalization ability to unseen binary files, ensuring that the model learns transferable signature recovery rules rather than simply memorizing training data.
[0031] In a preferred embodiment of the present invention, the target binary file is first converted into a raw Vex IR sequence; wherein, Vex IR is an architecture-independent intermediate representation under the angr binary analysis framework, and the raw Vex IR sequence is denoted as... ; For any data in V ,Will An expression tree that can be parsed into a binary or multi-way expression tree , The leaf nodes are: Iex_Const (constant), Iex_Get (register read), and Iex_Binder (bind variable); the internal nodes are: Iex_Binop (binary operation, such as Add, Xor, And, Mul), Iex_Unop (unary operation, such as Not, Neg), and Iex_Load (memory load); each node records the operation type op, the operand type width w (such as Ity_I32, Ity_I64), and a pointer to the child nodes. Then, using SSA form, the temporary variable Tmp of Vex IR is assigned a value only once, and a mapping DU is constructed: ,in For the statement index of this Tmp, This is the set of indexes for statements that reference this Tmp; for Record its That is, the set of registers read by this statement and That is, the set of registers written to by this statement; get The middle representation ; for The intermediate representation determines whether it hits any of the following garbage instruction modes: self-assignment register transfer, explicit no-operation instruction, dead assignment without side effects, or register write with unused result. Mode A: Self-Assignment Register Transfer Testing conditions: For Ist_Put and For a single-node Iex_Get, the target register of Put equals the source register of Get. Ist_Put is a register write statement, and Iex_Get is a register read expression node. That is, Put(reg, Get(reg)), where Put(reg,Get(reg)) means writing the result of reading from the register back to the register. The corresponding assembly instructions are mov reg, reg and mov reg, reg, which are assembly self-assignment instructions.
[0032] Mode B: Explicit no operation command Testing conditions: Ist_NoOp or Ist_IMark (marks instruction boundaries only, no semantics), where Ist_NoOp is a no-operation statement and Ist_IMark is an instruction marking statement. Mode C: Death assignment without side effects Testing conditions: For Ist_WrTmp, Ist_WrTmp is a temporary variable write statement, and its use_stmt violates a reference, meaning that the temporary variable is never referenced by any subsequent statement after being assigned a value. use_stmt is a set of reference statements, and this assignment is dead code; Mode D: Write to unused registers as a result Testing conditions: It is Ist_Put, and ,like If this register is read, another entry must have existed before the read. (i < k < j) Writing to the same register means that the write to that register is completely overwritten by subsequent writes, with no reads in between, which is an invalid write.
[0033] If a match is found, its corresponding flag number Flag[i] is set to 1; otherwise, Flag[i] is set to 0, thus obtaining the intermediate representation of M1. , An array containing all Flag[i]; For statements in M2 where Flag[i]=0, their expression trees are generated using a pre-established algebraic identity rule base R. Perform pattern matching and replace successfully matched nodes with the target expression tree corresponding to the rule in R. After replacement, continue pattern matching on the newly generated nodes until no match can be found. An example of R's application is shown in Table 1 below: Rule Number Matching pattern (source expression tree) Replace with (target expression tree) Corresponding obfuscation example R1 Add(Xor(a,b), Mul(Const(2), And(a,b))) Add(a,b) x + y → (x^y) + 2*(x & y) R2 Xor(a,a) Const(0) x^x → 0 R3 And(a, Const(0)) Const(0) x & 0 → 0 R4 Or(a, Const(0)) a x | 0 → x R5 And(a, Const(all_ones)) a x & 0xFFFFFFFF → x R6 Add(Add(a, Const(c)), Const(-c)) a (x+1)-1 → x R7 Sub(Add(a,b), b) a (x+y)-y → x R8 Or(And(a,b), And(a, Not(b))) a (x&y)|(x&~y) → x R9 Xor(Xor(a,b), b) a (x^y)^y → x R10 Mul(a, Const(1)) a x*1 → x R11 Mul(a, Const(0)) Const(0) x*0 → 0 R12 Shl(Const(1), a) → Pow(2,a) (Special marker) — 1<<x used for obfuscated jump R13 And(Add(a,b), Const(mask)) when mask is all 1s Add(a,b) Perform a bitwise AND operation with the all-1s mask. R14 Or(And(a, Const(m1)), And(a, Const(m2))) When m1|m2 = all 1s and m1&m2 = 0 a After splitting by bit, merge Table 1 Where a and b are wildcards in any subexpression, c is any constant, and Const(all_ones) represents a constant with all 1s in the corresponding bit width (e.g., 0xFFFFFFFF for 32 bits). If statement expression tree If the value degenerates into a single leaf node after pattern matching and is a temporary variable, then the statement can directly reference and update it. The expression tree is replaced, and the references of related temporary variables in DU are updated. The intermediate Tmp, which is about to be eliminated, is removed from its use set to obtain the intermediate representation. ,in The sequence of statements after pattern matching; Iterate through each temporary variable in M3 If its The corresponding expression tree If there are no Iex_Get or Iex_Load nodes, calculate their constant values. , Eval is the expression tree evaluation function, and w is the bit width of Tmp; All references Replace `Iex_Binder(Tmp_t)` in the statement with `Iex_Const(val_t)`, where `val_t` is the reference constant value. ; from Remove from And mark its definition statement as removable; Scan all Ist_WrTmp statements. Ist_WrTmp is a temporary variable write statement. If the Tmp defined by this statement is in... If the `use` collection is empty, then the statement is marked as deletable; Delete all statements that have been marked as removable, and remove the current statement from the use set of all Tmp referenced in its source operands; If the use set of a certain Tmp becomes empty as a result, then its definition statement also becomes deletable; Removing the statement with Flag[i]=1 from the sequence yields the final Vex IR representation.
[0034] When applying this example, taking the obfuscated case x+y → (x^y)+2*(x&y) as an example, the simplification process is as follows: The original IR corresponds to the expression tree: Add(Xor(a,b), Mul(Const(2), And(a,b))), where the original IR is the unsimplified original Vex intermediate IR representation, Add represents the addition node, Xor represents the bitwise XOR node, Mul represents the multiplication node, And represents the bitwise AND node, and Const represents the constant node. This original IR corresponds to the obfuscated equivalence relation: a+b=(a⊕b)+2×(a&b). After matching rules, this expression can be folded and simplified to Add(a,b), where Add(a,b) represents the addition of variables a and b. If a and b are constants, then they are further propagated to become constants. The intermediate temporary variables (the three Tmp values storing x^y, x&y, and 2*(x&y)) were eliminated because the use set became empty.
[0035] Results: The obfuscated sequence, which originally required 5 IR statements (3 WrTmp + 1 WrTmp final result + 1 Put), is simplified to only 1 Add operation statement. The number of operation nodes in the DFG is reduced from 5 to 1, and the data dependency path is reduced from 3 levels to 1 level, effectively reducing the noise introduced by obfuscation.
[0036] In this preferred embodiment, considering that the obfuscation tool replaces simple instructions with equivalent complex sequences (such as x+y→(x^y)+2*(x&y)), VEX IR faithfully transforms these complex sequences, resulting in an increase in the number of operation nodes and a longer data dependency path in the IR; inserted garbage instructions (such as mov eax, eax, nop, arithmetic operations without side effects) are converted into IR statements by VEX, increasing noise. Therefore, preprocessing the original Vex IR sequence in the above manner to obtain the optimized Vex IR sequence facilitates the subsequent construction of the data flow graph (DFG).
[0037] SSA (Static Single Assignment) form: refers to an intermediate representation where each temporary variable is assigned only once, which facilitates the construction of definition-use chains and data flow analysis; DU mapping, or definition-use mapping, records the position of the definition statement of each temporary variable and the position of all reference statements, and is the basic structure of data flow dependency analysis.
[0038] Operator mapping: used to map assembly operations of different architectures and instruction sets to operation nodes with a unified semantic level (e.g., mapping x86 ADD and ARM ADD to "addition" operations), eliminating architecture differences; edge label optimization classifies data dependency edges into three categories: "read dependency", "write dependency" and "address dependency", realizing cross-architecture normalization of DFG, enabling the model to learn general features that are independent of architecture.
[0039] Expression tree node types: Iex_Const is a constant node, Iex_Get is a register read node, Iex_Binder is a bound variable node, Iex_Binop is a binary operation node, Iex_Unop is a unary operation node, and Iex_Load is a memory load node. It is a structured representation of Vex IR instructions.
[0040] The algebraic identity rule base is mainly used to combat "equivalent instruction substitution" obfuscation techniques in code obfuscation (such as replacing x+y with (x^y)+2*(x&y)). It folds complex equivalent expressions into their simplest form through pattern matching, eliminates redundant operation nodes introduced by obfuscation, simplifies the data flow graph (DFG) structure, and improves the accuracy of subsequent signature recovery.
[0041] In this invention, "bargaining binary" refers to an executable binary file that has had its symbol table and debugging information removed, or has undergone code obfuscation and does not directly contain function signature information. It is a typical processing target for function signature recovery tasks.
[0042] The present invention also proposes a binary function signature stripping recovery device based on graph neural networks, characterized by comprising the following: The data acquisition module is used to acquire the target binary file; The Data Flow Graph (DFG) construction module is used to convert the target binary file into a Vex IR representation and construct a Data Flow Graph (DFG). The nodes of the DFG represent variables or operations, and the edges represent the dependencies between variables. The signature recovery module is used to input the data flow graph (DFG) into a pre-built and trained signature recovery model based on a graph neural network, and output the signature recovery result through the signature recovery model.
[0043] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or as software functional modules.
[0044] If the integrated module is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or system capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.
[0045] Although the description of the invention has been quite detailed and particularly of several described embodiments, it is not intended to limit it to any of these details or embodiments or any particular embodiment, but should be considered as providing a broad possible interpretation of the claims by referring to the appended claims and taking into account the prior art, thereby effectively covering the intended scope of the invention. Furthermore, the invention has been described above with respect to embodiments foreseeable by the inventors in order to provide a useful description, and non-substantial modifications to the invention that have not yet been foreseen may still represent equivalent modifications.
[0046] The above description is merely a preferred embodiment of the present invention. The present invention is not limited to the above-described embodiments. Any embodiment that achieves the technical effects of the present invention using the same means should fall within the protection scope of the present invention. Within the protection scope of the present invention, various modifications and variations can be made to the technical solutions and / or implementation methods.
Claims
1. A method for recovering extracted binary function signatures based on graph neural networks, characterized in that, Including the following: Obtain the target binary file; The target binary file is converted into a Vex IR representation, and a data flow graph (DFG) is constructed, where nodes in the DFG represent variables or operations, and edges represent dependencies between variables. The data flow graph (DFG) is input into a pre-built and trained signature recovery model based on a graph neural network, and the signature recovery model outputs the signature recovery result.
2. The method for recovering stripped binary function signatures based on graph neural networks according to claim 1, characterized in that, Specifically, the process of constructing a Data Flow Graph (DFG) includes: First, the binary file is loaded using Angr.Project, and loading options are set. Next, the binary code of the binary file is converted into an architecture-independent Vex intermediate representation (IR) using Angr's Block.vex interface, thus achieving a unified intermediate layer representation. Then, function and basic block information is extracted using the CGFast analysis function. During the data flow analysis phase, symbolic execution is performed based on the Vex IR to extract variables and their data dependencies along the paths, generating a path-level data flow graph (path-DFG). Then, the path-DFGs from different paths are aggregated into a function-level data flow graph (func-DFG), achieving data flow graph aggregation. After the function-level data flow graph (func-DFG) is generated, it is normalized by defining operator mappings and optimizing edge labels to obtain the final data flow graph (DFG). Finally, the final data flow graph (DFG) and its related information are encapsulated into an Input object and saved as a .pkl file for subsequent loading and use.
3. The method for recovering stripped binary function signatures based on graph neural networks according to claim 2, characterized in that, Specifically, the signature recovery model includes, Shared encoder: The input is a function-level data flow graph func-DFG, where nodes represent variables or operations and edges represent data dependencies. It uses a graph convolutional network (GCN) as its basic architecture to extract semantic features of nodes through multiple convolutions. The output is an encoded node feature vector that captures global data dependencies within the function. Task-specific decoders are used for parameter quantity identification, parameter type recovery, and return type inference, respectively. The inputs are all node features output by the shared encoder, and the network structure is a multilayer perceptron (MLP). They all output signature recovery results.
4. The method for recovering stripped binary function signatures based on graph neural networks according to claim 1, characterized in that, Specifically, the process of creating the training dataset for the signature recovery model includes: We collected C language code from open-source software libraries to obtain multiple binary files, and extended the compilation toolchain to support compilation of various architectures at different optimization levels. The generated binary file is preprocessed to extract the assembly instruction sequence of the function and retain the debugging information to obtain the original signature of the function to obtain the dataset. The dataset is then deduplicated to obtain the training dataset.
5. The method for recovering stripped binary function signatures based on graph neural networks according to claim 4, characterized in that, Specifically, during the training process of the signature recovery model, the compiler optimization level is used as a conditional signal input, and an adaptive optimizer is used for training.
6. The method for recovering stripped binary function signatures based on graph neural networks according to claim 1, characterized in that, The method further includes systematic evaluation and generalization capability verification: after completing the training of the signature recovery model, the performance indicators of the model are quantified, including the accuracy of parameter number recovery, the precision of parameter type and return type recovery, recall and F1 score, until the performance indicators meet the standards and the training of the signature recovery model is completed.
7. The method for recovering stripped binary function signatures based on graph neural networks according to claim 1, characterized in that, Specifically, the target binary file is converted into a Vex IR representation, including: First, the target binary file is converted into a raw Vex IR sequence; where Vex IR is an architecture-independent intermediate representation under the angr binary analysis framework. If the raw Vex IR sequence is denoted as... ; For any data in V ,Will An expression tree that can be parsed into a binary or multi-way expression tree The temporary variable Tmp of Vex IR is then processed in SSA form, which is a static single assignment form, meaning that each temporary variable Tmp is assigned a value only once. A mapping DU is then constructed. ,in For the statement index of this Tmp, This is the set of indexes for statements that reference this Tmp; for Record its That is, the set of registers read by this statement and That is, the set of registers written to by this statement; get The middle representation ; for The intermediate representation is determined by checking if it hits any of the following garbage instruction patterns: self-assignment register transfer, explicit no-operation instruction, dead assignment without side effects, or register write with unused result. If it does, the corresponding flag number Flag[i] is set to 1; otherwise, Flag[i] is set to 0, thus obtaining the intermediate representation of M1. , An array containing all Flag[i]; For statements in M2 where Flag[i]=0, their expression trees are generated using a pre-established algebraic identity rule base R. Perform pattern matching and replace successfully matched nodes with the target expression tree corresponding to the rule in R. After replacement, continue pattern matching on the newly generated nodes until no match can be found. If statement expression tree If the value degenerates into a single leaf node after pattern matching and is a temporary variable, then the statement can directly reference and update it. The expression tree is replaced, and the references of related temporary variables in DU are updated. The intermediate Tmp that is about to be eliminated is removed from its use set to obtain the intermediate representation. ,in This is the sequence of statements after pattern matching; Iterate through each temporary variable in M3 If its The corresponding expression tree If there are no Iex_Get or Iex_Load nodes, calculate their constant values. , Eval is the expression tree evaluation function, w is the bit width of Tmp, and mod is the modulo operation; All references Replace Iex_Binder(Tmp_t) in the statement with Iex_Const(val_t); from Remove from And mark its definition statement as removable; Scan all Ist_WrTmp statements; if the Tmp defined by that statement is in... If the `use` collection is empty, then the statement is marked as deletable; Delete all statements that have been marked as removable, and remove the current statement from the use set of all Tmp referenced in its source operands; If the use set of a certain Tmp becomes empty as a result, then its definition statement also becomes deletable; Removing the statement with Flag[i]=1 from the sequence yields the final Vex IR representation.
8. A binary function signature stripping recovery device based on graph neural networks, characterized in that, Including the following: The data acquisition module is used to acquire the target binary file; The Data Flow Graph (DFG) construction module is used to convert the target binary file into a Vex IR representation and construct a Data Flow Graph (DFG). The nodes of the DFG represent variables or operations, and the edges represent the dependencies between variables. The signature recovery module is used to input the data flow graph (DFG) into a pre-built and trained signature recovery model based on a graph neural network, and output the signature recovery result through the signature recovery model.
