How obfuscator-llvm/obfuscator works
Project Purpose
• This is the Obfuscator‑LLVM project, intended to implement obfuscation passes within the LLVM compilation pipeline. According to the README, the project provides software protection by integrating with LLVM (in this case, LLVM 4.0).
• The emphasis is on compiler-level transformations so that the compiled code is more resilient against reverse engineering.
Main Components
a. The Base Compiler Framework:
• LLVM Core: The standard LLVM components such as the Frontend, the IR (Intermediate Representation), the Pass Manager, and the Backend (the code generator).
b. Obfuscation Modules:
• Custom LLVM Passes: These are the individual obfuscation techniques that are inserted into the LLVM pass pipeline. They may include control flow flattening, instruction substitution, bogus control flows, etc.
c. Integration Points:
• Plugin or Patch Infrastructure: How these obfuscation passes integrate with LLVM’s pass manager or be registered as LLVM extensions.
d. External/Supporting Elements:
• Documentation and Wiki: Though not part of the compiled code itself, the wiki (as seen in the README) provides additional context on usage, design decisions, and potential configuration parameters.
• Build/Configuration Setup: While not shown here explicitly, expect build scripts or configuration files (possibly in the repository) that allow for compiling and integrating the custom passes within LLVM.
Relationships and Interactions
• The data flow starts with source code being compiled by LLVM’s Frontend.
• The produced LLVM IR then flows to the custom Obfuscator-LLVM passes.
• Each obfuscation pass might be responsible for a specific transformation on the IR.
• After the obfuscation passes, the modified IR is passed back into LLVM’s optimization and code generation pipelines.
• On the ordering and dependencies where each obfuscation pass might depend on the output of previous ones.
Architectural Patterns and Design Principles
• Modular Design: Each obfuscation technique is implemented as an independent LLVM pass.
• Pipeline Integration: The design leverages LLVM’s pass manager framework, effectively “plugging in” new behavior into the standard compilation pipeline.
• Extensibility: The system design should facilitate adding new obfuscation passes or modifying the order of existing ones.
• Separation of Concerns: Clearly separate LLVM’s core compilation responsibilities from the obfuscation functionalities.
Including Relevant Technologies
• C++ as the primary programming language.
• LLVM libraries and APIs (particularly for LLVM 4.0).
• Likely usage of CMake or other build systems for managing dependencies and build configuration.