-
Notifications
You must be signed in to change notification settings - Fork 755
Architecture Overview
Qiling Framework is designed with a modular and extensible architecture to support a wide range of use cases in binary analysis. Understanding its core components is key to leveraging its full potential.
The framework is built around a few key components that work together to create the emulation environment.
At the heart of Qiling is the Unicorn Engine, a lightweight, multi-platform, multi-architecture CPU emulator framework. Unicorn provides the raw CPU emulation capabilities, executing binary code instruction by instruction. Qiling builds a comprehensive layer of abstraction on top of Unicorn to handle the complexities of a full operating system environment.
Before emulation can begin, the binary file must be loaded into memory. Qiling's loaders are responsible for parsing various executable file formats and mapping them into the emulated address space. Each supported format has its own loader.
- ELF Loader: For Linux, BSD, and other Unix-like systems.
- PE Loader: For Windows executables.
- Mach-O Loader: For macOS and iOS binaries.
- Blob Loader: For raw binary blobs or shellcode, where you can specify the architecture, entry point, and memory layout manually.
This is where Qiling truly shines. A CPU emulator alone is not enough to run real-world programs, which rely on the underlying operating system for services like file I/O, networking, and process management. Qiling implements a sophisticated OS emulation layer that mimics the behavior of a real kernel.
-
Syscall Handling: Qiling intercepts and emulates system calls made by the binary. For example, when a program tries to open a file, Qiling's syscall handler for
open
is invoked. This handler interacts with a virtual filesystem, not the host's real filesystem. -
API Hooking: For higher-level libraries (like
libc
in Linux orkernel32.dll
in Windows), Qiling can hook API calls. This allows for more granular control and analysis than syscalls alone. - Virtual Filesystem (VFS): Qiling maintains a virtual filesystem for each emulated instance. You can map host directories into this VFS, create virtual files in memory, and control how the emulated program interacts with its environment.
The entire emulation environment is sandboxed. The emulated program cannot access the host system's resources directly unless you explicitly allow it. This makes Qiling a safe tool for analyzing potentially malicious code.
When you use Qiling, you interact with the main Qiling
object, often instantiated as ql
. This object is the central point of control and provides access to all other components:
-
ql.reg
: Access and modify CPU registers. -
ql.mem
: Read and write to the emulated memory. -
ql.fs
: Interact with the virtual filesystem. -
ql.loader
: Access information about the loaded binary (e.g., entry point, symbols). -
ql.os
: Access OS-specific emulation features and configurations.
Qiling's hooking mechanism is event-driven. You can register callback functions (hooks) that are triggered by specific events:
- Address Hooking: Triggered when execution reaches a specific memory address.
- Code Hooking: Triggered for every instruction or basic block.
- Syscall Hooking: Triggered before or after a system call is executed.
- API Hooking: Triggered when a specific library function is called.
- Interrupt Hooking: Triggered on a software interrupt.
This powerful mechanism allows you to build custom analysis tools, modify program behavior on the fly, and extract valuable information during emulation.
- Home
- Getting Started
- Core Concepts
- Usage
- Features
- Tutorials
- Development
- Resources