A Binary Code Similarity Detection Method Based on Multi-source Contrastive Learning
摘要
Existing binary code similarity detection (BCSD) methods often overlook the actual execution information and local semantic details of programs, leading to suboptimal performance in assembly code semantic representation learning, high training resource consumption, and poor similarity detection performance. To address these issues, this paper proposes a Multi-Source Coordinated Representation Learning (MSRL) method for binary code similarity detection. First, we extract the semantic correspondence between assembly instruction sequences and programming language fragments to construct a contrastive learning dataset. We then propose an assembly code and source code semantic alignment (ACSA) method, which uses the high-level semantics of source code as supervisory information. Through contrastive learning tasks, we align the feature representations of the ACSA-Asm encoder and the programming language encoder in the semantic space, thereby enhancing the semantic representation learning capability of ACSA-Asm for assembly instructions. Next, we design a graph-based binary function embedding (GBFE) method, which uses a semantic structure-aware network to fuse the semantic information extracted by ACSA-Asm with the actual execution information of the program, generating function embedding vectors for similarity detection. Experimental results show that, compared to existing methods, MSRL improves the Recall@1 metric for binary code similarity detection by 8%–33%. Additionally, in the context of code obfuscation, MSRL exhibits stronger resilience, with less degradation in the Recall@1 metric.