Source Code Reconstruction from Binary Files Using Embeddings and LLMs
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
The challenge is determining the source code of a binary software code when the source code version is not available, which is common due to compilation processes making it non-reversible, and existing decompilers provide only approximate results.
Innovation Solution
Utilizing a generative artificial intelligence language model (LLM) and a file encoder model to embed binary code and source code in a common latent space, generating file embedding vectors, and using similarity analysis and a large language model to determine the source code based on these vectors.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Loss of information
If traditional decompilers are used to convert binary code to source code, then source code can be obtained, but the accuracy and reliability of the reconstructed source code deteriorates
Solution Approach 1:
The patent replaces traditional mechanical decompilation processes with a deep learning-based neural network system. The neural network is trained on pairs of source code and binary code to learn the complex mapping relationships, then uses this learned knowledge to accurately reconstruct source code from binary code, achieving higher accuracy than conventional decompilers.
Solution Approach 2:
The patent transforms the source code reconstruction problem into a parameter optimization problem by adjusting neural network weights and biases during training. The system changes parameters iteratively to minimize the difference between reconstructed source code and original source code, thereby improving reconstruction accuracy.
2Productivity
If source code is compiled to binary code, then executable software is produced, but the ability to retrieve original source code deteriorates
Solution Approach 1:
The patent performs preliminary training of the neural network system before actual source code reconstruction is needed. By pre-training on large datasets of source-code pairs, the system prepares the necessary knowledge and patterns in advance, enabling accurate source code retrieval when binary code needs to be analyzed for security or maintenance purposes.
3Reliability
If binary code is analyzed for security risks without source code, then security analysis can be performed, but the precision of security risk detection deteriorates
Solution Approach 1:
The patent introduces reconstructed source code as an intermediary between binary code and security analysis tools. The neural network first reconstructs source code from binary code, then this reconstructed source code serves as input to security analysis tools, enabling more accurate and comprehensive security risk detection compared to analyzing binary code directly.
Data Source
Figure 1
Figure 2
Figure 3
AI summary
Systems, methods, and software can be used to determine source code of a software code. In some aspects, a method includes: processing a binary code by using a file encoder model to obtain a file embedding vector; and selecting one or more source code samples based on the file embedding vector and a distance function.