![]() |
Panoptes 1.0.0
Endpoint Detection and Response
|
#include "ExtensibilityCore.h"#include <cstdint>#include <memory>#include <string>#include <vector>Go to the source code of this file.
Classes | |
| struct | PeFeatures |
| class | MlModel |
| An ONNX model that scores a feature vector. The model must take one float tensor of shape [1, FEATURE_COUNT] (or [N, FEATURE_COUNT]) and output a float tensor whose last value is the malicious probability: [1, 1] or [1, 2] (benign, malicious). See README.md. More... | |
| struct | MlScanResult |
| One file's result, as sent to the service. More... | |
| struct | PanoMlTestResult |
| One file's result for a test tool. Every field has a fixed size, so a caller in any language can declare the same layout. More... | |
| class | PanoptesServiceClient |
| The Panoptes Service client used to talk to the service over gRPC. More... | |
Macros | |
| #define | PANO_ML_VERSION "1.0.0" |
| #define | PANO_ML_MODEL_FILE L"model.onnx" |
| The model file, loaded from the folder PanoptesML.dll is in (ext). | |
| #define | PANO_ML_THRESHOLD 0.5f |
| Score at or above which a file is reported as malicious. | |
| #define | PANO_ML_MAX_FILE_SIZE (256ULL * 1024 * 1024) |
| Files larger than this are not scored (the features are computed over the whole file). | |
| #define | PANO_ML_FEATURE_VERSION 1 |
| Version of the feature layout below. A model is trained for one layout; change this whenever a feature is added, removed or reordered, and retrain. | |
| #define | PANO_ML_MODEL_RESOURCE L"PANOML_MODEL" |
| Name of the embedded model's resource (type RCDATA). | |
| #define | PANO_ML_TEST_OK 0 |
| PanoMlScoreFile results. | |
| #define | PANO_ML_TEST_FAILED -1 |
| #define | PANO_ML_TEST_NO_MODEL -2 |
Enumerations | |
| enum | PanoMlFeature : size_t { FEATURE_BYTE_HISTOGRAM = 0 , FEATURE_ENTROPY = 256 , FEATURE_LOG_SIZE , FEATURE_IS_PE , FEATURE_IS_64BIT , FEATURE_IS_DLL , FEATURE_SUBSYSTEM_GUI , FEATURE_SECTION_COUNT , FEATURE_SECTION_ENTROPY_MAX , FEATURE_SECTION_ENTROPY_MIN , FEATURE_SECTION_ENTROPY_MEAN , FEATURE_WRITABLE_EXECUTABLE_SECTIONS , FEATURE_ENTRY_OUTSIDE_EXECUTABLE , FEATURE_IMPORTED_DLLS , FEATURE_IMPORTED_FUNCTIONS , FEATURE_HAS_SIGNATURE , FEATURE_HAS_TLS , FEATURE_HAS_DEBUG , FEATURE_HAS_RELOCATIONS , FEATURE_HAS_RESOURCES , FEATURE_OVERLAY_RATIO , FEATURE_IMAGE_TO_FILE_RATIO , FEATURE_ZERO_TIMESTAMP , FEATURE_COUNT } |
| The static features of one file, in the order the model takes them. See README.md for what each index means. Every value is a float, most scaled to about 0..1. More... | |
Functions | |
| PeFeatures | ExtractPeFeatures (const std::wstring &Path) |
| Reads a file and computes its static features. The file is only read, never run or loaded. Throws std::runtime_error when the file can't be read or is too large. | |
| PeFeatures | ExtractPeFeatures (const uint8_t *Data, size_t Size) |
| The same, from a file's bytes (used by ExtractPeFeatures and the tests). | |
| bool | LoadEmbeddedModel (std::vector< uint8_t > &Model) |
| The model built into the DLL (an encrypted RCDATA resource, see tools/sealmodel), decrypted into Model. Returns false when the DLL was built without one, so model.onnx is loaded from its folder instead. Throws std::runtime_error when the embedded model can't be decrypted (modified or corrupted). | |
| std::wstring | ModuleDirectory () |
| The folder this DLL was loaded from, with a trailing backslash. | |
| PANO_API int | PanoMlScoreFile (const wchar_t *Path, PanoMlTestResult *Result) |
| Computes a file's features and scores them with the model (embedded, or model.onnx from the DLL's folder). The file is only read. Thread-safe. | |
| PANO_API int | PanoMlFeatureName (int Index, char *Buffer, int BufferSize) |
| Copies the name of feature Index (e.g. "byte_4d", "section_entropy_max") into Buffer. | |
| const char * | FeatureName (size_t Index) |
| The name of feature Index, or nullptr when it is out of range. | |
| #define PANO_ML_FEATURE_VERSION 1 |
Version of the feature layout below. A model is trained for one layout; change this whenever a feature is added, removed or reordered, and retrain.
Definition at line 23 of file PanoptesML.h.
Referenced by PanoMlScoreFile(), and PanoptesServiceClient::SendResults_ML().
| #define PANO_ML_MAX_FILE_SIZE (256ULL * 1024 * 1024) |
Files larger than this are not scored (the features are computed over the whole file).
Definition at line 17 of file PanoptesML.h.
Referenced by ExtractPeFeatures().
| #define PANO_ML_MODEL_FILE L"model.onnx" |
The model file, loaded from the folder PanoptesML.dll is in (ext).
Definition at line 11 of file PanoptesML.h.
| #define PANO_ML_MODEL_RESOURCE L"PANOML_MODEL" |
Name of the embedded model's resource (type RCDATA).
Definition at line 103 of file PanoptesML.h.
| #define PANO_ML_TEST_FAILED -1 |
Definition at line 143 of file PanoptesML.h.
Referenced by PanoMlScoreFile().
| #define PANO_ML_TEST_NO_MODEL -2 |
Definition at line 144 of file PanoptesML.h.
Referenced by PanoMlScoreFile().
| #define PANO_ML_TEST_OK 0 |
PanoMlScoreFile results.
Definition at line 142 of file PanoptesML.h.
Referenced by PanoMlScoreFile().
| #define PANO_ML_THRESHOLD 0.5f |
Score at or above which a file is reported as malicious.
Definition at line 14 of file PanoptesML.h.
Referenced by PanoEntry(), PanoMlScoreFile(), and PanoptesServiceClient::SendResults_ML().
| #define PANO_ML_VERSION "1.0.0" |
Definition at line 8 of file PanoptesML.h.
| enum PanoMlFeature : size_t |
The static features of one file, in the order the model takes them. See README.md for what each index means. Every value is a float, most scaled to about 0..1.
Definition at line 27 of file PanoptesML.h.
| PeFeatures ExtractPeFeatures | ( | const std::wstring & | Path | ) |
Reads a file and computes its static features. The file is only read, never run or loaded. Throws std::runtime_error when the file can't be read or is too large.
Definition at line 326 of file pe_features.cpp.
References ExtractPeFeatures(), and PANO_ML_MAX_FILE_SIZE.
Referenced by PanoEntry(), and PanoMlScoreFile().
| PeFeatures ExtractPeFeatures | ( | const uint8_t * | Data, |
| size_t | Size ) |
The same, from a file's bytes (used by ExtractPeFeatures and the tests).
Definition at line 233 of file pe_features.cpp.
References PeLayout::AddressOfEntryPoint, FileView::Contains(), FEATURE_BYTE_HISTOGRAM, FEATURE_COUNT, FEATURE_ENTROPY, FEATURE_ENTRY_OUTSIDE_EXECUTABLE, FEATURE_HAS_DEBUG, FEATURE_HAS_RELOCATIONS, FEATURE_HAS_RESOURCES, FEATURE_HAS_SIGNATURE, FEATURE_HAS_TLS, FEATURE_IMAGE_TO_FILE_RATIO, FEATURE_IMPORTED_DLLS, FEATURE_IMPORTED_FUNCTIONS, FEATURE_IS_64BIT, FEATURE_IS_DLL, FEATURE_IS_PE, FEATURE_LOG_SIZE, FEATURE_OVERLAY_RATIO, FEATURE_SECTION_COUNT, FEATURE_SECTION_ENTROPY_MAX, FEATURE_SECTION_ENTROPY_MEAN, FEATURE_SECTION_ENTROPY_MIN, FEATURE_SUBSYSTEM_GUI, FEATURE_WRITABLE_EXECUTABLE_SECTIONS, FEATURE_ZERO_TIMESTAMP, PeLayout::FileHeader, PeLayout::Is64Bit, PeFeatures::IsPe, PeLayout::Sections, PeLayout::SizeOfImage, PeLayout::Subsystem, and PeFeatures::Values.
Referenced by ExtractPeFeatures().
| const char * FeatureName | ( | size_t | Index | ) |
The name of feature Index, or nullptr when it is out of range.
Definition at line 22 of file pe_features.cpp.
References FEATURE_COUNT.
Referenced by PanoMlFeatureName().
| bool LoadEmbeddedModel | ( | std::vector< uint8_t > & | Model | ) |
The model built into the DLL (an encrypted RCDATA resource, see tools/sealmodel), decrypted into Model. Returns false when the DLL was built without one, so model.onnx is loaded from its folder instead. Throws std::runtime_error when the embedded model can't be decrypted (modified or corrupted).
Definition at line 111 of file model_seal.cpp.
| std::wstring ModuleDirectory | ( | ) |
The folder this DLL was loaded from, with a trailing backslash.
Definition at line 122 of file ml_model.cpp.
References MAX_PATH, and ModuleDirectory().
Referenced by ModuleDirectory().
| PANO_API int PanoMlFeatureName | ( | int | Index, |
| char * | Buffer, | ||
| int | BufferSize ) |
Copies the name of feature Index (e.g. "byte_4d", "section_entropy_max") into Buffer.
Definition at line 181 of file dllmain.cpp.
References FeatureName(), and PANO_API.
| PANO_API int PanoMlScoreFile | ( | const wchar_t * | Path, |
| PanoMlTestResult * | Result ) |
Computes a file's features and scores them with the model (embedded, or model.onnx from the DLL's folder). The file is only read. Thread-safe.
Definition at line 141 of file dllmain.cpp.
References PanoMlTestResult::Error, ExtractPeFeatures(), FEATURE_COUNT, PanoMlTestResult::FeatureCount, PanoMlTestResult::Features, PanoMlTestResult::FeatureVersion, PanoMlTestResult::IsPe, PeFeatures::IsPe, PanoMlTestResult::Malicious, PanoMlTestResult::Model, MlModel::Name(), PANO_API, PANO_ML_FEATURE_VERSION, PANO_ML_TEST_FAILED, PANO_ML_TEST_NO_MODEL, PANO_ML_TEST_OK, PANO_ML_THRESHOLD, MlModel::Score(), PanoMlTestResult::Score, PanoMlTestResult::StructSize, PanoMlTestResult::Threshold, and PeFeatures::Values.