Documentation Index
Fetch the complete documentation index at: https://docs.malbox.app/llms.txt
Use this file to discover all available pages before exploring further.
Getting started
Create a new repository from the C++ plugin template by clicking Use this template on GitHub. Clone your new repository and rename the project inCMakeLists.txt and plugin.toml to match your plugin name.
The template gives you a working plugin with CMake configuration, a plugin.toml manifest, example source code, and CI already set up.
Prerequisites
- C++20 compiler (GCC 11+, Clang 13+, or MSVC 2019 16.10+)
- CMake 3.20+
- For Windows guest plugins: MinGW cross-compilation toolchain (provided by the Malbox devenv)
Project structure
Your plugin project has three essential files: a CMake build file, a plugin manifest, and your source code.CMakeLists.txt
The
malbox_generate_runtime_config function invokes the malbox-codegen CLI (shipped with the SDK) to read your plugin.toml and emit a malbox_runtime_config.hpp header with constexpr values. The header is regenerated whenever plugin.toml changes.plugin.toml
Every plugin needs a manifest alongside its binary. This tells the daemon how to manage your plugin.
src/main.cpp
malbox::Plugin and implements on_task at minimum. The on_start and on_stop lifecycle hooks are optional.
For a host plugin, change the metadata and entry point:
Handler methods
Override virtual methods on themalbox::Plugin base class:
| Method | Signature | Required |
|---|---|---|
on_task | (const Task&, const Context&) -> void | Yes |
on_start | (const std::unordered_map<std::string, std::string>&) -> void | No |
on_stop | () -> void | No |
health_check | () -> HealthStatus | No |
on_daemon_event | (DaemonEvent, const Context&) -> void | No |
on_task_event | (TaskEvent, const TaskEventPayload&, const Context&) -> void | No |
on_plugin_event | (PluginEvent, const PluginEventPayload&, const Context&) -> void | No |
on_sample_event | (SampleEvent, const SampleEventPayload&, const Context&) -> void | No |
on_task is required (pure virtual). All other handlers default to no-ops.
Pushing results
Results are pushed to the daemon duringon_task via ctx.push_result(). You can call it multiple times to stream results incrementally. There are three result types:
plugin.toml under [results.*].
Reports
For structured analysis output with verdicts, indicators, TTPs, and frontend-renderable sections, use theReportBuilder to construct a Report and push it as a result:
Handling errors
Plugin methods can throwmalbox::Error to signal failures. The SDK catches exceptions at the FFI boundary and reports them to the runtime.
task.sample_bytes() also throw malbox::Error on failure.
Subscribing to events
Beyond task processing, your plugin can react to system events by overriding the event handler methods:Thread safety
When usingExecutionContext::Parallel, multiple on_task calls may execute concurrently. Protect shared mutable state with std::mutex or similar synchronization primitives. Health checks may also arrive on a different thread regardless of execution context.
Build
Linux
Host plugins always target Linux (they run on the daemon machine). Guest plugins targeting a Linux guest VM also use this:Windows (cross-compile)
Guest plugins that run inside a Windows analysis VM need to be cross-compiled. The Malbox devenv provides a MinGW toolchain and a CMake toolchain file for this:.exe binary with no runtime DLL dependencies.
The MinGW toolchain file reads
MINGW_LIB_PATH and MINGW_INCLUDE_PATH environment variables for library and header search paths. The Malbox devenv sets these automatically.Deploy
Host plugins
Place the compiled binary andplugin.toml in a subdirectory of the daemon’s plugin directory. The daemon discovers plugins automatically on startup.
~/.config/malbox/plugins/
my-host-plugin-bin
plugin.toml
Guest plugins
Guest plugin binaries must be deployed inside the analysis VM. Place them in the daemon’s plugin directory (so the daemon knows about them), then provision the binary into the VM:~/.config/malbox/plugins/
my-guest-plugin-bin
plugin.toml