RESource: A Framework for Online Matching of Assembly with Open Source Code

Ashkan Rahimian, Philippe Charland, Stere Preda, Mourad DebbabiFPS 2012 · DOI

TL;DR

This paper introduces RESource, a novel framework that automatically matches disassembled assembly code to its original open-source code. By extracting features from assembly and querying online repositories, RESource helps reverse engineers quickly identify the origin of code, significantly simplifying tasks like malware analysis.

What Problem Does This Paper Address?

Reverse engineering assembly code is notoriously difficult, requiring deep expertise. A significant challenge is identifying the original source code from which a binary was compiled. While decompilers exist, they don't always provide a perfect 1:1 mapping and can produce hard-to-follow code. Existing tools like RE-Google attempted this but relied on deprecated APIs. This paper addresses the need for a robust, up-to-date tool that can reliably map assembly code to open-source repositories, thereby aiding reverse engineers in understanding binary functionality and origin.

Methods

RESource employs a two-pronged approach:

  • Online Analysis: It extracts features from assembly code, such as constants, imported libraries, function calls, exported functions, and strings. These features are then used to construct queries for various online code repositories. The goal is to find direct links to the original source files.
  • Offline Analysis: If online queries yield no results, or to supplement them, RESource performs a local analysis of the assembly code. This involves identifying function prototypes, arguments, local variables, and system calls. It utilizes a built-in dictionary of common Windows API functions to infer the functionality of code segments.

The framework is implemented as an IDA Pro plugin, leveraging the disassembler's API to interact with the binary and add comments to the assembly file with the findings. It also incorporates an interleaving technique to manage queries to multiple search engines efficiently, respecting rate limits.

Datasets

Not discussed in the paper. The paper focuses on the framework's methodology and its application to the "PreciseCalc Project" as a case study.

Key Insights and Ideas

  • Feature-Driven Matching: The core idea is that specific features within assembly code (constants, strings, function calls) are strong indicators of the original source code.
  • Hybrid Approach is Crucial: Relying solely on online repositories can be insufficient due to code obfuscation, proprietary components, or deprecated search APIs. The offline analysis module provides a valuable fallback and complementary information.
  • Efficiency Matters: For effective interaction with online repositories, managing query rates and interleaving requests across different search engines is essential to avoid being blocked and to maximize results.
  • IDA Pro Integration: Building RESource as an IDA Pro plugin makes it directly accessible to reverse engineers within their existing workflow, enhancing usability.

Key Results

The paper demonstrates RESource's effectiveness on the "PreciseCalc Project," a C++ application.

  • RESource was able to detect references to over 70% of the original source files with 100% accuracy.
  • The tool successfully identified matches for functions based on constants, strings, and imported libraries.
  • The offline analysis module provided valuable insights into function functionality, even when online results were limited.
  • The paper shows examples of how RESource adds comments to the assembly file, indicating online matches and offline analysis results, which are beneficial for reverse engineers.

Limitations and Future Work

  • Intra-Procedural vs. Inter-Procedural: The current approach is intra-procedural (analyzing functions individually). The authors suggest that an inter-procedural approach could potentially improve the accuracy of online analysis.
  • Search Engine Limitations: The paper notes that search engines have limitations, such as restricted query commands and the lack of direct APIs, which can affect the effectiveness of online matching.
  • Offline Analysis Dictionary: The accuracy of the offline analysis is dependent on the comprehensiveness of the function dictionary. The current dictionary focuses on common Windows API functions, particularly for malware analysis.
  • Heuristic Query Building: The current version does not include advanced heuristic query building. The authors suggest that developing algorithms that try different query elements and select the best match could further improve accuracy.
  • RE-Google Deprecation: The paper mentions that RE-Google, a similar tool, is no longer functional due to deprecated APIs, highlighting the need for RESource's more robust and adaptable approach.

Summary updated

BibTeX
@inproceedings{rahimian2012resource,
  author = {Ashkan Rahimian and Philippe Charland and Stere Preda and Mourad Debbabi},
  title = {{RESource: A Framework for Online Matching of Assembly with Open Source Code}},
  booktitle = {FPS},
  year = {2012},
  doi = {10.1007/978-3-642-37119-6\_14},
}
Figure