How ulexec/shelf-loading works
Main Components
• Source Code Files:
• Static PIE Loader (static-pie-loader.c) which likely contains the core loader logic.
• Test code (test.c) for exercising or demonstrating the loader’s functionality.
• Header files under the include directory (embedded.h and static-pie-loader.h) supporting modular definitions.
• Linker Script:
• static-pie.ld that directs the linker on how to layout the final PIE binary.
• Build and Deployment Tools:
• Makefile and build_and_run.sh script to automate compilation and testing.
• Dockerfile to create a containerized build environment if needed.
• Utility Scripts:
• strip_headers.py likely handles post-compilation modifications to remove or adjust headers for the desired evasive behavior.
• Documentation:
• README.md that provides context and credits, indicating that this tool is meant for creating evasive executables, possibly for security testing or research.
Flow and Interactions
• Development Environment: The Dockerfile indicates containerized builds, which encapsulate the build tools and runtime environment.
• Compilation Process:
• The Makefile (invoked manually or via build_and_run.sh) orchestrates the compile steps for the source files.
• The compiler uses the provided static-pie.ld linker script to enforce static PIE properties.
• Post-Compilation Processing:
• strip_headers.py is applied post-compilation to modify the output binary headers, hinting at techniques used to evade standard detection or analysis.
• Testing/Execution:
• test.c is used to test the final binary. The build_and_run.sh wraps up the build and run cycle for quick validation.
Architectural Patterns and Design Principles
• Modular Structure: The separation into source, include, and script files shows emphasis on clear modularization.
• Build Pipeline Pattern: There is a defined sequence from writing source code, invoking build scripts, applying linker customizations, and finally testing the output.
• Containerization: Dockerfile usage presents an isolated build environment ensuring consistency.
• Automation: The Makefile and build shell script automate steps to ensure repeatable builds.