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+
Project structure
CMakeLists.txt
plugin.toml
Every plugin needs a plugin.toml manifest alongside its binary. This tells the daemon how to manage your plugin.src/main.cpp
Handler methods
Override virtual methods on themalbox::HostPlugin base class:Pushing results
Results are pushed to the daemon via theResultSink obtained from ctx.results(). You can call push methods multiple times to stream results incrementally: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. Reports support:- Verdicts with classification (clean/suspicious/malicious/unknown), confidence, and score
- Indicators (IOCs) with open-vocabulary types like
sha256,ipv4,domain - TTPs referencing MITRE ATT&CK techniques
- Artifact references linking to sibling
PluginResultentries - Presentation sections with typed blocks (markdown, tables, code, hex dumps, graphs, timelines, and more)
Handling errors
Plugin methods can throwmalbox::Error to signal failures. The SDK catches exceptions at the FFI boundary and reports them to the runtime.ctx.task().sample_bytes() also throw malbox::Error on failure.Subscribing to events
Overrideon_event to react to system-wide or plugin lifecycle events:Thread safety
When usingExecutionContext::Parallel, multiple on_task calls may execute concurrently. Protect shared mutable state with std::mutex or similar. 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.Deploy
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