How mustime/adrill works
Main Components
• Main Executable:
• Represented by source/main.cc. This is the entry point of the application where command-line arguments are parsed (options like --pid, --pname, and --libpath).
• It directs the flow, triggering the injection process.
• Injection Core:
• Found in files like source/call_procedure.cc/h, which likely encapsulate the injection logic.
• This component will orchestrate the injection sequence.
• Architecture-Specific Backends:
• Located in source/backend with subdirectories arm, arm64, x64, and x86.
• Each backend (e.g., call_procedure-arm.cc, call_procedure-x86.cc) implements architecture-specific procedures for function calls or memory operations.
• Ptrace Interface:
• Implemented in source/ptrace_wrapper.cc/h.
• Responsible for interfacing with the operating system to attach and control target processes.
• Dynamic Linking and ELF Handling:
• Handled by source/elf_dlfcn.cc/h.
• This module manages ELF file interactions and dynamic loading necessary for injection.
• Utility and Support Modules:
• File utilities in file_utils.cc/h.
• Logging via logger.h and macros for internal debugging.
• Other supportive code modules like sdk_code.cc/h and selinux.cc/h for additional control and error handling.
• Configuration:
• The file config.h.in shows that some configurable parameters are provided—these might affect how the injection is set up.
Diagramming the Component Relationships
• Entry Point (main executable): Mark this as the starting node.
▸ The Injection Core (calling into call_procedure).
▸ The Ptrace Interface: This component is essential for process control.
• Beneath the Injection Core, expand to show:
• A branch for Architecture-Specific Backends:
• A connection from these backends to the “Dynamic Linking/ELF Handling” module, emphasizing that injection involves manipulation of library loading.
• Incorporate Utility Functions:
• External Interactions:
• You might also label a note or external dependency: “Requires Root Privilege” for execution, which is crucial context.
Architectural Patterns and Design Principles
• Abstraction: The main injection logic is abstracted away from low-level operations (ptrace, ELF handling), meaning each component should be drawn so that responsibilities are clearly segmented.
• Extensibility: The use of separate directories for each backend architecture highlights an extensible design to support additional architectures if needed.