Panoptes 1.0.0
Endpoint Detection and Response
Loading...
Searching...
No Matches
extensibility Directory Reference

Directories

 
core
 
PanoptesML
 
PanoptesYara

Detailed Description

Extensibility Modules

Extensibility modules are DLLs that scan files. Each one runs inside its own container process, which gives:

See the main README for how the components fit together.

PanoptesYara

The core detection module (PanoptesYara/, installed as ext\PanoptesYara.dll).

Compile your own rules with the Yara-X CLI and place rules.pkg in C:\Program Files\Panoptes\:

yr.exe compile <PATH_TO_YARA_RULES_FOLDER> -o rules.pkg

Its tests are in PanoptesYara/test (Test_PanoptesYara.exe, built with BUILD_TESTS).

PanoptesML

An optional module (PanoptesML/, installed as ext\PanoptesML.dll) that scores static PE files with an ONNX model. The file is only read: its features come from its bytes and headers, and it is never loaded or run.

The model

PanoptesML doesn't ship a model, so it needs one before it can score files. Put it at assets/ml/model.onnx, and the build encrypts it into the DLL. Without it, every scan fails with "cannot load model.onnx". The model must:

To try the pipeline before a real model exists, PanoptesML/tools/maketestmodel (Go) writes a placeholder (a fixed logistic regression on four features, not a detector). It encodes the ONNX protobuf itself, so it needs only Go:

cd src\extensibility\PanoptesML\tools
go run ./maketestmodel ../../../../assets/ml/model.onnx

The output goes to assets/ml/model.onnx, where the build picks it up; it only needs regenerating after the generator changes.

A model trained on one feature version doesn't work with another. Changing the features means raising PANO_ML_FEATURE_VERSION and retraining.

The embedded, encrypted model

By default no model.onnx is shipped. When PanoptesML is built, tools/sealmodel (Go) encrypts assets/ml/model.onnx with AES-256-GCM under a new random key. The result is linked into PanoptesML.dll as the RCDATA resource PANOML_MODEL, and the key is compiled in from a generated header (model_key.h, in the build folder only). At the first scan, the DLL decrypts the model in memory with Windows CNG (src/model_seal.cpp), hands it to ONNX Runtime and wipes the decrypted copy. Results report the model as embedded model.onnx.

Training on EMBER2024

PanoptesML/tools/embertrain (Go) trains a model on EMBER2024 (Apache-2.0). It is plain Go without cgo, so it builds into one static binary for a NAS or any Linux machine with the data:

cd src\extensibility\PanoptesML\tools
$env:GOOS = "linux"; $env:GOARCH = "amd64"; $env:CGO_ENABLED = "0" # arm64 for ARM NASes
go build -trimpath -o embertrain ./embertrain

On that machine:

cd /volume1/ember
./embertrain train -data Win64_train/ Win32_train/ Dot_Net_train/ Win64_test/ Win32_test/ Dot_Net_test/ -out model.onnx

How EMBER's records map to the features is in embertrain/features.go, beside the C++ it must match (src/pe_features.cpp). One feature can't be reproduced exactly: when a file's entry point is in no section, EMBER names the first executable section instead, so entry_outside_executable is 0 in training where PanoptesML computes 1. Section entropy and overlay can also differ slightly, because pefile aligns section offsets and our parser doesn't. To compare the two for the same files, use embertrain inspect <file.jsonl> and PanoptesMLQuery -json, which both print one JSON line per file with its features.

Building

PanoptesML is off by default. Turn it on with -DBUILD_ML=ON:

cmake --preset default -DBUILD_ML=ON
cmake --build build/default --config Debug --target PanoptesML

ONNX Runtime needs a newer protobuf than the gRPC the rest of Panoptes is pinned to. PanoptesML therefore has its own vcpkg manifest (PanoptesML/vcpkg.json and vcpkg-configuration.json, with a newer baseline) and builds as a separate sub-build with its own vcpkg_installed. None of its packages reach the other components. The first build compiles ONNX Runtime and gRPC from source, which takes a long while; later builds come from the vcpkg binary cache.

PanoptesML/vcpkg-overlays/onnx overrides vcpkg's onnx port for this build only. It's the same port with ONNX_DISABLE_STATIC_REGISTRATION=ON added, which ONNX Runtime requires; without it, every model fails to load with a SchemasRegisterer assertion.

The service starts a container for PanoptesML only when ext\PanoptesML.dll exists.

Testing with PanoptesMLQuery

PanoptesMLQuery.exe (PanoptesML/tools/mlquery, Go) scores files with the DLL directly, without the service or a container. It's built into bin\<config> with PanoptesML when Go is installed, and the TargetPackage includes it next to ext\.

PanoptesMLQuery.exe C:\Windows\System32\notepad.exe # score and verdict
PanoptesMLQuery.exe -features C:\samples\sample.exe # plus the named features
PanoptesMLQuery.exe -json -r C:\samples > features.jsonl # one JSON line per file, every feature

It loads ext\PanoptesML.dll from next to itself (or -dll <path>), and the DLL uses its embedded model (or model.onnx from its own folder). It exits 1 if any file couldn't be scored. With -json, each line holds the file's 278 features in model order, so its output can also be used to build a training set.

The tool calls the DLL's test exports, PanoMlScoreFile and PanoMlFeatureName (declared in PanoptesML.h). They run the same feature extraction and model as a container scan, but return the result instead of sending it to the service. The result struct, PanoMlTestResult, has a fixed layout that main.go repeats, so the tool and the DLL must be built from the same sources; a mismatch is reported rather than read.

Writing a module

A module exports three functions, declared in core/ExtensibilityCore.h:

Export Signature Called
PanoBind int PanoBind(int ContainerPort) Once the container's gRPC server is running, with the service's port from the registry. The module registers with the service (Hello); the container retries with backoff until it has.
PanoEntry bool PanoEntry(PeScan* data) For each file to scan; PeScan holds the file's path and hash
PanoUnbind bool PanoUnbind() Once, when the container shuts down

The module reports its results to the service over gRPC (ScanResults), as PanoptesYara does in src/service_client_yara.cpp. To have the service start a container for a new module, add it to BuildContainerCommandLine and StartContainers in src/service/src/containers.cpp.