8#define PANO_ML_VERSION "1.0.0"
11#define PANO_ML_MODEL_FILE L"model.onnx"
14#define PANO_ML_THRESHOLD 0.5f
17#define PANO_ML_MAX_FILE_SIZE (256ULL * 1024 * 1024)
19#pragma region Features
23#define PANO_ML_FEATURE_VERSION 1
77 explicit MlModel(
const std::wstring& ModelPath);
79 MlModel(
const void* Data,
size_t Size,
const std::string&
Name);
85 float Score(
const std::vector<float>& Features);
87 const std::string&
Name()
const {
return m_name; }
92 std::unique_ptr<Impl> m_impl;
103#define PANO_ML_MODEL_RESOURCE L"PANOML_MODEL"
119#pragma region Test interface
142#define PANO_ML_TEST_OK 0
143#define PANO_ML_TEST_FAILED -1
144#define PANO_ML_TEST_NO_MODEL -2
ExtensibilityType
The type of extensibility.
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 fol...
std::wstring ModuleDirectory()
The folder this DLL was loaded from, with a trailing backslash.
bool LoadEmbeddedModel(std::vector< uint8_t > &Model)
The model built into the DLL (an encrypted RCDATA resource, see tools/sealmodel), decrypted into Mode...
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.
PanoMlFeature
The static features of one file, in the order the model takes them. See README.md for what each index...
@ FEATURE_IMPORTED_FUNCTIONS
@ FEATURE_HAS_RELOCATIONS
@ FEATURE_ENTRY_OUTSIDE_EXECUTABLE
@ FEATURE_SECTION_ENTROPY_MAX
@ FEATURE_IMAGE_TO_FILE_RATIO
@ FEATURE_WRITABLE_EXECUTABLE_SECTIONS
@ FEATURE_SECTION_ENTROPY_MIN
@ FEATURE_SECTION_ENTROPY_MEAN
PeFeatures ExtractPeFeatures(const std::wstring &Path)
Reads a file and computes its static features. The file is only read, never run or loaded....
float Score(const std::vector< float > &Features)
Runs the model on one file's features. Returns the malicious probability.
MlModel(const MlModel &)=delete
MlModel & operator=(const MlModel &)=delete
MlModel(const std::wstring &ModelPath)
Loads the model. Throws Ort::Exception or std::runtime_error when it can't be loaded or doesn't take ...
const std::string & Name() const
The Panoptes Service client used to talk to the service over gRPC.
bool SendResults_ML(const std::string &PePath, const std::string &FileHash, const MlScanResult &Result)
bool Hello(ExtensibilityType extensibilityType, std::string port)
The Hello function sends a Hello message to the Panoptes main service from the container.
One file's result, as sent to the service.
One file's result for a test tool. Every field has a fixed size, so a caller in any language can decl...
float Features[FEATURE_COUNT]
std::vector< float > Values